尝试访问我的Alfresco存储库时出现CmisObjectNotFoundException

编程入门 行业动态 更新时间:2024-10-25 18:36:41
本文介绍了尝试访问我的Alfresco存储库时出现CmisObjectNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是CMIS和Alfresco的新手,在尝试使用AtomPUB绑定连接到我的Alfresco存储库时遇到此错误。我不知道我的问题的根源。除非是功能吗?这是我的凭证吗? 当我安装它时,我只选择: - Alfresco社区 - Solr4

I'm new with CMIS and Alfresco and I got this error when in try to connect to my Alfresco's repository using AtomPUB binding. I have no idea about the source of my problem. Is it unless a functionality ? Is it my Credential ? When I install it, I choose only : - Alfresco community - Solr4

如果我想使用我该怎么办?网页服务 ?我应该在Alfresco中安装特定的插件吗?

How should I do if I want to use web services ? Should I install a specific plugin in my Alfresco ?

我收到错误:

SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/C:/Users/ME%2ME/.m2/repository/org/slf4j/slf4j-simple/1.7.9/slf4j-simple-1.7.9.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/C:/Users/ME%2ME/.m2/repository/ch/qos/logback/logback-classic/1.1.3/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See www.slf4j/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory] Exception in thread "main" org.apache.chemistry.opencmismons.exceptions.CmisObjectNotFoundException: Introuvable at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:499) at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.read(AbstractAtomPubService.java:701) at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.getRepositoriesInternal(AbstractAtomPubService.java:873) at org.apache.chemistry.opencmis.client.bindings.spi.atompub.RepositoryServiceImpl.getRepositoryInfos(RepositoryServiceImpl.java:66) at org.apache.chemistry.opencmis.client.bindings.impl.RepositoryServiceImpl.getRepositoryInfos(RepositoryServiceImpl.java:92) at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.getRepositories(SessionFactoryImpl.java:120) at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.getRepositories(SessionFactoryImpl.java:107) at fr.omb.TestOMB.connect(TestOMB.java:160) at fr.omb.TestOMB.main(TestOMB.java:35)

我的代码:

