AnsweredAssumed Answered

aspect is invalid error

Question asked by gokceng on Mar 8, 2011
I'm using Java API to generate some test data on Alfresco Repository.

Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>();
Map<QName, Serializable> aspectProps = new HashMap<QName, Serializable>();
String docData = createXMLDocData(config);
aspectProps.put(ABDYModel.PROPERTY_DOCUMENT_DATA, docData);
String fileName = "_" + String.valueOf((new Date()).getTime());
contentProps.put(ContentModel.PROP_NAME, fileName);
QName alfrescoFileName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, fileName);
ChildAssociationRef association = nodeService.createNode(testSpace, ContentModel.ASSOC_CONTAINS, alfrescoFileName,
                     ContentModel.TYPE_CONTENT, contentProps);
nodeService.addAspect(association.getChildRef(), ContentModel.ASPECT_VERSIONABLE, null);
nodeService.addAspect(association.getChildRef(), ABDYModel.ASPECT_DOCUMENT, aspectProps);

This gives aspect is invalid error {my.uri}Document.
But when I removed aspect adding operation and make the code like this:


Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>();
String docData = createXMLDocData(config);
contentProps.put(ABDYModel.PROPERTY_DOCUMENT_DATA, docData);
String fileName = "_" + String.valueOf((new Date()).getTime());
contentProps.put(ContentModel.PROP_NAME, fileName);
QName alfrescoFileName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, fileName);
ChildAssociationRef association = nodeService.createNode(testSpace, ContentModel.ASSOC_CONTAINS, alfrescoFileName,
                     ContentModel.TYPE_CONTENT, contentProps);
nodeService.addAspect(association.getChildRef(), ContentModel.ASPECT_VERSIONABLE, null);

it works. So it seems while ABDYModel.PROPERTY_DOCUMENT_DATA is recognized, ABDYModel.ASPECT_DOCUMENT is not or there is another problem.
ABDYModel is here:


public static final String ABDY_URI = "my.uri";
public static final String ABDY_PREFIX = "my";
public static final QName ASPECT_DOCUMENT = QName.createQName(ABDY_URI, "Document");
public static final QName PROPERTY_DOCUMENT_DATA = QName.createQName(ABDY_URI, "documentData");

Outcomes