/** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      FailWorkflowExecutionFailedEventAttributes failWorkflowExecutionFailedEventAttributes,
      StructuredJsonGenerator jsonGenerator) {

    if (failWorkflowExecutionFailedEventAttributes == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonGenerator.writeStartObject();

      if (failWorkflowExecutionFailedEventAttributes.getCause() != null) {
        jsonGenerator
            .writeFieldName("cause")
            .writeValue(failWorkflowExecutionFailedEventAttributes.getCause());
      }
      if (failWorkflowExecutionFailedEventAttributes.getDecisionTaskCompletedEventId() != null) {
        jsonGenerator
            .writeFieldName("decisionTaskCompletedEventId")
            .writeValue(
                failWorkflowExecutionFailedEventAttributes.getDecisionTaskCompletedEventId());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<RespondDecisionTaskCompletedRequest> marshall(
      RespondDecisionTaskCompletedRequest respondDecisionTaskCompletedRequest) {

    if (respondDecisionTaskCompletedRequest == null) {
      throw new SdkClientException("Invalid argument passed to marshall(...)");
    }

    Request<RespondDecisionTaskCompletedRequest> request =
        new DefaultRequest<RespondDecisionTaskCompletedRequest>(
            respondDecisionTaskCompletedRequest, "AmazonSimpleWorkflow");
    request.addHeader("X-Amz-Target", "SimpleWorkflowService.RespondDecisionTaskCompleted");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (respondDecisionTaskCompletedRequest.getTaskToken() != null) {
        jsonGenerator
            .writeFieldName("taskToken")
            .writeValue(respondDecisionTaskCompletedRequest.getTaskToken());
      }

      java.util.List<Decision> decisionsList = respondDecisionTaskCompletedRequest.getDecisions();
      if (decisionsList != null) {
        jsonGenerator.writeFieldName("decisions");
        jsonGenerator.writeStartArray();
        for (Decision decisionsListValue : decisionsList) {
          if (decisionsListValue != null) {

            DecisionJsonMarshaller.getInstance().marshall(decisionsListValue, jsonGenerator);
          }
        }
        jsonGenerator.writeEndArray();
      }
      if (respondDecisionTaskCompletedRequest.getExecutionContext() != null) {
        jsonGenerator
            .writeFieldName("executionContext")
            .writeValue(respondDecisionTaskCompletedRequest.getExecutionContext());
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      SignalExternalWorkflowExecutionInitiatedEventAttributes
          signalExternalWorkflowExecutionInitiatedEventAttributes,
      StructuredJsonGenerator jsonGenerator) {

    if (signalExternalWorkflowExecutionInitiatedEventAttributes == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonGenerator.writeStartObject();

      if (signalExternalWorkflowExecutionInitiatedEventAttributes.getWorkflowId() != null) {
        jsonGenerator
            .writeFieldName("workflowId")
            .writeValue(signalExternalWorkflowExecutionInitiatedEventAttributes.getWorkflowId());
      }
      if (signalExternalWorkflowExecutionInitiatedEventAttributes.getRunId() != null) {
        jsonGenerator
            .writeFieldName("runId")
            .writeValue(signalExternalWorkflowExecutionInitiatedEventAttributes.getRunId());
      }
      if (signalExternalWorkflowExecutionInitiatedEventAttributes.getSignalName() != null) {
        jsonGenerator
            .writeFieldName("signalName")
            .writeValue(signalExternalWorkflowExecutionInitiatedEventAttributes.getSignalName());
      }
      if (signalExternalWorkflowExecutionInitiatedEventAttributes.getInput() != null) {
        jsonGenerator
            .writeFieldName("input")
            .writeValue(signalExternalWorkflowExecutionInitiatedEventAttributes.getInput());
      }
      if (signalExternalWorkflowExecutionInitiatedEventAttributes.getDecisionTaskCompletedEventId()
          != null) {
        jsonGenerator
            .writeFieldName("decisionTaskCompletedEventId")
            .writeValue(
                signalExternalWorkflowExecutionInitiatedEventAttributes
                    .getDecisionTaskCompletedEventId());
      }
      if (signalExternalWorkflowExecutionInitiatedEventAttributes.getControl() != null) {
        jsonGenerator
            .writeFieldName("control")
            .writeValue(signalExternalWorkflowExecutionInitiatedEventAttributes.getControl());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<ListActivityTypesRequest> marshall(
      ListActivityTypesRequest listActivityTypesRequest) {
    if (listActivityTypesRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<ListActivityTypesRequest> request =
        new DefaultRequest<ListActivityTypesRequest>(
            listActivityTypesRequest, "AmazonSimpleWorkflow");
    String target = "SimpleWorkflowService.ListActivityTypes";
    request.addHeader("X-Amz-Target", target);
    request.addHeader("Content-Type", "application/x-amz-json-1.0");
    request.setHttpMethod(POST);

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);
      jsonWriter.object();

      if (listActivityTypesRequest.getDomain() != null) {
        jsonWriter.key("domain").value(listActivityTypesRequest.getDomain());
      }
      if (listActivityTypesRequest.getName() != null) {
        jsonWriter.key("name").value(listActivityTypesRequest.getName());
      }
      if (listActivityTypesRequest.getRegistrationStatus() != null) {
        jsonWriter
            .key("registrationStatus")
            .value(listActivityTypesRequest.getRegistrationStatus());
      }
      if (listActivityTypesRequest.getNextPageToken() != null) {
        jsonWriter.key("nextPageToken").value(listActivityTypesRequest.getNextPageToken());
      }
      if (listActivityTypesRequest.getMaximumPageSize() != null) {
        jsonWriter.key("maximumPageSize").value(listActivityTypesRequest.getMaximumPageSize());
      }
      if (listActivityTypesRequest.isReverseOrder() != null) {
        jsonWriter.key("reverseOrder").value(listActivityTypesRequest.isReverseOrder());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes("UTF-8");
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      return request;
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<RespondActivityTaskFailedRequest> marshall(
      RespondActivityTaskFailedRequest respondActivityTaskFailedRequest) {

    if (respondActivityTaskFailedRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<RespondActivityTaskFailedRequest> request =
        new DefaultRequest<RespondActivityTaskFailedRequest>(
            respondActivityTaskFailedRequest, "AmazonSimpleWorkflow");
    request.addHeader("X-Amz-Target", "SimpleWorkflowService.RespondActivityTaskFailed");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (respondActivityTaskFailedRequest.getTaskToken() != null) {
        jsonGenerator
            .writeFieldName("taskToken")
            .writeValue(respondActivityTaskFailedRequest.getTaskToken());
      }
      if (respondActivityTaskFailedRequest.getReason() != null) {
        jsonGenerator
            .writeFieldName("reason")
            .writeValue(respondActivityTaskFailedRequest.getReason());
      }
      if (respondActivityTaskFailedRequest.getDetails() != null) {
        jsonGenerator
            .writeFieldName("details")
            .writeValue(respondActivityTaskFailedRequest.getDetails());
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      WorkflowTypeConfiguration workflowTypeConfiguration, StructuredJsonGenerator jsonGenerator) {

    if (workflowTypeConfiguration == null) {
      throw new SdkClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonGenerator.writeStartObject();

      if (workflowTypeConfiguration.getDefaultTaskStartToCloseTimeout() != null) {
        jsonGenerator
            .writeFieldName("defaultTaskStartToCloseTimeout")
            .writeValue(workflowTypeConfiguration.getDefaultTaskStartToCloseTimeout());
      }
      if (workflowTypeConfiguration.getDefaultExecutionStartToCloseTimeout() != null) {
        jsonGenerator
            .writeFieldName("defaultExecutionStartToCloseTimeout")
            .writeValue(workflowTypeConfiguration.getDefaultExecutionStartToCloseTimeout());
      }
      if (workflowTypeConfiguration.getDefaultTaskList() != null) {
        jsonGenerator.writeFieldName("defaultTaskList");
        TaskListJsonMarshaller.getInstance()
            .marshall(workflowTypeConfiguration.getDefaultTaskList(), jsonGenerator);
      }
      if (workflowTypeConfiguration.getDefaultTaskPriority() != null) {
        jsonGenerator
            .writeFieldName("defaultTaskPriority")
            .writeValue(workflowTypeConfiguration.getDefaultTaskPriority());
      }
      if (workflowTypeConfiguration.getDefaultChildPolicy() != null) {
        jsonGenerator
            .writeFieldName("defaultChildPolicy")
            .writeValue(workflowTypeConfiguration.getDefaultChildPolicy());
      }
      if (workflowTypeConfiguration.getDefaultLambdaRole() != null) {
        jsonGenerator
            .writeFieldName("defaultLambdaRole")
            .writeValue(workflowTypeConfiguration.getDefaultLambdaRole());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
コード例 #7
0
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      ExecutionTimeFilter executionTimeFilter, StructuredJsonGenerator jsonGenerator) {

    if (executionTimeFilter == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonGenerator.writeStartObject();

      if (executionTimeFilter.getOldestDate() != null) {
        jsonGenerator.writeFieldName("oldestDate").writeValue(executionTimeFilter.getOldestDate());
      }
      if (executionTimeFilter.getLatestDate() != null) {
        jsonGenerator.writeFieldName("latestDate").writeValue(executionTimeFilter.getLatestDate());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      RequestCancelActivityTaskDecisionAttributes requestCancelActivityTaskDecisionAttributes,
      StructuredJsonGenerator jsonGenerator) {

    if (requestCancelActivityTaskDecisionAttributes == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonGenerator.writeStartObject();

      if (requestCancelActivityTaskDecisionAttributes.getActivityId() != null) {
        jsonGenerator
            .writeFieldName("activityId")
            .writeValue(requestCancelActivityTaskDecisionAttributes.getActivityId());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  /** Marshall the given parameter object, and output to a SdkJsonGenerator */
  public void marshall(
      ActivityTaskFailedEventAttributes activityTaskFailedEventAttributes,
      StructuredJsonGenerator jsonGenerator) {

    if (activityTaskFailedEventAttributes == null) {
      throw new SdkClientException("Invalid argument passed to marshall(...)");
    }

    try {
      jsonGenerator.writeStartObject();

      if (activityTaskFailedEventAttributes.getReason() != null) {
        jsonGenerator
            .writeFieldName("reason")
            .writeValue(activityTaskFailedEventAttributes.getReason());
      }
      if (activityTaskFailedEventAttributes.getDetails() != null) {
        jsonGenerator
            .writeFieldName("details")
            .writeValue(activityTaskFailedEventAttributes.getDetails());
      }
      if (activityTaskFailedEventAttributes.getScheduledEventId() != null) {
        jsonGenerator
            .writeFieldName("scheduledEventId")
            .writeValue(activityTaskFailedEventAttributes.getScheduledEventId());
      }
      if (activityTaskFailedEventAttributes.getStartedEventId() != null) {
        jsonGenerator
            .writeFieldName("startedEventId")
            .writeValue(activityTaskFailedEventAttributes.getStartedEventId());
      }

      jsonGenerator.writeEndObject();
    } catch (Throwable t) {
      throw new SdkClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<ListClosedWorkflowExecutionsRequest> marshall(
      ListClosedWorkflowExecutionsRequest listClosedWorkflowExecutionsRequest) {
    if (listClosedWorkflowExecutionsRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<ListClosedWorkflowExecutionsRequest> request =
        new DefaultRequest<ListClosedWorkflowExecutionsRequest>(
            listClosedWorkflowExecutionsRequest, "AmazonSimpleWorkflow");
    String target = "SimpleWorkflowService.ListClosedWorkflowExecutions";
    request.addHeader("X-Amz-Target", target);
    request.addHeader("Content-Type", "application/x-amz-json-1.0");

    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "";

    uriResourcePath = uriResourcePath.replaceAll("//", "/");

    if (uriResourcePath.contains("?")) {
      String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1);
      uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?"));

      for (String s : queryString.split("[;&]")) {
        String[] nameValuePair = s.split("=");
        if (nameValuePair.length == 2) {
          request.addParameter(nameValuePair[0], nameValuePair[1]);
        } else {
          request.addParameter(s, null);
        }
      }
    }

    request.setResourcePath(uriResourcePath);

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (listClosedWorkflowExecutionsRequest.getDomain() != null) {
        jsonWriter.key("domain").value(listClosedWorkflowExecutionsRequest.getDomain());
      }
      ExecutionTimeFilter startTimeFilter =
          listClosedWorkflowExecutionsRequest.getStartTimeFilter();
      if (startTimeFilter != null) {

        jsonWriter.key("startTimeFilter");
        jsonWriter.object();

        if (startTimeFilter.getOldestDate() != null) {
          jsonWriter.key("oldestDate").value(startTimeFilter.getOldestDate());
        }
        if (startTimeFilter.getLatestDate() != null) {
          jsonWriter.key("latestDate").value(startTimeFilter.getLatestDate());
        }
        jsonWriter.endObject();
      }
      ExecutionTimeFilter closeTimeFilter =
          listClosedWorkflowExecutionsRequest.getCloseTimeFilter();
      if (closeTimeFilter != null) {

        jsonWriter.key("closeTimeFilter");
        jsonWriter.object();

        if (closeTimeFilter.getOldestDate() != null) {
          jsonWriter.key("oldestDate").value(closeTimeFilter.getOldestDate());
        }
        if (closeTimeFilter.getLatestDate() != null) {
          jsonWriter.key("latestDate").value(closeTimeFilter.getLatestDate());
        }
        jsonWriter.endObject();
      }
      WorkflowExecutionFilter executionFilter =
          listClosedWorkflowExecutionsRequest.getExecutionFilter();
      if (executionFilter != null) {

        jsonWriter.key("executionFilter");
        jsonWriter.object();

        if (executionFilter.getWorkflowId() != null) {
          jsonWriter.key("workflowId").value(executionFilter.getWorkflowId());
        }
        jsonWriter.endObject();
      }
      CloseStatusFilter closeStatusFilter =
          listClosedWorkflowExecutionsRequest.getCloseStatusFilter();
      if (closeStatusFilter != null) {

        jsonWriter.key("closeStatusFilter");
        jsonWriter.object();

        if (closeStatusFilter.getStatus() != null) {
          jsonWriter.key("status").value(closeStatusFilter.getStatus());
        }
        jsonWriter.endObject();
      }
      WorkflowTypeFilter typeFilter = listClosedWorkflowExecutionsRequest.getTypeFilter();
      if (typeFilter != null) {

        jsonWriter.key("typeFilter");
        jsonWriter.object();

        if (typeFilter.getName() != null) {
          jsonWriter.key("name").value(typeFilter.getName());
        }
        if (typeFilter.getVersion() != null) {
          jsonWriter.key("version").value(typeFilter.getVersion());
        }
        jsonWriter.endObject();
      }
      TagFilter tagFilter = listClosedWorkflowExecutionsRequest.getTagFilter();
      if (tagFilter != null) {

        jsonWriter.key("tagFilter");
        jsonWriter.object();

        if (tagFilter.getTag() != null) {
          jsonWriter.key("tag").value(tagFilter.getTag());
        }
        jsonWriter.endObject();
      }
      if (listClosedWorkflowExecutionsRequest.getNextPageToken() != null) {
        jsonWriter
            .key("nextPageToken")
            .value(listClosedWorkflowExecutionsRequest.getNextPageToken());
      }
      if (listClosedWorkflowExecutionsRequest.getMaximumPageSize() != null) {
        jsonWriter
            .key("maximumPageSize")
            .value(listClosedWorkflowExecutionsRequest.getMaximumPageSize());
      }
      if (listClosedWorkflowExecutionsRequest.isReverseOrder() != null) {
        jsonWriter.key("reverseOrder").value(listClosedWorkflowExecutionsRequest.isReverseOrder());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes("UTF-8");
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
コード例 #11
0
  public Request<StartWorkflowExecutionRequest> marshall(
      StartWorkflowExecutionRequest startWorkflowExecutionRequest) {
    if (startWorkflowExecutionRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<StartWorkflowExecutionRequest> request =
        new DefaultRequest<StartWorkflowExecutionRequest>(
            startWorkflowExecutionRequest, "AmazonSimpleWorkflow");
    String target = "SimpleWorkflowService.StartWorkflowExecution";
    request.addHeader("X-Amz-Target", target);

    request.setHttpMethod(HttpMethodName.POST);
    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (startWorkflowExecutionRequest.getDomain() != null) {
        jsonWriter.key("domain").value(startWorkflowExecutionRequest.getDomain());
      }
      if (startWorkflowExecutionRequest.getWorkflowId() != null) {
        jsonWriter.key("workflowId").value(startWorkflowExecutionRequest.getWorkflowId());
      }
      WorkflowType workflowType = startWorkflowExecutionRequest.getWorkflowType();
      if (workflowType != null) {

        jsonWriter.key("workflowType");
        jsonWriter.object();

        if (workflowType.getName() != null) {
          jsonWriter.key("name").value(workflowType.getName());
        }
        if (workflowType.getVersion() != null) {
          jsonWriter.key("version").value(workflowType.getVersion());
        }
        jsonWriter.endObject();
      }
      TaskList taskList = startWorkflowExecutionRequest.getTaskList();
      if (taskList != null) {

        jsonWriter.key("taskList");
        jsonWriter.object();

        if (taskList.getName() != null) {
          jsonWriter.key("name").value(taskList.getName());
        }
        jsonWriter.endObject();
      }
      if (startWorkflowExecutionRequest.getInput() != null) {
        jsonWriter.key("input").value(startWorkflowExecutionRequest.getInput());
      }
      if (startWorkflowExecutionRequest.getExecutionStartToCloseTimeout() != null) {
        jsonWriter
            .key("executionStartToCloseTimeout")
            .value(startWorkflowExecutionRequest.getExecutionStartToCloseTimeout());
      }

      com.amazonaws.internal.ListWithAutoConstructFlag<String> tagListList =
          (com.amazonaws.internal.ListWithAutoConstructFlag<String>)
              (startWorkflowExecutionRequest.getTagList());
      if (tagListList != null && !(tagListList.isAutoConstruct() && tagListList.isEmpty())) {

        jsonWriter.key("tagList");
        jsonWriter.array();

        for (String tagListListValue : tagListList) {
          if (tagListListValue != null) {
            jsonWriter.value(tagListListValue);
          }
        }
        jsonWriter.endArray();
      }
      if (startWorkflowExecutionRequest.getTaskStartToCloseTimeout() != null) {
        jsonWriter
            .key("taskStartToCloseTimeout")
            .value(startWorkflowExecutionRequest.getTaskStartToCloseTimeout());
      }
      if (startWorkflowExecutionRequest.getChildPolicy() != null) {
        jsonWriter.key("childPolicy").value(startWorkflowExecutionRequest.getChildPolicy());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", "application/x-amz-json-1.0");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<RegisterActivityTypeRequest> marshall(
      RegisterActivityTypeRequest registerActivityTypeRequest) {

    if (registerActivityTypeRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<RegisterActivityTypeRequest> request =
        new DefaultRequest<RegisterActivityTypeRequest>(
            registerActivityTypeRequest, "AmazonSimpleWorkflow");
    request.addHeader("X-Amz-Target", "SimpleWorkflowService.RegisterActivityType");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      final StructuredJsonGenerator jsonGenerator = protocolFactory.createGenerator();

      jsonGenerator.writeStartObject();

      if (registerActivityTypeRequest.getDomain() != null) {
        jsonGenerator.writeFieldName("domain").writeValue(registerActivityTypeRequest.getDomain());
      }
      if (registerActivityTypeRequest.getName() != null) {
        jsonGenerator.writeFieldName("name").writeValue(registerActivityTypeRequest.getName());
      }
      if (registerActivityTypeRequest.getVersion() != null) {
        jsonGenerator
            .writeFieldName("version")
            .writeValue(registerActivityTypeRequest.getVersion());
      }
      if (registerActivityTypeRequest.getDescription() != null) {
        jsonGenerator
            .writeFieldName("description")
            .writeValue(registerActivityTypeRequest.getDescription());
      }
      if (registerActivityTypeRequest.getDefaultTaskStartToCloseTimeout() != null) {
        jsonGenerator
            .writeFieldName("defaultTaskStartToCloseTimeout")
            .writeValue(registerActivityTypeRequest.getDefaultTaskStartToCloseTimeout());
      }
      if (registerActivityTypeRequest.getDefaultTaskHeartbeatTimeout() != null) {
        jsonGenerator
            .writeFieldName("defaultTaskHeartbeatTimeout")
            .writeValue(registerActivityTypeRequest.getDefaultTaskHeartbeatTimeout());
      }
      if (registerActivityTypeRequest.getDefaultTaskList() != null) {
        jsonGenerator.writeFieldName("defaultTaskList");
        TaskListJsonMarshaller.getInstance()
            .marshall(registerActivityTypeRequest.getDefaultTaskList(), jsonGenerator);
      }
      if (registerActivityTypeRequest.getDefaultTaskPriority() != null) {
        jsonGenerator
            .writeFieldName("defaultTaskPriority")
            .writeValue(registerActivityTypeRequest.getDefaultTaskPriority());
      }
      if (registerActivityTypeRequest.getDefaultTaskScheduleToStartTimeout() != null) {
        jsonGenerator
            .writeFieldName("defaultTaskScheduleToStartTimeout")
            .writeValue(registerActivityTypeRequest.getDefaultTaskScheduleToStartTimeout());
      }
      if (registerActivityTypeRequest.getDefaultTaskScheduleToCloseTimeout() != null) {
        jsonGenerator
            .writeFieldName("defaultTaskScheduleToCloseTimeout")
            .writeValue(registerActivityTypeRequest.getDefaultTaskScheduleToCloseTimeout());
      }

      jsonGenerator.writeEndObject();

      byte[] content = jsonGenerator.getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", protocolFactory.getContentType());
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }
  public Request<RegisterWorkflowTypeRequest> marshall(
      RegisterWorkflowTypeRequest registerWorkflowTypeRequest) {
    if (registerWorkflowTypeRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<RegisterWorkflowTypeRequest> request =
        new DefaultRequest<RegisterWorkflowTypeRequest>(
            registerWorkflowTypeRequest, "AmazonSimpleWorkflow");
    String target = "SimpleWorkflowService.RegisterWorkflowType";
    request.addHeader("X-Amz-Target", target);
    request.addHeader("Content-Type", "application/x-amz-json-1.0");
    request.setHttpMethod(POST);

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);
      jsonWriter.object();

      if (registerWorkflowTypeRequest.getDomain() != null) {
        jsonWriter.key("domain").value(registerWorkflowTypeRequest.getDomain());
      }
      if (registerWorkflowTypeRequest.getName() != null) {
        jsonWriter.key("name").value(registerWorkflowTypeRequest.getName());
      }
      if (registerWorkflowTypeRequest.getVersion() != null) {
        jsonWriter.key("version").value(registerWorkflowTypeRequest.getVersion());
      }
      if (registerWorkflowTypeRequest.getDescription() != null) {
        jsonWriter.key("description").value(registerWorkflowTypeRequest.getDescription());
      }
      if (registerWorkflowTypeRequest.getDefaultTaskStartToCloseTimeout() != null) {
        jsonWriter
            .key("defaultTaskStartToCloseTimeout")
            .value(registerWorkflowTypeRequest.getDefaultTaskStartToCloseTimeout());
      }
      if (registerWorkflowTypeRequest.getDefaultExecutionStartToCloseTimeout() != null) {
        jsonWriter
            .key("defaultExecutionStartToCloseTimeout")
            .value(registerWorkflowTypeRequest.getDefaultExecutionStartToCloseTimeout());
      }
      if (registerWorkflowTypeRequest != null) {
        TaskList taskListDefaultTaskList = registerWorkflowTypeRequest.getDefaultTaskList();
        if (taskListDefaultTaskList != null) {
          jsonWriter.key("defaultTaskList").object();
          if (taskListDefaultTaskList.getName() != null) {
            jsonWriter.key("name").value(taskListDefaultTaskList.getName());
          }
          jsonWriter.endObject();
        }
      }
      if (registerWorkflowTypeRequest.getDefaultChildPolicy() != null) {
        jsonWriter
            .key("defaultChildPolicy")
            .value(registerWorkflowTypeRequest.getDefaultChildPolicy());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes("UTF-8");
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      return request;
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }
  }
  public Request<StartWorkflowExecutionRequest> marshall(
      StartWorkflowExecutionRequest startWorkflowExecutionRequest) {
    if (startWorkflowExecutionRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<StartWorkflowExecutionRequest> request =
        new DefaultRequest<StartWorkflowExecutionRequest>(
            startWorkflowExecutionRequest, "AmazonSimpleWorkflow");
    String target = "SimpleWorkflowService.StartWorkflowExecution";
    request.addHeader("X-Amz-Target", target);
    request.addHeader("Content-Type", "application/x-amz-json-1.0");

    request.setHttpMethod(HttpMethodName.POST);

    String uriResourcePath = "";

    uriResourcePath = uriResourcePath.replaceAll("//", "/");

    if (uriResourcePath.contains("?")) {
      String queryString = uriResourcePath.substring(uriResourcePath.indexOf("?") + 1);
      uriResourcePath = uriResourcePath.substring(0, uriResourcePath.indexOf("?"));

      for (String s : queryString.split("[;&]")) {
        String[] nameValuePair = s.split("=");
        if (nameValuePair.length == 2) {
          request.addParameter(nameValuePair[0], nameValuePair[1]);
        } else {
          request.addParameter(s, null);
        }
      }
    }

    request.setResourcePath(uriResourcePath);

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (startWorkflowExecutionRequest.getDomain() != null) {
        jsonWriter.key("domain").value(startWorkflowExecutionRequest.getDomain());
      }
      if (startWorkflowExecutionRequest.getWorkflowId() != null) {
        jsonWriter.key("workflowId").value(startWorkflowExecutionRequest.getWorkflowId());
      }
      WorkflowType workflowType = startWorkflowExecutionRequest.getWorkflowType();
      if (workflowType != null) {

        jsonWriter.key("workflowType");
        jsonWriter.object();

        if (workflowType.getName() != null) {
          jsonWriter.key("name").value(workflowType.getName());
        }
        if (workflowType.getVersion() != null) {
          jsonWriter.key("version").value(workflowType.getVersion());
        }
        jsonWriter.endObject();
      }
      TaskList taskList = startWorkflowExecutionRequest.getTaskList();
      if (taskList != null) {

        jsonWriter.key("taskList");
        jsonWriter.object();

        if (taskList.getName() != null) {
          jsonWriter.key("name").value(taskList.getName());
        }
        jsonWriter.endObject();
      }
      if (startWorkflowExecutionRequest.getInput() != null) {
        jsonWriter.key("input").value(startWorkflowExecutionRequest.getInput());
      }
      if (startWorkflowExecutionRequest.getExecutionStartToCloseTimeout() != null) {
        jsonWriter
            .key("executionStartToCloseTimeout")
            .value(startWorkflowExecutionRequest.getExecutionStartToCloseTimeout());
      }

      java.util.List<String> tagListList = startWorkflowExecutionRequest.getTagList();
      if (tagListList != null && tagListList.size() > 0) {

        jsonWriter.key("tagList");
        jsonWriter.array();

        for (String tagListListValue : tagListList) {
          if (tagListListValue != null) {
            jsonWriter.value(tagListListValue);
          }
        }
        jsonWriter.endArray();
      }
      if (startWorkflowExecutionRequest.getTaskStartToCloseTimeout() != null) {
        jsonWriter
            .key("taskStartToCloseTimeout")
            .value(startWorkflowExecutionRequest.getTaskStartToCloseTimeout());
      }
      if (startWorkflowExecutionRequest.getChildPolicy() != null) {
        jsonWriter.key("childPolicy").value(startWorkflowExecutionRequest.getChildPolicy());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes("UTF-8");
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }