manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From piergior...@apache.org
Subject svn commit: r1452476 - in /manifoldcf/trunk: ./ connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/
Date Mon, 04 Mar 2013 20:08:42 GMT
Author: piergiorgio
Date: Mon Mar  4 20:08:42 2013
New Revision: 1452476

URL: http://svn.apache.org/r1452476
Log:
added mimetype and filename support to Alfresco connector (CONNECTORS-655)

Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java
    manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1452476&r1=1452475&r2=1452476&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Mon Mar  4 20:08:42 2013
@@ -3,6 +3,9 @@ $Id$
 
 ======================= 1.2-dev =====================
 
+CONNECTORS-655: Add mimetype and/or filename support to Alfresco connector
+(Piergiorgio Lucidi)
+
 CONNECTORS-658: Add common metadata support (mimetype etc)
 to Livelink connector.
 (David Morana, Karl Wright)

Modified: manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java?rev=1452476&r1=1452475&r2=1452476&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java
(original)
+++ manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/AlfrescoRepositoryConnector.java
Mon Mar  4 20:08:42 2013
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InterruptedIOException;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -812,11 +811,18 @@ public class AlfrescoRepositoryConnector
         long fileLength = 0;
         try {
           //properties ingestion
-          RepositoryDocument rd = new RepositoryDocument();
+          RepositoryDocument rd = new RepositoryDocument();      
           PropertiesUtils.ingestProperties(rd, properties);
 
           // binaries ingestion - in Alfresco we could have more than one binary for each
node (custom content models)
           List<NamedValue> contentProperties = PropertiesUtils.getContentProperties(properties);
+          
+          String fileName = PropertiesUtils.getPropertyValues(properties, Constants.PROP_NAME)[0];
+          String mimeType = PropertiesUtils.getMimeType(contentProperties);
+          
+          rd.setFileName(fileName);
+          rd.setMimeType(mimeType);
+          
           for (NamedValue contentProperty : contentProperties) {
             //we are ingesting all the binaries defined as d:content property in the Alfresco
content model
             Content binary = ContentReader.read(username, password, session, predicate, contentProperty.getName());

Modified: manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java?rev=1452476&r1=1452475&r2=1452476&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java
(original)
+++ manifoldcf/trunk/connectors/alfresco/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/PropertiesUtils.java
Mon Mar  4 20:08:42 2013
@@ -19,6 +19,7 @@
 package org.apache.manifoldcf.crawler.connectors.alfresco;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import org.alfresco.webservice.types.NamedValue;
@@ -35,6 +36,8 @@ public class PropertiesUtils {
 
   private static final String PROP_CONTENT_PREFIX_1 = "contentUrl";
   private static final String PROP_CONTENT_PREFIX_2 = "ContentData";
+  private static final String PROP_CONTENT_SEP = "|";
+  private static final String PROP_MIMETYPE_SEP = "=";
   
   public static String[] getPropertyValues(NamedValue[]  properties, String qname){
     String[] propertyValues = null;
@@ -134,4 +137,27 @@ public class PropertiesUtils {
     return versionLabel;
   }
   
+  /**
+   * This method returns the mimetype of the default content defined for the node.
+   * Notice that more than one binary can be defined in a custom model of Alfresco and also
that 
+   * it could exist some contents that don't have a binary
+   * @param contentProperties
+   * @return mimetype of the default content property
+   */
+  public static String getMimeType(List<NamedValue> contentProperties){
+    if(contentProperties!=null && contentProperties.size()>0){
+      Iterator<NamedValue> i = contentProperties.iterator();
+      while(i.hasNext()){
+        NamedValue contentProperty = i.next();
+        if(Constants.PROP_CONTENT.equals(contentProperty.getName())){
+          String defaultContentPropertyValue = contentProperty.getValue();
+          String[] contentSplitted = StringUtils.split(defaultContentPropertyValue, PROP_CONTENT_SEP);
+          String[] mimeTypeSplitted = StringUtils.split(contentSplitted[1], PROP_MIMETYPE_SEP);
+          return mimeTypeSplitted[1];
+        }
+      }
+    }
+    return StringUtils.EMPTY;
+  }
+  
 }



Mime
View raw message