Skip navigation
All Places > Alfresco Content Services (ECM) > Blog > Author: sakshik

Disable Download on a File

Posted by sakshik Apr 4, 2018

Problem: You don't want to disable download for all the files. You want to have a control over disabling download action on particular files in alfresco.

Solution: Use aspects. We will conditionalize disabling download action on an aspect and then apply that aspect to the file for which we want to disable download.



Here are the steps:

First: Disable the top right corner Download button

Step 1) Stop alfresco server

Step 2) Create an XML file called hide-download-pdf.xml under


         <id>Hide Download Buttons</id>


Step 3) Create a file node-header.get.js with the following under 


<import resource="classpath:/alfresco/templates/org/alfresco/import/alfresco-util.js">
var nodeDetails = AlfrescoUtil.getNodeDetails(model.nodeRef,, null, model.libraryRoot);
var count =["cm:autoVersion"];

if (count != undefined)
model.showDownload = "false";

Step 4) Restart alfresco server.

Go to a file in Alfresco -> Click Manage Aspects from the details options -> add cm:versionable aspect -> Hit Apply changes. You will see that the Download button will disappear


Second: Disable the Download action from browse options:


Step 1) Stop alfresco server

Step 2) To create a custom evaluator for an aspect, create an XML file custom-action-context.xml under
<ALF HOME>/tomcat/shared/classes/alfresco/web-extension folder.


<?xml version="1.0" encoding="UTF-8"?>
<bean id="custom.evaluator.doclib.hasversionable" class="org.alfresco.web.evaluator.HasAspectEvaluator">
<property name="aspects">



Step 3) Add the following to share-config-custom.xml under

<config evaluator="string-compare" condition="DocLibActions">
<action id="document-download" type="link" label="">
<param name="href">{downloadUrl}</param>
<evaluator negate=true>custom.evaluator.doclib.hasversionable</evaluator >

Step 4) Restart alfresco server.

Go to a file in Alfresco -> Click Manage Aspects from the details options -> add cm:versionable aspect -> Hit Apply changes. You will see that the Download action from browse menu disappeared


Rename a folder/File

Posted by sakshik Mar 31, 2018

Web script to rename a folder or a file in alfresco:

Arguments to script: alfresco ID(dir) and New name(rename_to) of the folder/file

Create 3 files in Data Dictionary/Web Scripts/

  • changeName.get.desc.xml 


<?xml version="1.0" encoding="UTF-8"?>
   <description>Rename folder or file</description>

  •  changeName.get.html



  • changeName.get.js

var docNodeId = args.dir;
var newName = args.rename_to
function main()
   if((docNodeId != "") && (docNodeId != null))
      var docNode = search.findNode("workspace://SpacesStore/"+docNodeId); = newName
      status.setCode(404,"File name missing in the call");

Refresh Web scripts.

Usage : https://<domain name>/alfresco/s/changename?dir=2e36b38b-0af9-4973-a7a4-e01869b0722c&rename_to=test 

Steps to add a custom button/link in Document Actions and Folder Actions on Document and Folder Level:


Step 1: Create a directory scripts in ...\tomcat\shared\classes\alfresco\extension\

Step 2 :

cd into ...\tomcat\shared\classes\alfresco\extension\scripts

Create a file publishDoc.js


document.copy(DestNode) - [write script according to your requirement]


Step 3:

Registering action

Create a context file custom-action-services-context.xml in \tomcat\shared\classes\alfresco\extension\ with the following code :


<?xml version='1.0' encoding='UTF-8'?>
   <bean id="publish-doc-action" parent="script">
      <property name="scriptLocation">
      <bean class="org.alfresco.repo.jscript.ClasspathScriptLocation">


Step 4:

Calling action

Add the following code to tomcat\shared\classes\alfresco\web-extension\share-config-custom.xml:

<config evaluator="string-compare" condition="DocLibActions">

Action definitions
<!– Publish Document –>
   <action id="publish-doc" icon="ic-publish" type="javascript" label="Publish">
      <param name="function">onActionSimpleRepoAction</param>
      <param name="action">publish-doc-action</param>
      <param name="successMessage">Successfully Published</param>
      <param name="failureMessage">failed</param>


<!-- For action button to show up at document level -->
   <actionGroup id="document-browse">
      <action index="460" id="publish-doc"/>
   <actionGroup id="document-details">
      <action index="400" id="publish-doc"/>

<!-- For action button to show up at Folder level -->

   <actionGroup id="folder-browse">
      <action index="460" id="publish-doc"/>
   <actionGroup id="folder-details">   
      <action index="400" id="publish-doc"/>


Step 5: Add icon image named ic-publish-16.png in tomcat\webapps\share\components\documentlibrary\actions\


Restart Alfresco server


You will be able to see a button in document Action and in Folder Action:

Alfresco SDK Setup on Eclipse

  1.      Install Maven:
  •    Add the path of bin folder of the created directory apache-maven-3.5.0 to the PATH environment variable

Confirm with mvn –v after entering bin directory.


  1.      Create Maven project:
  •    Open eclipse

   Make sure your internet connection doesn't have a firewall enabled 

  •  Go to Windows – Open Perspective – Java
  •  File – New –Project – Maven Project – Leave everything as default - Click Next – Click on Configure button – Add Remote catalog –

Catalog File:

          Description: Alfresco Public

  •     Click OK
  •     On the ‘New Maven Project’ dialog, select All catalog in the drop down
  • Type org.alfresco.maven in the filter: select allinone – Click Next

Group Id:

Artifact Id: ws4js-repo

  •    Click on Finish
  1.         If an error comes saying plugin execution not covered by life cycle configuration.

Right click on error – Quick fix – select permanently mark goal run in pom.xml as ignored in Eclipse build 

  1. 4. Right click on project – Select Maven- Update project
  2.      Create custom Run Configuration for Maven project:
  • On the Eclipse toolbar select 'Run', and then 'Run Configurations’ – This will open the 'Run Configurations' dialog box.
  • Select the Maven Build

"Maven Integration Test REPO" and edit the Base directory to point to your project. Make sure it

Matches the following:

Base directory: ${workspace_loc:/ws4js-repo}

In Goal: clean install –DskipTests=true alfresco:run


Note: If an error comes saying: no compiler is provided in this environment perhaps you are running on a jre instead of jdk

Go to Windows – Preferences – Java – Installed JREs

Change the path from jre to jdk click OK

Then Run the same way.

It will take some time


  1.     Check browser : localhost:8080/share


Login: admin

Password: admin

Filter Blog

By date: By tag: