AnsweredAssumed Answered

Change made through a  webscript not reflected on ShareUI

Question asked by annakan on Apr 14, 2011
Latest reply on Apr 19, 2011 by annakan
Hello all,

I am trying to make changes to nodes through a webscript not although all API call are ok (not raising any error), NOTHING is translated in the shareUI.

The exact same thing happens when I run code into the debugger evaluate console
Taking a leaf from http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook#Creating_different_child_node_types.2C_including_via_a_specific_named_child_association_and_with_default_properties
% var props = new Array();
% props["cm:name"] = "node name4.txt";
% destNode.nodeRef
workspace://SpacesStore/2ce29180-ea37-4511-a754-fd3a6f6f5fab
% destNode.name
AutreAutreDossier
% var node5 = destNode.createNode(null, "cm:content", props, "cm:contains");
for(i in destNode.children) {logger.log(i +":"+destNode.children[i].name)}
The console output this
1:599_2.jpg
2:Bidon Folder
3:47dae0d4-1b44-4208-bbe9-e9965b4f9a77
4:node name4.txt

but going into the folder shows nothing, the node name4.txt is not there.
The "Bidon folder" was created like this :
% destNode.createFolder("Bidon Folder")
Node Type: {http://www.alfresco.org/model/content/1.0}folder, Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable]
and then doing
% destNode.name
AutreAutreDossier
% destNode.createFolder("Bidon Folder")
Wrapped org.alfresco.service.cmr.model.FileExistsException: Existing file or folder Bidon Folder already exists
shows the folder exists.
but it does not shows up in the UI as a child of destNode ????
and in the  the node explorer examining the nodeDest folder shows that it has NONE of the children I just added, in fact looking for node5.nodeRef shows it as non existent, but trying to do
% var node5 = destNode.createNode(null, "cm:content", props, "cm:contains");
Wrapped org.alfresco.service.cmr.repository.DuplicateChildNodeNameException: Duplicate child name not allowed: node name4.txt

The debugger seems to operate in another transaction ? how can I merge the changes then ?

The root of the problem, why did I try this :

I tried this because I try to do this in my code to no avail :
if (String(curParent.qnamePath)===String(sourceFolder.qnamePath))
                        {
                           logger.log("Complexe MATCH : " + curParent.qnamePath );
                           //fileNode.parents[i]=sourceFolder // Too obvious DOES NOT WORK
                           logger.log("creating association to:" + destNode.qnamePath);
                           destNode.createAssociation(fileNode,"cm:contains");
                           logger.log("removing association toward:" + sourceFolder.qnamePath);
                           fileNode.removeAssociation(sourceFolder,"cm:contains");
                           //fileNode.save(); //Does not change a thing
                           break;
                        }
                     };

the code
logger.log("*********** parents AFTER ****************** ");
                     for(i=0;i < fileNode.parents.length; i+=1){
                        curParent=fileNode.parents[i];
                        logger.log("curParent"+curParent);
                        logger.log("Parent["+i+"]:"+curParent.qnamePath+"**"+curParent.id);
                        };    
                     logger.log("*********** assoc contains AFTER ****************** ");
                     for(i=0;i < fileNode.parentAssocs["cm:contains"][0].length; i+=1){
                        curParent=fileNode.parentAssocs["cm:contains"][0][i];
                        logger.log("curParent"+curParent);
                        logger.log("Parent["+i+"]:"+curParent.qnamePath+"**"+curParent.id);
                        };    
Shows that NONE of the parents properties where updated/changed ??????

But the repository IS modified, I can see that because  the next time I run that code on the same "fileNode", Alfresco throw an exception for the duplicate items, but NOTHING happens in the UI, nowhere in my sight.



It is highly probable that I miss something obvious or misunderstand the "containment semantic" but right now I am at a loss.

Changing parents from java DOES work, and is reflected in the shareUI… (but I can't do what I am doing in JAVA for complex reasons tied to the current state of share (for the whole story see http://forums.alfresco.com/en/viewtopic.php?f=11&t=37710http://forums.alfresco.com/en/viewtopic.php?f=47&t=38098, and my goal is http://forums.alfresco.com/en/viewtopic.php?f=48&t=38233, but none of this matter for the problem at hand)

I am a few hours before declaring our proof of concept with alfresco a failure, so any help would be greatly appreciated :)

thanks a lot for your time.


What am I missing ?

Outcomes