Giter VIP home page Giter VIP logo

trashcancleaner's Introduction

trashcancleaner

Alfresco trashcancleaner using canned queries for purging a large number of nodes from the bin.

Building the module:

mkdir work
cd work
git clone https://github.com/pdubois/trashcancleaner.git
cd trashcancleaner/alfrescotrashcancleaner2
mvn install
chmod +x run.sh

Outcome:

The module "alfrescotrashcancleaner2.amp" is generqted under "target" folder.

Module options:

You need to adjust to your needs the following options in you alfresco-global.properties depending on how long you want to keep the documents in the bin and how often the thrahcancleaner will run.

trashcan.cleaner.pagelen indicates the maximum number of nodes purged during each iteration/transaction.

trashcan.cleaner.protected.day=7
trashcan.cleaner.cron=0 0 4 * * ?
trashcan.cleaner.pagelen=3

Protecting types from deletion

It is possible to protect some types from automatic deletion by the trashcancleaner by overriding trashcanCleaner bean definition under shared/classes/alfresco/extention in a *-context.xml file.

Example:

	<bean id="trashcanCleaner" class="org.alfresco.trashcan.cleaner.TrashcanCleaner">
		<property name="nodeService">
			<ref bean="nodeService" />
		</property>
		<property name="transactionService">
			<ref bean="TransactionService" />
		</property>
		<property name="protectedDays">
			<value>${trashcan.cleaner.protected.day}</value>
		</property>
		<property name="dictionaryService">
			<ref bean="DictionaryService" />
		</property>
		<property name="jobLockService">
            <ref bean="jobLockService" />
        </property>
        <property name="searchService">
            <ref bean="searchService" />
        </property>
		<property name="pageLen" value="${trashcan.cleaner.pagelen}" />
		<!-- Set of type that must be protected from deletetion -->
		<!-- results in a setAddressSet(java.util.Set) call -->
		<property name="setToProtect">
			<set>
			    <!-- Example: QName of type to protect -->
				<!-- value>{http://www.alfresco.org/model/site/1.0}site</value -->
				<!-- THIS TYPE MUSE ALWAYS BE PROTECTED: {http://www.alfresco.org/model/system/1.0}archiveUser -->
				<value>{http://www.alfresco.org/model/system/1.0}archiveUser</value>
			</set>
		</property>
		<property name="nodesToSkip">
            <value>${trashcan.cleaner.nodestoskip}</value>
        </property>
        <property name="cleanerMaxRunningTime">
            <value>${trashcan.cleaner.cleanermaxrunningtime}</value>
        </property>
	</bean>

Protecting some specific nodes against deletion

It is possible to protect some specific nodes against deletion by the trashcancleaner specifying a value for trashcan.cleaner.nodestoskip in alfresco-global.properties. The value is a comma separated list of nodeRef to protect.

Example:

trashcan.cleaner.nodestoskip=archive://SpacesStore/86936ddc-176c-4233-b5d0-647889e4bc15,archive://SpacesStore/e177ebcf-02f9-43d7-b9d7-a3118f1818e0

Limiting duration of execution

Execution time of the cleaner can be configured specifying trashcan.cleaner.cleanermaxrunningtimein alfresco-global.properties. Time is specified in miliseconds. Next time cron expression will trigger, execution will resume.

Example:

trashcan.cleaner.cleanermaxrunningtime=14400000

Control webscripts are available to disable, enable trashcan clean at will

Example:

 curl -v http://localhost:8080/alfresco/service/api/login?u=admin&pw=<your pw>
 curl -v http://127.0.0.1:8080/alfresco/s/trashcan/disable?alf_ticket=TICKET_0f96c193bd3f088c87cb5bbbcd663e55a373f0b9
 curl -v http://127.0.0.1:8080/alfresco/s/trashcan/enable?alf_ticket=TICKET_0f96c193bd3f088c87cb5bbbcd663e55a373f0b9

Note: disable might take a bit of time depending how fast query retrieving elements to get rid of performs. You need to use ticket returned while executing first line in the example above.

Example of properties that must be defined in alfresco-global.properties

trashcan.cleaner.cleanermaxrunningtime=14400000
trashcan.cleaner.cron=0/30 * * * * ?
trashcan.cleaner.protected.day=1
trashcan.cleaner.pagelen=100

Gotcha:

When installing the module with the Module Management Tool (MMT) spcify the "-force" option or remove manually "slf4j-api-1.7.5.jar" from the module.

trashcancleaner's People

Contributors

pdubois avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.