Uploaded image for project: 'Service Packs and Hot Fixes'
  1. Service Packs and Hot Fixes
  2. MNT-16641

CMIS API: Applying aspects including protected properties results in CmisInvalidArgumentException: Property is read-only!

    Details

    • Type: Service Pack Request
    • Status: Closed (View Workflow)
    • Resolution: Fixed
    • Affects Version/s: 5.1
    • Fix Version/s: 5.2.2
    • Component/s: CMIS
    • Labels:
      None

      Description

      By using standard CMIS API (chemistry-opencmis-client-impl) and AtomPub 1.1 protocol, try to add an aspect including protected properties.

      For example, taking "doc" as any Alfresco document:

      Map<String, Object> properties = new HashMap<String, Object>();
      addAspect(doc,  "P:cm:lockable", properties);
      
      public Document addAspect(Document document, String aspect, Map<String, Object> properties) {
      		
      	List<Object> aspects = document.getProperty(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues();
      		
      	if (!aspects.contains(aspect)) {
      		aspects.add(aspect);
      		properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, aspects);
      		document.updateProperties(properties);
      	}
      		
      	return document;
      		
      }
      

      This will produce:

      Caused by: org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Property cm:lockOwner is read-only!
      	at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:475)
      	at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.put(AbstractAtomPubService.java:685)
      	at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.put(AbstractAtomPubService.java:672)
      	at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.updateProperties(ObjectServiceImpl.java:340)
      	at org.apache.chemistry.opencmis.client.runtime.AbstractCmisObject.updateProperties(AbstractCmisObject.java:376)
      	at org.apache.chemistry.opencmis.client.runtime.AbstractCmisObject.updateProperties(AbstractCmisObject.java:340)
      	at es.keensoft.alfresco.cmis.CmisClient.addAspect(CmisClient.java:160)
      	at es.keensoft.alfresco.az.ModelConformanceChecker.createSimpleDocument(ModelConformanceChecker.java:34)
      	at es.keensoft.alfresco.AlfrescoCmisClientApplication.run(AlfrescoCmisClientApplication.java:35)
      	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:806)
      	... 12 more
      

      I've located (and patched) the problem at org.alfresco.opencmis.CMISConnector.setProperties(): https://github.com/Alfresco/community-edition/blob/master/projects/repository/source/java/org/alfresco/opencmis/CMISConnector.java#L3097
      All the properties for the aspect, ignoring if they have been passed as param or not, are assigned to the node. So, "read-only" properties are also included and exception is thrown.

      IMO, this should be patched to set only properties passed as parameter to "updateProperties" CMIS function.

      This behavior also happen in Enterprise 5.1

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                closedbugs Closed Bugs
                Reporter:
                angel.borroy Angel Borroy
              • Votes:
                1 Vote for this issue
                Watchers:
                11 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 10 minutes
                  1h 10m