camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bibr...@apache.org
Subject svn commit: r1371928 - in /camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis: CMISProducer.java CMISQueryProducer.java CMISSessionFacade.java
Date Sat, 11 Aug 2012 12:30:30 GMT
Author: bibryam
Date: Sat Aug 11 12:30:30 2012
New Revision: 1371928

URL: http://svn.apache.org/viewvc?rev=1371928&view=rev
Log:
Improve logging and  fix a bug in cmis component

Modified:
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java
    camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java

Modified: camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java?rev=1371928&r1=1371927&r2=1371928&view=diff
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java
(original)
+++ camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISProducer.java
Sat Aug 11 12:30:30 2012
@@ -49,6 +49,7 @@ public class CMISProducer extends Defaul
 
     public void process(Exchange exchange) throws Exception {
         CmisObject cmisObject = createNode(exchange);
+        LOG.debug("Created node with id: {}", cmisObject.getId());
         exchange.getOut().setBody(cmisObject.getId());
     }
 

Modified: camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java?rev=1371928&r1=1371927&r2=1371928&view=diff
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java
(original)
+++ camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISQueryProducer.java
Sat Aug 11 12:30:30 2012
@@ -43,11 +43,18 @@ public class CMISQueryProducer extends D
 
     private List<Map<String, Object>> executeQuery(Exchange exchange) throws
Exception {
         String query = exchange.getIn().getMandatoryBody(String.class);
-        boolean retrieveContent = exchange.getIn().getHeader(CamelCMISConstants.CAMEL_CMIS_RETRIEVE_CONTENT,
-                false, Boolean.class);
-        int readSize = exchange.getIn().getHeader(CamelCMISConstants.CAMEL_CMIS_READ_SIZE,
0, Integer.class);
+        Boolean retrieveContent = getRetrieveContent(exchange);
+        Integer readSize = getReadSize(exchange);
 
         ItemIterable<QueryResult> itemIterable = cmisSessionFacade.executeQuery(query);
         return cmisSessionFacade.retrieveResult(retrieveContent, readSize, itemIterable);
     }
+
+    private Integer getReadSize(Exchange exchange) {
+        return exchange.getIn().getHeader(CamelCMISConstants.CAMEL_CMIS_READ_SIZE, Integer.class);
+    }
+
+    private Boolean getRetrieveContent(Exchange exchange) {
+        return exchange.getIn().getHeader(CamelCMISConstants.CAMEL_CMIS_RETRIEVE_CONTENT,
Boolean.class);
+    }
 }

Modified: camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java?rev=1371928&r1=1371927&r2=1371928&view=diff
==============================================================================
--- camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java
(original)
+++ camel/trunk/components/camel-cmis/src/main/java/org/apache/camel/component/cmis/CMISSessionFacade.java
Sat Aug 11 12:30:30 2012
@@ -28,6 +28,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.DocumentType;
 import org.apache.chemistry.opencmis.client.api.Folder;
 import org.apache.chemistry.opencmis.client.api.ItemIterable;
+import org.apache.chemistry.opencmis.client.api.ObjectType;
 import org.apache.chemistry.opencmis.client.api.OperationContext;
 import org.apache.chemistry.opencmis.client.api.QueryResult;
 import org.apache.chemistry.opencmis.client.api.Session;
@@ -117,9 +118,11 @@ public class CMISSessionFacade {
     }
 
     //some duplication
-    public List<Map<String, Object>> retrieveResult(boolean retrieveContent,
int readSize,
+    public List<Map<String, Object>> retrieveResult(Boolean retrieveContent,
Integer readSize,
                                                     ItemIterable<QueryResult> itemIterable)
{
         List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
+        boolean queryForContent = retrieveContent != null ? retrieveContent : readContent;
+        int documentsToRead = readSize != null ? readSize : readCount;
         int count = 0;
         int pageNumber = 0;
         boolean finished = false;
@@ -128,14 +131,14 @@ public class CMISSessionFacade {
             LOG.debug("Processing page {}", pageNumber);
             for (QueryResult item : currentPage) {
                 Map<String, Object> properties = CMISHelper.propertyDataToMap(item.getProperties());
-                if (retrieveContent) {
+                if (queryForContent) {
                     InputStream inputStream = getContentStreamFor(item);
                     properties.put(CamelCMISConstants.CAMEL_CMIS_CONTENT_STREAM, inputStream);
                 }
 
                 result.add(properties);
                 count++;
-                if (count == readSize) {
+                if (count == documentsToRead) {
                     finished = true;
                     break;
                 }
@@ -156,7 +159,9 @@ public class CMISSessionFacade {
 
     public Document getDocument(QueryResult queryResult) {
         if (CamelCMISConstants.CMIS_DOCUMENT
-                .equals(queryResult.getPropertyValueById(PropertyIds.OBJECT_TYPE_ID))) {
+                .equals(queryResult.getPropertyValueById(PropertyIds.OBJECT_TYPE_ID)) ||
+                CamelCMISConstants.CMIS_DOCUMENT
+                                .equals(queryResult.getPropertyValueById(PropertyIds.BASE_TYPE_ID)))
{
             String objectId = (String)queryResult.getPropertyById(PropertyIds.OBJECT_ID).getFirstValue();
             ObjectIdImpl objectIdImpl = new ObjectIdImpl(objectId);
             return (org.apache.chemistry.opencmis.client.api.Document)session.getObject(objectIdImpl);
@@ -177,7 +182,11 @@ public class CMISSessionFacade {
     }
 
     public boolean isObjectTypeVersionable(String objectType) {
-        return ((DocumentType)session.getTypeDefinition(objectType)).isVersionable();
+        if (CamelCMISConstants.CMIS_DOCUMENT.equals(objectType)) {
+            ObjectType typeDefinition = session.getTypeDefinition(objectType);
+            return ((DocumentType)typeDefinition).isVersionable();
+        }
+        return false;
     }
 
     public ContentStream createContentStream(String fileName, byte[] buf, String mimeType)
throws Exception {



Mime
View raw message