incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From piergior...@apache.org
Subject svn commit: r1206810 - /incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java
Date Sun, 27 Nov 2011 19:36:04 GMT
Author: piergiorgio
Date: Sun Nov 27 19:36:03 2011
New Revision: 1206810

URL: http://svn.apache.org/viewvc?rev=1206810&view=rev
Log:
- added the support for multivalue properties (CONNECTORS-295)

Modified:
    incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java

Modified: incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java?rev=1206810&r1=1206809&r2=1206810&view=diff
==============================================================================
--- incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java
(original)
+++ incubator/lcf/trunk/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java
Sun Nov 27 19:36:03 2011
@@ -892,6 +892,7 @@ public class CmisRepositoryConnector ext
     outputResource(EDIT_SPEC_HEADER_FORWARD, out, params);
   }
 
+  @SuppressWarnings("unchecked")
   @Override
   public void processDocuments(String[] documentIdentifiers, String[] versions,
       IProcessActivity activities, DocumentSpecification spec,
@@ -946,11 +947,11 @@ public class CmisRepositoryConnector ext
           String id = StringUtils.EMPTY;
           for (Property<?> property : properties) {
             String propertyId = property.getId();
-            Object propertyValue = property.getValue();
             if (propertyId.endsWith(Constants.PARAM_OBJECT_ID))
-              id = (String) propertyValue;
+              id = (String) property.getValue();
 
-            if (propertyValue != null) {
+            if (property.getValue() !=null 
+                || property.getValues() != null) {
               PropertyType propertyType = property.getType();
 
               switch (propertyType) {
@@ -959,29 +960,66 @@ public class CmisRepositoryConnector ext
               case ID:
               case URI:
               case HTML:
-                String stringValue = (String) propertyValue;
-                rd.addField(propertyId, stringValue);
+                if(property.isMultiValued()){
+                  List<String> htmlPropertyValues = (List<String>) property.getValues();
+                  for (String htmlPropertyValue : htmlPropertyValues) {
+                    rd.addField(propertyId, htmlPropertyValue);
+                  }
+                } else {
+                  String stringValue = (String) property.getValue();
+                  rd.addField(propertyId, stringValue);
+                  
+                }
                 break;
-
+     
               case BOOLEAN:
-                Boolean booleanValue = (Boolean) propertyValue;
-                rd.addField(propertyId, booleanValue.toString());
+                if(property.isMultiValued()){
+                  List<Boolean> booleanPropertyValues = (List<Boolean>) property.getValues();
+                  for (Boolean booleanPropertyValue : booleanPropertyValues) {
+                    rd.addField(propertyId, booleanPropertyValue.toString());
+                  }
+                } else {
+                  Boolean booleanValue = (Boolean) property.getValue();
+                  rd.addField(propertyId, booleanValue.toString());
+                }
                 break;
 
               case INTEGER:
-                BigInteger integerValue = (BigInteger) propertyValue;
-                rd.addField(propertyId, integerValue.toString());
+                if(property.isMultiValued()){
+                  List<BigInteger> integerPropertyValues = (List<BigInteger>)
property.getValues();
+                  for (BigInteger integerPropertyValue : integerPropertyValues) {
+                    rd.addField(propertyId, integerPropertyValue.toString());
+                  }
+                } else {
+                  BigInteger integerValue = (BigInteger) property.getValue();
+                  rd.addField(propertyId, integerValue.toString());
+                }
                 break;
 
               case DECIMAL:
-                BigDecimal decimalValue = (BigDecimal) propertyValue;
-                rd.addField(propertyId, decimalValue.toString());
+                if(property.isMultiValued()){
+                  List<BigDecimal> decimalPropertyValues = (List<BigDecimal>)
property.getValues();
+                  for (BigDecimal decimalPropertyValue : decimalPropertyValues) {
+                    rd.addField(propertyId, decimalPropertyValue.toString());
+                  }
+                } else {
+                  BigDecimal decimalValue = (BigDecimal) property.getValue();
+                  rd.addField(propertyId, decimalValue.toString());
+                }
                 break;
 
               case DATETIME:
-                GregorianCalendar dateValue = (GregorianCalendar) propertyValue;
-                rd.addField(propertyId,
-                    ISO8601_DATE_FORMATTER.format(dateValue.getTime()));
+                if(property.isMultiValued()){
+                  List<GregorianCalendar> datePropertyValues = (List<GregorianCalendar>)
property.getValues();
+                  for (GregorianCalendar datePropertyValue : datePropertyValues) {
+                    rd.addField(propertyId,
+                        ISO8601_DATE_FORMATTER.format(datePropertyValue.getTime()));
+                  }
+                } else {
+                  GregorianCalendar dateValue = (GregorianCalendar) property.getValue();
+                  rd.addField(propertyId,
+                      ISO8601_DATE_FORMATTER.format(dateValue.getTime()));
+                }
                 break;
 
               default:



Mime
View raw message