cancel
Showing results for 
Search instead for 
Did you mean: 

How to install trash clean in alfresco community 4.2

MrNico
Star Contributor
Star Contributor

Hello, I need you to tell me how to install this https://github.com/rjmfernandes/alfresco-trashcan-cleaner on my alfresco 4.2.
Unfortunately I have no idea how to do that. I hope they can give me some help.
Thanks!

10 REPLIES 10

abhinavmishra14
World-Class Innovator
World-Class Innovator

Clone the project and build it. It should result in an amp file. Check this : https://github.com/rjmfernandes/alfresco-trashcan-cleaner/blob/master/pom.xml#L9

git clone https://github.com/rjmfernandes/alfresco-trashcan-cleaner.git

cd alfresco-trashcan-cleaner

mvn clean install

You need to install that amp to alfresco.war file. Check this doc on how to install the amps (unfortunately docs are not available for your specific version but 5.2 docs should be relevant) : https://docs.alfresco.com/content-services/5.2/develop/extension-packaging/#using-the-module-managem...

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

Thanks for your answer, but my level is very basic to compile what you indicate. What is mvn? Will it be possible to do a step by step on how to install this module?

abhinavmishra14
World-Class Innovator
World-Class Innovator

mvn is maven command line. You may go through this or any tutorial (just google) to learn basics of maven: https://www.tutorialspoint.com/maven/index.htm 

What i outlined above are the basic steps. Let me try to add it point by point if that helps. These are very basic steps that needs to be performed to get the extension applied to your repository.

1- Clone the repository on your machine

git clone https://github.com/rjmfernandes/alfresco-trashcan-cleaner.git

 2- Once cloned, go to the alfresco-trashcan-cleaner folder/directory:

cd alfresco-trashcan-cleaner

3- Execute maven command to build, package and install the project as an amp. Amp stands for "alfresco module package". It is a way to apply any customizations on alfresco.war or share.war as required. You can learn in detail about amps here: https://docs.alfresco.com/content-services/latest/develop/extension-packaging/

mvn clean install

4- Once command is succesful, install the amp on alfresco.war file:

java -jar <yourAlfrescoInstallation>/bin/alfresco-mmt-2.1.0.jar install <yourlocalworkspace>/alfresco-trashcan-cleaner/target/alfresco-trashcan-cleaner-2.1-SNAPSHOT.amp <yourAlfrescoInstallation>/tomcat/webapps/alfresco.war 

If maven is not available on your server/machine, install it and update the path so that you can execute the above given maven command. You can see this tutorial on how to install maven as needed: https://www.baeldung.com/install-maven-on-windows-linux-mac

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

Thanks for the help, but i have this error

