How to create custom action "disable download document" in alfresco

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
sandeepreddy1
Active Member II

How to create custom action "disable download document" in alfresco

Hai Everyone,

I need to create custom action "disable download document" in alfresco document actions. it means if user upload a document into alfresco, user can disable download action to the remaining users in alfresco. Can anyone help me please.

Anyone help me please... 

I attached screenshots. Please find the attachments.

19 Replies
ruudg
Active Member II

Re: How to create custom action "disable download document" in alfresco

Hi,

An idea is to use a custom aspect. When you want to disable the action, you add this aspect and with an evaluator you disable the download action.
You need to:
- Create the custom aspect
- Create 2 custom actions (Enable and Disable download) (here's a tutorial http://docs.alfresco.com/5.2/concepts/doclib-web-tier.html )
- Override the Download action and add an HasAspectEvaluator

sandeepreddy1
Active Member II

Re: How to create custom action "disable download document" in alfresco

Hai  Ruud Gianesinivb ,

Can you please explain Enable and Disable download custom actions, i need help please.

ruudg
Active Member II

Re: How to create custom action "disable download document" in alfresco

My idea is to create a custom action "Disable download" (follow the link that i posted above) that call a webscript to add your custom aspect to the node. In the same way you can create the action "Enable dowload" to remove the aspect.

You can use the webscript http://localhost:8080/alfresco/service/description/org/alfresco/slingshot/documentlibrary/action/asp... 

Than create the HasAspectEvaluator in your share context and add it to the Download action.

sandeepreddy1
Active Member II

Re: How to create custom action "disable download document" in alfresco

Hai ruudg,

I am little bit confusing for custom creation of disable download action in

alfresco, Can you please explain steps wise. i am facing issues for this

action. please help me friend

ruudg
Active Member II

Re: How to create custom action "disable download document" in alfresco

1. Create the file /config/alfresco/web-extension/custom-slingshot-share-context.xml and add this lines:
    <bean id="share.custom.config" class="org.springframework.extensions.config.ConfigBootstrap"
        init-method="register">
        <property name="configService" ref="web.config" />
        <property name="configs">
            <list>
                <value>classpath:alfresco/web-extension/doclib-share-config.xml</value>
            </list>
        </property>
    </bean>
    <bean id="evaluator.doclib.isDisableDownloadEvaluator" parent="evaluator.doclib.action.hasAspect">
        <property name="aspects">
            <list>
                <value>my:disableDownload</value>
            </list>
        </property>
    </bean>

2. Create the file /config/alfresco/web-extension/doclib-share-config.xml and add this config:

       <!-- Document Library Custom Code config section -->
       <config evaluator="string-compare" condition="DocLibCustom">
         <dependencies>
            <js src="my-custom-action.js" />
         </dependencies>
          <dependencies />
       </config>

    <config evaluator="string-compare" condition="DocLibActions">
        <actions>
            <action id="disable-download" type="javascript" label="actions.disable-download">
                <param name="function">onDisableDownload</param>
                <evaluator negate="true">evaluator.doclib.isDisableDownloadEvaluator</evaluator>
            </action>
            <action id="enable-download" type="javascript" label="actions.enable-download">
                <param name="function">onEnableDownload</param>
                <evaluator>evaluator.doclib.isDisableDownloadEvaluator</evaluator>
            </action>

             <!-- OVERRIDE ACTION Download document -->
             <action id="document-download" type="link" label="actions.document.download">
                <param name="href">{downloadUrl}</param>
                <param name="target">_blank</param>
                <evaluator>evaluator.doclib.action.downloadBrowser</evaluator>
                <evaluator>evaluator.doclib.action.hasContent</evaluator>
                <evaluator negate="true">evaluator.doclib.isDisableDownloadEvaluator</evaluator>
             </action>

        </actions>


        <actionGroups>
              <actionGroup id="document-browse">
                <action index="101" id="disable-download" />
                <action index="102" id="enable-download" />
              </actionGroup>
        </actionGroups>
    </config>

2. Create the file /web/my-custom-actions.js and add this config:

(function () {

    YAHOO.Bubbling.fire("registerAction", {
        actionName: "onDisableDownload",
        fn: function dlA_onDisableDownload(asset) {

            var url = Alfresco.constants.PROXY_URI + "slingshot/doclib/action/aspects/node/{store_type}/{store_id}/{id}";
            Alfresco.util.Ajax.jsonRequest({
                url: url,
                method: "POST",
                dataObj:
                {
                 added: ["my:disableDownload"]
                },
                successMessage: me.msg("message.success"),
                failureMessage: me.msg("message.failure")
            });
        }
    });
    YAHOO.Bubbling.fire("registerAction", {
        actionName: "onEnableDownload",
        fn: function dlA_onEnableDownload(asset) {

            var url = Alfresco.constants.PROXY_URI + "slingshot/doclib/action/aspects/node/{store_type}/{store_id}/{id}";
            Alfresco.util.Ajax.jsonRequest({
                url: url,
                method: "POST",
                dataObj:
                {
                 removed: ["my:disableDownload"]
                },
                successMessage: me.msg("message.success"),
                failureMessage: me.msg("message.failure")
            });
        }
    });

})();

PS: I've not tested the code. It's only a trace of what you've got to do.

sandeepreddy1
Active Member II

Re: How to create custom action "disable download document" in alfresco

Hai ruudg,

Thank you Friend,

I will test and come back to you friend thank you so much,

sandeepreddy1
Active Member II

Re: How to create custom action "disable download document" in alfresco

Hai Ruudg,

I tested that code, but that is not working friend. that is not taking any

action. please suggest me.

1. I created custom-slingshot-share-context.xml file with code

(\tomcat\shared\classes\alfresco\extension\scripts)

please help if i did any mistake.

help me friend.

On Mon, Mar 27, 2017 at 1:38 PM, Vemuganti Sandeepreddy <

sandeepreddy1
Active Member II

Re: How to create custom action "disable download document" in alfresco

Hai Ruudg,

I tested that code, but that is not working friend. that is not taking any

action. please suggest me.

1. Create the file

/config/alfresco/web-extension/custom-slingshot-share-context.xml and add

this lines:

2. Create the file /web/my-custom-actions.js and add this config:

(function () {

YAHOO.Bubbling.fire("registerAction", {

actionName: "onDisableDownload",

fn: function dlA_onDisableDownload(asset) {

var url = Alfresco.constants.PROXY_URI +

"slingshot/doclib/action/aspects/node/{store_type}//"; Alfresco.util.Ajax.jsonRequest(, successMessage: me.msg("message.success"), failureMessage: me.msg("message.failure") }); } }); YAHOO.Bubbling.fire("registerAction", //";

Alfresco.util.Ajax.jsonRequest(,

successMessage: me.msg("message.success"),

failureMessage: me.msg("message.failure")

});

}

});

})();

