23 May

Developing a massive deletion of a large set of nodes from Alfresco

Deleting of a large set of nodes from Alfresco is not an easy task using Alfresco Share or the repository’s API. After the probe to discover if your SolR index server is working or not, in this new project Francesco Fornasari and Cristian Tiralosi have developed another interesting stand alone application written in Java, to cover an interesting feature not easily available.

The Java program is available on GitHub and it is very easy to use and customize for your needs. But let’s start form the very beginning.

How to build it by yourself

Using git, clone the project (using git clone https://github.com/fsforna/MassiveDelete) and configure the application by editing the conf.properties file. Then run mvn package and everything will be ready into your project folder.

How to customize it for your Alfresco instance

As you can see from the beginning, the conf.properties file contains all the customizations you would need to run the massive delete into your environment. In particular you can specify:

alfresco.url=http://localhost:8080/alfresco
alfresco.user=admin
alfresco.password=alfresco

If you would prefer, you can provide an external property file as you can see in the ‘how to run’ paragraph.

How to define the se of nodes to delete

The idea behind the program is quite simple: give to the program a list of nodes to delete, available in a simple text file. The requirement is that the text file will be defined with a line for each UUID.

As an example, you can create the text file executing the SQL query below over the Alfresco database. In particular the query lists all the nodes into the repository, of your requested type.

SELECT
 nodes.UUID
FROM
 alf_node nodes, alf_qname names
WHERE
 nodes.type_qname_id=names.id 
 AND names.local_name='<WRITE_TYPE_HERE>';

How to run it

To run the program you can use some few commands into the terminal.

-- using built-in configuration file
nohup /opt/alfresco/java/bin/java -cp  "MassiveDelete-1.0.jar:$(find lib/ -name "*.jar" | sed -e 's,^,:,g' | tr -d '\n')" MassiveDelete path_to_UUID_LIST_file &

-- using an external configuration file
nohup /opt/alfresco/java/bin/java -Dconf=path_to_conf_file -cp  "MassiveDelete-1.0.jar:$(find lib/ -name "*.jar" | sed -e 's,^,:,g' | tr -d '\n')" MassiveDelete path_to_UUID_LIST_file &   

If some kind of error occurs, the log will show the failed node and the reason for your interest.

Conclusion

In this post we discovered a simple Java program use to massive delete nodes into your Alfresco repository. The program aims to overcome Alfresco API limits for deleting a large set of nodes in your repository in a very simple way.

About the authors

fsforna

Francesco Fornasarialfresco-certified-engineeralfresco-certified-administrator

tiralosi

Cristian Tiralosi

alfresco-certified-engineer

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.