cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicate Child Node Name Exception

patrik
Champ on-the-rise
Champ on-the-rise
Hi! I'm having a problem when using simple workflow and transformation from doc to pdf. I trigger the workflow to copy an item to another space where a rule says that the item should be transformed to pdf and copied to a space. This works fine the first time. But the second time i get this error:

ERROR [ui.common.Utils] Failed to approve the document due to system error: Duplicate child name not allowed: {filename}
org.alfresco.service.cmr.repository.DuplicateChildNodeNameException: Duplicate child name not allowed: {filename}

Can't alfresco replace this file and update it with a new version? It doesn't matter if i delete the previous doc-file that was created if i keep the pdf. As long as any of the two files are left nothing happens besides the duplicate error. It works well when i replace the recently created doc-file in webdav. Then the pdf gets updated.

I use alfresco 2.1 Enterprise version.

Help appreciated
11 REPLIES 11

sacco
Champ in-the-making
Champ in-the-making
The destination node may have different permissions i.e. may be accessable by different users.

Yes, I can see that, but, if I've understood correctly, content data
(i.e. binary files stored in the Content Store) are effectively read-only
in Alfresco.

So if I were to replace:
// write the content from the current document into the destination
destNode.content.write(document.properties.content);
with:
// set the destination to refer to the content from the current document
destNode.properties["cm:content"] = document.properties.content;

then I would simply have an extra reference to the same stream of bits on the disk.
As this binary data is never modified,  each user's access sees the same data in
both cases.  I'm guessing that they could even see the same data with different
MIME types (set in the node's content metadata),
e.g. text/html and application/xhtml+xml

So I'm trying to understand why I would ever want to have two instances of the
exact same sequence of bits: where does the access control for download stream
come from, particularly in the case of multiple references to the same raw content?

I'm assuming that it can't depend directly upon the node from which it is accessed,
but all of my experiments so far suggest that access to the content stream through
different nodes is achieved through different URLs, and so different permissions
can be set for exactly the same bits for read-only access through different URLs.

Is there some loophole in this that I am missing?

adelatorre
Champ in-the-making
Champ in-the-making
Hi!

I'll help with a code snippet this helpful reply

You should design your script to:
* Check out a working copy of your versioned node.
* Use the new write method to update the content of your working copy.
* Check in your working copy.

This is a move function, that detects if a node already exists
(Variables are in spanish)


// Moves a node to a destination
function moveNode (nodo, destino) {
   // Search if exists
   var encontrado = destino.childByNamePath(nodo.name);
  
   if (encontrado != null) {
      if (! encontrado.hasAspect("cm:versionable")) {
         encontrado.addAspect("cm:versionable");
      }
      var wc = encontrado.checkout();
      wc.properties["cm:content"]=nodo.properties["cm:content"];
      wc.save();     
      wc.checkin("Update element: "+nodo.name);
      nodo.remove();
   }
   else
   {
      nodo.move(destino);
   }  
}

This only has a problem, increases two versions each time. I guess wc.save(), make his part in it, while we are updating that node.

I hope this helps