AnsweredAssumed Answered

CMIS Property Value Validation

Question asked by philbarr on Apr 20, 2011
Hi all,

Is there a way to validate that a value of a property is legal before trying to set it? Or to retrieve the correct error message when setting one is disallowed?

I'm using the ATOMPUB bindings like this:

      SessionFactory factory = SessionFactoryImpl.newInstance();

      final Map<String, String> params = new HashMap<String, String>();

      params.put(USER, "admin");
      params.put(PASSWORD, "admin");

      params.put(ATOMPUB_URL, "http://localhost:8081/alfresco/s/cmis");
      params.put(BINDING_TYPE, ATOMPUB.value());

      params.put(SessionParameter.REPOSITORY_ID, "24ce5697-2114-4ced-aa37-a4335881f348");

      Session session = factory.createSession(params);
against an Alfresco 3.3 repository.
When I then try this:

      Document doc = (Document) session.getObject(session.createObjectId("workspace://SpacesStore/d22b2109-d696-4665-a21a-fd11b27ee28d"));
      
      Map<String, Object> props = new HashMap<String, Object>();
      props.put("cmis:name", "."); // "." is an invalid value for this property
      
      Document updateDoc = (Document) doc.updateProperties(props);
      printProps(updateDoc); //method to verify new name
      System.out.println("done");
I get a decent stack trace on the server:

17:14:21,605 User:admin ERROR [node.integrity.IntegrityChecker] Found 1 integrit
y violations:
Invalid property value:
   Node: workspace://SpacesStore/d22b2109-d696-4665-a21a-fd11b27ee28d
   Type: {http://www.alfresco.org/model/content/1.0}content
   Property: {http://www.alfresco.org/model/content/1.0}name
   Constraint: 03200011 Value '.' is not valid as a file name. This property mus
t be a valid file name.
17:14:21,621  ERROR [extensions.webscripts.AbstractRuntime] Exception from execu
teScript - redirecting to status template error: 03200012 Found 1 integrity viol
ations:
Invalid property value:
   Node: workspace://SpacesStore/d22b2109-d696-4665-a21a-fd11b27ee28d
   Type: {http://www.alfresco.org/model/content/1.0}content
   Property: {http://www.alfresco.org/model/content/1.0}name
   Constraint: 03200011 Value '.' is not valid as a file name. This property mus
t be a valid file name.
org.alfresco.repo.node.integrity.IntegrityException: 03200012 Found 1 integrity
violations:
Invalid property value:
   Node: workspace://SpacesStore/d22b2109-d696-4665-a21a-fd11b27ee28d
   Type: {http://www.alfresco.org/model/content/1.0}content
   Property: {http://www.alfresco.org/model/content/1.0}name
   Constraint: 03200011 Value '.' is not valid as a file name. This property mus
t be a valid file name.
        at org.alfresco.repo.node.integrity.IntegrityChecker.checkIntegrity(Inte
grityChecker.java:661)
        at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionS
ynchronizationImpl.beforeCommit(AlfrescoTransactionSupport.java:683)
but a rubbish one in the client:

Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException: Parsing exception!
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.parse(AbstractAtomPubService.java:458)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.updateProperties(ObjectServiceImpl.java:282)
   at org.apache.chemistry.opencmis.client.runtime.AbstractCmisObject.updateProperties(AbstractCmisObject.java:314)
   at org.apache.chemistry.opencmis.client.runtime.AbstractCmisObject.updateProperties(AbstractCmisObject.java:277)
   at com.phil.cmis.CmisOp.<init>(CmisOp.java:22)
   at com.phil.cmis.CmisOp.main(CmisOp.java:12)
Caused by: com.ctc.wstx.exc.WstxParsingException: Can not have DOCTYPE declaration in epilog
at [row,col {unknown-source}]: [92,17]
   at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:605)
   at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:461)

How do I validate the property value beforehand, or retrieve the proper IntegrityException from the server?

Kind Regards,

Phil.

Outcomes