cancel
Showing results for 
Search instead for 
Did you mean: 

Custom DocLib Publish Action

lungpow
Champ in-the-making
Champ in-the-making
I have created a doclib action, backed by a webscript which uses a custom publishing channel to publish content. This channel is configured just like the other channels e.g. facebook, linkedin, etc.

My action does NOT respect the permissions that are configured on the publishing channel. e.g. say you created a group and then applied the group to the channel and removed the inherit and everyone so only members of the group can publish.

The default Publish action in the doclib seems to respect the permissions configured in/on the Channel. i.e it will not show you the channel if you are not part of the group. Any ideas how this works or how I can apply this to my custom action?

I was thinking to use an evaluator but beyond that I am not sure how to move forward. I have been looking at the JS that is called by the publish action but it's not clear how the channel permissions are determined?
4 REPLIES 4

lungpow
Champ in-the-making
Champ in-the-making
Trying to understand how the publish action works.

I know the action is configured in the share-config

         <!– Publish document –>
         <action id="document-publish" type="javascript" label="actions.document.publish">
            <param name="function">onActionPublish</param>
            <evaluator negate="true">evaluator.doclib.action.isLocked</evaluator>
         </action>


I can see the JS function is called.

<param name="function">onActionPublish</param>


I need help to understand how the JS works.

      /**
       * Social Publishing
       *
       * @method onActionPublish
       * @param record {object} Object literal representing the file or folder to be actioned
       */
      onActionPublish: function dlA_onActionPublish(record)
      {
         // Call the Social Publishing Module
         Alfresco.module.getSocialPublishingInstance().show(
         {
            nodeRef: record.nodeRef,
            filename: record.fileName
         });
      },


I really want to know how the action displays only the available channels, as shown in the attached screenshot.

aaditvmajmudar
Confirmed Champ
Confirmed Champ
Hi,

"Alfresco.module.getSocialPublishingInstance()" is the function available in the same file.

In this function, you will find code which calls the module called "Alfresco.module.socialPublishing" which is there already in the same file.

And inside this "Alfresco.module.socialPublishing" module code, you will find "show" method which is responsible to get channels and show then on popup.

Hope this hepls.

lungpow
Champ in-the-making
Champ in-the-making
Aadit your instruction was helpful. tracing through the code from the show function I think I found what I needed. In the the social-publish.get.js I found the following code. Now I need to figure out how to use this in an evaluator.


<import resource="classpath:/alfresco/templates/org/alfresco/import/alfresco-util.js">

function getDocumentChannels(nodeRef)
{
   var result = remote.call("/api/publishing/" + nodeRef.replace("://", "/") + "/channels");
   if (result.status != 200)
   {
      AlfrescoUtil.error(result.status, 'Could not load publishing channels');
   }
   return eval('(' + result + ')').data;
}

function main()
{
   AlfrescoUtil.param('nodeRef');
   channels = getDocumentChannels(model.nodeRef);
   model.urlLength = channels.urlLength;
   model.publishChannels = channels.publishChannels
   model.statusUpdateChannels = channels.statusUpdateChannels
}

main();

lungpow
Champ in-the-making
Champ in-the-making
I did figure this out. I used the the /api/publishing/" + nodeRef.replace("://", "/") + "/channels webscript in my evaluator to get the channels and determine if there was an available channel for the node/user.

example

final JSONObject node = (JSONObject) actionObject.get("node");// get node
final String nodeRef = (String) node.get("nodeRef");// get noderef of content
final RequestContext rc = ThreadLocalRequestContext.getRequestContext();// get request context
final String userId = rc.getUserId();
final Connector conn = rc.getServiceRegistry().getConnectorService().getConnector("alfresco", userId, ServletUtil.getSession());// get connector

// custom repository webscript which checks if noderef has given association or not
//final String url = "/node/association/" + contentRef.replace("://", "/") + "/" + associations.get(0).replace(":", "_");
final String url = "/api/publishing/" + nodeRef.replace("://", "/") + "/channels";
         

final Response response = conn.call(url);// get response

if (Status.STATUS_OK == response.getStatus().getCode())// make sure we are getting valid response
{
   final org.json.JSONObject scriptResponse = new org.json.JSONObject(response.getResponse());
            
   org.json.JSONObject channelData = (org.json.JSONObject) scriptResponse.get("data");
   org.json.JSONArray publishChannels = (org.json.JSONArray) channelData.get("publishChannels");
   for (int i=0; publishChannels.length()>i; i++)
   {
      org.json.JSONObject channel = (org.json.JSONObject)publishChannels.getJSONObject(i);
      org.json.JSONObject channelType = channel.getJSONObject("channelType");
           String id = channelType.getString("id");
      if (id.equalsIgnoreCase("everfresco"))
         result = true;
      break;
   }
   return result;
         }
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.