chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1663992 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/mai...
Date Wed, 04 Mar 2015 13:44:05 GMT
Author: fmui
Date: Wed Mar  4 13:44:05 2015
New Revision: 1663992

URL: http://svn.apache.org/r1663992
Log:
client: added workaround for SharePoint (check-in only works if at least one property is set)

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/VersioningServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/configs/sharepoint-2010-atompub.properties
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/configs/sharepoint-2013-atompub.properties

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/VersioningServiceImpl.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/atompub/VersioningServiceImpl.java?rev=1663992&r1=1663991&r2=1663992&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/VersioningServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/VersioningServiceImpl.java
Wed Mar  4 13:44:05 2015
@@ -32,20 +32,26 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomLink;
 import org.apache.chemistry.opencmis.client.bindings.spi.http.Output;
 import org.apache.chemistry.opencmis.client.bindings.spi.http.Response;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
 import org.apache.chemistry.opencmis.commons.data.Acl;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.data.Properties;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.Constants;
 import org.apache.chemistry.opencmis.commons.impl.ReturnVersion;
 import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringImpl;
 import org.apache.chemistry.opencmis.commons.spi.Holder;
 import org.apache.chemistry.opencmis.commons.spi.VersioningService;
 
@@ -162,6 +168,41 @@ public class VersioningServiceImpl exten
         url.addParameter(Constants.PARAM_MAJOR, major);
         url.addParameter(Constants.PARAM_CHECK_IN, "true");
 
+        // workaround for SharePoint - check in without property change
+        if (getSession().get(SessionParameter.ADD_NAME_ON_CHECK_IN, false)) {
+            if (properties == null || properties.getPropertyList().isEmpty()) {
+                properties = new PropertiesImpl();
+
+                try {
+                    String name = null;
+
+                    // fetch the current name
+                    ObjectData obj = getObjectInternal(repositoryId, IdentifierType.ID, objectId.getValue(),
+                            ReturnVersion.THIS, "cmis:objectId,cmis:name", Boolean.FALSE,
IncludeRelationships.NONE,
+                            "cmis:none", Boolean.FALSE, Boolean.FALSE, null);
+
+                    if (obj != null && obj.getProperties() != null && obj.getProperties().getProperties()
!= null
+                            && obj.getProperties().getProperties().get(PropertyIds.NAME)
!= null) {
+                        PropertyData<?> nameProp = obj.getProperties().getProperties().get(PropertyIds.NAME);
+                        if (nameProp.getFirstValue() instanceof String) {
+                            name = (String) nameProp.getFirstValue();
+                        }
+                    }
+
+                    if (name == null) {
+                        throw new CmisRuntimeException("Could not determine the name of the
PWC!");
+                    }
+
+                    // set the document name to the same value - silly, but
+                    // SharePoint requires that at least one property value has
+                    // to be changed and the name is the only reliable property
+                    ((PropertiesImpl) properties).addProperty(new PropertyStringImpl(PropertyIds.NAME,
name));
+                } catch (CmisBaseException e) {
+                    throw new CmisRuntimeException("Could not determine the name of the PWC:
" + e.toString(), e);
+                }
+            }
+        }
+
         // set up writer
         final AtomEntryWriter entryWriter = new AtomEntryWriter(createObject(properties,
null, policies),
                 getCmisVersion(repositoryId), contentStream);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.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/SessionParameter.java?rev=1663992&r1=1663991&r2=1663992&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
Wed Mar  4 13:44:05 2015
@@ -553,6 +553,16 @@ package org.apache.chemistry.opencmis.co
  * <td>no</td>
  * <td>"false"</td>
  * </tr>
+ * <tr>
+ * <td>{@link #ADD_NAME_ON_CHECK_IN}</td>
+ * <td>Defines if the document name should be added to the properties on check
+ * in if no properties are updated<br>
+ * (Workaround for SharePoint 2010 and SharePoint 2013)</td>
+ * <td>AtomPub</td>
+ * <td>"true", "false"</td>
+ * <td>no</td>
+ * <td>"false"</td>
+ * </tr>
  * </table>
  */
 public final class SessionParameter {
@@ -701,4 +711,5 @@ public final class SessionParameter {
     public static final String INCLUDE_OBJECTID_URL_PARAM_ON_CHECKOUT = "org.apache.chemistry.opencmis.workaround.includeObjectIdOnCheckout";
     public static final String INCLUDE_OBJECTID_URL_PARAM_ON_MOVE = "org.apache.chemistry.opencmis.workaround.includeObjectIdOnMove";
     public static final String OMIT_CHANGE_TOKENS = "org.apache.chemistry.opencmis.workaround.omitChangeTokens";
+    public static final String ADD_NAME_ON_CHECK_IN = "org.apache.chemistry.opencmis.workaround.addNameOnCheckIn";
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/configs/sharepoint-2010-atompub.properties
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/configs/sharepoint-2010-atompub.properties?rev=1663992&r1=1663991&r2=1663992&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/configs/sharepoint-2010-atompub.properties
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/configs/sharepoint-2010-atompub.properties
Wed Mar  4 13:44:05 2015
@@ -30,5 +30,6 @@ org.apache.chemistry.opencmis.password=<
 org.apache.chemistry.opencmis.workaround.includeObjectIdOnCheckout=true
 org.apache.chemistry.opencmis.workaround.includeObjectIdOnMove=true
 org.apache.chemistry.opencmis.workaround.omitChangeTokens=true
+org.apache.chemistry.opencmis.workaround.addNameOnCheckIn=true
 
 cmis.workbench.folder.filter=*
\ No newline at end of file

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/configs/sharepoint-2013-atompub.properties
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/configs/sharepoint-2013-atompub.properties?rev=1663992&r1=1663991&r2=1663992&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/configs/sharepoint-2013-atompub.properties
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/configs/sharepoint-2013-atompub.properties
Wed Mar  4 13:44:05 2015
@@ -27,5 +27,6 @@ org.apache.chemistry.opencmis.user=<doma
 org.apache.chemistry.opencmis.password=<password>
 
 org.apache.chemistry.opencmis.workaround.omitChangeTokens=true
+org.apache.chemistry.opencmis.workaround.addNameOnCheckIn=true
 
 cmis.workbench.folder.filter=*
\ No newline at end of file



Mime
View raw message