package fr.omb; import java.io.ByteArrayInputStream; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.apache.chemistry.opencmis.client.api.CmisObject; import org.apache.chemistry.opencmis.client.api.Document; import org.apache.chemistry.opencmis.client.api.Folder; import org.apache.chemistry.opencmis.client.api.Repository; import org.apache.chemistry.opencmis.client.api.Session; import org.apache.chemistry.opencmis.client.api.SessionFactory; import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl; import org.apache.chemistry.opencmismons.PropertyIds; import org.apache.chemistry.opencmismons.SessionParameter; import org.apache.chemistry.opencmismons.data.ContentStream; import org.apache.chemistry.opencmismons.enums.BaseTypeId; import org.apache.chemistry.opencmismons.enums.BindingType; import org.apache.chemistry.opencmismons.enums.UnfileObject; import org.apache.chemistry.opencmismons.enums.VersioningState; import org.apache.chemistry.opencmismons.exceptions.CmisObjectNotFoundException; import org.apachemons.lang3.StringUtils; public class TestOMB { private static Session session; private static final String ALFRSCO_ATOMPUB_URL = "localhost:8080/alfresco/service/cmis"; private static final String TEST_FOLDER_NAME = "chemistryTestFolder"; private static final String TEST_DOCUMENT_NAME_1 = "chemistryTest1.txt"; private static final String TEST_DOCUMENT_NAME_2 = "chemistryTest2.txt"; public static void main(String[] args) { Folder root = connect(); cleanup(root, TEST_FOLDER_NAME); Folder newFolder = createFolder(root, TEST_FOLDER_NAME); createDocument(newFolder, TEST_DOCUMENT_NAME_1); createDocument(newFolder, TEST_DOCUMENT_NAME_2); System.out.println("+++ List Folder +++"); listFolder(0, newFolder); DeleteDocument(newFolder, "/" + TEST_DOCUMENT_NAME_2); System.out.println("+++ List Folder +++"); listFolder(0, newFolder); } /** * Clean up test folder before executing test * * @param target * @param delFolderName */ private static void cleanup(Folder target, String delFolderName) { try { CmisObject object = session.getObjectByPath(target.getPath() + delFolderName); Folder delFolder = (Folder) object; delFolder.deleteTree(true, UnfileObject.DELETE, true); } catch (CmisObjectNotFoundException e) { System.err.println("No need to clean up."); } } /** * * @param target */ private static void listFolder(int depth, Folder target) { String indent = StringUtils.repeat("\t", depth); for (Iterator<CmisObject> it = target.getChildren().iterator(); it.hasNext();) { CmisObject o = it.next(); if (BaseTypeId.CMIS_DOCUMENT.equals(o.getBaseTypeId())) { System.out.println(indent + "[Docment] " + o.getName()); } else if (BaseTypeId.CMIS_FOLDER.equals(o.getBaseTypeId())) { System.out.println(indent + "[Folder] " + o.getName()); listFolder(++depth, (Folder) o); } } } /** * Delete test document * * @param target * @param delDocName */ private static void DeleteDocument(Folder target, String delDocName) { try { CmisObject object = session.getObjectByPath(target.getPath() + delDocName); Document delDoc = (Document) object; delDoc.delete(true); } catch (CmisObjectNotFoundException e) { System.err.println("Document is not found: " + delDocName); } } /** * Create test document with content * * @param target * @param newDocName */ private static void createDocument(Folder target, String newDocName) { Map<String, String> props = new HashMap<String, String>(); props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document"); props.put(PropertyIds.NAME, newDocName); System.out.println("This is a test document: " + newDocName); String content = "aegif Mind Share Leader Generating New Paradigms by aegif corporation."; byte[] buf = null; try { buf = content.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } ByteArrayInputStream input = new ByteArrayInputStream(buf); ContentStream contentStream = session.getObjectFactory().createContentStream(newDocName, buf.length, "text/plain; charset=UTF-8", input); target.createDocument(props, contentStream, VersioningState.MAJOR); } /** * Create test folder directly under target folder * * @param target * @param createFolderName * @return newly created folder */ private static Folder createFolder(Folder target, String newFolderName) { Map<String, String> props = new HashMap<String, String>(); props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); props.put(PropertyIds.NAME, newFolderName); Folder newFolder = target.createFolder(props); return newFolder; } /** * Connect to alfresco repository * * @return root folder object */ private static Folder connect() { SessionFactory sessionFactory = SessionFactoryImpl.newInstance(); Map<String, String> parameters = new HashMap<String, String>(); // User credentials. parameters.put(SessionParameter.USER, "myuser"); parameters.put(SessionParameter.PASSWORD, "mypassword"); // Connection settings. parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); parameters.put(SessionParameter.ATOMPUB_URL, ALFRSCO_ATOMPUB_URL); parameters.put(SessionParameter.AUTH_HTTP_BASIC, "true"); parameters.put(SessionParameter.COOKIES, "true"); parameters.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl"); // Create session. // Alfresco only provides one repository. Repository repository = sessionFactory.getRepositories(parameters).get(0); Session session = repository.createSession(); return session.getRootFolder(); } }

推荐答案

我找到了解决方案,这是因为Alfresco的版本。自V4.x以来,AtomPUB的网址是 http:// localhost:8080 / alfresco / cmisatom 。

I found the solution, it's because of Alfresco's version. Since the V4.x the url of the AtomPUB is localhost:8080/alfresco/cmisatom.

https:// community.alfresco/docs/DOC-5527-cmis

  • 对于Alfresco 3.x: http:// [host]:[port] / alfresco / service / cmis
  • 对于Alfresco 4.0.x,Alfresco 4.1.x和Alfresco 4.2.ac: http:// [主持人]:[端口] / alfresco / cmisatom
  • 对于Alfresco 4.2.df,Alfresco 5.0和Alfresco 5.1: http:// [host]:[port] / alfresco / api /-default-/public/cmis/versions/1.0/atom
  • For Alfresco 3.x : [host]:[port]/alfresco/service/cmis
  • For Alfresco 4.0.x, Alfresco 4.1.x and Alfresco 4.2.a-c: [host]:[port]/alfresco/cmisatom
  • For Alfresco 4.2.d-f, Alfresco 5.0 and Alfresco 5.1: [host]:[port]/alfresco/api/-default-/public/cmis/versions/1.0/atom

更多推荐

尝试访问我的Alfresco存储库时出现CmisObjectNotFoundException

本文发布于:2023-11-28 10:22:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642013.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Alfresco   CmisObjectNotFoundException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!