You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2012/08/03 16:03:09 UTC

svn commit: r1368965 - in /chemistry/opencmis/trunk/chemistry-opencmis-client: chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runti...

Author: fmui
Date: Fri Aug  3 14:03:08 2012
New Revision: 1368965

URL: http://svn.apache.org/viewvc?rev=1368965&view=rev
Log:
Fixed createContentStream() behavior if a negative length is provided

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.java?rev=1368965&r1=1368964&r2=1368965&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ObjectFactory.java Fri Aug  3 14:03:08 2012
@@ -37,7 +37,11 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.Updatability;
 
 /**
- * A factory to create CMIS objects.
+ * A factory to create and convert CMIS objects.
+ * 
+ * Custom {@link ObjectFactory} implementations may use the convert methods to
+ * inject specific implementations of the interfaces when the data is transfered
+ * from the low level API to the high level API.
  * 
  * @see org.apache.chemistry.opencmis.client.api.Session#getObjectFactory()
  */
@@ -67,8 +71,31 @@ public interface ObjectFactory {
 
     // content stream
 
+    /**
+     * Creates an object that implements the {@link ContentStream} interface.
+     * 
+     * @param filename
+     *            the filename, should be set
+     * @param length
+     *            the length of the stream or -1 if the length is unknown
+     * @param mimetype
+     *            the MIME type, if unknown "application/octet-stream" should be
+     *            used
+     * @param stream
+     *            the stream, should not be <code>null</code>
+     * 
+     * @return the {@link ContentStream} object
+     */
     ContentStream createContentStream(String filename, long length, String mimetype, InputStream stream);
 
+    /**
+     * Converts a low level {@link ContentStream} object into a high level
+     * {@link ContentStream} object.
+     * 
+     * @param contentStream
+     *            the original {@link ContentStream} object
+     * @return the {@link ContentStream} object
+     */
     ContentStream convertContentStream(ContentStream contentStream);
 
     // types

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java?rev=1368965&r1=1368964&r2=1368965&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/repository/ObjectFactoryImpl.java Fri Aug  3 14:03:08 2012
@@ -190,7 +190,7 @@ public class ObjectFactoryImpl implement
     // content stream
 
     public ContentStream createContentStream(String filename, long length, String mimetype, InputStream stream) {
-        return new ContentStreamImpl(filename, BigInteger.valueOf(length), mimetype, stream);
+        return new ContentStreamImpl(filename, (length < 0 ? null : BigInteger.valueOf(length)), mimetype, stream);
     }
 
     public ContentStream convertContentStream(ContentStream contentStream) {
@@ -449,7 +449,7 @@ public class ObjectFactoryImpl implement
                     List<GregorianCalendar> list = new ArrayList<GregorianCalendar>(values.size());
                     for (Object d : values) {
                         GregorianCalendar cal = new GregorianCalendar();
-                        cal.setTime((Date)d);
+                        cal.setTime((Date) d);
                         list.add(cal);
                     }
                     propertyData = bof.createPropertyDateTimeData(id, list);
@@ -569,7 +569,7 @@ public class ObjectFactoryImpl implement
 
         return new ChangeEventsImpl(changeLogToken, events, hasMoreItems, totalNumItems);
     }
-    
+
     private void throwWrongTypeError(Object obj, String type, Class<?> clazz, String id) {
         String expectedTypes;
         if (clazz.equals(BigInteger.class))
@@ -580,11 +580,10 @@ public class ObjectFactoryImpl implement
             expectedTypes = "<java.util.GregorianCalendar, java.util.Date>";
         else
             expectedTypes = clazz.getName();
-            
-        String message = "Property '" + id +"' is a " + type + " property. Expected type '"
-                + expectedTypes + "' but received a '" + obj.getClass().getName() + "' property.";
-        
+
+        String message = "Property '" + id + "' is a " + type + " property. Expected type '" + expectedTypes
+                + "' but received a '" + obj.getClass().getName() + "' property.";
+
         throw new IllegalArgumentException(message);
     }
 }
-