0

Using Alfresco 5.0 community edition.

When trying to deploy the custom model provided in the answer to another question, but using the dynamic deployment approach as specified at [http://docs.alfresco.com/5.0/tasks/deploy-dynamic.html]

Although the GUI says the model is "activated", I get the following WARN in the alfresco.log:

21:24:30,587 WARN  [org.alfresco.repo.dictionary.DictionaryDAO] [ajp-apr-8009-exec-4]
                   org.alfresco.service.cmr.dictionary.DictionaryException: 
                   00140008 Model '{custom.model}custommodel' does not exist

When I try to use it with CMIS 1.1, I'm getting an error back from the web service:

Type 'P:cmod:customDoc' is unknown!

Here is the relevant bit of the code which uses opencmis java api:

Map<String, Object> props = new HashMap<String, Object>();
props.put("cmis:objectTypeId", "cmis:document");
props.put("cmis:secondaryObjectTypeIds", Arrays.asList(new String[] {"P:cm:titled", "P:cmod:customDoc"}));
props.put("cmis:name", "myName");
props.put("cmod:property1", "value1");
ObjectId id = folder.createDocument(props, contentStream, VersioningState.MAJOR);

Am I specifying the namespace and aspect correctly (P:cmod:customDoc)? I've also tried cmod:aspectBase and other combinations, getting the same error.

My goal is to make a simple model where I can add a few extra fields to document objects (extending the default ContentModel).

Community
  • 1
  • 1
Matt
  • 362
  • 5
  • 21
  • Are you certain you put your custom model file into the right place on the server? – Gagravarr Jan 14 '15 at 23:11
  • Yes, in 'Repository> Data Dictionary> Model'. Then I click on the Model Active checkbox in the properties. The GUI says the model is active: 'Is Active: trueModel Name: custommodelModel Description: Custom Model' BUT I get the warning in the log immediately. – Matt Jan 15 '15 at 00:08
  • Btw: this is using the dynamic deployment approach: [http://docs.alfresco.com/5.0/tasks/deploy-dynamic.html](http://docs.alfresco.com/5.0/tasks/deploy-dynamic.html) – Matt Jan 15 '15 at 00:13
  • Can you edit your question and put that info in? Formatting has been lost as a comment, so I can't quite work out what's what of that gui info – Gagravarr Jan 15 '15 at 09:43

1 Answers1

0

It seems the warning is just that, it can be ignored.

But using CMIS 1.1, I have to do two steps to add in the extra properties from the custom aspect. (Trying to do it in one step gives the error "Type 'P:cmod:customDoc' is unknown!")

First createDocument() with the cmis:secondaryObjectTypeIds including the custom namespace, BUT don't add any custom properties.

Second, add the custom properties to the resulting document, and then updateProperties(). This will add in the custom property values to the document.

Map<String, Object> props = new HashMap<String, Object>();
props.put("cmis:objectTypeId", "cmis:document");
props.put("cmis:secondaryObjectTypeIds", 
          Arrays.asList(new String[] {"P:cm:titled", "P:cmod:customDoc"}));
props.put("cmis:name", "myName");
Document document = folder.createDocument(props, contentStream, VersioningState.MAJOR);

props = new HashMap<String, Object>();
props.put("cmod:property1", "value1");  //here is where you add the custom properties
document = (Document) document.updateProperties(properties);

(note: you need to reassign the document from the updateProperties result, otherwise it will be missing some information, such as parents)

Matt
  • 362
  • 5
  • 21