public Request<UpdateHostedZoneCommentRequest> marshall(UpdateHostedZoneCommentRequest updateHostedZoneCommentRequest) { if (updateHostedZoneCommentRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } Request<UpdateHostedZoneCommentRequest> request = new DefaultRequest<UpdateHostedZoneCommentRequest>(updateHostedZoneCommentRequest, "AmazonRoute53"); request.setHttpMethod(HttpMethodName.POST); String uriResourcePath = "/2013-04-01/hostedzone/{Id}"; uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall(uriResourcePath, "Id", updateHostedZoneCommentRequest.getId()); request.setResourcePath(uriResourcePath); try { StringWriter stringWriter = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/"); xmlWriter.startElement("UpdateHostedZoneCommentRequest"); if (updateHostedZoneCommentRequest != null) { if (updateHostedZoneCommentRequest.getComment() != null) { xmlWriter.startElement("Comment").value(updateHostedZoneCommentRequest.getComment()).endElement(); } } xmlWriter.endElement(); request.setContent(new StringInputStream(stringWriter.getBuffer().toString())); request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", "application/xml"); } } catch (Throwable t) { throw new SdkClientException("Unable to marshall request to XML: " + t.getMessage(), t); } return request; }
request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(uriResourcePath); try { StringWriter stringWriter = new StringWriter(); AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter); if (createAppRequest.getCreateApplicationRequest() != null) { String snippet = stringWriter.toString(); byte[] content = snippet.getBytes(UTF8); request.setContent(new StringInputStream(snippet)); request.addHeader("Content-Length", Integer.toString(content.length)); } catch (Throwable t) {
@Override public InputStream adapt(String source) { if (source == null) { return null; } try { return new StringInputStream(source); } catch (UnsupportedEncodingException e) { throw new SdkClientException(e); } } }
public List<FilterPattern> parse() throws InvalidFilterException { try { this.inputStream = new InputStreamReader(new StringInputStream(input)); } catch ( UnsupportedEncodingException e ) { throw new InvalidFilterException(e.getMessage()); } this.tokenizer = new StreamTokenizer(inputStream); try { return doParse(); } catch ( IOException e ) { throw new InvalidFilterException(e.getMessage()); } }
request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(uriResourcePath); try { StringWriter stringWriter = new StringWriter(); AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter); if (setLoggingOptionsRequest.getLoggingOptionsPayload() != null) { String snippet = stringWriter.toString(); byte[] content = snippet.getBytes(UTF8); request.setContent(new StringInputStream(snippet)); request.addHeader("Content-Length", Integer.toString(content.length)); } catch (Throwable t) {
@Override public InputStream adapt(String source) { if (source == null) { return null; } try { return new StringInputStream(source); } catch (UnsupportedEncodingException e) { throw new SdkClientException(e); } } }
// note that if your XML already declares the XSD to which it has to conform, then there's no need to declare the schemaName here void validate(String xml, String schemaName) throws Exception { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); builderFactory.setNamespaceAware(true); DocumentBuilder parser = builderFactory .newDocumentBuilder(); // parse the XML into a document object Document document = parser.parse(new StringInputStream(xml)); SchemaFactory factory = SchemaFactory .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); // associate the schema factory with the resource resolver, which is responsible for resolving the imported XSD's factory.setResourceResolver(new ResourceResolver()); // note that if your XML already declares the XSD to which it has to conform, then there's no need to create a validator from a Schema object Source schemaFile = new StreamSource(getClass().getClassLoader() .getResourceAsStream(schemaName)); Schema schema = factory.newSchema(schemaFile); Validator validator = schema.newValidator(); validator.validate(new DOMSource(document)); }
request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(uriResourcePath); try { StringWriter stringWriter = new StringWriter(); AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter); if (phoneNumberValidateRequest.getNumberValidateRequest() != null) { String snippet = stringWriter.toString(); byte[] content = snippet.getBytes(UTF8); request.setContent(new StringInputStream(snippet)); request.addHeader("Content-Length", Integer.toString(content.length)); } catch (Throwable t) {
public Request<CreateQueryLoggingConfigRequest> marshall(CreateQueryLoggingConfigRequest createQueryLoggingConfigRequest) { throw new SdkClientException("Invalid argument passed to marshall(...)"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(uriResourcePath); StringWriter stringWriter = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/"); xmlWriter.startElement("CreateQueryLoggingConfigRequest"); if (createQueryLoggingConfigRequest != null) { xmlWriter.startElement("HostedZoneId").value(createQueryLoggingConfigRequest.getHostedZoneId()).endElement(); xmlWriter.endElement(); request.setContent(new StringInputStream(stringWriter.getBuffer().toString())); request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", "application/xml"); throw new SdkClientException("Unable to marshall request to XML: " + t.getMessage(), t);
@Override public InputStream adapt(String source) { if (source == null) { return null; } try { return new StringInputStream(source); } catch (UnsupportedEncodingException e) { throw new SdkClientException(e); } } }
@BeforeClass public static void init() throws UnsupportedEncodingException { inputStream = new StringInputStream(INPUT_STRING); } @Before
"AWSKMS"); String target = "TrentService.EnableKey"; request.addHeader("X-Amz-Target", target); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(uriResourcePath); try { StringWriter stringWriter = new StringWriter(); AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter); jsonWriter.beginObject(); String snippet = stringWriter.toString(); byte[] content = snippet.getBytes(UTF8); request.setContent(new StringInputStream(snippet)); request.addHeader("Content-Length", Integer.toString(content.length)); } catch (Throwable t) {
public Request<CreateReusableDelegationSetRequest> marshall(CreateReusableDelegationSetRequest createReusableDelegationSetRequest) { throw new SdkClientException("Invalid argument passed to marshall(...)"); "AmazonRoute53"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(uriResourcePath); StringWriter stringWriter = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/"); xmlWriter.startElement("CreateReusableDelegationSetRequest"); if (createReusableDelegationSetRequest != null) { xmlWriter.startElement("CallerReference").value(createReusableDelegationSetRequest.getCallerReference()).endElement(); xmlWriter.endElement(); request.setContent(new StringInputStream(stringWriter.getBuffer().toString())); request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", "application/xml"); throw new SdkClientException("Unable to marshall request to XML: " + t.getMessage(), t);
@SuppressWarnings("rawtypes") public static Request<?> getSampleRequestWithRepeatableContent( AmazonWebServiceRequest amazonWebServiceRequest) { DefaultRequest<?> request = new DefaultRequest( amazonWebServiceRequest, "non-existent-service"); request.setEndpoint(URI.create("http://non-existent-service.amazonaws.com")); // StringInputStream#markSupported() returns true try { String content = "Some content that could be read for multiple times."; request.setContent(new StringInputStream(content)); request.addHeader("Content-Length", String.valueOf(content.length())); } catch (UnsupportedEncodingException e) { Assert.fail("Unable to set up the request content"); } return request; }
listTagsLogGroupRequest, "AmazonCloudWatchLogs"); String target = "Logs_20140328.ListTagsLogGroup"; request.addHeader("X-Amz-Target", target); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(uriResourcePath); try { StringWriter stringWriter = new StringWriter(); AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter); jsonWriter.beginObject(); String snippet = stringWriter.toString(); byte[] content = snippet.getBytes(UTF8); request.setContent(new StringInputStream(snippet)); request.addHeader("Content-Length", Integer.toString(content.length)); } catch (Throwable t) {
public Request<CreateCloudFrontOriginAccessIdentityRequest> marshall(CreateCloudFrontOriginAccessIdentityRequest createCloudFrontOriginAccessIdentityRequest) { throw new SdkClientException("Invalid argument passed to marshall(...)"); createCloudFrontOriginAccessIdentityRequest, "AmazonCloudFront"); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(uriResourcePath); StringWriter stringWriter = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(stringWriter, "http://cloudfront.amazonaws.com/doc/2018-11-05/"); xmlWriter.startElement("CloudFrontOriginAccessIdentityConfig"); xmlWriter.startElement("CallerReference").value(cloudFrontOriginAccessIdentityConfig.getCallerReference()).endElement(); request.setContent(new StringInputStream(stringWriter.getBuffer().toString())); request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", "application/xml"); throw new SdkClientException("Unable to marshall request to XML: " + t.getMessage(), t);
@Test public void testZeroPaddedDigestSHA256() throws Exception { inputStream2 = new StringInputStream(INPUT_STRING_NO3); String result = DigestHelper.digest(SHA_256, inputStream2).toString(); Assert.assertEquals(ZERO_PADDED_SHA256_CHECKSUM, result); }
deleteAliasRequest, "AWSKMS"); String target = "TrentService.DeleteAlias"; request.addHeader("X-Amz-Target", target); request.setHttpMethod(HttpMethodName.POST); request.setResourcePath(uriResourcePath); try { StringWriter stringWriter = new StringWriter(); AwsJsonWriter jsonWriter = JsonUtils.getJsonWriter(stringWriter); jsonWriter.beginObject(); String snippet = stringWriter.toString(); byte[] content = snippet.getBytes(UTF8); request.setContent(new StringInputStream(snippet)); request.addHeader("Content-Length", Integer.toString(content.length)); } catch (Throwable t) {
public Request<UpdateTrafficPolicyCommentRequest> marshall(UpdateTrafficPolicyCommentRequest updateTrafficPolicyCommentRequest) { throw new SdkClientException("Invalid argument passed to marshall(...)"); "AmazonRoute53"); request.setHttpMethod(HttpMethodName.POST); uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall(uriResourcePath, "Id", updateTrafficPolicyCommentRequest.getId()); uriResourcePath = com.amazonaws.transform.PathMarshallers.NON_GREEDY.marshall(uriResourcePath, "Version", updateTrafficPolicyCommentRequest.getVersion()); request.setResourcePath(uriResourcePath); StringWriter stringWriter = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(stringWriter, "https://route53.amazonaws.com/doc/2013-04-01/"); xmlWriter.startElement("UpdateTrafficPolicyCommentRequest"); if (updateTrafficPolicyCommentRequest != null) { xmlWriter.startElement("Comment").value(updateTrafficPolicyCommentRequest.getComment()).endElement(); xmlWriter.endElement(); request.setContent(new StringInputStream(stringWriter.getBuffer().toString())); request.addHeader("Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length)); if (!request.getHeaders().containsKey("Content-Type")) { request.addHeader("Content-Type", "application/xml"); throw new SdkClientException("Unable to marshall request to XML: " + t.getMessage(), t);
@Test public void testZeroPaddedDigestMD5() throws Exception { inputStream2 = new StringInputStream(INPUT_STRING_NO2); String result = DigestHelper.digest(MD5, inputStream2).toString(); Assert.assertEquals(ZERO_PADDED_MD5_CHECKSUM, result); }