Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
6 replies Latest Post - ‏2012-05-31T21:30:14Z by SystemAdmin
XQNX_clayton_bernardo
6 Posts
ACCEPTED ANSWER

Pinned topic error to store a documento on Content Manager

‏2012-03-05T17:46:14Z |
why do I'm getting the following error whem I try to store a document?

org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: CQL119: Cannot create Item with name teste.txt under Repository Root with name cmRoot and ID -3_cmRootv-1 because the target location is not a library or folder within a library. The root can contain only library groups, and library groups can contain only libraries. Choose the new item relative to a library or folder within a library.
at org.apache.chemistry.opencmis.client.bindings.spi.webservices.AbstractWebServicesService.convertException(AbstractWebServicesService.java:115)
at org.apache.chemistry.opencmis.client.bindings.spi.webservices.ObjectServiceImpl.createDocument(ObjectServiceImpl.java:86)
at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(SessionImpl.java:650)
at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:88)
at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:443)
at org.apache.chemistry.opencmis.doc.conn.createTestArea(conn.java:169)
at org.apache.chemistry.opencmis.doc.conn.getCmisClientSession(conn.java:108)
at org.apache.chemistry.opencmis.doc.conn.main(conn.java:249)
I'm using http://chemistry.apache.org/java/examples/example-create-update.html
Updated on 2012-05-31T21:30:14Z at 2012-05-31T21:30:14Z by SystemAdmin
  • TigerTrix
    TigerTrix
    38 Posts
    ACCEPTED ANSWER

    Re: error to store a documento on Content Manager

    ‏2012-03-05T19:27:46Z  in response to XQNX_clayton_bernardo
    You are getting this error for the reason explained in the error returned, CQL119. You are probably creating a document or folder directly in CMIS root, which by default is a virtual mounting mechanism. So the first 2 levels by default are restricted and created only by configuration and administration tools, like LibraryGroupCreate and LibraryCreate. If you go down 2 levels to a library (which mounts a real folder), then you can start creating folders and documents. If you must be able to create documents and folders directly in CMIS root, you can reconfigure CMIS root to point to any other folder in the system, such as picking one library to become the CMIS root instead of having CMIS root show all library groups and then all libraries.

    There is more information in the documentation for configuration setting "cmisRoot" for cmpathservice.properties.

    See: http://publib.boulder.ibm.com/infocenter/cmgmt/v8r4m0/index.jsp?topic=%2Fcom.ibm.installingcmcmis.doc%2Fcmscf001.htm
    • XQNX_clayton_bernardo
      6 Posts
      ACCEPTED ANSWER

      Re: error to store a documento on Content Manager

      ‏2012-03-06T14:43:41Z  in response to TigerTrix
      ok, I would like to store a document in my item type on content manager 8.4 not in a folder in server's filesystem, how do I configure this in my code or cmis configuration?
      • TigerTrix
        TigerTrix
        38 Posts
        ACCEPTED ANSWER

        Re: error to store a documento on Content Manager

        ‏2012-03-06T18:17:42Z  in response to XQNX_clayton_bernardo
        CMIS has an unfiled collection. All you have to do is post to it rather than a folder to create it as unfiled versus in a folder or root. It should definitely work. But how you post to it will depend on the API you are using. I can confirm it is possible via the raw CMIS spec and API. Check for unfiled support in the API you are using.

        There are some item types in IBM Content Manager that do not support unfiled, which are item types designated as "hierarchical", a new constraint in CM V8.4.3 or later.

        There is another trick to post an unfiled doc if you cannot directly use the CMIS unfiled collection such as if you use an API that doesn't support unfiled. CM's implementation of CMIS virtually files all unfiled documents in a virtual folder that is named for the item type. This is a hidden folder, but you usually see it if you start navigating up from an unfiled doc you find by query or retrieved by ID. It also varies depending on your cmisRoot= configuration. By default, it appears in 3 levels of hierarchy -- /ALLITEMTYPES_APP/ALLITEMTYPES_LIB/itemTypeShortName. But if you configure cmisRoot any differently, then it appears as /$type/itemTypeShortName. The later case might always work with /$type as well. Posting to the virtual item type folder will allow you to create an instance with a doc type that is the same as that item type. But note that name-only paths will not work from these folders because it is not sufficiently unique, so it will come back with an ID embedded in the path before the file extension.

        But you should use the official unfiled collection if at all possible. Only use the workaround if you must. It is an API trick, not a real API, but it exists for situations such as this.
  • SystemAdmin
    SystemAdmin
    76 Posts
    ACCEPTED ANSWER

    Re: error to store a documento on Content Manager

    ‏2012-05-31T16:38:20Z  in response to XQNX_clayton_bernardo
    Is there any sample code in Java API to show how to POST a document to an unfiled collection? I am having trouble to figure how to get the object ID of the URL of unfiled collection. Here is my code. Note that "/xxxx/xxxx/Unfiled" is the URL to the unfiled collection. I am not sure if it is the right way to get the object ID and tie it to the document.

    File file = new File("C:\\hello.pdf");
    Map<String, String> properties = new HashMap<String, String>();
    properties.put(PropertyIds.NAME, file.getName());
    properties.put(PropertyIds.CHECKIN_COMMENT, "");
    properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
    ContentStream contentStream = new ContentStreamImpl(file.getName(), BigInteger.valueOf(file.length()),
    new MimetypesFileTypeMap().getContentType(file), new FileInputStream(file));
    session.createDocument(properties, session.createObjectId("/xxxx/xxxx/Unfiled"),
    contentStream, VersioningState.MAJOR);
    • Dave Sanders
      Dave Sanders
      19 Posts
      ACCEPTED ANSWER

      Re: error to store a documento on Content Manager

      ‏2012-05-31T17:59:48Z  in response to SystemAdmin
      OpenCMIS client 0.7.0 supports creating an unfiled document by specifying null for session.createDocument's folderId parameter.

      A similar question was recently asked in the Chemistry forum [1].

      [1] http://mail-archives.apache.org/mod_mbox/chemistry-dev/201205.mbox/%3C1ab2c96b9d839a30194d98c0d3df776a-EhVcXl9JQQFXRwQFDQkEXR0wfgZLV15fQUBFBEFYXS9ZUF0WWlloB11LX15YLkQBXFJdRltVXQs%3D-webmailer2%40server05.webmailer.hosteurope.de%3E
      • SystemAdmin
        SystemAdmin
        76 Posts
        ACCEPTED ANSWER

        Re: error to store a documento on Content Manager

        ‏2012-05-31T21:30:14Z  in response to Dave Sanders
        Thanks for the reply. Now, I am able to create (POST) documents in the Unfiled Collection. However, they don't show up when I try to find them with the Collection Service’s URL. But I was able to bring them back using the query service and their object ids.