0

alfresco にあるドキュメントからContentResultを取得したい :

このコードを使用して

   ContentResult contentResult = AlfrescoClientWS.getContentsById(docid,"HTTP://192.168.8.100:9080/alfresco/api",
                    GedListener.credentialUser, GedListener.credentialPwd);

私は jboss 7.1 で作業しており、この jar を使用しています:

alfresco-web-service-client-4.0.d.jar,axis-1.4.jar,axis-saaj-1.2.jar,wsdl4j-1.6.2.jar,wss4j-1.5.4-patched.jar,xmlsec-1.4. 1.瓶

しかし、テストすると、次のエラーが発生します。

17:07:40,546 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/myProject].[FileUploadServlet]] (http-localhost-127.0.0.1-8080-5) "Servlet.service()" pour la servlet FileUploadServlet a généré une exception: java.lang.NoSuchMethodError: org.apache.xml.security.transforms.Transform.init()V
    at org.apache.ws.security.WSSConfig.staticInit(WSSConfig.java:244) [wss4j-1.5.4-patched.jar:]
    at org.apache.ws.security.WSSConfig.<init>(WSSConfig.java:256) [wss4j-1.5.4-patched.jar:]
    at org.apache.ws.security.WSSConfig.getNewInstance(WSSConfig.java:265) [wss4j-1.5.4-patched.jar:]
    at org.apache.ws.security.handler.WSHandler.doSenderAction(WSHandler.java:89) [wss4j-1.5.4-patched.jar:]
    at org.apache.ws.axis.security.WSDoAllSender.invoke(WSDoAllSender.java:170) [wss4j-1.5.4-patched.jar:]
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) [axis-1.4.jar:]
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) [axis-1.4.jar:]
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) [axis-1.4.jar:]
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:127) [axis-1.4.jar:]
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784) [axis-1.4.jar:]
    at org.apache.axis.client.Call.invoke(Call.java:2767) [axis-1.4.jar:]
    at org.apache.axis.client.Call.invoke(Call.java:2443) [axis-1.4.jar:]
    at org.apache.axis.client.Call.invoke(Call.java:2366) [axis-1.4.jar:]
    at org.apache.axis.client.Call.invoke(Call.java:1812) [axis-1.4.jar:]
    at org.alfresco.webservice.content.ContentServiceSoapBindingStub.read(ContentServiceSoapBindingStub.java:467) [alfresco-web-service-client-4.0.d.jar:]
    at com.dq.urbanplanning.web.ged.AlfrescoClientWS.getContentsById(AlfrescoClientWS.java:162) [classes:]
............
.........

私はこのクラス java :AlfrescoClientWS.java を持っています

import org.alfresco.webservice.content.Content;
import org.alfresco.webservice.content.ContentFault;
import org.alfresco.webservice.content.ContentServiceSoapBindingStub;
import org.alfresco.webservice.repository.QueryResult;
import org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub;
import org.alfresco.webservice.repository.UpdateResult;
import org.alfresco.webservice.types.CML;
import org.alfresco.webservice.types.CMLAddAspect;
import org.alfresco.webservice.types.CMLCreate;
import org.alfresco.webservice.types.ContentFormat;
import org.alfresco.webservice.types.NamedValue;
import org.alfresco.webservice.types.ParentReference;
import org.alfresco.webservice.types.Predicate;
import org.alfresco.webservice.types.Query;
import org.alfresco.webservice.types.Reference;
import org.alfresco.webservice.types.ResultSet;
import org.alfresco.webservice.types.ResultSetRow;
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.Utils;
import org.alfresco.webservice.util.WebServiceFactory;

import org.apache.commons.io.IOUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import java.rmi.RemoteException;

import java.util.ArrayList;
import java.util.List;

import javax.activation.MimetypesFileTypeMap;


