cancel
Showing results for 
Search instead for 
Did you mean: 

ContentWriter InvalidTypeException

melw
Champ in-the-making
Champ in-the-making
Hi

I think I am missing a basic point here, could anyone help ?

Within the example model, I have created an aspect with a property of type d:content. When I attempt to get a ContentWriter on a node with the aspect and property, the process throws an InvalidTypeException.

As I understand it, the ContentService.getWriter() calls ContentReader.getReader() to validate the type. A PropertyDefinition is obtained from the dictionaryService using the type of the node. In this case the Alfresco model was returned, which does not contain the aspect and property - so it fails.

Thanks and kind regards
Mel.
4 REPLIES 4

davidc
Star Contributor
Star Contributor
Could you provide the aspect definition and getWriter call, so we can diagnose.  Thanks.

melw
Champ in-the-making
Champ in-the-making
Apologies David, I should have waited and posted the details - unfortunately,  I do not have the test case here.

my aspect is:

<aspect name="my:thumbnailed">
    <title>Thumbnail</title>
    <properties>
        <property name="my:thumbnail">
            <type>d:content</type>
        </property>
     </properties>
</aspect>

The call to the writer is something like:

QName property = QName.createQName("my.new.model", "thumbnail");
ContentWriter writer = contentService.getWriter(nodeRef, property, true)

where the nodeRef refers to a "File" Node of type ContentModel.TYPE_CONTENT (taken from SimpleExampleWithContent.java) with the thumbnailed aspect included.

I will post the test case this evening.

Thanks Mel.

davidc
Star Contributor
Star Contributor
Actually, after some investigation, it seems you've found a bug.  This will be fixed in the next nightly build or if you feel brave you can apply the following patch:

In RoutingContentService.java - replace lines 202/203:

QName nodeType = nodeService.getType(nodeRef);
PropertyDefinition contentPropDef = dictionaryService.getProperty(nodeType, propertyQName);

with:

PropertyDefinition contentPropDef = dictionaryService.getProperty(propertyQName);

Also remove the following line in the same function:

"   node type: " + nodeType + "\n" +

That'll do the trick.

melw
Champ in-the-making
Champ in-the-making
Ah, the penny drops. Thanks very much David.

Mel.