incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From piergior...@apache.org
Subject svn commit: r1295462 - in /incubator/lcf/trunk: ./ connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/ tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/
Date Thu, 01 Mar 2012 08:19:25 GMT
Author: piergiorgio
Date: Thu Mar  1 08:19:24 2012
New Revision: 1295462

URL: http://svn.apache.org/viewvc?rev=1295462&view=rev
Log:
added the ingestDocument method for the Alfresco connector for each binary property defined
in a single node (CONNECTORS-419)

Modified:
    incubator/lcf/trunk/CHANGES.txt
    incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java
    incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/Constants.java
    incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/Messages.java
    incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/NodeUtils.java
    incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java
    incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/APISanityIT.java
    incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/BaseDerby.java

Modified: incubator/lcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/CHANGES.txt?rev=1295462&r1=1295461&r2=1295462&view=diff
==============================================================================
--- incubator/lcf/trunk/CHANGES.txt (original)
+++ incubator/lcf/trunk/CHANGES.txt Thu Mar  1 08:19:24 2012
@@ -3,6 +3,9 @@ $Id$
 
 ======================= 0.5-dev =====================
 
+CONNECTORS-419: Alfresco Connector needs to invoke the ingestDocument for each d:content
property of a node
+(Piergiorgio Lucidi)
+
 CONNECTORS-417: CMIS Connector creates documentURI with wrong value when version is null.

 Now the documentURI to get the content stream is retrieved from the CMIS server using an
internal method of the OpenCMIS API.
 (Piergiorgio Lucidi)

Modified: incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java?rev=1295462&r1=1295461&r2=1295462&view=diff
==============================================================================
--- incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java
(original)
+++ incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java
Thu Mar  1 08:19:24 2012
@@ -124,6 +124,9 @@ public class AlfrescoRepositoryConnector
   
   /** Alfresco Server configuration tab name */
   private static final String ALFRESCO_SERVER_TAB_NAME = "Server";
