BrightSide Workbench Full Report + Source Code
org.turro.http.ElephantPost Class Reference

Public Member Functions

 ElephantPost (String serverUrl)
 
void addParameter (String name, String value)
 
ElephantResponse doPost () throws IOException
 

Static Public Member Functions

static boolean isValid (HttpServletRequest request)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 41 of file ElephantPost.java.

Constructor & Destructor Documentation

◆ ElephantPost()

org.turro.http.ElephantPost.ElephantPost ( String  serverUrl)

Definition at line 46 of file ElephantPost.java.

46  {
47  this.serverUrl = serverUrl;
48  parameters = new HashMap<>();
49  }

Member Function Documentation

◆ addParameter()

void org.turro.http.ElephantPost.addParameter ( String  name,
String  value 
)

Definition at line 51 of file ElephantPost.java.

51  {
52  parameters.put(name, value);
53  }
Here is the caller graph for this function:

◆ doPost()

ElephantResponse org.turro.http.ElephantPost.doPost ( ) throws IOException

Definition at line 55 of file ElephantPost.java.

55  {
56  if(serverUrl == null || parameters.isEmpty()) {
57  return null;
58  }
59  List<NameValuePair> nvps = new ArrayList<>();
60  for(String key : parameters.keySet()) {
61  String value = parameters.get(key);
62  if(!Strings.isBlank(value)) {
63  nvps.add(new BasicNameValuePair(key, value));
64  }
65  }
66  nvps.add(new BasicNameValuePair("skey", Secrets.getSecret("key=post")));
67  HttpPost httpPost = new HttpPost(serverUrl);
68  httpPost.setEntity(new UrlEncodedFormEntity(nvps));
69  try (CloseableHttpClient closeableClient = (CloseableHttpClient) HttpClients.createDefault()) {
70  try (CloseableHttpResponse closeableResponse = (CloseableHttpResponse) closeableClient.execute(httpPost)) {
71  HttpEntity resEntity = closeableResponse.getEntity();
72  return ElephantResponse.getResponse(resEntity);
73  }
74  }
75  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValid()

static boolean org.turro.http.ElephantPost.isValid ( HttpServletRequest  request)
static

Definition at line 77 of file ElephantPost.java.

77  {
78  return Secrets.getSecret("key=post").equals(request.getParameter("skey"));
79  }
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: