chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r799653 - in /incubator/chemistry/trunk/chemistry: chemistry-api/src/main/java/org/apache/chemistry/ chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/ chemistry-atompub-server/src/main/java/org/apache/chemistry/ato...
Date Fri, 31 Jul 2009 16:15:12 GMT
Author: fguillaume
Date: Fri Jul 31 16:15:11 2009
New Revision: 799653

URL: http://svn.apache.org/viewvc?rev=799653&view=rev
Log:
CMIS-44: added rendition APIs (no implementation yet)

Added:
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Rendition.java
  (with props)
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RenditionCapability.java
  (with props)
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRendition.java
Modified:
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ContentStream.java
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Document.java
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RepositoryCapabilities.java
    incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepositoryCapabilities.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
    incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java
    incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrRepository.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/CMISObject.java
Fri Jul 31 16:15:11 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.chemistry;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.net.URI;
@@ -244,6 +246,24 @@
     void setValues(Map<String, Serializable> values);
 
     /**
+     * Gets a byte stream for this document.
+     *
+     * @param renditionId the rendition ID, or {@code null} for the primary
+     *            stream
+     * @return the byte stream
+     */
+    InputStream getStream(String renditionId) throws IOException;
+
+    /**
+     * Gets a content stream for this document.
+     *
+     * @param renditionId the rendition ID, or {@code null} for the primary
+     *            stream
+     * @return the content stream
+     */
+    ContentStream getContentStream(String renditionId) throws IOException;
+
+    /**
      * Saves the modifications done to the object through {@link #setValue},
      * {@link #setValues} and {@link Document#setContentStream}.
      * <p>

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ContentStream.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ContentStream.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ContentStream.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/ContentStream.java
Fri Jul 31 16:15:11 2009
@@ -25,14 +25,14 @@
 public interface ContentStream {
 
     /**
-     * The content stream length.
+     * The content stream MIME type.
      */
-    long getLength();
+    String getMimeType();
 
     /**
-     * The content stream MIME type.
+     * The content stream length.
      */
-    String getMimeType();
+    long getLength();
 
     /**
      * The content stream file name, or {@code null} if none is provided.

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Document.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Document.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Document.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Document.java
Fri Jul 31 16:15:11 2009
@@ -109,21 +109,21 @@
      */
 
     /**
-     * Gets the byte stream for this document.
+     * Gets the primary byte stream for this document.
      *
      * @return the byte stream
      */
     InputStream getStream() throws IOException;
 
     /**
-     * Gets the content stream for this document.
+     * Gets the primary content stream for this document.
      *
      * @return the content stream
      */
     ContentStream getContentStream() throws IOException;
 
     /**
-     * Sets the content stream for this document.
+     * Sets the primary content stream for this document.
      *
      * @param contentStream
      * @throws IOException if the stream could not be read

Added: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Rendition.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Rendition.java?rev=799653&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Rendition.java
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Rendition.java
Fri Jul 31 16:15:11 2009
@@ -0,0 +1,102 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry;
+
+import java.util.Map;
+
+/**
+ * A rendition is an alternative representation for a document or folder.
+ * <p>
+ * Renditions could be image previews, thumbnails, format-converted versions,
+ * etc.
+ * <p>
+ * The server is responsible for determining the number, type and availability
+ * of renditions present for a given document or folder. A rendition may not be
+ * immediately available after document creation checkin. Renditions are
+ * specific to the version of the document and may differ between document
+ * versions.
+ */
+public interface Rendition {
+
+    String KIND_THUMBNAIL = "cmis:thumbnail";
+
+    /**
+     * The rendition ID.
+     * <p>
+     * This ID has meaning only in the context of the rendition's base document
+     * or folder.
+     * <p>
+     * This ID may be passed to {@link SPI#getContentStream} to retrieve the
+     * rendition stream.
+     */
+    String getId();
+
+    /**
+     * The object ID of the base document or folder that this rendition is
+     * about.
+     */
+    ObjectId getObjectId();
+
+    /**
+     * The rendition document object ID (optional).
+     * <p>
+     * This is only available if this rendition is represented as a document by
+     * the repository, otherwise it is {@code null}.
+     */
+    ObjectId getRenditionDocumentId();
+
+    /**
+     * The rendition stream MIME type.
+     */
+    String getMimeType();
+
+    /**
+     * The rendition stream length.
+     */
+    long getLength();
+
+    /**
+     * The rendition title, or {@code null}
+     */
+    String getTitle();
+
+    /**
+     * The rendition kind.
+     * <p>
+     * The only predefined value is {@link #KIND_THUMBNAIL}.
+     */
+    String getKind();
+
+    /**
+     * The height, or -1 if not specified.
+     */
+    long getHeight();
+
+    /**
+     * The width, or -1 if not specified.
+     */
+    long getWidth();
+
+    /**
+     * The rendition metadata.
+     * <p>
+     * If specified, height and width are also in this map (represented as
+     * strings).
+     */
+    Map<String, String> getMetadata();
+
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Rendition.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Rendition.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/Rendition.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RenditionCapability.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RenditionCapability.java?rev=799653&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RenditionCapability.java
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RenditionCapability.java
Fri Jul 31 16:15:11 2009
@@ -0,0 +1,70 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ *     Florent Guillaume, Nuxeo
+ */
+package org.apache.chemistry;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Support for renditions.
+ */
+public enum RenditionCapability {
+
+    /**
+     * The repository does not expose renditions at all.
+     */
+    NONE("none"),
+
+    /**
+     * Renditions are provided by the repository and readable by the client.
+     */
+    READ("read");
+
+    private final String value;
+
+    private RenditionCapability(String value) {
+        this.value = value;
+    }
+
+    private static final Map<String, RenditionCapability> all = new HashMap<String,
RenditionCapability>();
+    static {
+        for (RenditionCapability o : values()) {
+            all.put(o.value, o);
+        }
+    }
+
+    public static RenditionCapability get(String value) {
+        RenditionCapability o = all.get(value);
+        if (o == null) {
+            throw new IllegalArgumentException(value);
+        }
+        return o;
+    }
+
+    public static RenditionCapability get(String value, RenditionCapability def) {
+        RenditionCapability o = all.get(value);
+        if (o == null) {
+            o = def;
+        }
+        return o;
+    }
+
+    @Override
+    public String toString() {
+        return value;
+    }
+}

Propchange: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RenditionCapability.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RenditionCapability.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RenditionCapability.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RepositoryCapabilities.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RepositoryCapabilities.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RepositoryCapabilities.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/RepositoryCapabilities.java
Fri Jul 31 16:15:11 2009
@@ -66,4 +66,9 @@
      */
     JoinCapability getJoinCapability();
 
+    /**
+     * Support for renditions.
+     */
+    RenditionCapability getRenditionCapability();
+
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-api/src/main/java/org/apache/chemistry/SPI.java
Fri Jul 31 16:15:11 2009
@@ -17,7 +17,6 @@
 package org.apache.chemistry;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.List;
@@ -326,6 +325,26 @@
             boolean includeAllowableActions, boolean includeRelationships);
 
     /**
+     * Gets the list of associated renditions for an object.
+     * <p>
+     * A rendition filter can be included. It is either {@code "*"}, {@code
+     * "cmis:none"}, or a comma-separated list of either kinds of MIME types
+     * (which may have a subtype of {@code "*"}). The {@code null} value is
+     * equivalent to {@code "cmis:none"}.
+     *
+     * @param object the object
+     * @param filter a rendition filter, or {@code null} for none
+     * @param maxItems the maximum number of renditions to returned, or {@code
+     *            0} for a repository-specific default
+     * @param skipCount the skip count
+     * @return the list of renditions
+     *
+     * @throws UnsupportedOperationException if renditions are not supported
+     */
+    List<Rendition> getRenditions(ObjectId object, String filter, int maxItems,
+            int skipCount);
+
+    /**
      * Checks if the document has an associated content stream.
      * <p>
      * Note that the content stream may be present but still have length 0.
@@ -335,15 +354,18 @@
     boolean hasContentStream(ObjectId document);
 
     /**
-     * Gets the content stream for a document.
+     * Gets a content stream for a document or folder.
+     * <p>
+     * If a rendition ID is provided, the content stream returned will be for
+     * the given rendition.
+     *
+     * @param object the document or folder
+     * @param renditionId the rendition ID, or {@code null}
+     * @return the content stream
      *
-     * @param document the document
-     * @param offset the offset into the content stream
-     * @param length the length of stream to return, or {@code -1} for all
-     * @return the specified part of the content stream
      * @throws IOException
      */
-    InputStream getContentStream(ObjectId document, int offset, int length)
+    ContentStream getContentStream(ObjectId object, String renditionId)
             throws IOException;
 
     /**

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPConnection.java
Fri Jul 31 16:15:11 2009
@@ -19,10 +19,10 @@
 package org.apache.chemistry.atompub.client;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.LinkedList;
@@ -41,6 +41,7 @@
 import org.apache.chemistry.Property;
 import org.apache.chemistry.Relationship;
 import org.apache.chemistry.RelationshipDirection;
+import org.apache.chemistry.Rendition;
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.SPI;
 import org.apache.chemistry.Type;
@@ -393,13 +394,18 @@
         throw new UnsupportedOperationException();
     }
 
+    public List<Rendition> getRenditions(ObjectId object, String filter,
+            int maxItems, int skipCount) {
+        return Collections.emptyList();
+    }
+
     public boolean hasContentStream(ObjectId document) {
         // TODO Auto-generated method stub
         throw new UnsupportedOperationException();
     }
 
-    public InputStream getContentStream(ObjectId document, int offset,
-            int length) throws IOException {
+    public ContentStream getContentStream(ObjectId object, String renditionId)
+            throws IOException {
         // TODO Auto-generated method stub
         throw new UnsupportedOperationException();
     }

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPObject.java
Fri Jul 31 16:15:11 2009
@@ -17,12 +17,14 @@
  */
 package org.apache.chemistry.atompub.client;
 
+import java.io.InputStream;
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
 import org.apache.chemistry.BaseType;
+import org.apache.chemistry.ContentStream;
 import org.apache.chemistry.Folder;
 import org.apache.chemistry.Policy;
 import org.apache.chemistry.Property;
@@ -91,6 +93,16 @@
         throw new UnsupportedOperationException();
     }
 
+    public InputStream getStream(String renditionId) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public ContentStream getContentStream(String renditionId) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
     /*
      * ----- Navigation Services -----
      */

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepositoryCapabilities.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepositoryCapabilities.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepositoryCapabilities.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/APPRepositoryCapabilities.java
Fri Jul 31 16:15:11 2009
@@ -18,6 +18,7 @@
 
 import org.apache.chemistry.JoinCapability;
 import org.apache.chemistry.QueryCapability;
