AnsweredAssumed Answered

custom document library action

Question asked by pchoe on Mar 16, 2010
I am trying to create a custom document library action where I would be able to view audit log for the document.

I tried to follow the document on creating custom document library from alfresco, but I have question about how to process the data (i.e. audit logs) back from the alfresco repository to share.

What I have so far is that I have created the document library action on share and call a webscript defined in the alfresco repository. What I am not sure of is how format the audit log entries and how to process the audit logs to display in share.

Below is the document library action.
/**
* Action "Audit" action
*
* @namespace Alfresco
* @class Alfresco.DocumentList
*/
(function()
{
   /**
    * Audit log single document.
    *
    * @method onActionAuditLog
    * @param row
    *            {object} DataTable row representing file to be actioned
    */
    Alfresco.DocumentList.prototype.onActionAuditLog = function DL_onActionAuditLog(asset)
   {
         var displayName = asset.displayName,
         nodeRef = new Alfresco.util.NodeRef(asset.nodeRef);
         this.modules.actions.genericAction(
                {
                   success:
                   {
                      message: this.msg("message.auditlog.success", displayName)
                   },
                   failure:
                   {
                      message: this.msg("message.auditlog.failure", displayName)
                   },
                   webscript:
                   {
                      name: "com/microstrat/cpg/auditlog/{nodeRef}",
                      method: Alfresco.util.Ajax.POST,
                      params:
                      {
                      nodeRef: nodeRef.uri
                      }
                   }
      });
   };
})();


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

/**
* Checkin file action
* @method POST
* @param uri {string} /{siteId}/{containerId}/{filepath}
*/

/**
* Entrypoint required by action.lib.js
*
* @method runAction
* @param p_params {object} standard action parameters: nodeRef, siteId, containerId, path
* @return {object|null} object representation of action result
*/
function runAction(p_params)
{
   var results;

   try
   {
      var assetNode = p_params.destNode;

      // Construct the result object
      results = [
      {
         id: "",
         nodeRef: "",
         action: "auditLogAsset",
         success: true
      }];
   }
   catch(e)
   {
      status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, e.toString());
      return;
   }

   return results;
}

/* Bootstrap action script */
main();

My alfresco.auditlog.post.json

<#import "action.lib.ftl" as actionLib />
<@actionLib.resultsJSON results=results />

So, as far as I can figure, I would need to probably add something in the audit log action code to handle the response that comes back from the alfresco repository.  But I am not sure how to handle this.  Is there documentation on this process?

Peter Choe

Outcomes