1. I created custom-slingshot-share-context.xml file with code

(\tomcat\shared\

classes\alfresco\extension\scripts)

please help if i did any mistake.

help me friend.

On Mon, Mar 27, 2017 at 3:40 PM, Vemuganti Sandeepreddy <

sandeepreddy1
Active Member II

Re: How to create custom action "disable download document" in alfresco

Hai Ruudg,
I tested that code, but that is not working friend. that is not taking any action. please suggest me.

1. Create the file /config/alfresco/web-extension/custom-slingshot-share-context.xml and add this lines:
    <bean id="share.custom.config" class="org.springframework.extensions.config.ConfigBootstrap"
        init-method="register">
        <property name="configService" ref="web.config" />
        <property name="configs">
            <list>
                <value>classpath:alfresco/web-extension/doclib-share-config.xml</value>
            </list>
        </property>
    </bean>
    <bean id="evaluator.doclib.isDisableDownloadEvaluator" parent="evaluator.doclib.action.hasAspect">
        <property name="aspects">
            <list>
                <value>my:disableDownload</value>
            </list>
        </property>
    </bean>

 

2. Create the file /config/alfresco/web-extension/doclib-share-config.xml and add this config:

       <!-- Document Library Custom Code config section -->
       <config evaluator="string-compare" condition="DocLibCustom">
         <dependencies>
            <js src="my-custom-action.js" />
         </dependencies>
          <dependencies />
       </config>

 

    <config evaluator="string-compare" condition="DocLibActions">
        <actions>
            <action id="disable-download" type="javascript" label="actions.disable-download">
                <param name="function">onDisableDownload</param>
                <evaluator negate="true">evaluator.doclib.isDisableDownloadEvaluator</evaluator>
            </action>
            <action id="enable-download" type="javascript" label="actions.enable-download">
                <param name="function">onEnableDownload</param>
                <evaluator>evaluator.doclib.isDisableDownloadEvaluator</evaluator>
            </action>

 

             <!-- OVERRIDE ACTION Download document -->
             <action id="document-download" type="link" label="actions.document.download">
                <param name="href">{downloadUrl}</param>
                <param name="target">_blank</param>
                <evaluator>evaluator.doclib.action.downloadBrowser</evaluator>
                <evaluator>evaluator.doclib.action.hasContent</evaluator>
                <evaluator negate="true">evaluator.doclib.isDisableDownloadEvaluator</evaluator>
             </action>

 

        </actions>

 


        <actionGroups>
              <actionGroup id="document-browse">
                <action index="101" id="disable-download" />
                <action index="102" id="enable-download" />
              </actionGroup>
        </actionGroups>
    </config>

 

2. Create the file /web/my-custom-actions.js and add this config:

 

(function () {

    YAHOO.Bubbling.fire("registerAction", {
        actionName: "onDisableDownload",
        fn: function dlA_onDisableDownload(asset) {

 

            var url = Alfresco.constants.PROXY_URI + "slingshot/doclib/action/aspects/node/{store_type}/{store_id}/{id}";
            Alfresco.util.Ajax.jsonRequest({
                url: url,
                method: "POST",
                dataObj:
                {
                 added: ["my:disableDownload"]
                },
                successMessage: me.msg("message.success"),
                failureMessage: me.msg("message.failure")
            });
        }
    });
    YAHOO.Bubbling.fire("registerAction", {
        actionName: "onEnableDownload",
        fn: function dlA_onEnableDownload(asset) {

 

            var url = Alfresco.constants.PROXY_URI + "slingshot/doclib/action/aspects/node/{store_type}/{store_id}/{id}";
            Alfresco.util.Ajax.jsonRequest({
                url: url,
                method: "POST",
                dataObj:
                {
                 removed: ["my:disableDownload"]
                },
                successMessage: me.msg("message.success"),
                failureMessage: me.msg("message.failure")
            });
        }
    });

 

})();

1. I created custom-slingshot-share-context.xml file with code (<alfresco>\tomcat\shared\classes\alfresco\web-extension)
2. I created  doclib-share-config.xml with code (<alfresco>\tomcat\shared\classes\alfresco\web-extension)
3. I created my-custom-actions.js file with code (<alfresco>\tomcat\shared\classes\alfresco\extension\scripts)


please help if i did any mistake.

help me friend.