+import org.apache.chemistry.RenditionCapability;
 import org.apache.chemistry.RepositoryCapabilities;
 
 /**
@@ -29,6 +30,8 @@
 
     protected QueryCapability queryCapability;
 
+    protected RenditionCapability renditionCapability;
+
     protected boolean hasUnfiling;
 
     protected boolean hasMultifiling;
@@ -49,6 +52,10 @@
         return queryCapability;
     }
 
+    public RenditionCapability getRenditionCapability() {
+        return renditionCapability;
+    }
+
     public boolean hasMultifiling() {
         return hasMultifiling;
     }
@@ -104,4 +111,9 @@
     public void setQueryCapability(QueryCapability queryCapability) {
         this.queryCapability = queryCapability;
     }
+
+    public void setRenditionCapability(RenditionCapability renditionCapability) {
+        this.renditionCapability = renditionCapability;
+    }
+
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/CMISObjectsCollection.java
Fri Jul 31 16:15:11 2009
@@ -309,7 +309,8 @@
         // TODO entry was fetched for mostly nothing...
         SPI spi = repository.getSPI(); // TODO XXX connection leak
         try {
-            return spi.getContentStream(object, 0, -1);
+            ContentStream contentStream = spi.getContentStream(object, null);
+            return contentStream == null ? null : contentStream.getStream();
         } catch (IOException e) {
             throw new ResponseContextException(500, e);
         }

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleConnection.java
Fri Jul 31 16:15:11 2009
@@ -18,7 +18,6 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -51,6 +50,7 @@
 import org.apache.chemistry.PropertyDefinition;
 import org.apache.chemistry.Relationship;
 import org.apache.chemistry.RelationshipDirection;
+import org.apache.chemistry.Rendition;
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.SPI;
 import org.apache.chemistry.Type;
@@ -440,23 +440,28 @@
         }
     }
 
+    public List<Rendition> getRenditions(ObjectId object, String filter,
+            int maxItems, int skipCount) {
+        return Collections.emptyList();
+    }
+
     public boolean hasContentStream(ObjectId document) {
         SimpleData data = repository.datas.get(document.getId());
         byte[] bytes = (byte[]) data.get(SimpleProperty.CONTENT_BYTES_KEY);
         return bytes != null;
     }
 
-    public InputStream getContentStream(ObjectId document, int offset,
-            int length) {
-        SimpleData data = repository.datas.get(document.getId());
+    public ContentStream getContentStream(ObjectId object, String renditionId) {
+        // TODO renditionId
+        SimpleData data = repository.datas.get(object.getId());
         byte[] bytes = (byte[]) data.get(SimpleProperty.CONTENT_BYTES_KEY);
         if (bytes == null) {
             return null;
         }
-        if (length == -1) {
-            length = bytes.length;
-        }
-        return new ByteArrayInputStream(bytes, offset, length);
+        // length is recomputed, no need to read it
+        String mimeType = (String) data.get(Property.CONTENT_STREAM_MIME_TYPE);
+        String filename = (String) data.get(Property.CONTENT_STREAM_FILENAME);
+        return new SimpleContentStream(bytes, mimeType, filename);
     }
 
     public ObjectId setContentStream(ObjectId document, boolean overwrite,

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleObject.java
Fri Jul 31 16:15:11 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.chemistry.impl.simple;
 
+import java.io.InputStream;
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.List;
@@ -23,6 +24,7 @@
 
 import org.apache.chemistry.BaseType;
 import org.apache.chemistry.CMISObject;
+import org.apache.chemistry.ContentStream;
 import org.apache.chemistry.Folder;
 import org.apache.chemistry.Policy;
 import org.apache.chemistry.Property;
@@ -145,6 +147,16 @@
         return new SimpleProperty(entry, id, propertyDefinition);
     }
 
+    public InputStream getStream(String renditionId) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public ContentStream getContentStream(String renditionId) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
     public void save() {
         if (getId() == null) {
             entry.connection.saveObject(this);

Added: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRendition.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRendition.java?rev=799653&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRendition.java
(added)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRendition.java
Fri Jul 31 16:15:11 2009
@@ -0,0 +1,89 @@
+package org.apache.chemistry.impl.simple;
+
+import java.util.Map;
+
+import org.apache.chemistry.ObjectId;
+import org.apache.chemistry.Rendition;
+
+public class SimpleRendition implements Rendition {
+
+    private final String id;
+
+    private final ObjectId objectId;
+
+    private final ObjectId renditionDocumentId;
+
+    private final String mimeType;
+
+    private final long length;
+
+    private final String title;
+
+    private final String kind;
+
+    private final long height;
+
+    private final long width;
+
+    private final Map<String, String> metadata;
+
+    public SimpleRendition(String id, ObjectId objectId,
+            ObjectId renditionDocumentId, String mimeType, long length,
+            String title, String kind, long height, long width,
+            Map<String, String> metadata) {
+        if (id == null) {
+            throw new IllegalArgumentException("Rendition id cannot be null");
+        }
+        this.id = id;
+        this.objectId = objectId;
+        this.renditionDocumentId = renditionDocumentId;
+        this.mimeType = mimeType;
+        this.length = length;
+        this.title = title;
+        this.kind = kind;
+        this.height = height;
+        this.width = width;
+        this.metadata = metadata;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public ObjectId getObjectId() {
+        return objectId;
+    }
+
+    public ObjectId getRenditionDocumentId() {
+        return renditionDocumentId;
+    }
+
+    public String getMimeType() {
+        return mimeType;
+    }
+
+    public long getLength() {
+        return length;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public String getKind() {
+        return kind;
+    }
+
+    public long getHeight() {
+        return height;
+    }
+
+    public long getWidth() {
+        return width;
+    }
+
+    public Map<String, String> getMetadata() {
+        return metadata;
+    }
+
+}

Modified: incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-commons/src/main/java/org/apache/chemistry/impl/simple/SimpleRepository.java
Fri Jul 31 16:15:11 2009
@@ -32,6 +32,7 @@
 import org.apache.chemistry.ObjectId;
 import org.apache.chemistry.Property;
 import org.apache.chemistry.QueryCapability;
+import org.apache.chemistry.RenditionCapability;
 import org.apache.chemistry.SPI;
 import org.apache.chemistry.impl.base.BaseRepository;
 
@@ -173,4 +174,8 @@
         return QueryCapability.BOTH_COMBINED;
     }
 
+    public RenditionCapability getRenditionCapability() {
+        return RenditionCapability.NONE;
+    }
+
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrConnection.java
Fri Jul 31 16:15:11 2009
@@ -17,7 +17,6 @@
 package org.apache.chemistry.jcr;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -43,6 +42,7 @@
 import org.apache.chemistry.Policy;
 import org.apache.chemistry.Relationship;
 import org.apache.chemistry.RelationshipDirection;
+import org.apache.chemistry.Rendition;
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.SPI;
 import org.apache.chemistry.Unfiling;
@@ -57,6 +57,7 @@
     private static final Log log = LogFactory.getLog(JcrConnection.class);
 
     private final Session session;
+
     private final JcrRepository repository;
 
     public JcrConnection(Session session, JcrRepository repository) {
@@ -70,7 +71,8 @@
 
     public CMISObject getObject(ObjectId objectId) {
         try {
-            String relPath = JcrObjectEntry.getPath(objectId.getId()).substring(1);
+            String relPath = JcrObjectEntry.getPath(objectId.getId()).substring(
+                    1);
             if (relPath.equals("")) {
                 return getRootFolder();
             } else {
@@ -145,7 +147,8 @@
         throw new UnsupportedOperationException();
     }
 
-    //---------------------------------------------------------------------- SPI
+    // ----------------------------------------------------------------------
+    // SPI
 
     public void addObjectToFolder(ObjectId objectId, ObjectId folderId) {
         throw new UnsupportedOperationException();
@@ -160,8 +163,8 @@
     }
 
     public ObjectId checkIn(ObjectId documentId, boolean major,
-                          Map<String, Serializable> properties,
-                          ContentStream contentStream, String comment) {
+            Map<String, Serializable> properties, ContentStream contentStream,
+            String comment) {
         throw new UnsupportedOperationException();
     }
 
@@ -171,9 +174,8 @@
 
     // TODO add IOException to throws clause
     public ObjectId createDocument(String typeId,
-                                 Map<String, Serializable> properties,
-                                 ObjectId folderId, ContentStream contentStream,
-                                 VersioningState versioningState) {
+            Map<String, Serializable> properties, ObjectId folderId,
+            ContentStream contentStream, VersioningState versioningState) {
 
         try {
             JcrFolder folder = (JcrFolder) getObject(folderId);
@@ -194,20 +196,18 @@
     }
 
     public ObjectId createFolder(String typeId,
-                               Map<String, Serializable> properties,
-                               ObjectId folderId) {
+            Map<String, Serializable> properties, ObjectId folderId) {
         throw new UnsupportedOperationException();
     }
 
     public ObjectId createPolicy(String typeId,
-                               Map<String, Serializable> properties,
-                               ObjectId folderId) {
+            Map<String, Serializable> properties, ObjectId folderId) {
         throw new UnsupportedOperationException();
     }
 
     public ObjectId createRelationship(String typeId,
-                                     Map<String, Serializable> properties,
-                                     ObjectId sourceId, ObjectId targetId) {
+            Map<String, Serializable> properties, ObjectId sourceId,
+            ObjectId targetId) {
         throw new UnsupportedOperationException();
     }
 
@@ -225,35 +225,30 @@
     }
 
     public Collection<ObjectEntry> getAllVersions(String versionSeriesId,
-                                                  String filter) {
+            String filter) {
         throw new UnsupportedOperationException();
     }
 
-    public Collection<String> getAllowableActions(ObjectId objectId, String asUser)
{
+    public Collection<String> getAllowableActions(ObjectId objectId,
+            String asUser) {
         throw new UnsupportedOperationException();
     }
 
     public Collection<ObjectEntry> getAppliedPolicies(ObjectId objectId,
-                                                      String filter) {
+            String filter) {
         throw new UnsupportedOperationException();
     }
 
     public Collection<ObjectEntry> getCheckedoutDocuments(ObjectId folderId,
-                                                          String filter,
-                                                          boolean includeAllowableActions,
-                                                          boolean includeRelationships,
-                                                          int maxItems,
-                                                          int skipCount,
-                                                          boolean[] hasMoreItems) {
+            String filter, boolean includeAllowableActions,
+            boolean includeRelationships, int maxItems, int skipCount,
+            boolean[] hasMoreItems) {
         throw new UnsupportedOperationException();
     }
 
-    public List<ObjectEntry> getChildren(ObjectId folderId,
-                                         String filter,
-                                         boolean includeAllowableActions,
-                                         boolean includeRelationships,
-                                         int maxItems, int skipCount,
-                                         String orderBy, boolean[] hasMoreItems) {
+    public List<ObjectEntry> getChildren(ObjectId folderId, String filter,
+            boolean includeAllowableActions, boolean includeRelationships,
+            int maxItems, int skipCount, String orderBy, boolean[] hasMoreItems) {
 
         try {
             if (maxItems == 0) {
@@ -261,7 +256,8 @@
             }
 
             Node node = session.getRootNode();
-            String relPath = JcrObjectEntry.getPath(folderId.getId()).substring(1);
+            String relPath = JcrObjectEntry.getPath(folderId.getId()).substring(
+                    1);
             if (!relPath.equals("")) {
                 node = node.getNode(relPath);
             }
@@ -299,14 +295,15 @@
         return this;
     }
 
-    public InputStream getContentStream(ObjectId documentId, int offset,
-                                        int length) throws IOException {
-
+    public ContentStream getContentStream(ObjectId documentId,
+            String renditionId) throws IOException {
+        // TODO renditionId
         try {
-            String relPath = JcrObjectEntry.getPath(documentId.getId()).substring(1);
+            String relPath = JcrObjectEntry.getPath(documentId.getId()).substring(
+                    1);
             Node node = session.getRootNode().getNode(relPath);
             JcrDocument document = new JcrDocument(node);
-            return document.getStream();
+            return document.getContentStream();
         } catch (RepositoryException e) {
             String msg = "Unable to get object: " + documentId;
             log.error(msg, e);
@@ -314,38 +311,33 @@
         return null;
     }
 
-    public List<ObjectEntry> getDescendants(ObjectId folderId,
-                                            int depth, String filter,
-                                            boolean includeAllowableActions,
-                                            boolean includeRelationships,
-                                            String orderBy) {
+    public List<ObjectEntry> getDescendants(ObjectId folderId, int depth,
+            String filter, boolean includeAllowableActions,
+            boolean includeRelationships, String orderBy) {
         // TODO Auto-generated method stub
         return null;
     }
 
     public List<ObjectEntry> getFolderParent(ObjectId folderId, String filter,
-                                             boolean includeAllowableActions,
-                                             boolean includeRelationships,
-                                             boolean returnToRoot) {
+            boolean includeAllowableActions, boolean includeRelationships,
+            boolean returnToRoot) {
         // TODO Auto-generated method stub
         return null;
     }
 
     public Collection<ObjectEntry> getObjectParents(ObjectId objectId,
-                                                    String filter,
-                                                    boolean includeAllowableActions,
-                                                    boolean includeRelationships) {
+            String filter, boolean includeAllowableActions,
+            boolean includeRelationships) {
         // TODO Auto-generated method stub
         return null;
     }
 
-    public ObjectEntry getProperties(ObjectId objectId,
-                                     String filter,
-                                     boolean includeAllowableActions,
-                                     boolean includeRelationships) {
+    public ObjectEntry getProperties(ObjectId objectId, String filter,
+            boolean includeAllowableActions, boolean includeRelationships) {
 
         try {
-            String relPath = JcrObjectEntry.getPath(objectId.getId()).substring(1);
+            String relPath = JcrObjectEntry.getPath(objectId.getId()).substring(
+                    1);
             if (relPath.equals("")) {
                 return (ObjectEntry) getRootFolder();
             } else {
@@ -363,22 +355,23 @@
         return null;
     }
 
-    public Map<String, Serializable> getPropertiesOfLatestVersion(String versionSeriesId,
-                                                                  boolean major,
-                                                                  String filter) {
+    public Map<String, Serializable> getPropertiesOfLatestVersion(
+            String versionSeriesId, boolean major, String filter) {
         // TODO Auto-generated method stub
         return null;
     }
 
     public List<ObjectEntry> getRelationships(ObjectId objectId,
-                                              RelationshipDirection direction,
-                                              String typeId,
-                                              boolean includeSubRelationshipTypes,
-                                              String filter,
-                                              String includeAllowableActions,
-                                              int maxItems, int skipCount,
-                                              boolean[] hasMoreItems) {
+            RelationshipDirection direction, String typeId,
+            boolean includeSubRelationshipTypes, String filter,
+            String includeAllowableActions, int maxItems, int skipCount,
+            boolean[] hasMoreItems) {
+
+        return Collections.emptyList();
+    }
 
+    public List<Rendition> getRenditions(ObjectId object, String filter,
+            int maxItems, int skipCount) {
         return Collections.emptyList();
     }
 
@@ -394,12 +387,9 @@
     }
 
     public Collection<ObjectEntry> query(String statement,
-                                         boolean searchAllVersions,
-                                         boolean includeAllowableActions,
-                                         boolean includeRelationships,
-                                         int maxItems, int skipCount,
-                                         boolean[] hasMoreItems) {
-
+            boolean searchAllVersions, boolean includeAllowableActions,
+            boolean includeRelationships, int maxItems, int skipCount,
+            boolean[] hasMoreItems) {
 
         try {
             QueryManager qm = session.getWorkspace().getQueryManager();
@@ -436,12 +426,12 @@
     }
 
     public ObjectId setContentStream(ObjectId documentId, boolean overwrite,
-                                 ContentStream contentStream) {
+            ContentStream contentStream) {
         throw new UnsupportedOperationException();
     }
 
     public ObjectId updateProperties(ObjectId objectId, String changeToken,
-                                   Map<String, Serializable> properties) {
+            Map<String, Serializable> properties) {
         throw new UnsupportedOperationException();
     }
 

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrDocument.java
Fri Jul 31 16:15:11 2009
@@ -42,7 +42,8 @@
         super(node);
     }
 
-    protected JcrDocument() {}
+    protected JcrDocument() {
+    }
 
     public ContentStream getContentStream() {
         try {
@@ -55,6 +56,11 @@
         return null;
     }
 
+    public ContentStream getContentStream(String renditionId) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
     public Folder getParent() {
         try {
             return new JcrFolder(node.getParent());
@@ -77,6 +83,11 @@
         return null;
     }
 
+    public InputStream getStream(String renditionId) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
     @Override
     public String getString(String id) {
         if (id.equals(Property.CONTENT_STREAM_MIME_TYPE)) {

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrFolder.java
Fri Jul 31 16:15:11 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.chemistry.jcr;
 
+import java.io.InputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -29,6 +30,7 @@
 
 import org.apache.chemistry.BaseType;
 import org.apache.chemistry.CMISObject;
+import org.apache.chemistry.ContentStream;
 import org.apache.chemistry.Document;
 import org.apache.chemistry.Folder;
 import org.apache.chemistry.ObjectId;
@@ -137,4 +139,16 @@
     public BaseType getBaseType() {
         return BaseType.FOLDER;
     }
+
+    public InputStream getStream(String renditionId) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+    public ContentStream getContentStream(String renditionId) {
+        // TODO Auto-generated method stub
+        throw new UnsupportedOperationException();
+    }
+
+
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrRepository.java?rev=799653&r1=799652&r2=799653&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrRepository.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-jcr/src/main/java/org/apache/chemistry/jcr/JcrRepository.java
Fri Jul 31 16:15:11 2009
@@ -35,6 +35,7 @@
 import org.apache.chemistry.JoinCapability;
 import org.apache.chemistry.ObjectId;
 import org.apache.chemistry.QueryCapability;
+import org.apache.chemistry.RenditionCapability;
 import org.apache.chemistry.Repository;
 import org.apache.chemistry.RepositoryCapabilities;
 import org.apache.chemistry.RepositoryEntry;
@@ -217,6 +218,10 @@
         return QueryCapability.BOTH_SEPARATE;
     }
 
+    public RenditionCapability getRenditionCapability() {
+        return RenditionCapability.NONE;
+    }
+
     public boolean hasMultifiling() {
         return true;
     }



Mime
View raw message