Featured Post

Applying Email Validation to a JavaFX TextField Using Binding

This example uses the same controller as in a previous post but adds a use case to support email validation.  A Commons Validator object is ...

Friday, March 30, 2012

Fixing a Pasting Error Caused by an Alfresco 4.0 SDK Client

When cutting and pasting a document I created using a custom Alfresco client, I received an error indicating a problem with the node's URI.

After cutting a document in one space and attempting to paste the document in another space using "Paste All", I received the following error in Alfresco 4.0 CE

Unable to paste item due to system error:A namespace prefix is not registered for uri cm

The document was created using an SDK client based on FirstFoundationClient.  My client re-used the following code snippet.

ChildAssociationRef association = nodeService.createNode(targetDir,
   ContentModel.ASSOC_CONTAINS,
   QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, f.getName()),
 ContentModel.TYPE_CONTENT,
   contentProps);


CONTENT_MODEL_PREFIX is "cm".  Switching the createQName() call to use a URI rather than a prefix solved the problem.

ChildAssociationRef association = nodeService.createNode(targetDir,
   ContentModel.ASSOC_CONTAINS,
   QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, f.getName ()),
   ContentModel.TYPE_CONTENT,
   contentProps);


This problem seems to occur only with a move.  Copy and other operations work well.  It seems like there is a problem resolving the prefix, so maybe you can use the _PREFIX constant if the namespace is set up correctly.

No comments:

Post a Comment