cancel
Showing results for 
Search instead for 
Did you mean: 

How can be simulate the Submit All Using Web Services

senthilnathan_s
Champ in-the-making
Champ in-the-making
Hi
   I have a scenario,which requires to simulate the submit all action,present in the user-sandboxes view using webservices API.Is there a way to simulate the same using webservices API. :?:
11 REPLIES 11

pmonks
Star Contributor
Star Contributor
The WCM functionality is not accessible via the Web Services API.  Instead you should use Web Scripts, since they have full access to all of the native Alfresco APIs.

Cheers,
Peter

tommorris
Champ in-the-making
Champ in-the-making
If you do decide to use a Java-Backed Web-Script, the following API calls may help (taken from SimpleAVMSubmitAction, I think):

NodeRef actionedUponNodeRef = AVMNodeConverter.ToNodeRef(-1, "webproj–admin:/www/avm_webapps/ROOT");
Pair<Integer, String> avmVersionPath = AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef);
int version = avmVersionPath.getFirst();
String path = avmVersionPath.getSecond();

List<AVMDifference> diffs = avmSyncService.compare(version, path, -1, avmDest, excluder);
if ((diffs != null) && (diffs.size() > 0)) {
    avmSyncService.update(diffs, excluder, false, false, true, true, "Auto Submit " + AVMNodeConverter.SplitBase(path)[1], null);
    AVMDAOs.Instance().fAVMNodeDAO.flush();  // This cleanup was needed for some reason.
    avmSyncService.flatten(storePath[0] + ":/" + JNDIConstants.DIR_DEFAULT_WWW, "webproj"+ ":/" + JNDIConstants.DIR_DEFAULT_WWW);
}

I'm not sure about the quality, but I hope that's helpful.
Tom

pmonks
Star Contributor
Star Contributor
Rather than copy the code out of the submit snapshot action, I'd suggest using the action API to invoke it directly.  The action API is also available to Javascript, so it shouldn't be necessary to drop to Java for this.

Cheers,
Peter

senthilnathan_s
Champ in-the-making
Champ in-the-making
Hi I am  the trying with the actions JavaScript API.
var action= actions.create("simple-avm-submit");
But I am not sure on the parameters I should set on the action variable before executing the action.Can somebody help me stating the parameters that should be set before excuting the action and also on what object should i execute this action.

senthilnathan_s
Champ in-the-making
Champ in-the-making
HI Finally I was able to exceute the 'simple-avm-submit',but whenever i do so the program looks for a staging area with the name appended with –staging.But usaully when i create a webproject eg:"Project1" the staging sandbox name of the project will be "Project1",but when the  'simple-avm-submit', is triggered It looks for a staging sanbox with the name Project1–staging.Is there a way to configure the staging sandbox names in Alfresco  :?:

yqu
Champ in-the-making
Champ in-the-making
Can you check out the source code SimpleAVMSubmitAction.java and change the following line

String avmDest = websiteName + "-staging:" + storePath[1];

to

String avmDest = websiteName + storePath[1];

and recompile and update it in the alfresco-repository.jar?

If it works, I will submit a bug report on it.

Thanks!

Yong

senthilnathan_s
Champ in-the-making
Champ in-the-making
The above given solution works for me.Thanks Smiley Very Happy

rdifrango
Champ in-the-making
Champ in-the-making
Would anyone here mind posting the complete source code for the Webscript that you used to get it working?  Here is what I started with and it does not appear to work correctly:

script:
{   
   var storeid = "portal" +
      ((args.user != null) ? "–" + args.user : "");
    var fullpath = "/www/avm_webapps/ROOT/";
   
    if (fullpath.length == 0)
    {
      status.code = 400;
      status.message = "Store id has not been provided.";
      status.redirect = true;
      break script;
    }
   
    // locate avm node from path
    var store = avm.lookupStore(storeid);
    if (store == undefined)
    {
      status.code = 404;
      status.message = "Store " + storeid + " not found.";
      status.redirect = true;
      break script;
    }
    var node = avm.lookupNode(storeid + ":" + fullpath);

if (node != null)
{
    var workflowType = "jbpm$wf:simple-avm-submit";

    var description = args.desc;

    var workflow = actions.create("simple-avm-submit");

    workflow.parameters.workflowName = workflowType;

    workflow.parameters["bpm:workflowDescription"] = description;

    if ((args.duedate) && (args.duedate != ""))
    {
       var dueDate = new Date(args.duedate);
       workflow.parameters["bpm:workflowDueDate"] = dueDate;
    }

    workflow.execute(node);
}

}

rdifrango
Champ in-the-making
Champ in-the-making
Or better yet, the patched JAR file.  I finally hit the same bug.