0

我想从 alfresco 获取文件,

我使用 jboss 7 并使用这个 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.jar

我也在WEB-INF jboss-deployment-structure.xml下这个文件哈哈

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
    <ear-subdeployments-isolated>true</ear-subdeployments-isolated>
    <deployment>
        <dependencies>
            <module name="deployment.javaee.api" />
        </dependencies>
        <exclusions>
            <module name="javaee.api" />
        </exclusions>
    </deployment>
    <module name="deployment.javaee.api">
        <dependencies>
            <module name="javaee.api" export="true">
                <imports>
                    <exclude path="org/apache/xml/security/**" />
                </imports>
            </module>
        </dependencies>
    </module>
</jboss-deployment-structure>

我有这个代码:

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

这是一个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;
    }

}

但是当我测试我有这个错误:

15:26:16,334 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) org.apache.xml.security.c14n.InvalidCanonicalizerException: No message with ID "signature.Canonicalizer.UnknownCanonicalizer" found in resource bundle "org/apache/xml/security/resource/xmlsecurity"

15:26:16,338 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.xml.security.c14n.Canonicalizer.<init>(Unknown Source)

15:26:16,340 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.xml.security.c14n.Canonicalizer.getInstance(Unknown Source)

15:26:16,341 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.xml.security.utils.XMLUtils.outputDOM(Unknown Source)

15:26:16,343 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.ws.axis.security.WSDoAllSender.invoke(WSDoAllSender.java:195)

15:26:16,345 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)

15:26:16,347 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

15:26:16,348 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

15:26:16,350 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.client.AxisClient.invoke(AxisClient.java:127)

15:26:16,352 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

15:26:16,352 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.client.Call.invoke(Call.java:2767)

15:26:16,354 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.client.Call.invoke(Call.java:2443)

15:26:16,356 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.client.Call.invoke(Call.java:2366)

15:26:16,358 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.apache.axis.client.Call.invoke(Call.java:1812)

15:26:16,359 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at org.alfresco.webservice.content.ContentServiceSoapBindingStub.read(ContentServiceSoapBindingStub.java:467)

15:26:16,361 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)   at com.dq.test.web.ged.AlfrescoClientWS.getContentsById(AlfrescoClientWS.java:158)

此错误与此行有关:

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

0 回答 0