@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof S3Origin == false) return false; S3Origin other = (S3Origin) obj; if (other.getDomainName() == null ^ this.getDomainName() == null) return false; if (other.getDomainName() != null && other.getDomainName().equals(this.getDomainName()) == false) return false; if (other.getOriginAccessIdentity() == null ^ this.getOriginAccessIdentity() == null) return false; if (other.getOriginAccessIdentity() != null && other.getOriginAccessIdentity().equals(this.getOriginAccessIdentity()) == false) return false; return true; }
public Request<CreateStreamingDistributionRequest> marshall( CreateStreamingDistributionRequest createStreamingDistributionRequest) { if (createStreamingDistributionRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<CreateStreamingDistributionRequest> request = new DefaultRequest<CreateStreamingDistributionRequest>( createStreamingDistributionRequest, "AmazonCloudFront"); request.setHttpMethod(HttpMethodName.POST); String uriResourcePath = "2014-05-31/streaming-distribution"; 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); StringWriter stringWriter = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(stringWriter, "http://cloudfront.amazonaws.com/doc/2014-05-31/"); if (createStreamingDistributionRequest != null) { StreamingDistributionConfig streamingDistributionConfigStreamingDistributionConfig = createStreamingDistributionRequest.getStreamingDistributionConfig(); if (streamingDistributionConfigStreamingDistributionConfig != null) { xmlWriter.startElement("StreamingDistributionConfig"); if (streamingDistributionConfigStreamingDistributionConfig.getCallerReference() != null) { xmlWriter .startElement("CallerReference") .value(streamingDistributionConfigStreamingDistributionConfig.getCallerReference()) .endElement(); } if (streamingDistributionConfigStreamingDistributionConfig != null) { S3Origin s3OriginS3Origin = streamingDistributionConfigStreamingDistributionConfig.getS3Origin(); if (s3OriginS3Origin != null) { xmlWriter.startElement("S3Origin"); if (s3OriginS3Origin.getDomainName() != null) { xmlWriter .startElement("DomainName") .value(s3OriginS3Origin.getDomainName()) .endElement(); } if (s3OriginS3Origin.getOriginAccessIdentity() != null) { xmlWriter .startElement("OriginAccessIdentity") .value(s3OriginS3Origin.getOriginAccessIdentity()) .endElement(); } xmlWriter.endElement(); } } if (streamingDistributionConfigStreamingDistributionConfig != null) { Aliases aliasesAliases = streamingDistributionConfigStreamingDistributionConfig.getAliases(); if (aliasesAliases != null) { xmlWriter.startElement("Aliases"); if (aliasesAliases.getQuantity() != null) { xmlWriter.startElement("Quantity").value(aliasesAliases.getQuantity()).endElement(); } if (aliasesAliases != null) { java.util.List<String> aliasesAliasesitemsList = aliasesAliases.getItems(); if (aliasesAliasesitemsList != null && aliasesAliasesitemsList.size() > 0) { int aliasesAliasesitemsListIndex = 1; xmlWriter.startElement("Items"); for (String aliasesAliasesitemsListValue : aliasesAliasesitemsList) { xmlWriter.startElement("CNAME"); xmlWriter.value(aliasesAliasesitemsListValue); xmlWriter.endElement(); aliasesAliasesitemsListIndex++; } xmlWriter.endElement(); } } xmlWriter.endElement(); } } if (streamingDistributionConfigStreamingDistributionConfig.getComment() != null) { xmlWriter .startElement("Comment") .value(streamingDistributionConfigStreamingDistributionConfig.getComment()) .endElement(); } if (streamingDistributionConfigStreamingDistributionConfig != null) { StreamingLoggingConfig streamingLoggingConfigLogging = streamingDistributionConfigStreamingDistributionConfig.getLogging(); if (streamingLoggingConfigLogging != null) { xmlWriter.startElement("Logging"); if (streamingLoggingConfigLogging.isEnabled() != null) { xmlWriter .startElement("Enabled") .value(streamingLoggingConfigLogging.isEnabled()) .endElement(); } if (streamingLoggingConfigLogging.getBucket() != null) { xmlWriter .startElement("Bucket") .value(streamingLoggingConfigLogging.getBucket()) .endElement(); } if (streamingLoggingConfigLogging.getPrefix() != null) { xmlWriter .startElement("Prefix") .value(streamingLoggingConfigLogging.getPrefix()) .endElement(); } xmlWriter.endElement(); } } if (streamingDistributionConfigStreamingDistributionConfig != null) { TrustedSigners trustedSignersTrustedSigners = streamingDistributionConfigStreamingDistributionConfig.getTrustedSigners(); if (trustedSignersTrustedSigners != null) { xmlWriter.startElement("TrustedSigners"); if (trustedSignersTrustedSigners.isEnabled() != null) { xmlWriter .startElement("Enabled") .value(trustedSignersTrustedSigners.isEnabled()) .endElement(); } if (trustedSignersTrustedSigners.getQuantity() != null) { xmlWriter .startElement("Quantity") .value(trustedSignersTrustedSigners.getQuantity()) .endElement(); } if (trustedSignersTrustedSigners != null) { java.util.List<String> trustedSignersTrustedSignersitemsList = trustedSignersTrustedSigners.getItems(); if (trustedSignersTrustedSignersitemsList != null && trustedSignersTrustedSignersitemsList.size() > 0) { int trustedSignersTrustedSignersitemsListIndex = 1; xmlWriter.startElement("Items"); for (String trustedSignersTrustedSignersitemsListValue : trustedSignersTrustedSignersitemsList) { xmlWriter.startElement("AwsAccountNumber"); xmlWriter.value(trustedSignersTrustedSignersitemsListValue); xmlWriter.endElement(); trustedSignersTrustedSignersitemsListIndex++; } xmlWriter.endElement(); } } xmlWriter.endElement(); } } if (streamingDistributionConfigStreamingDistributionConfig.getPriceClass() != null) { xmlWriter .startElement("PriceClass") .value(streamingDistributionConfigStreamingDistributionConfig.getPriceClass()) .endElement(); } if (streamingDistributionConfigStreamingDistributionConfig.isEnabled() != null) { xmlWriter .startElement("Enabled") .value(streamingDistributionConfigStreamingDistributionConfig.isEnabled()) .endElement(); } xmlWriter.endElement(); } } try { request.setContent(new StringInputStream(stringWriter.getBuffer().toString())); request.addHeader( "Content-Length", Integer.toString(stringWriter.getBuffer().toString().getBytes(UTF8).length)); request.addHeader("Content-Type", "application/xml"); } catch (UnsupportedEncodingException e) { throw new AmazonClientException("Unable to marshall request to XML", e); } return request; }