public class AlfrescoClientWS {

public static ContentResult getContentsById(String contentId, String cmurl, String userName, String pwd)
        throws Exception {
        ContentResult contentResult = new ContentResult();

        // Start the session
        WebServiceFactory.setEndpointAddress(cmurl);
        AuthenticationUtils.startSession(userName, pwd);

        try {
            Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
            ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();

            Reference contentReference = new Reference(storeRef, contentId, null);
            Content[] readResult = null;

            try {
                readResult = contentService.read(new Predicate(new Reference[] { contentReference }, storeRef, null), Constants.PROP_CONTENT);
            } catch (ContentFault e) {
                e.printStackTrace();
            } catch (RemoteException e) {
                e.printStackTrace();
            }

            if ((readResult != null) && (readResult[0] != null)) {
                Content content = readResult[0];
                ContentFormat cnf = content.getFormat();
                Reference ref = content.getNode();

                String[] splitedUrl = content.getUrl().split("/");
                String name = splitedUrl[splitedUrl.length - 1];

                InputStream is = ContentUtils.getContentAsInputStream(content);
                byte[] contentByte = IOUtils.toByteArray(is);

                contentResult.setName(name);
                contentResult.setMimetype(cnf.getMimetype());
                contentResult.setId(ref.getUuid());
                contentResult.setUrl(content.getUrl());
                contentResult.setPath(ref.getPath());
                contentResult.setContentByte(contentByte);
                System.out.println(" document has been retrieved");
            }
        } catch (Exception e) {
            System.out.println(e.toString());
        } finally {
            // End the session
            AuthenticationUtils.endSession();

            // System.exit(0);
        }

        return contentResult;
    }

}

エラーは次の行に関連しています:

  readResult = contentService.read(new Predicate(new Reference[] { contentReference }, storeRef, null), Constants.PROP_CONTENT);

このコードで Main クラスを使用してコードをテストします。

import org.alfresco.webservice.content.Content;
import org.alfresco.webservice.content.ContentFault;
import org.alfresco.webservice.content.ContentServiceSoapBindingStub;
import org.alfresco.webservice.repository.QueryResult;
import org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub;
import org.alfresco.webservice.repository.UpdateResult;
import org.alfresco.webservice.types.CML;
import org.alfresco.webservice.types.CMLAddAspect;
import org.alfresco.webservice.types.CMLCreate;
import org.alfresco.webservice.types.ContentFormat;
import org.alfresco.webservice.types.NamedValue;
import org.alfresco.webservice.types.ParentReference;
import org.alfresco.webservice.types.Predicate;
import org.alfresco.webservice.types.Query;
import org.alfresco.webservice.types.Reference;
import org.alfresco.webservice.types.ResultSet;
import org.alfresco.webservice.types.ResultSetRow;
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.Utils;
import org.alfresco.webservice.util.WebServiceFactory;

import org.apache.commons.io.IOUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import java.rmi.RemoteException;

import java.util.ArrayList;
import java.util.List;

import javax.activation.MimetypesFileTypeMap;


public class AlfrescoClientWS {
    public static void main(String[] args) {
        try {


            ContentResult contentResult =AlfrescoClientWS.getContentsById("85e686c6-aecd-4747-9f2e-56d8c58a3e08",
                   "HTTP://192.168.0.100:9080/alfresco/api", "admin", "12345");

            System.out.println("-- contentResult:" + contentResult.getName());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 public static ContentResult getContentsById(String contentId, String cmurl, String userName, String pwd)
        throws Exception {
        ContentResult contentResult = new ContentResult();

        // Start the session
        WebServiceFactory.setEndpointAddress(cmurl);
        AuthenticationUtils.startSession(userName, pwd);

        try {
            Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
            ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();

            Reference contentReference = new Reference(storeRef, contentId, null);
            Content[] readResult = null;

            try {
                readResult = contentService.read(new Predicate(new Reference[] { contentReference }, storeRef, null), Constants.PROP_CONTENT);
            } catch (ContentFault e) {
                e.printStackTrace();
            } catch (RemoteException e) {
                e.printStackTrace();
            }

            if ((readResult != null) && (readResult[0] != null)) {
                Content content = readResult[0];
                ContentFormat cnf = content.getFormat();
                Reference ref = content.getNode();

                String[] splitedUrl = content.getUrl().split("/");
                String name = splitedUrl[splitedUrl.length - 1];

                InputStream is = ContentUtils.getContentAsInputStream(content);
                byte[] contentByte = IOUtils.toByteArray(is);

                contentResult.setName(name);
                contentResult.setMimetype(cnf.getMimetype());
                contentResult.setId(ref.getUuid());
                contentResult.setUrl(content.getUrl());
                contentResult.setPath(ref.getPath());
                contentResult.setContentByte(contentByte);
                System.out.println(" document has been retrieved");
            }
        } catch (Exception e) {
            System.out.println(e.toString());
        } finally {
            // End the session
            AuthenticationUtils.endSession();

            // System.exit(0);
        }

        return contentResult;
    }

}

しかし、jboss を使用してコードをテストすると、問題が発生します

4

0 に答える 0