public MaintenanceWindowAutomationParameters unmarshall(JsonUnmarshallerContext context) throws Exception { MaintenanceWindowAutomationParameters maintenanceWindowAutomationParameters = new MaintenanceWindowAutomationParameters(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (context.testExpression("DocumentVersion", targetDepth)) { context.nextToken(); maintenanceWindowAutomationParameters.setDocumentVersion(context.getUnmarshaller(String.class).unmarshall(context)); if (context.testExpression("Parameters", targetDepth)) { context.nextToken(); maintenanceWindowAutomationParameters.setParameters(new MapUnmarshaller<String, java.util.List<String>>(context .getUnmarshaller(String.class), new ListUnmarshaller<String>(context.getUnmarshaller(String.class))).unmarshall(context));
public InitiateVaultLockResult unmarshall(JsonUnmarshallerContext context) throws Exception { InitiateVaultLockResult initiateVaultLockResult = new InitiateVaultLockResult(); if (context.isStartOfDocument()) { if (context.getHeader("x-amz-lock-id") != null) { context.setCurrentHeader("x-amz-lock-id"); initiateVaultLockResult.setLockId(context.getUnmarshaller(String.class).unmarshall(context)); } } return initiateVaultLockResult; }
public Map<K, V> unmarshall(JsonUnmarshallerContext context) throws Exception { Map<K, V> map = new HashMap<K, V>(); int originalDepth = context.getCurrentDepth(); if (context.getCurrentToken() == JsonToken.VALUE_NULL) { return null; } while (true) { JsonToken token = context.nextToken(); if (token == null) return map; if (token == FIELD_NAME) { K k = keyUnmarshaller.unmarshall(context); token = context.nextToken(); V v = valueUnmarshaller.unmarshall(context); map.put(k, v); } else if (token == END_ARRAY || token == END_OBJECT) { if (context.getCurrentDepth() <= originalDepth) return map; } } }
/** * Unmarshalls the current token in the Json document to list. */ private List<T> unmarshallJsonToList(JsonUnmarshallerContext context) throws Exception { List<T> list = new ArrayList<T>(); if (context.getCurrentToken() == JsonToken.VALUE_NULL) { return null; } while (true) { JsonToken token = context.nextToken(); if (token == null) { return list; } if (token == END_ARRAY) { return list; } else { list.add(itemUnmarshaller.unmarshall(context)); } } } }
public BigDecimal unmarshall(JsonUnmarshallerContext unmarshallerContext) throws Exception { JsonParser parser = unmarshallerContext.getJsonParser(); Unmarshaller<BigInteger, JsonUnmarshallerContext> bigIntegerUnmarshaller = unmarshallerContext.getUnmarshaller(BigInteger.class); JsonToken current = parser.getCurrentToken(); if (current != JsonToken.START_ARRAY) { throw new SdkClientException("Invalid BigDecimal Format."); } parser.nextToken(); int exponent = parser.getIntValue(); parser.nextToken(); BigInteger mantissa = bigIntegerUnmarshaller.unmarshall(unmarshallerContext); return new BigDecimal(mantissa, exponent); }
/** * Un marshalls the response header into the list. */ private List<T> unmarshallResponseHeaderToList( JsonUnmarshallerContext context) throws Exception { String headerValue = context.readText(); List<T> list = new ArrayList<T>(); String[] headerValues = headerValue.split("[,]"); for (final String headerVal : headerValues) { list.add(itemUnmarshaller.unmarshall(new JsonUnmarshallerContext() { @Override public String readText() { return headerVal; } })); } return list; }
/** * @see com.amazonaws.http.HttpResponseHandler#handle(com.amazonaws.http.HttpResponse) */ public AmazonWebServiceResponse<T> handle(HttpResponse response) throws Exception { AmazonWebServiceResponse<T> awsResponse = parseResponseMetadata(response); responseHeaders = response.getHeaders(); if (responseUnmarshaller != null) { log.trace("Beginning to parse service response XML"); T result = responseUnmarshaller.unmarshall(response.getContent()); log.trace("Done parsing service response XML"); awsResponse.setResult(result); } return awsResponse; }
public PurchaseProvisionedCapacityResult unmarshall(JsonUnmarshallerContext context) throws Exception { PurchaseProvisionedCapacityResult purchaseProvisionedCapacityResult = new PurchaseProvisionedCapacityResult(); if (context.isStartOfDocument()) { if (context.getHeader("x-amz-capacity-id") != null) { context.setCurrentHeader("x-amz-capacity-id"); purchaseProvisionedCapacityResult.setCapacityId(context.getUnmarshaller(String.class).unmarshall(context)); } } return purchaseProvisionedCapacityResult; }
private AmazonServiceException createAse(HttpResponse errorResponse) throws Exception { // Try to parse the error response as XML final Document document = documentFromContent(errorResponse.getContent(), idString(errorResponse)); /* * We need to select which exception unmarshaller is the correct one to * use from all the possible exceptions this operation can throw. * Currently we rely on the unmarshallers to return null if they can't * unmarshall the response, but we might need something a little more * sophisticated in the future. */ for (Unmarshaller<AmazonServiceException, Node> unmarshaller : unmarshallerList) { AmazonServiceException ase = unmarshaller.unmarshall(document); if (ase != null) { ase.setStatusCode(errorResponse.getStatusCode()); return ase; } } return null; }
public DeploymentCommand unmarshall(JsonUnmarshallerContext context) throws Exception { DeploymentCommand deploymentCommand = new DeploymentCommand(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (context.testExpression("Name", targetDepth)) { context.nextToken(); deploymentCommand.setName(context.getUnmarshaller(String.class).unmarshall(context)); if (context.testExpression("Args", targetDepth)) { context.nextToken(); deploymentCommand.setArgs(new MapUnmarshaller<String, java.util.List<String>>(context.getUnmarshaller(String.class), new ListUnmarshaller<String>(context.getUnmarshaller(String.class))).unmarshall(context));
public CreateVaultResult unmarshall(JsonUnmarshallerContext context) throws Exception { CreateVaultResult createVaultResult = new CreateVaultResult(); if (context.isStartOfDocument()) { if (context.getHeader("Location") != null) { context.setCurrentHeader("Location"); createVaultResult.setLocation(context.getUnmarshaller(String.class).unmarshall(context)); } } return createVaultResult; }
public EndpointUser unmarshall(JsonUnmarshallerContext context) throws Exception { EndpointUser endpointUser = new EndpointUser(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (context.testExpression("UserAttributes", targetDepth)) { context.nextToken(); endpointUser.setUserAttributes(new MapUnmarshaller<String, java.util.List<String>>(context.getUnmarshaller(String.class), new ListUnmarshaller<String>(context.getUnmarshaller(String.class))).unmarshall(context)); if (context.testExpression("UserId", targetDepth)) { context.nextToken(); endpointUser.setUserId(context.getUnmarshaller(String.class).unmarshall(context));
public UploadMultipartPartResult unmarshall(JsonUnmarshallerContext context) throws Exception { UploadMultipartPartResult uploadMultipartPartResult = new UploadMultipartPartResult(); if (context.isStartOfDocument()) { if (context.getHeader("x-amz-sha256-tree-hash") != null) { context.setCurrentHeader("x-amz-sha256-tree-hash"); uploadMultipartPartResult.setChecksum(context.getUnmarshaller(String.class).unmarshall(context)); } } return uploadMultipartPartResult; }
public DefaultMessage unmarshall(JsonUnmarshallerContext context) throws Exception { DefaultMessage defaultMessage = new DefaultMessage(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (context.testExpression("Body", targetDepth)) { context.nextToken(); defaultMessage.setBody(context.getUnmarshaller(String.class).unmarshall(context)); if (context.testExpression("Substitutions", targetDepth)) { context.nextToken(); defaultMessage.setSubstitutions(new MapUnmarshaller<String, java.util.List<String>>(context.getUnmarshaller(String.class), new ListUnmarshaller<String>(context.getUnmarshaller(String.class))).unmarshall(context));
public InitiateMultipartUploadResult unmarshall(JsonUnmarshallerContext context) throws Exception { InitiateMultipartUploadResult initiateMultipartUploadResult = new InitiateMultipartUploadResult(); if (context.isStartOfDocument()) { if (context.getHeader("Location") != null) { context.setCurrentHeader("Location"); initiateMultipartUploadResult.setLocation(context.getUnmarshaller(String.class).unmarshall(context)); } if (context.getHeader("x-amz-multipart-upload-id") != null) { context.setCurrentHeader("x-amz-multipart-upload-id"); initiateMultipartUploadResult.setUploadId(context.getUnmarshaller(String.class).unmarshall(context)); } } return initiateMultipartUploadResult; }
public ListConfigurationsResult unmarshall(JsonUnmarshallerContext context) throws Exception { ListConfigurationsResult listConfigurationsResult = new ListConfigurationsResult(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (context.testExpression("configurations", targetDepth)) { context.nextToken(); listConfigurationsResult.setConfigurations(new ListUnmarshaller<java.util.Map<String, String>>(new MapUnmarshaller<String, String>(context .getUnmarshaller(String.class), context.getUnmarshaller(String.class))).unmarshall(context)); if (context.testExpression("nextToken", targetDepth)) { context.nextToken(); listConfigurationsResult.setNextToken(context.getUnmarshaller(String.class).unmarshall(context));
public UploadArchiveResult unmarshall(JsonUnmarshallerContext context) throws Exception { UploadArchiveResult uploadArchiveResult = new UploadArchiveResult(); if (context.isStartOfDocument()) { if (context.getHeader("Location") != null) { context.setCurrentHeader("Location"); uploadArchiveResult.setLocation(context.getUnmarshaller(String.class).unmarshall(context)); } if (context.getHeader("x-amz-sha256-tree-hash") != null) { context.setCurrentHeader("x-amz-sha256-tree-hash"); uploadArchiveResult.setChecksum(context.getUnmarshaller(String.class).unmarshall(context)); } if (context.getHeader("x-amz-archive-id") != null) { context.setCurrentHeader("x-amz-archive-id"); uploadArchiveResult.setArchiveId(context.getUnmarshaller(String.class).unmarshall(context)); } } return uploadArchiveResult; }
public FailureDetails unmarshall(JsonUnmarshallerContext context) throws Exception { FailureDetails failureDetails = new FailureDetails(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (context.testExpression("FailureStage", targetDepth)) { context.nextToken(); failureDetails.setFailureStage(context.getUnmarshaller(String.class).unmarshall(context)); if (context.testExpression("FailureType", targetDepth)) { context.nextToken(); failureDetails.setFailureType(context.getUnmarshaller(String.class).unmarshall(context)); if (context.testExpression("Details", targetDepth)) { context.nextToken(); failureDetails.setDetails(new MapUnmarshaller<String, java.util.List<String>>(context.getUnmarshaller(String.class), new ListUnmarshaller<String>(context.getUnmarshaller(String.class))).unmarshall(context));
public InitiateJobResult unmarshall(JsonUnmarshallerContext context) throws Exception { InitiateJobResult initiateJobResult = new InitiateJobResult(); if (context.isStartOfDocument()) { if (context.getHeader("Location") != null) { context.setCurrentHeader("Location"); initiateJobResult.setLocation(context.getUnmarshaller(String.class).unmarshall(context)); } if (context.getHeader("x-amz-job-id") != null) { context.setCurrentHeader("x-amz-job-id"); initiateJobResult.setJobId(context.getUnmarshaller(String.class).unmarshall(context)); } if (context.getHeader("x-amz-job-output-path") != null) { context.setCurrentHeader("x-amz-job-output-path"); initiateJobResult.setJobOutputPath(context.getUnmarshaller(String.class).unmarshall(context)); } } return initiateJobResult; }
public ListUniqueProblemsResult unmarshall(JsonUnmarshallerContext context) throws Exception { ListUniqueProblemsResult listUniqueProblemsResult = new ListUniqueProblemsResult(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (context.testExpression("uniqueProblems", targetDepth)) { context.nextToken(); listUniqueProblemsResult.setUniqueProblems(new MapUnmarshaller<String, java.util.List<UniqueProblem>>( context.getUnmarshaller(String.class), new ListUnmarshaller<UniqueProblem>(UniqueProblemJsonUnmarshaller.getInstance())) .unmarshall(context)); if (context.testExpression("nextToken", targetDepth)) { context.nextToken(); listUniqueProblemsResult.setNextToken(context.getUnmarshaller(String.class).unmarshall(context));