Alfresco使用Web服务永久删除节点

时间:2014-07-25 12:18:09

标签: alfresco

我正在尝试使用Web服务永久删除Alfresco(CE,v.2.1)中的节点(不先将其移至垃圾箱)。

我的用例是这样的:创建一个独立的作业,用于查询存储库以查找超过2年的文件,并使用Web服务永久删除它们。然后清理作业将删除的文件移动到content.deleted,我可以安全删除。

以下是我的代码

import org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub;
import org.alfresco.webservice.types.CML;
import org.alfresco.webservice.types.CMLAddAspect;
import org.alfresco.webservice.types.CMLDelete;
import org.alfresco.webservice.types.Node;
import org.alfresco.webservice.types.Predicate;
import org.alfresco.webservice.types.Reference;
import org.alfresco.webservice.types.Store;
import org.alfresco.webservice.util.AuthenticationUtils;
import org.alfresco.webservice.util.Constants;
import org.alfresco.webservice.util.ContentUtils;
import org.alfresco.webservice.util.WebServiceFactory;

public class NodeDeletionService {

    protected static final Store STORE = new Store(Constants.WORKSPACE_STORE,
            "SpacesStore");

    public static void main(String[] args) {

        try {

            AuthenticationUtils.startSession("admin", "admin");

            RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory
                    .getRepositoryService();

            Reference reference = new Reference(STORE,
                    "8abb6223-11bb-11e4-a335-65e3a9c8626a", null);
            Predicate predicate = new Predicate(new Reference[] { reference },
                    null, null);
            Node[] nodes = repositoryService.get(predicate);

            CMLDelete delete = new CMLDelete(predicate);

            CML cml = new CML();

            cml.setDelete(new CMLDelete[] { delete });

            CMLAddAspect addAspect = new CMLAddAspect("temporary", null, predicate, null);

            cml.setAddAspect(new CMLAddAspect[]{addAspect});

            // Execute the CMLDelete statement

            try {
                WebServiceFactory.getRepositoryService().update(cml);
                System.out.println("Deleted succesfully");
            } catch (Exception e2) {
                System.err.println("Can not delete the space.");
                throw e2;
            }

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            AuthenticationUtils.endSession();
        }
    }
}

但我得到了一个例外

{http://www.alfresco.org/ws/service/repository/1.0}RepositoryFault:<ns1:errorCode>0</ns1:errorCode><ns1:message>org.alfresco.service.cmr.dictionary.InvalidAspectException: The aspect is invalid: {}temporary</ns1:message> {http://xml.apache.org/axis/}exceptionName:org.alfresco.repo.webservice.repository.RepositoryFault

我尝试过不同的方面,例如temporarycm:temporarysys:temporary - 但都是徒劳的。有什么想法吗?

0 个答案:

没有答案