Exemplo n.º 1
0
 /** Operation Execution Methods Sync * */
 public <T> T execute(String operationId, OperationBody body) {
   Object input = body.getInput();
   if (input instanceof Blob) { // If input is blob or blobs -> use multipart
     List<MultipartBody.Part> filePart = new ArrayList<>();
     RequestBody fbody =
         RequestBody.create(
             MediaType.parse(((Blob) input).getMimeType()), ((Blob) input).getFile());
     filePart.add(
         MultipartBody.Part.createFormData(INPUT_PART, ((Blob) input).getFileName(), fbody));
     return (T) getResponse(operationId, body, filePart);
   } else if (input instanceof Blobs) { // If input is blob or blobs -> use multipart
     List<MultipartBody.Part> fileParts = new ArrayList<>();
     for (int i = 0; i < ((Blobs) input).size(); i++) {
       Blob fileBlob = ((Blobs) input).getBlobs().get(i);
       RequestBody fbody =
           RequestBody.create(MediaType.parse(fileBlob.getMimeType()), fileBlob.getFile());
       fileParts.add(
           MultipartBody.Part.createFormData(
               INPUT_PARTS + String.valueOf(i), fileBlob.getFileName(), fbody));
     }
     return (T) getResponse(operationId, body, fileParts);
   } else {
     return (T) getResponse(operationId, body);
   }
 }
Exemplo n.º 2
0
 /** Operation Execution Methods Async * */
 public void execute(String operationId, OperationBody body, Callback<Object> callback) {
   Object input = body.getInput();
   if (input instanceof Blob) { // If input is blob or blobs -> use multipart
     Map<String, RequestBody> fbodys = new HashMap<>();
     RequestBody fbody =
         RequestBody.create(
             MediaType.parse(((Blob) input).getMimeType()), ((Blob) input).getFile());
     fbodys.put(INPUT_PART, fbody);
     super.execute(callback, operationId, body, fbodys);
   } else if (input instanceof Blobs) { // If input is blob or blobs -> use multipart
     Map<String, RequestBody> fbodys = new HashMap<>();
     for (int i = 0; i < ((Blobs) input).size(); i++) {
       Blob fileBlob = ((Blobs) input).getBlobs().get(i);
       RequestBody fbody =
           RequestBody.create(MediaType.parse(fileBlob.getMimeType()), fileBlob.getFile());
       fbodys.put(INPUT_PARTS + String.valueOf(i), fbody);
     }
     super.execute(callback, operationId, body, fbodys);
   } else {
     super.execute(callback, operationId, body);
   }
 }
Exemplo n.º 3
0
 public Operation context(Map<String, Object> context) {
   body.setContext(context);
   return this;
 }
Exemplo n.º 4
0
 public Operation parameters(Map<String, Object> parameters) {
   body.setParameters(parameters);
   return this;
 }
Exemplo n.º 5
0
 public Operation context(String key, Object contextValue) {
   body.getContext().put(key, contextValue);
   return this;
 }
Exemplo n.º 6
0
 public Operation param(String key, Object parameter) {
   body.getParameters().put(key, parameter);
   return this;
 }
Exemplo n.º 7
0
 public Operation input(Object input) {
   body.setInput(input);
   return this;
 }