cancel
Showing results for 
Search instead for 
Did you mean: 

node metadata is reverting on restart,

supratim
Champ in-the-making
Champ in-the-making
Hi all,
I am using following webscript to make change to metadata of a node..
using

<javascript>
notenode.properties['cmc:fileNoteDesc']=textx; 
</javascript>

here is the full code…

<javascript>
function main() {
 
  var noteid=args.nid;

  var textx=args.ncont;

  var notenode=getFileNoteById(noteid);

  notenode.properties['cmc:fileNoteDesc']=textx;  

  notenode.save();  

  model.msg = "Updated   #"+noteid;
     
}


function getFileNoteById(fileNoteId)
{
   var searchResult = new Array();

   var qry="";
   qry+='TYPE:"{com.cmc.model.repository}fileNoting"';
   qry+=" AND @cmc\\:fileNoteId:"+fileNoteId;

   var sNode = search.luceneSearch(qry);
   if(sNode[0] !=null)
   {
      return   sNode[0];   
   }else{
           return null;
   }
   
}


main();

</javascript>

Change is reflected in alfresco until restart.
Once restarted node has the old value in metadata.
Please help!
4 REPLIES 4

mitpatoliya
Star Collaborator
Star Collaborator
Is this property ['emdc:fileNoteDesc'] included in your custom content model?
Also I can see you are using different prefixes in properties like "cmc" and "emdc".  Do you have two custom content model? or you are trying to add this property on the fly?

supratim
Champ in-the-making
Champ in-the-making
Yes,
I have corrected my post.. they are actually all cmc.. the problem persists.

mitpatoliya
Star Collaborator
Star Collaborator
And I am assuming you have put it properly under model.
Is there any chance that this script called again out of your knowledge?
Because if you are saving node properties there is no way it could be changed again by itself.

supratim
Champ in-the-making
Champ in-the-making
I am calling this script from curl from outside only once…
This property actually holds an html string which can be pretty big.
Does this have anything to do with transaction? My webscript uses transaction like this


<webscript>
<shortname>fixnote</shortname>
<description>Reset The Repository For Development Purpose</description>
<url>/content/fixnote</url>
<format default="html">extension</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>


Curl is fired like this


echo "Processing" $f "file..";
ncontx=$(rhino ./encoder.js $f);
echo "ncont="$ncontx>ncont
#echo "ncont=aGVsbG8=">ncont
nidx="${f%.html}"
curl -v -X POST -d nid=$nidx -d @ncont "http://admin:admin@192.168.0.22:82/alfresco/service/content/fixnote";
echo "Processed "$nidx;
echo "***************************";

Here nid=$nidx is actually passing a node id to the script and @ncont reading the big html string from the file.
Funny thing is I can see the node changed property in alfresco . Then I restart alfresco to find it is back to the previous string. There is no other function or webscript is being invoked anywhere.