[root@palfresco alfresco-trashcan-cleaner]# mvn clean install
[INFO] Scanning for projects...
Downloading from alfresco-private-repository: https://artifacts.alfresco.com/nexus/content/groups/private/org/alfresco/maven/alfresco-sdk-parent/1...
Downloading from central: https://repo.maven.apache.org/maven2/org/alfresco/maven/alfresco-sdk-parent/1.1.1/alfresco-sdk-paren...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for org.alfresco:alfresco-trashcan-cleaner:2.1-SNAPSHOT: Could not transfer artifact org.alfresco.maven:alfresco-sdk-parentSmiley Tongueom:1.1.1 from/to alfresco-private-repository (https://artifacts.alfresco.com/nexus/content/groups/private😞 Not authorized , ReasonPhrase:Unauthorized. and 'parent.relativePath' points at wrong local POM @ line 12, column 13
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project org.alfresco:alfresco-trashcan-cleaner:2.1-SNAPSHOT (/root/tmp_maven/alfresco-trashcan-cleaner/pom.xml) has 1 error
[ERROR] Non-resolvable parent POM for org.alfresco:alfresco-trashcan-cleaner:2.1-SNAPSHOT: Could not transfer artifact org.alfresco.maven:alfresco-sdk-parentSmiley Tongueom:1.1.1 from/to alfresco-private-repository (https://artifacts.alfresco.com/nexus/content/groups/private😞 Not authorized , ReasonPhrase:Unauthorized. and 'parent.relativePath' points at wrong local POM @ line 12, column 13 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
[root@palfresco alfresco-trashcan-cleaner]#

abhinavmishra14
World-Class Innovator
World-Class Innovator

@MrNico check the comments in the pom file here: https://github.com/rjmfernandes/alfresco-trashcan-cleaner/blob/master/pom.xml#L85

Comment out this:

<repository>
            <id>alfresco-private-repository</id>
            <url>https://artifacts.alfresco.com/nexus/content/groups/private</url>
</repository>

and uncomment:

       <repository>
            <id>alfresco-public</id>
            <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
        </repository>
        <repository>
            <id>alfresco-public-snapshots</id>
            <url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
        </repository>

Then, try maven command again (mvn clean install).

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

MrNico
Star Contributor
Star Contributor

after reviewing the pom.xml file I have managed to make it connect to the "community" repository but even though it downloads many files, it finally gives the following error

Downloaded from clojars.org: http://clojars.org/repo/org/clojars/pmonks/bookmark-writer/0.1.0/bookmark-writer-0.1.0.jar (110 kB at 18 kB/s)
Downloaded from clojars.org: http://clojars.org/repo/org/clojars/pmonks/spinner/0.2.0/spinner-0.2.0.jar (12 kB at 1.9 kB/s)
Downloading from alfresco-public: https://artifacts.alfresco.com/nexus/content/groups/public/org/alfresco/alfresco-platform-distributi...
Downloading from alfresco-public-snapshots: https://artifacts.alfresco.com/nexus/content/groups/public-snapshots/org/alfresco/alfresco-platform-...
Downloading from central: https://repo.maven.apache.org/maven2/org/alfresco/alfresco-platform-distribution/4.2.0/alfresco-plat...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Non-resolvable import POM: Could not find artifact org.alfresco:alfresco-platform-distributionSmiley Tongueom:4.2.0 in alfresco-public (https://artifacts.alfresco.com/nexus/content/groups/public) @ line 50, column 25
[ERROR] 'dependencies.dependency.version' for org.alfresco:alfresco-repository:jar is missing. @ line 63, column 21
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project org.alfresco:alfresco-trashcan-cleaner:2.1-SNAPSHOT (/root/tmp_maven/alfresco-trashcan-cleaner/pom.xml) has 2 errors
[ERROR] Non-resolvable import POM: Could not find artifact org.alfresco:alfresco-platform-distributionSmiley Tongueom:4.2.0 in alfresco-public (https://artifacts.alfresco.com/nexus/content/groups/public) @ line 50, column 25 -> [Help 2]
[ERROR] 'dependencies.dependency.version' for org.alfresco:alfresco-repository:jar is missing. @ line 63, column 21
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

abhinavmishra14
World-Class Innovator
World-Class Innovator

It seems that the add-on is using enterperise version number by default. You have to update the pom file to use community version:

https://github.com/rjmfernandes/alfresco-trashcan-cleaner/blob/master/pom.xml#L27

https://github.com/rjmfernandes/alfresco-trashcan-cleaner/blob/master/pom.xml#L37

Change below properties to use version "4.2.f" instead of "4.2.0" in the pom file and try maven command again.

<alfresco.version>4.2.f</alfresco.version>
<alfresco.client.war.version>4.2.f</alfresco.client.war.version>

It may still not work for you, when i tried i got the below error:

 Could not resolve dependencies for project org.alfresco:alfresco-trashcan-cleaner:amp:2.1-SNAPSHOT: The following artifacts could not be resolved: org.springframework.extensions.surf:spring-surf-core-configservice:jar:1.2.0-M14, org.springframework.extensions.surf:spring-webscripts:jar:1.2.0-M14, org.springframework.extensions.surf:spring-webscripts-api:jar:1.2.0-M14, org.springframework.social:spring-social-facebook:jar:1.0.0.RC1: Could not find artifact org.springframework.extensions.surf:spring-surf-core-configservice:jar:1.2.0-M14 in central (https://repo1.maven.org/maven2/) -> [Help 1]

Seems these jars are no longer available in the repository here: https://artifacts.alfresco.com/nexus/content/repositories/public/org/springframework/extensions/surf or https://artifacts.alfresco.com/nexus/content/groups/public/org/springframework/extensions/surf

I had to additionally add the below dependencies with a version that's available:

<dependency>
	<groupId>org.springframework.extensions.surf</groupId>
	<artifactId>spring-surf-core-configservice</artifactId>
	<version>1.2.0-M17</version>
	<scope>provided</scope>
</dependency>
<dependency>
	<groupId>org.springframework.social</groupId>
	<artifactId>spring-social-facebook</artifactId>
	<version>1.0.0.RELEASE</version>
</dependency>
<dependency>
	<groupId>org.springframework.extensions.surf</groupId>
	<artifactId>spring-webscripts-api</artifactId>
	<version>1.2.0-M17</version>
</dependency>
<dependency>
	<groupId>org.springframework.extensions.surf</groupId>
	<artifactId>spring-webscripts</artifactId>
	<version>1.2.0-M17</version>
</dependency>

Here is full pom example which works:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.alfresco</groupId>
    <artifactId>alfresco-trashcan-cleaner</artifactId>
    <version>2.1-SNAPSHOT</version>
    <name>alfresco-trashcan-cleaner AMP project</name>
    <packaging>amp</packaging>
    <description>Manages the lifecycle of the alfresco-trashcan-cleaner AMP (Alfresco Module Package)</description>

    <parent>
        <groupId>org.alfresco.maven</groupId>
        <artifactId>alfresco-sdk-parent</artifactId>
        <version>1.1.1</version>
    </parent>

    <!-- 
       | SDK properties have sensible defaults in the SDK parent,
       | but you can override the properties below to use another version. 
       | For more available properties see the alfresco-sdk-parent POM. 
       -->
    <properties>
        <!-- Defines the alfresco edition to compile against. Allowed values are [org.alfresco|org.alfresco.enterprise]--> 
        <alfresco.groupId>org.alfresco</alfresco.groupId>
        <!-- Defines the alfresco version to compile against -->
        <alfresco.version>4.2.f</alfresco.version>
        <app.log.root.level>WARN</app.log.root.level>
        <alfresco.data.location>alf_data_dev</alfresco.data.location>
        <!-- Defines the target WAR artifactId to run this amp, only used with the -Pamp-to-war switch
        .    | Allowed values: alfresco | share. Defaults to a repository AMP, but could point to your foundation WAR -->
        <alfresco.client.war>alfresco</alfresco.client.war>
        <!-- Defines the target WAR groupId to run this amp, only used with the -Pamp-to-war switch
        .    | Could be org.alfresco | org.alfresco.enterprise or your corporate groupId -->
        <alfresco.client.war.groupId>org.alfresco</alfresco.client.war.groupId>
        <!-- Defines the target WAR version to run this amp, only used with the -Pamp-to-war switch -->
        <alfresco.client.war.version>4.2.f</alfresco.client.war.version>
        <!-- This controls which properties will be picked in src/test/properties for embedded run -->
        <env>local</env>
    </properties>

    <!-- Here we realize the connection with the Alfresco selected platform 
        (e.g.version and edition) -->
    <dependencyManagement>
        <dependencies>
            <!-- This will import the dependencyManagement for all artifacts in the selected Alfresco version/edition
                (see http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies) 
                NOTE: You still need to define dependencies in your POM, but you can omit version as it's enforced by this dependencyManagement. NOTE: It defaults 
                to the latest version this SDK pom has been tested with, but alfresco version can/should be overridden in your project's pom -->
            <dependency>
                <groupId>${alfresco.groupId}</groupId>
                <artifactId>alfresco-platform-distribution</artifactId>
                <version>${alfresco.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <!-- Following dependencies are needed for compiling Java code in src/main/java; 
         <scope>provided</scope> is inherited for each of the following; 
         for more info, please refer to alfresco-platform-distribution POM -->
    <dependencies>
        <dependency>
            <groupId>${alfresco.groupId}</groupId>
            <artifactId>alfresco-repository</artifactId>
        </dependency>
		<dependency>
			<groupId>org.springframework.extensions.surf</groupId>
			<artifactId>spring-surf-core-configservice</artifactId>
			<version>1.2.0-M17</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.social</groupId>
			<artifactId>spring-social-facebook</artifactId>
			<version>1.0.0.RELEASE</version>
<scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.extensions.surf</groupId> <artifactId>spring-webscripts-api</artifactId> <version>1.2.0-M17</version>
<scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.extensions.surf</groupId> <artifactId>spring-webscripts</artifactId> <version>1.2.0-M17</version>
<scope>provided</scope> </dependency>
<!-- Test dependencies --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.1</version> <scope>test</scope> </dependency> </dependencies> <!-- This repository is only needed to retrieve Alfresco parent POM. NOTE: This can be removed when/if Alfresco will be on Maven Central NOTE: The repository to be used for Alfresco Enterprise artifacts is https://artifacts.alfresco.com/nexus/content/groups/private/. Please check with Alfresco Support to get credentials to add to your ~/.m2/settings.xml if you are a Enterprise customer or Partner --> <repositories> <!-- Community Settings --> <repository> <id>alfresco-public</id> <url>https://artifacts.alfresco.com/nexus/content/groups/public</url> </repository> <repository> <id>alfresco-public-snapshots</id> <url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url> </repository> <!-- <repository> <id>alfresco-private-repository</id> <url>https://artifacts.alfresco.com/nexus/content/groups/private</url> </repository>--> </repositories> </project>

If you are still having issues building this project, you can download the amp from here that i generated from this project and apply it to alfresco.war : https://github.com/abhinavmishra14/alfresco-4.2-trashcan-cleaner/blob/master/dist/alfresco-trashcan-...

Alternatively, you can also down this jar file directly and just copy it to "tomcat/webapps/alfresco/Web-INF/lib", if above option still doesn't work :

https://artifacts.alfresco.com/nexus/service/local/repositories/releases/content/org/alfresco/alfres...

The above jar is built from this project : https://github.com/Alfresco/alfresco-trashcan-cleaner-module

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

I appreciate the effort, but I give up already, I tried to use the amp file you sent me, but it gives error when I restart alfresco. Also try uploading the "jar" file and it also gives an error

2021-11-25 10:33:01,222 ERROR [web.context.ContextLoader] [localhost-startStop-1] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'trashcanCleaner' defined in class path resource [alfresco
/module/alfresco-trashcan-cleaner-amp/context/service-context.xml]: Invocation of init method failed; nested exception is java.text.ParseException
: Unexpected character: $
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:142
0)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:63)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.text.ParseException: Unexpected character: $
at org.quartz.CronExpression.storeExpressionVals(CronExpression.java:642)
at org.quartz.CronExpression.buildExpression(CronExpression.java:430)
at org.quartz.CronExpression.<init>(CronExpression.java:255)
at org.quartz.CronTrigger.setCronExpression(CronTrigger.java:471)
at org.quartz.CronTrigger.<init>(CronTrigger.java:302)
at org.alfresco.util.CronTriggerBean.getTrigger(CronTriggerBean.java:76)
at org.alfresco.util.AbstractTriggerBean.afterPropertiesSet(AbstractTriggerBean.java:119)
at org.alfresco.util.CronTriggerBean.afterPropertiesSet(CronTriggerBean.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:
1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:141
7)
... 27 more

PS: why complicate something that should be so easy = (

abhinavmishra14
World-Class Innovator
World-Class Innovator

Did you configure these in global properties file before restarting ?

trashcan.cron=0 30 * * * ?

trashcan.daysToKeep=1

trashcan.deleteBatchCount=1000

https://github.com/rjmfernandes/alfresco-trashcan-cleaner#readme

~Abhinav
(ACSCE, AWS SAA, Azure Admin)