You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2007/11/08 00:15:55 UTC
svn commit: r592943 - in
/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource:
NonExistingResource.java Resource.java ResourceMetadata.java
Author: fmeschbe
Date: Wed Nov 7 15:15:54 2007
New Revision: 592943
URL: http://svn.apache.org/viewvc?rev=592943&view=rev
Log:
SLING-99 Add Resource.getInputStream method and define more properties
pertaining to streamable resources.
Modified:
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/Resource.java
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceMetadata.java
Modified: incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java?rev=592943&r1=592942&r2=592943&view=diff
==============================================================================
--- incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java (original)
+++ incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java Wed Nov 7 15:15:54 2007
@@ -18,6 +18,8 @@
*/
package org.apache.sling.api.resource;
+import java.io.InputStream;
+
/**
* Simple helper class representing nonexisting resources.
*/
@@ -56,4 +58,8 @@
return null;
}
+ /** Returns null for a non-existing resource */
+ public InputStream getInputStream() {
+ return null;
+ }
}
Modified: incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/Resource.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/Resource.java?rev=592943&r1=592942&r2=592943&view=diff
==============================================================================
--- incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/Resource.java (original)
+++ incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/Resource.java Wed Nov 7 15:15:54 2007
@@ -16,6 +16,9 @@
*/
package org.apache.sling.api.resource;
+import java.io.IOException;
+import java.io.InputStream;
+
/** Resources are pieces of content on which Sling acts */
public interface Resource {
@@ -69,6 +72,19 @@
* Jackrabbit OCM mapping would be used to provide this object.
*/
Object getObject();
+
+ /**
+ * Returns an <code>InputStream</code> to read the data from this resource
+ * if the resoure can be streamed. Otherwise <code>null</code> is returned.
+ * <p>
+ * For a JCR Repository based implementation this method may return the
+ * stream of the <code>jcr:content/jcr:data</code> property of an
+ * <code>nt:file</code> node.
+ *
+ * @throws IOException May be thrown if an error occurrs trying to create
+ * the input stream.
+ */
+ InputStream getInputStream() throws IOException;
/**
* Returns the metadata of this resource. The concrete data contained in the
Modified: incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceMetadata.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceMetadata.java?rev=592943&r1=592942&r2=592943&view=diff
==============================================================================
--- incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceMetadata.java (original)
+++ incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceMetadata.java Wed Nov 7 15:15:54 2007
@@ -20,7 +20,6 @@
import java.util.HashMap;
-
/**
* The <code>ResourceMetadata</code> interface defines the API for the
* metadata of a Sling {@link Resource}. Essentially the resource's metadata is
@@ -43,5 +42,38 @@
* instance belongs (value is "sling.resolutionPath").
*/
public static final String RESOLUTION_PATH = "sling.resolutionPath";
+
+ /**
+ * The name of the optional property providing the content type of the
+ * resource if the resource is streamable (value is "sling.contentType").
+ * This property may be missing if the resource is not streamable or if the
+ * content type is not known.
+ */
+ public static final String CONTENT_TYPE = "sling.contentType";
+
+ /**
+ * The name of the optional property providing the character encoding of the
+ * resource if the resource is streamable and contains character data (value
+ * is "sling.characterEncoding"). This property may be missing if the
+ * resource is not streamable or if the character encoding is not known.
+ */
+ public static final String CHARACTER_ENCODING = "sling.characterEncoding";
+
+ /**
+ * Returns the creation time of this resource in the repository in
+ * milliseconds (value is "sling.creationTime"). The type of this property
+ * is <code>java.lang.Long</code>. The property may be missing if the
+ * resource is not streamable or if the creation time is not known.
+ */
+ public static final String CREATION_TIME = "sling.creationTime";
+
+ /**
+ * Returns the last modification time of this resource in the repository in
+ * milliseconds (value is "sling.modificationTime"). The type of this
+ * property is <code>java.lang.Long</code>. The property may be missing
+ * if the resource is not streamable or if the last modification time is not
+ * known.
+ */
+ public static final String MODIFICATION_TIME = "sling.modificationTime";
}