开发者

How to delete the versions for particular space/ document

开发者 https://www.devze.com 2023-02-15 06:26 出处:网络
I had applied the document version at the top level space.. and i copied the 6 documents to the space & edited randomly & it is created the versions.. I want to delete the all the previous ver

I had applied the document version at the top level space.. and i copied the 6 documents to the space & edited randomly & it is created the versions.. I want to delete the all the previous versions in the space.. how can i achieve this one..

This is no开发者_运维技巧t a mad question, This is one of my client requirement...

Please give any suggestions to achieve this...

Thanks Murali


I guess as simple as this:

import java.util.List;

import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.version.VersionService;

public class DeleteVersionHistoryActionExecuter extends ActionExecuterAbstractBase{

    private VersionService versionService;

    @Override
    protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
        versionService.deleteVersionHistory(actionedUponNodeRef);

    }

    @Override
    protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
        // TODO Auto-generated method stub

    }

    public void setVersionService(VersionService versionService) {
        this.versionService = versionService;
    }
}

And define the ActionExecuter in a *.context.xml file

<?xml version='1.0' encoding='UTF-8'?>

<bean name="deleteVersionHistoryAction" class="com.your.package.DeleteVersionHistoryActionExecuter" parent="action-executer">
    <property name="versionService" ref="versionService" />
</bean>

Now restart your Alfresco, you can now use your ActionExecter. With the runas functionality, or defining a rule on a folder, where the action gets triggerd.


The VersionService provides both deleteVersion and deleteVersionHistory. There's currently no way to access such methods via Javascript, so you need to code some Java. I'd suggest you to write a custom Java Action that calls such methods.

0

精彩评论

暂无评论...
验证码 换一张
取 消