cancel
Showing results for 
Search instead for 
Did you mean: 

Thread safety of javascript based web script

narayana_giri
Champ in-the-making
Champ in-the-making
Created the following web script to assign a unique identifier through aspects for each uploaded document :

docID = parseInt(space.properties["my:uniId"]);
NewDocID = docID + 1;
space.properties["my:uniId"] = NewDocID;
space.save();
document.properties["my:uniId"] = NewDocID;
document.save();

The above web script is assigned to space as a rule to apply for each upload.

Is the above web script is thread safe(If multiple users try to upload documents simultaneously using Alfresco Web Service API or through Alfresco Explorer, the above unique identifier will take care of concurrency?)
4 REPLIES 4

mrogers
Star Contributor
Star Contributor
There's a chance it might work.    However I suggest you test and see what happens.    Sequence generation probably needs another approach since its deceptively tricky.

Thanks for the information.

Could you please suggest what is the best approach for sequence generation.

narayana_giri
Champ in-the-making
Champ in-the-making
Please let me know what is the equivalent REST API for the below authentication scenario as we have some issues with login ticket generated by SOAP API(Exception is - org.apache.ws.security.WSSecurityException: The security token could not be authenticated or authorized):
WebServiceFactory.setEndpointAddress(soapapi);
      try {
         AuthenticationUtils.startSession(userid, password);
         // AuthenticationUtils.startSession("admin", "admin");
      } catch (AuthenticationFault authenticationFault) {
         authenticationFault.printStackTrace();
      }

kaynezhang
World-Class Innovator
World-Class Innovator
please use

/alfresco/service/api/login