chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1428906 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/ chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/c...
Date Fri, 04 Jan 2013 14:55:07 GMT
Author: fmui
Date: Fri Jan  4 14:55:07 2013
New Revision: 1428906

URL: http://svn.apache.org/viewvc?rev=1428906&view=rev
Log:
CMIS 1.1: implemented bulkUpdateProperties

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/spi/ObjectService.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateObjectIdAndChangeTokenImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.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/Session.java?rev=1428906&r1=1428905&r2=1428906&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-api/src/main/java/org/apache/chemistry/opencmis/client/api/Session.java
Fri Jan  4 14:55:07 2013
@@ -502,8 +502,8 @@ public interface Session extends Seriali
     /**
      * Updates multiple objects in one request.
      */
-    BulkUpdateObjectIdAndChangeToken bulkUpdateProperties(BulkUpdateObjectIdAndChangeToken
objectIdsAndChangeToken,
-            Map<String, ?> properties, List<String> addSecondaryTypeIds, List<String>
removeSecondaryTypeIds);
+    List<BulkUpdateObjectIdAndChangeToken> bulkUpdateProperties(List<CmisObject>
objects, Map<String, ?> properties,
+            List<String> addSecondaryTypeIds, List<String> removeSecondaryTypeIds);
 
     /**
      * Deletes an object and, if it is a document, all versions in the version

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java?rev=1428906&r1=1428905&r2=1428906&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java
Fri Jan  4 14:55:07 2013
@@ -401,7 +401,7 @@ public class ObjectServiceImpl extends A
         UrlBuilder url = getRepositoryUrl(repositoryId);
 
         // prepare form data
-        final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_CREATE_DOCUMENT);
+        final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_BULK_UPDATE);
         formData.addObjectIdsAndChangeTokens(objectIdAndChangeToken);
         formData.addPropertiesParameters(properties);
         formData.addSecondaryTypeIds(addSecondaryTypeIds);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.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/SessionImpl.java?rev=1428906&r1=1428905&r2=1428906&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
Fri Jan  4 14:55:07 2013
@@ -21,6 +21,7 @@ package org.apache.chemistry.opencmis.cl
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
@@ -72,6 +73,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.BulkUpdateObjectIdAndChangeTokenImpl;
 import org.apache.chemistry.opencmis.commons.spi.AclService;
 import org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider;
 import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
@@ -954,14 +956,60 @@ public class SessionImpl implements Sess
 
     // --- bulk update ---
 
-    public BulkUpdateObjectIdAndChangeToken bulkUpdateProperties(
-            BulkUpdateObjectIdAndChangeToken objectIdsAndChangeToken, Map<String, ?>
properties,
-            List<String> addSecondaryTypeIds, List<String> removeSecondaryTypeIds)
{
+    public List<BulkUpdateObjectIdAndChangeToken> bulkUpdateProperties(List<CmisObject>
objects,
+            Map<String, ?> properties, List<String> addSecondaryTypeIds, List<String>
removeSecondaryTypeIds) {
         if (repositoryInfo.getCmisVersion() == CmisVersion.CMIS_1_0) {
             throw new CmisNotSupportedException("This method is not supported for CMIS 1.0
repositories.");
         }
 
-        throw new CmisNotSupportedException("Not implemented, yet");
+        if ((objects == null) || objects.isEmpty()) {
+            throw new IllegalArgumentException("Objects must be set!");
+        }
+
+        ObjectType objectType = null;
+        Map<String, SecondaryType> secondaryTypes = new HashMap<String, SecondaryType>();
+
+        // gather secondary types
+        if (addSecondaryTypeIds != null) {
+            for (String stid : addSecondaryTypeIds) {
+                ObjectType secondaryType = getTypeDefinition(stid);
+
+                if (!(secondaryType instanceof SecondaryType)) {
+                    throw new IllegalArgumentException("Secondary types contains a type that
is not a secondary type: "
+                            + secondaryType.getId());
+                }
+
+                secondaryTypes.put(secondaryType.getId(), (SecondaryType) secondaryType);
+            }
+        }
+
+        // gather ids and change tokens
+        List<BulkUpdateObjectIdAndChangeToken> objectIdsAndChangeTokens = new ArrayList<BulkUpdateObjectIdAndChangeToken>();
+        for (CmisObject object : objects) {
+            if (object == null) {
+                continue;
+            }
+
+            objectIdsAndChangeTokens.add(new BulkUpdateObjectIdAndChangeTokenImpl(object.getId(),
object
+                    .getChangeToken()));
+
+            if (objectType == null) {
+                objectType = object.getType();
+            }
+
+            if (object.getSecondaryTypes() != null) {
+                for (SecondaryType secondaryType : object.getSecondaryTypes()) {
+                    secondaryTypes.put(secondaryType.getId(), secondaryType);
+                }
+            }
+        }
+
+        Set<Updatability> updatebility = new HashSet<Updatability>();
+        updatebility.add(Updatability.READWRITE);
+
+        return getBinding().getObjectService().bulkUpdateProperties(getRepositoryId(), objectIdsAndChangeTokens,
+                objectFactory.convertProperties(properties, objectType, secondaryTypes.values(),
updatebility),
+                addSecondaryTypeIds, removeSecondaryTypeIds, null);
     }
 
     // --- delete ---

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/spi/ObjectService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/spi/ObjectService.java?rev=1428906&r1=1428905&r2=1428906&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/spi/ObjectService.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/spi/ObjectService.java
Fri Jan  4 14:55:07 2013
@@ -393,7 +393,7 @@ public interface ObjectService {
      * 
      * @param repositoryId
      *            the identifier for the repository
-     * @param objectIdAndChangeToken
+     * @param objectIdsAndChangeTokens
      *            the ids and change tokens of the objects to update
      * @param properties
      *            the properties to set
@@ -403,7 +403,7 @@ public interface ObjectService {
      *            the secondary types to remove
      */
     List<BulkUpdateObjectIdAndChangeToken> bulkUpdateProperties(String repositoryId,
-            List<BulkUpdateObjectIdAndChangeToken> objectIdAndChangeToken, Properties
properties,
+            List<BulkUpdateObjectIdAndChangeToken> objectIdsAndChangeTokens, Properties
properties,
             List<String> addSecondaryTypeIds, List<String> removeSecondaryTypeIds,
ExtensionsData extension);
 
     /**

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateObjectIdAndChangeTokenImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateObjectIdAndChangeTokenImpl.java?rev=1428906&r1=1428905&r2=1428906&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateObjectIdAndChangeTokenImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/dataobjects/BulkUpdateObjectIdAndChangeTokenImpl.java
Fri Jan  4 14:55:07 2013
@@ -23,7 +23,8 @@ import java.util.List;
 import org.apache.chemistry.opencmis.commons.data.BulkUpdateObjectIdAndChangeToken;
 import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
 
-public class BulkUpdateObjectIdAndChangeTokenImpl extends AbstractExtensionData implements
BulkUpdateObjectIdAndChangeToken {
+public class BulkUpdateObjectIdAndChangeTokenImpl extends AbstractExtensionData implements
+        BulkUpdateObjectIdAndChangeToken {
 
     private static final long serialVersionUID = 1L;
     private String id;
@@ -32,17 +33,18 @@ public class BulkUpdateObjectIdAndChange
 
     public BulkUpdateObjectIdAndChangeTokenImpl(String id, String changeToken) {
         this.id = id;
-        this.newId = id;
+        this.newId = null;
         this.changeToken = changeToken;
     }
-    
+
     public BulkUpdateObjectIdAndChangeTokenImpl(String id, String newId, String changeToken)
{
         this.id = id;
         this.newId = newId;
         this.changeToken = changeToken;
     }
 
-    public BulkUpdateObjectIdAndChangeTokenImpl(String id, String newId, String changeToken,
List<CmisExtensionElement> extensions) {
+    public BulkUpdateObjectIdAndChangeTokenImpl(String id, String newId, String changeToken,
+            List<CmisExtensionElement> extensions) {
         this.id = id;
         this.newId = newId;
         this.changeToken = changeToken;
@@ -61,4 +63,9 @@ public class BulkUpdateObjectIdAndChange
         return changeToken;
     }
 
+    @Override
+    public String toString() {
+        return "BulkUpdateObjectIdAndChangeToken [id=" + id + ", newId=" + newId + ", changeToken="
+ changeToken + "]"
+                + super.toString();
+    }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java?rev=1428906&r1=1428905&r2=1428906&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserBindingUtils.java
Fri Jan  4 14:55:07 2013
@@ -232,6 +232,7 @@ public final class BrowserBindingUtils {
 
             if (PropertyIds.SECONDARY_OBJECT_TYPE_IDS.equals(propertId) && multiValuePropertyMap
!= null) {
                 Map<Integer, String> values = multiValuePropertyMap.get(i);
+
                 if (values != null) {
                     for (String secTypeId : values.values()) {
                         TypeDefinition typeDef = typeCache.getTypeDefinition(secTypeId);
@@ -239,6 +240,14 @@ public final class BrowserBindingUtils {
                             throw new CmisInvalidArgumentException("Invalid secondary type:
" + secTypeId);
                         }
                     }
+                } else if (singleValuePropertyMap != null) {
+                    String value = singleValuePropertyMap.get(i);
+                    if (value != null) {
+                        TypeDefinition typeDef = typeCache.getTypeDefinition(value);
+                        if (typeDef == null) {
+                            throw new CmisInvalidArgumentException("Invalid secondary type:
" + value);
+                        }
+                    }
                 }
             }
 



Mime
View raw message