cancel
Showing results for 
Search instead for 
Did you mean: 

CMIS: populating properties (type and aspect)

srowsell
Champ in-the-making
Champ in-the-making
I was helped out a while back in this community in this thread, and I was able to get things working well enough in my local test environment (4.1.7.3 Enterprise).  Now it's time to get it to work on what will become the production environment (4.2.f for now) and it's failing to populate a property.  Here's the code I'm using, with the following provisos:

- the session is established and is working
- the document specified by "id" is there, and is being accessed
- the propertyName parameter is valid
- the propertyValue parameter is valid

All that it's not doing is setting a property, and if I set a property manually the log.debug instruction at the bottom returns null (even in the working environment).

Any thoughts?


private static void changeProperties(String id, String propertyName, String propertyValue)
   {
      AlfrescoDocument alfDoc = (AlfrescoDocument) session.getObject(id);
   
      PropertiesImpl properties = new PropertiesImpl();
      List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
   
      CmisExtensionElement valueElem = new CmisExtensionElementImpl(
            ALFRESCO_EXTENSION_NAMESPACE, VALUE, null, propertyValue);
      
      List<CmisExtensionElement> valueElems = new ArrayList<CmisExtensionElement>();
      valueElems.add(valueElem);
   
      List<CmisExtensionElement> children = new ArrayList<CmisExtensionElement>();
      Map<String, String> attributes = new HashMap<String, String>();
      attributes.put(PROPERTY_DEFINITION_ID, propertyName);
      children.add(new CmisExtensionElementImpl(ALFRESCO_EXTENSION_NAMESPACE,
            PROPERTY_STRING, attributes, valueElems));
   
      List<CmisExtensionElement> propertyValuesExtension = new ArrayList<CmisExtensionElement>();
      propertyValuesExtension.add(new CmisExtensionElementImpl(
            ALFRESCO_EXTENSION_NAMESPACE, PROPERTIES, null, children));
   
      CmisExtensionElement setAspectsExtension = new CmisExtensionElementImpl(
            ALFRESCO_EXTENSION_NAMESPACE, SET_ASPECTS, null,
            propertyValuesExtension);
      extensions.add(setAspectsExtension);
      properties.setExtensions(extensions);
      String repId = session.getRepositoryInfo().getId();
      Holder<String> objectIdHolder = new Holder<String>(alfDoc.getId());
      session.getBinding().getObjectService().updateProperties(repId, objectIdHolder, null, properties, null);
      
      log.debug((alfDoc.getPropertyValue(propertyName)).toString());
   }
2 REPLIES 2

jpotts
World-Class Innovator
World-Class Innovator
I can't figure out why you are using CmisExtensionElement for your properties and aspect? If you are using the Alfresco OpenCMIS Extension you can simply set the properties and add the aspects per the examples on <a href="https://code.google.com/a/apache-extras.org/p/alfresco-opencmis-extension/">this page</a>. But maybe you've got a reason that I'm missing.

Also, something to think about: If you are using 4.2, you can now leverage CMIS 1.1 which means aspects are supported by the CMIS spec (referred to as "secondary types") which means you can work with aspects and aspect-defined properties without the extension.

Jeff

srowsell
Champ in-the-making
Champ in-the-making
Jeff…

I had built that piece (using the suggestions in the post I mentioned) to work with the local test instance I had been using, which was a 4.1.7.3 installation.  (I'm new to the OpenCMIS stuff, though I've worked through most of your book.)  The version I'm developing on now is 4.2f.

The actual root problem at the time was using the wrong AtomPub URL; the problem was that it didn't fail outright, but just didn't quite work.  The correct URL made the big difference.

Thanks,

Steve