From bf965645828ef88cc196094c7f0dcca35b018d24 Mon Sep 17 00:00:00 2001 From: rainbowbreeze Date: Wed, 15 Sep 2010 12:39:02 +0200 Subject: [PATCH] added additional properties to Payload for content disposition management --- .../src/main/java/org/jclouds/io/Payload.java | 48 +++++++++++++++++ .../org/jclouds/io/payloads/BasePayload.java | 51 +++++++++++++++++++ .../io/payloads/DelegatingPayload.java | 48 +++++++++++++++++ .../jclouds/io/payloads/StreamingPayload.java | 49 ++++++++++++++++++ 4 files changed, 196 insertions(+) diff --git a/core/src/main/java/org/jclouds/io/Payload.java b/core/src/main/java/org/jclouds/io/Payload.java index 3830640e90..a2562db641 100644 --- a/core/src/main/java/org/jclouds/io/Payload.java +++ b/core/src/main/java/org/jclouds/io/Payload.java @@ -72,6 +72,54 @@ public interface Payload extends InputSupplier, WriteTo, Closeable @Nullable String getContentType(); + + /** + * Set Content Disposition of the payload + *

+ * Not all providers may support it + * + * @param contentDisposition + */ + void setContentDisposition(@Nullable String contentDisposition); + + /** + * Get Content Disposition of the payload + *

+ * Not all providers may support it + */ + @Nullable String getContentDisposition(); + + /** + * Set Content Language of the payload + *

+ * Not all providers may support it + * + * @param contentLanguage + */ + void setContentLanguage(@Nullable String contentLanguage); + /** + * Get Content Language of the payload + *

+ * Not all providers may support it + */ + @Nullable String getContentLanguage(); + + /** + * Set Content Encoding of the payload + *

+ * Not all providers may support it + * + * @param contentEncoding + */ + void setContentEncoding(@Nullable String contentEncoding); + /** + * Get Content Encoding of the payload + *

+ * Not all providers may support it + */ + @Nullable String getContentEncoding(); + + /** * release resources used by this entity. This should be called when data is * discarded. diff --git a/core/src/main/java/org/jclouds/io/payloads/BasePayload.java b/core/src/main/java/org/jclouds/io/payloads/BasePayload.java index 0b582294fd..a3c5dc1577 100644 --- a/core/src/main/java/org/jclouds/io/payloads/BasePayload.java +++ b/core/src/main/java/org/jclouds/io/payloads/BasePayload.java @@ -40,6 +40,9 @@ public abstract class BasePayload implements Payload { protected String contentType; protected Long contentLength; protected byte[] contentMD5; + protected String contentDisposition; + protected String contentLanguage; + protected String contentEncoding; protected transient volatile boolean written; protected BasePayload(V content, @Nullable String contentType, @@ -118,6 +121,54 @@ public abstract class BasePayload implements Payload { this.contentType = contentType; } + /** + * {@inheritDoc} + */ + @Override + public void setContentDisposition(@Nullable String contentDisposition) { + this.contentDisposition = contentDisposition; + } + + /** + * {@inheritDoc} + */ + @Override + public String getContentDisposition() { + return this.contentDisposition; + } + + /** + * {@inheritDoc} + */ + @Override + public void setContentLanguage(@Nullable String contentLanguage) { + this.contentLanguage = contentLanguage; + } + + /** + * {@inheritDoc} + */ + @Override + public String getContentLanguage() { + return this.contentLanguage; + } + + /** + * {@inheritDoc} + */ + @Override + public void setContentEncoding(@Nullable String contentEncoding) { + this.contentEncoding = contentEncoding; + } + + /** + * {@inheritDoc} + */ + @Override + public String getContentEncoding() { + return this.contentEncoding; + } + /** * {@inheritDoc} */ diff --git a/core/src/main/java/org/jclouds/io/payloads/DelegatingPayload.java b/core/src/main/java/org/jclouds/io/payloads/DelegatingPayload.java index aaeb372c88..067c96a88d 100644 --- a/core/src/main/java/org/jclouds/io/payloads/DelegatingPayload.java +++ b/core/src/main/java/org/jclouds/io/payloads/DelegatingPayload.java @@ -119,6 +119,54 @@ public class DelegatingPayload implements Payload { delegate.setContentType(md5); } + /** + * {@inheritDoc} + */ + @Override + public void setContentDisposition(String contentDisposition) { + delegate.setContentDisposition(contentDisposition); + } + + /** + * {@inheritDoc} + */ + @Override + public String getContentDisposition() { + return delegate.getContentDisposition(); + } + + /** + * {@inheritDoc} + */ + @Override + public void setContentLanguage(String contentLanguage) { + delegate.setContentLanguage(contentLanguage); + } + + /** + * {@inheritDoc} + */ + @Override + public String getContentLanguage() { + return delegate.getContentLanguage(); + } + + /** + * {@inheritDoc} + */ + @Override + public void setContentEncoding(String contentEncoding) { + delegate.setContentEncoding(contentEncoding); + } + + /** + * {@inheritDoc} + */ + @Override + public String getContentEncoding() { + return delegate.getContentEncoding(); + } + /** * {@inheritDoc} */ diff --git a/core/src/main/java/org/jclouds/io/payloads/StreamingPayload.java b/core/src/main/java/org/jclouds/io/payloads/StreamingPayload.java index fa462a0606..21a09f3bb3 100644 --- a/core/src/main/java/org/jclouds/io/payloads/StreamingPayload.java +++ b/core/src/main/java/org/jclouds/io/payloads/StreamingPayload.java @@ -112,6 +112,54 @@ public class StreamingPayload implements Payload { this.contentType = contentType; } + /** + * {@inheritDoc} + */ + @Override + public void setContentDisposition(String contentDisposition) { + throw new UnsupportedOperationException("this payload is for streaming writes only"); + } + + /** + * {@inheritDoc} + */ + @Override + public String getContentDisposition() { + throw new UnsupportedOperationException("this payload is for streaming writes only"); + } + + /** + * {@inheritDoc} + */ + @Override + public void setContentLanguage(String contentLanguage) { + throw new UnsupportedOperationException("this payload is for streaming writes only"); + } + + /** + * {@inheritDoc} + */ + @Override + public String getContentLanguage() { + throw new UnsupportedOperationException("this payload is for streaming writes only"); + } + + /** + * {@inheritDoc} + */ + @Override + public void setContentEncoding(String contentEncoding) { + throw new UnsupportedOperationException("this payload is for streaming writes only"); + } + + /** + * {@inheritDoc} + */ + @Override + public String getContentEncoding() { + throw new UnsupportedOperationException("this payload is for streaming writes only"); + } + /** * {@inheritDoc} */ @@ -172,4 +220,5 @@ public class StreamingPayload implements Payload { public void close() { release(); } + } \ No newline at end of file