private void init() { exceptionUnmarshallers.add(new LegacyErrorUnmarshaller(com.amazonaws.services.ec2.model.AmazonEC2Exception.class)); setServiceNameIntern(DEFAULT_SIGNING_NAME); setEndpointPrefix(ENDPOINT_PREFIX); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("https://ec2.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/ec2/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/ec2/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); }
@Override public AmazonServiceException unmarshall(Node in) throws Exception { XPath xpath = xpath(); String errorCode = parseErrorCode(in, xpath); String message = asString("Response/Errors/Error/Message", in, xpath); String requestId = asString("Response/RequestID", in, xpath); String errorType = asString("Response/Errors/Error/Type", in, xpath); Constructor<? extends AmazonServiceException> constructor = exceptionClass.getConstructor(String.class); AmazonServiceException ase = constructor.newInstance(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if (errorType.equalsIgnoreCase("server")) { ase.setErrorType(ErrorType.Service); } else if (errorType.equalsIgnoreCase("client")) { ase.setErrorType(ErrorType.Client); } return ase; }
@Override public AmazonServiceException unmarshall(Node node) throws Exception { // Bail out if this isn't the right error code that this // marshaller understands String errorCode = parseErrorCode(node); if (errorCode == null || !errorCode.equals("NumberDomainAttributesExceeded")) return null; NumberDomainAttributesExceededException e = (NumberDomainAttributesExceededException) super.unmarshall(node); e.setBoxUsage(XpathUtils.asFloat(getErrorPropertyPath("BoxUsage"), node)); return e; } }
@Test public void testUnmarshall() throws TransformerFactoryConfigurationError, Exception { Document xmlDoc = new DocumentImpl(); Element root = xmlDoc.createElement("Response"); Element requestId = xmlDoc.createElement("RequestID"); requestId.appendChild(xmlDoc.createTextNode("TestId")); Element errors = xmlDoc.createElement("Errors"); Element error = xmlDoc.createElement("Error"); Element message = xmlDoc.createElement("Message"); message.appendChild(xmlDoc.createTextNode("TestMessage")); Element type = xmlDoc.createElement("Type"); type.appendChild(xmlDoc.createTextNode("server")); Element code = xmlDoc.createElement("Code"); code.appendChild(xmlDoc.createTextNode("TestCode")); error.appendChild(message); error.appendChild(type); error.appendChild(code); errors.appendChild(error); root.appendChild(errors); root.appendChild(requestId); xmlDoc.appendChild(root); LegacyErrorUnmarshaller leu = new LegacyErrorUnmarshaller(); AmazonServiceException ase = leu.unmarshall(xmlDoc); assertEquals(ase.getErrorCode(), "TestCode"); assertEquals(ase.getErrorMessage(), "TestMessage"); assertEquals(ase.getErrorType(), ErrorType.Service); assertEquals(ase.getRequestId(), "TestId"); }
@Test public void testGetErrorPropertyPath() { LegacyErrorUnmarshaller leu = new LegacyErrorUnmarshaller(); assertEquals(leu.getErrorPropertyPath("Property"), "Response/Errors/Error/Property"); } }
@Override public AmazonServiceException unmarshall(Node node) throws Exception { // Bail out if this isn't the right error code that this // marshaller understands String errorCode = parseErrorCode(node); if (errorCode == null || !errorCode.equals("NumberDomainsExceeded")) return null; NumberDomainsExceededException e = (NumberDomainsExceededException) super.unmarshall(node); e.setBoxUsage(XpathUtils.asFloat(getErrorPropertyPath("BoxUsage"), node)); return e; } }
private void init() { exceptionUnmarshallers.add(new NumberItemAttributesExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberSubmittedItemsExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidNumberPredicatesExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberDomainBytesExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new AttributeDoesNotExistExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberDomainsExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new NoSuchDomainExceptionUnmarshaller()); exceptionUnmarshallers.add(new RequestTimeoutExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidParameterValueExceptionUnmarshaller()); exceptionUnmarshallers.add(new DuplicateItemNameExceptionUnmarshaller()); exceptionUnmarshallers.add(new TooManyRequestedAttributesExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberSubmittedAttributesExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidQueryExpressionExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberDomainAttributesExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidNumberValueTestsExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidNextTokenExceptionUnmarshaller()); exceptionUnmarshallers.add(new MissingParameterExceptionUnmarshaller()); exceptionUnmarshallers.add(new LegacyErrorUnmarshaller(com.amazonaws.services.simpledb.model.AmazonSimpleDBException.class)); setServiceNameIntern(DEFAULT_SIGNING_NAME); setEndpointPrefix(ENDPOINT_PREFIX); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("sdb.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/simpledb/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/simpledb/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); }
@Override public AmazonServiceException unmarshall(Node in) throws Exception { String errorCode = parseErrorCode(in); String message = XpathUtils.asString("Response/Errors/Error/Message", in); String requestId = XpathUtils.asString("Response/RequestID", in); String errorType = XpathUtils.asString("Response/Errors/Error/Type", in); Constructor<? extends AmazonServiceException> constructor = exceptionClass .getConstructor(String.class); AmazonServiceException ase = constructor.newInstance(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if ("server".equalsIgnoreCase(errorType)) { ase.setErrorType(ErrorType.Service); } else if ("client".equalsIgnoreCase(errorType)) { ase.setErrorType(ErrorType.Client); } return ase; }
@Override public AmazonServiceException unmarshall(Node node) throws Exception { // Bail out if this isn't the right error code that this // marshaller understands String errorCode = parseErrorCode(node); if (errorCode == null || !errorCode.equals("InvalidNextToken")) return null; InvalidNextTokenException e = (InvalidNextTokenException) super.unmarshall(node); e.setBoxUsage(XpathUtils.asFloat(getErrorPropertyPath("BoxUsage"), node)); return e; } }
private void init() { exceptionUnmarshallers.add(new LegacyErrorUnmarshaller()); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("ec2.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain( "/com/amazonaws/services/ec2/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain( "/com/amazonaws/services/ec2/request.handler2s")); }
@Override public AmazonServiceException unmarshall(Node in) throws Exception { XPath xpath = xpath(); String errorCode = parseErrorCode(in, xpath); String message = asString("Response/Errors/Error/Message", in, xpath); String requestId = asString("Response/RequestID", in, xpath); String errorType = asString("Response/Errors/Error/Type", in, xpath); Constructor<? extends AmazonServiceException> constructor = exceptionClass.getConstructor(String.class); AmazonServiceException ase = constructor.newInstance(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if (errorType.equalsIgnoreCase("server")) { ase.setErrorType(ErrorType.Service); } else if (errorType.equalsIgnoreCase("client")) { ase.setErrorType(ErrorType.Client); } return ase; }
@Override public AmazonServiceException unmarshall(Node node) throws Exception { // Bail out if this isn't the right error code that this // marshaller understands String errorCode = parseErrorCode(node); if (errorCode == null || !errorCode.equals("DuplicateItemName")) return null; DuplicateItemNameException e = (DuplicateItemNameException) super.unmarshall(node); e.setBoxUsage(XpathUtils.asFloat(getErrorPropertyPath("BoxUsage"), node)); return e; } }
private void init() { exceptionUnmarshallers.add(new InvalidNextTokenExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberItemAttributesExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberDomainAttributesExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new DuplicateItemNameExceptionUnmarshaller()); exceptionUnmarshallers.add(new TooManyRequestedAttributesExceptionUnmarshaller()); exceptionUnmarshallers.add(new AttributeDoesNotExistExceptionUnmarshaller()); exceptionUnmarshallers.add(new MissingParameterExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberSubmittedItemsExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidQueryExpressionExceptionUnmarshaller()); exceptionUnmarshallers.add(new NoSuchDomainExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberDomainsExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidParameterValueExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidNumberValueTestsExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberSubmittedAttributesExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new RequestTimeoutExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberDomainBytesExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidNumberPredicatesExceptionUnmarshaller()); exceptionUnmarshallers.add(new LegacyErrorUnmarshaller()); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("sdb.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain( "/com/amazonaws/services/simpledb/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain( "/com/amazonaws/services/simpledb/request.handler2s")); }
@Override public AmazonServiceException unmarshall(Node in) throws Exception { String errorCode = parseErrorCode(in); String message = XpathUtils.asString("Response/Errors/Error/Message", in); String requestId = XpathUtils.asString("Response/RequestID", in); String errorType = XpathUtils.asString("Response/Errors/Error/Type", in); Constructor<? extends AmazonServiceException> constructor = exceptionClass .getConstructor(String.class); AmazonServiceException ase = constructor.newInstance(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if ("server".equalsIgnoreCase(errorType)) { ase.setErrorType(ErrorType.Service); } else if ("client".equalsIgnoreCase(errorType)) { ase.setErrorType(ErrorType.Client); } return ase; }
@Override public AmazonServiceException unmarshall(Node node) throws Exception { // Bail out if this isn't the right error code that this // marshaller understands String errorCode = parseErrorCode(node); if (errorCode == null || !errorCode.equals("NumberDomainBytesExceeded")) return null; NumberDomainBytesExceededException e = (NumberDomainBytesExceededException) super.unmarshall(node); e.setBoxUsage(XpathUtils.asFloat(getErrorPropertyPath("BoxUsage"), node)); return e; } }
private void init() { exceptionUnmarshallers.add(new LegacyErrorUnmarshaller(com.amazonaws.services.ec2.model.AmazonEC2Exception.class)); setServiceNameIntern(DEFAULT_SIGNING_NAME); setEndpointPrefix(ENDPOINT_PREFIX); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("https://ec2.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/ec2/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/ec2/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); }
@Override public AmazonServiceException unmarshall(Node in) throws Exception { String errorCode = parseErrorCode(in); String message = XpathUtils.asString("Response/Errors/Error/Message", in); String requestId = XpathUtils.asString("Response/RequestID", in); String errorType = XpathUtils.asString("Response/Errors/Error/Type", in); Constructor<? extends AmazonServiceException> constructor = exceptionClass .getConstructor(String.class); AmazonServiceException ase = constructor.newInstance(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if ("server".equalsIgnoreCase(errorType)) { ase.setErrorType(ErrorType.Service); } else if ("client".equalsIgnoreCase(errorType)) { ase.setErrorType(ErrorType.Client); } return ase; }
@Override public AmazonServiceException unmarshall(Node node) throws Exception { // Bail out if this isn't the right error code that this // marshaller understands String errorCode = parseErrorCode(node); if (errorCode == null || !errorCode.equals("NumberSubmittedItemsExceeded")) return null; NumberSubmittedItemsExceededException e = (NumberSubmittedItemsExceededException) super.unmarshall(node); e.setBoxUsage(XpathUtils.asFloat(getErrorPropertyPath("BoxUsage"), node)); return e; } }
private void init() { exceptionUnmarshallers.add(new NumberItemAttributesExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberSubmittedItemsExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidNumberPredicatesExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberDomainBytesExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new AttributeDoesNotExistExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberDomainsExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new NoSuchDomainExceptionUnmarshaller()); exceptionUnmarshallers.add(new RequestTimeoutExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidParameterValueExceptionUnmarshaller()); exceptionUnmarshallers.add(new DuplicateItemNameExceptionUnmarshaller()); exceptionUnmarshallers.add(new TooManyRequestedAttributesExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberSubmittedAttributesExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidQueryExpressionExceptionUnmarshaller()); exceptionUnmarshallers.add(new NumberDomainAttributesExceededExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidNumberValueTestsExceptionUnmarshaller()); exceptionUnmarshallers.add(new InvalidNextTokenExceptionUnmarshaller()); exceptionUnmarshallers.add(new MissingParameterExceptionUnmarshaller()); exceptionUnmarshallers.add(new LegacyErrorUnmarshaller(com.amazonaws.services.simpledb.model.AmazonSimpleDBException.class)); setServiceNameIntern(DEFAULT_SIGNING_NAME); setEndpointPrefix(ENDPOINT_PREFIX); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("sdb.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/simpledb/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/simpledb/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); }
@Override public AmazonServiceException unmarshall(Node in) throws Exception { XPath xpath = xpath(); String errorCode = parseErrorCode(in, xpath); String message = asString("Response/Errors/Error/Message", in, xpath); String requestId = asString("Response/RequestID", in, xpath); String errorType = asString("Response/Errors/Error/Type", in, xpath); Constructor<? extends AmazonServiceException> constructor = exceptionClass.getConstructor(String.class); AmazonServiceException ase = constructor.newInstance(message); ase.setErrorCode(errorCode); ase.setRequestId(requestId); if (errorType == null) { ase.setErrorType(ErrorType.Unknown); } else if (errorType.equalsIgnoreCase("server")) { ase.setErrorType(ErrorType.Service); } else if (errorType.equalsIgnoreCase("client")) { ase.setErrorType(ErrorType.Client); } return ase; }