+  
+  /** Separator used when a node has more than one content stream. More than one d:content
property */
+  private static final String INGESTION_SEPARATOR_FOR_MULTI_BINARY = ";";
 
   /**
    * Constructor
@@ -859,8 +862,26 @@ public class AlfrescoRepositoryConnector
             fileLength = binary.getLength();
             is = ContentReader.getBinary(binary, username, password, session);
             rd.setBinary(is, fileLength);
+            
+            //id is the node reference only if the node has an unique content stream
+            //For a node with a single d:content property: id = node reference
+            String id = PropertiesUtils.getNodeReference(properties);
+            
+            //For a node with multiple d:content properties: id = node reference;QName
+            //The QName of a property of type d:content will be appended to the node reference
+            if(contentProperties.size()>1){
+              id = id + INGESTION_SEPARATOR_FOR_MULTI_BINARY + contentProperty.getName();
+            }
+            
+            //version label
+            String version = PropertiesUtils.getVersionLabel(properties);
+            
+            //the document uri is related to the specific d:content property available in
the node
+            //we want to ingest each content stream that are nested in a single node
+            String documentURI = binary.getUrl();
+            activities.ingestDocument(id, version, documentURI, rd);
           }
-
+          
         } finally {
           try {
             if(is!=null){

Modified: incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/Constants.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/Constants.java?rev=1295462&r1=1295461&r2=1295462&view=diff
==============================================================================
--- incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/Constants.java
(original)
+++ incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/Constants.java
Thu Mar  1 08:19:24 2012
@@ -26,5 +26,6 @@ public class Constants extends org.alfre
   public static final String PROP_NODE_UUID = createQNameString(NAMESPACE_SYSTEM_MODEL, "node-uuid");
   public static final String PROP_STORE_PROTOCOL = createQNameString(NAMESPACE_SYSTEM_MODEL,
"store-protocol");
   public static final String PROP_STORE_ID = createQNameString(NAMESPACE_SYSTEM_MODEL, "store-identifier");
+  public static final String NODE_REFERENCE = createQNameString(NAMESPACE_CONTENT_MODEL,
"noderef");
 
 }

Modified: incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/Messages.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/Messages.java?rev=1295462&r1=1295461&r2=1295462&view=diff
==============================================================================
--- incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/Messages.java
(original)
+++ incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/Messages.java
Thu Mar  1 08:19:24 2012
@@ -23,6 +23,11 @@ import java.util.Map;
 import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
 import org.apache.manifoldcf.core.interfaces.IHTTPOutput;
 
+/**
+ * 
+ * @author Piergiorgio Lucidi
+ *
+ */
 public class Messages extends org.apache.manifoldcf.ui.i18n.Messages
 {
   public static final String DEFAULT_BUNDLE_NAME="org.apache.manifoldcf.crawler.connectors.alfresco.common";

Modified: incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/NodeUtils.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/NodeUtils.java?rev=1295462&r1=1295461&r2=1295462&view=diff
==============================================================================
--- incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/NodeUtils.java
(original)
+++ incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/NodeUtils.java
Thu Mar  1 08:19:24 2012
@@ -33,6 +33,7 @@ import org.apache.manifoldcf.crawler.sys
 /**
  * 
  * This is an utility class dedicated to the Alfresco Node Web Services API  
+ * @author Piergiorgio Lucidi
  *
  */
 public class NodeUtils {

Modified: incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java?rev=1295462&r1=1295461&r2=1295462&view=diff
==============================================================================
--- incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java
(original)
+++ incubator/lcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java
Thu Mar  1 08:19:24 2012
@@ -26,9 +26,15 @@ import org.apache.commons.lang.StringUti
 import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
 import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
 
+/**
+ * Utility class dedicatd to manage Alfresco properties
+ * @author Piergiorgio Lucidi
+ *
+ */
 public class PropertiesUtils {
 
-  private static final String PROP_CONTENT_PREFIX = "contentUrl";
+  private static final String PROP_CONTENT_PREFIX_1 = "contentUrl";
+  private static final String PROP_CONTENT_PREFIX_2 = "ContentData";
   
   public static String[] getPropertyValues(NamedValue[]  properties, String qname){
     String[] propertyValues = null;
@@ -72,7 +78,8 @@ public class PropertiesUtils {
           if(property.getIsMultiValue()!=null){
             if(!property.getIsMultiValue()){
               if(StringUtils.isNotEmpty(property.getValue())){
-                if(property.getValue().startsWith(PROP_CONTENT_PREFIX)){
+                if(property.getValue().startsWith(PROP_CONTENT_PREFIX_1)
+                    || property.getValue().startsWith(PROP_CONTENT_PREFIX_2)){
                     contentProperties.add(property);
                 }
               }
@@ -113,4 +120,18 @@ public class PropertiesUtils {
     return nodeReference;
   }
   
+  /**
+   * 
+   * @param properties
+   * @return version label of the latest version of the node
+   */
+  public static String getVersionLabel(NamedValue[] properties){
+    String[] versionLabelList = PropertiesUtils.getPropertyValues(properties, Constants.PROP_VERSION_LABEL);
+    String versionLabel = StringUtils.EMPTY;
+    if(versionLabelList!=null && versionLabelList.length>0){
+      versionLabel = versionLabelList[0];
+    }
+    return versionLabel;
+  }
+  
 }

Modified: incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/APISanityIT.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/APISanityIT.java?rev=1295462&r1=1295461&r2=1295462&view=diff
==============================================================================
--- incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/APISanityIT.java
(original)
+++ incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/APISanityIT.java
Thu Mar  1 08:19:24 2012
@@ -1,4 +1,3 @@
-package org.apache.manifoldcf.alfresco_tests;
 /* $Id$ */
 
 /**
@@ -18,6 +17,7 @@ package org.apache.manifoldcf.alfresco_t
 * limitations under the License.
 */
 
+package org.apache.manifoldcf.alfresco_tests;
 
 import java.io.IOException;
 import java.rmi.RemoteException;
@@ -516,7 +516,7 @@ public class APISanityIT extends BaseDer
       // The test data area has 3 documents and one directory, and we have to count the root
directory too.
       count = getJobDocumentsProcessed(jobIDString);
       if (count != 4)
-        throw new ManifoldCFException("Wrong number of documents processed after delete -
expected 5, saw "+new Long(count).toString());
+        throw new ManifoldCFException("Wrong number of documents processed after delete -
expected 4, saw "+new Long(count).toString());
 
       // Now, delete the job.
       deleteJob(jobIDString);

Modified: incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/BaseDerby.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/BaseDerby.java?rev=1295462&r1=1295461&r2=1295462&view=diff
==============================================================================
--- incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/BaseDerby.java
(original)
+++ incubator/lcf/trunk/tests/alfresco/src/test/java/org/apache/manifoldcf/alfresco_tests/BaseDerby.java
Thu Mar  1 08:19:24 2012
@@ -64,7 +64,7 @@ public class BaseDerby extends org.apach
     alfrescoServer = new Server(9090);
     alfrescoServer.setStopAtShutdown(true);
 
-    String alfrescoServerWarPath = "../../connectors/alfresco/build/alfresco-war/alfresco.war";
+    String alfrescoServerWarPath = "../../connectors/alfresco/alfresco-war/alfresco.war";
 
     if (System.getProperty("alfrescoServerWarPath") != null)
       alfrescoServerWarPath = System.getProperty("alfrescoServerWarPath");



Mime
View raw message