Categories
Uncategorized

Adding email aliases to Alfresco folders via CMIS

This took me a ridiculously long time to figure out, largely because there isn’t any documentation. So, in case anyone else out there needs to know how to do it, here’s how you set an alias on a node in an Alfresco repository in Java (via OpenCMIS and the Alfresco OpenCMIS Extensions).

 

try {
  // folder/emailFolderName is the node path
  AlfrescoFolder emailFolder = (AlfrescoFolder)session.
                                  getObjectByPath("folder/emailFolderName");
} catch (CmisObjectNotFoundException e) {
  // Folder doesn't exist - handle appropriately
}

emailFolder.addAspect("P:emailserver:aliasable");

Map<String, String> properties = new HashMap<String, String>(1);
// my-email-folder is the chosen alias for this node
properties.put("emailserver:alias", "my-email-folder");
emailFolder.updateProperties(properties);

And that’s all there is to it. I wish it hadn’t taken me nearly a whole day to work that out…

One thing I have discovered is the incredibly useful CMIS Workbench, highly recommended for working out the CMIS names for obscure properties. There’s a useful guide to getting started with it in the answer to this StackOverflow question.

Leave a Reply

Your email address will not be published. Required fields are marked *