gpt4 book ai didi

java - 使用 CMIS 连接到 Alfresco

转载 作者:搜寻专家 更新时间:2023-11-01 01:14:09 25 4
gpt4 key购买 nike

我从 Alfresco 开始。我安装了 Alfresco 4 Community Edition 并尝试使用 OpenCMIS 连接到它。我从 OpenCMIS 页面获取了这段代码:

    SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
Map<String, String> parameter = new HashMap<String, String>();
parameter.put(SessionParameter.USER, "admin");
parameter.put(SessionParameter.PASSWORD, "admin");
parameter.put(SessionParameter.ATOMPUB_URL,
"http://repo.opencmis.org/inmemory/atom/");
parameter.put(SessionParameter.BINDING_TYPE,
BindingType.ATOMPUB.value());
parameter.put(SessionParameter.REPOSITORY_ID,
"");

Session s = sessionFactory.createSession(parameter);

但是,我无法找出存储库 ID 应该是什么以及如何指定 Alfresco 的 URL。有人可以向我解释吗?谢谢。

最佳答案

tl;dr:

// User credentials.
parameters.put(SessionParameter.USER, "admin");
parameters.put(SessionParameter.PASSWORD, "admin");

// Connection settings.
parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
parameters.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/service/cmis"); // URL to your CMIS server.
parameters.put(SessionParameter.AUTH_HTTP_BASIC, "true" );
parameters.put(SessionParameter.COOKIES, "true" );

// Create session.
// Alfresco only provides one repository.
Repository repository = sessionFactory.getRepositories(parameters).get(0);
Session session = repository.createSession();

来自CMIS spec :

An application MUST use the CMIS “"Get Repositories”" service (getRepositories) to obtain a list of repositories that are available at that endpoint

存储库 ID 是由 CMIS 存储库生成的不透明字符串,您通常会发现而不是事先知道。此外,单个 CMIS 服务器可以托管多个存储库(尽管 Alfresco 暂时只支持一个)。

当涉及到 Alfresco 时,存储库 ID 在每个实例的基础上是不同的,因此如果您从一个干净的数据库重新开始,该 ID 将被重新生成,如果它依赖于硬编码的存储库 ID,则会破坏您的应用程序.

AtomPub 绑定(bind)中的服务文档和 Web 服务绑定(bind)中的 cmisRepositoryEntryType 使存储库 ID 发现成为可能。

关于java - 使用 CMIS 连接到 Alfresco,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9545319/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com