谁能告诉我 Java 实用程序可以从 filenet 中的 Content Engine 下载文档到您的本地 PC?

Can anyone tell me the Java utility to download documents to your local PC from Content Engine in filenet?

大家好,我正在尝试编写 java 实用程序以将文档从 filenet 中的内容引擎下载到本地 PC 有谁能帮帮我吗?

您应该了解 FileNet P8 CE API,您可以开始 here:

您要知道,FileNet Content Engine 有两种类型的接口可以用来连接它:RMI 和SOAP。您打算编写的 cmd 行应用程序只能通过 SOAP 连接(我不确定这是否适用于最新版本,但绝对正确的是,设置 SOAP 连接比 EJB 容易得多),所以您必须阅读文档的那一部分,了解如何以这种方式与您的内容引擎建立连接。

在上面的 link 中,您可以看到首先您必须收集 SOAP 连接所需的 jar:请检查 "Required for a Content Engine Java API CEWS transport client" 部分的文件名。

收集完它们后,您将需要一个 SOAP WSDL URL 和一个正确的用户和密码,用户必须对您要下载的文档具有读取属性和读取内容的权限。您还需要知道 ObjectStore 名称和标识符或文档的位置。

现在还要继续用这个Setting Up a Thick Client Development Environmentlink(我是从上面的页面打开的。)

在这里您必须向下滚动到 "CEWS transport protocol (non-application-server dependent)" 部分。

在这里您可以看到,您必须创建一个包含以下内容的 jaas.conf 文件:

FileNetP8WSI  {
   com.filenet.api.util.WSILoginModule  required;
};

当您 运行 我们将创建 class 时,必须将此文件添加为以下 JVM 参数: java -cp %CREATE_PROPER_CLASSPATH% -Djava.security.auth.login.config=jaas.conf 下载客户端

现在,在页面的右上角,您可以看到 links,其中描述了如何获得连接,例如 "Getting Connection"、"Retrieving an EntireNetwork Object"等。我使用该片段为您创建了下面的 class。

    public class DownloadClient {

    public static void main(String[] args) throws Exception{
        String uri = "http://filenetcehost:9080/wsi/FNCEWS40MTOM";
        String userId = "ceadmin";
        String password = "password";
        String osName = "Test";
        UserContext uc = UserContext.get();

        try {

            //Get the connection and default domain
            Connection conn = Factory.Connection.getConnection(uri); 
            Domain domain = Factory.Domain.getInstance(conn, null);
            ObjectStore os = Factory.ObjectStore.fetchInstance(domain, osName, null);
            // the last value (jaas samza name) must match with the name of the login module in jaas.conf
            Subject subject =UserContext.createSubject(connection, userId, password, "FileNetP8WSI");
            // set the subject to the local thread via threadlocal
            uc.pushSubject(subject);

            // from now, we are connected to FileNet CE, and objectStore "Test"
            //https://www.ibm.com/support/knowledgecenter/en/SSNW2F_5.2.0/com.ibm.p8.ce.dev.ce.doc/document_procedures.htm
            Document doc = Factory.Document.getInstance(os, ClassNames.DOCUMENT, new Id("{F4DD983C-B845-4255-AC7A-257202B557EC}") );
            // because in FileNet a document can have more that one associated content element
            // (e.g. stores single page tifs and handle it as a multipaged document), we have to
            // get the content elements and iterate list.
            ContentElementList docContentList = doc.get_ContentElements();
            Iterator iter = docContentList.iterator();
            while (iter.hasNext() )
            {   
                ContentTransfer ct = (ContentTransfer) iter.next();
                // Print element sequence number and content type of the element.
                // Get and print the content of the element.
                InputStream stream = ct.accessContentStream();
                // now you have an inputstream to the document content, you can save it local file,
                // or you can do what you want with it, just do not forget to close the stream at the end.
                stream.close();
            }
        } finally {
            uc.popSubject(); 
        }
    }
}

这段代码只是展示了如何实现这样一个胖客户端,我现在是使用文档创建的,而不是生产代码。但是在指定要导入的包并处理异常后它可能会起作用。

当然,您必须指定权限 URL、用户、密码和 docId,并且您必须实现从 TransferInputStream 到 FileOutputStream 的复制,例如通过使用 commons.io 或 java NIO 等