cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Document Library Action Always Displays Successful

vamirr
Champ on-the-rise
Champ on-the-rise
I'm writing a custom document library action that will unzip a zip file in place within a site's document library.   I'm following this documentation: http://wiki.alfresco.com/wiki/Custom_Document_Library_Action.

This is on a 3.4.4 Enterprise install.   The custom action seems to always result in a successful message result even when it's not.   I've trivialized the code to the below.    Executing that action still results in the success message displayed when it clearly has the success set to false.

I'm trying to add error checking functionality so that in the event the user clicks to unpack the zip file twice, it returns something other than successful as it actually fails due to file naming conflicts.

Any ideas on what I'm doing wrong?


<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js">

function runAction(p_params){
        try{    logger.log("<!—————————————————start unzip.get.js –>");

                var node, zipFileNodeRef, folderNodeRef, myNewAction, results, result;

                node = url.templateArgs["nodeRef"].replace("workspace:/SpacesStore", "workspace://SpacesStore");
                zipFileNode = utils.getNodeFromString(node);
                folderNode = zipFileNode.parent;


                results = [];
                result = {};
                result.id = zipFileNode.name;
                result.nodeRef =  zipFileNode.nodeRef;
                result.action = "Unzip";
                result.success = false;
                results.push(result);

                myNewAction = actions.create('import');
                myNewAction.parameters.destination = folderNode;
                myNewAction.parameters.encoding = "UTF-8";
                myNewAction.execute(zipFileNode);
        }
        catch(err){
                logger.log("ERROR in importZipFile : " + err);
        }
        finally{
                logger.log("<!—————————————————end unzip.get.js –>");
                return results;
        }
}

main();
1 REPLY 1

vamirr
Champ on-the-rise
Champ on-the-rise
The problem was I wasn't setting a response status.

http://wiki.alfresco.com/wiki/Web_Scripts#Response_Status