In Techno
Did you ever had the following entry in your alfresco.log:
org.alfresco.service.namespace.NamespaceException: A namespace prefix is not registered for uri http://<your cool custom uri>.
9 out of 10 time this is probably you’re missing a model  and in very few cases like me you thought of changing the uri cause there was a spelling mistake in it or it didn’t match the model.I’ll never do that again, changing the uri :P.Steps I followed before hacking into the database:

  1. Created a new model with the old uri, but with a new prefix –> didn’t help
  2. I already created content with the new uri, so couldn’t just put back the old one.
  3. Delete the content by searching on uri instead on prefix –> didn’t help

Cause I’m a geek I didn’t go for the easy path, the easy path is:

  1. Delete all the new uri content in Alfresco by adding sys:temporary to the nodes.
  2. Put back the old uri model and do step 1
The geeky path:
var ctx = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();

var nodeService = ctx.getBean("nodeDAO");
var qname = Packages.org.alfresco.service.namespace.QName;
var aspect = qname.createQName("http://www.contezza.nl/alfresco/error/model/1.0", "hack");
var collection = Packages.java.util.Collections;

var folders = search.luceneSearch("ASPECT:\"{http://www.contezza.nl/alfresco/error/model/1.0}hack\"");

for each(var folder in folders) {
  logger.warn("Polling for folder " + folder.name);
  var node = folder.nodeRef;

  var nodeId = nodeService.getNodePair(node);
  nodeService.removeNodeAspects(nodeId.getFirst(), collection.singleton(aspect));
}

So to breakdown what is happening.

  • I’m getting the nodeDAO
  • Creating a QName for the aspect/property
  • Getting the nodes where the old uri is added
  • Getting a specialized node id, it’s not the NodeRef (tried that)
  • removing the aspect in the database

Have fun using this and if you break Alfresco afterwards cause you messed-up –>  don’t blame me :D.

Recent Posts

Start typing and press Enter to search