/** * Add the multipart upload file name for this request. * * @param multipartFileName * the multipart file name * @param contentType * the multipart contentType * @return this request */ public RestRequest addMultipartFileName(String multipartFileName, String contentType ) { RestMultipart restMultipart = new RestMultipart(RestMultipart.RestMultipartType.FILE,multipartFileName, contentType); return this.addMultipart(FILE, restMultipart); }
/** * Checks validity of this request. * * In this implementation a request is valid if both the method and the * resource Uri not null * * @return true if valid */ public boolean isValid() { return getMethod() != null && getResource() != null; }
/** * String representation of this request. * * @return the string representation */ public String toString() { StringBuilder builder = new StringBuilder(); if (getMethod() != null) builder.append(getMethod().toString()).append(" "); if (getResource() != null) builder.append(this.getResource()); if (getQuery() != null) builder.append("?").append(this.getQuery()); builder.append(LINE_SEPARATOR); builder.append(super.toString()); return builder.toString(); } }
private void addHeaders(HttpMethod m, RestRequest request) { for (RestData.Header h : request.getHeaders()) { m.addRequestHeader(h.getName(), h.getValue()); } } }
/** * @return string representation of this response */ public String toString() { StringBuilder builder = new StringBuilder(); if (getStatusCode() != null) builder.append(String.format("[%s] %s", this.getStatusCode(), this.getStatusText())); builder.append(LINE_SEPARATOR); builder.append(super.toString()); return builder.toString(); }
/** * See {@link smartrics.rest.client.RestClient#execute(smartrics.rest.client.RestRequest)} */ public RestResponse execute(RestRequest request) { return execute(getBaseUrl(), request); }
public String getContentType() { return getHeaderValue("Content-Type"); }
/** * Builds a empty rest request. * * @return the rest request. */ public RestRequest buildRestRequest() { return new RestRequest(); }
@Override public String handle(RunnerVariablesProvider variablesProvider, Config config, RestResponse response, Object expressionContext, String expression) { return response.getBody(); }
public RestData setBody(String body) { if(body == null) { setRawBody(null); } else { setRawBody(body.getBytes()); } return this; }
/** * Add the multipart upload file name for this request. * * @param multipartFileName * the multipart file name * @return this request */ public RestRequest addMultipartFileName(String multipartFileName ) { RestMultipart restMultipart = new RestMultipart(RestMultipart.RestMultipartType.FILE, multipartFileName); return this.addMultipart(FILE, restMultipart); }
public String getContentLength() { return getHeaderValue("Content-Length"); }
/** * Add the multipart upload file name for this request. * * @param multipartFileName * the multipart file name * @param contentType * the multipart contentType * @param charSet * the multipart charSet * @return this request */ public RestRequest addMultipartFileName(String multipartFileName, String contentType, String charSet ) { RestMultipart restMultipart = new RestMultipart(RestMultipart.RestMultipartType.FILE, multipartFileName, contentType, charSet); return this.addMultipart(FILE, restMultipart); }
/** * @return the multipart upload files name for this request */ public Map<String,RestMultipart> getMultipartFileNames() { // Add History Api if ( (this.multipartFileName!=null) && (!this.multipartFileName.trim().isEmpty()) ) { RestMultipart restMultipart = new RestMultipart(RestMultipart.RestMultipartType.FILE, this.multipartFileName); this.addMultipart( this.multipartFileParameterName, restMultipart); } // Return the Map return multipartFileByParamName; }