AnsweredAssumed Answered

Uploading custom object type to repository with CMIS

Question asked by loshmeey on Mar 26, 2013
Latest reply on Mar 27, 2013 by loshmeey
Hello everyone,

i have a little problem,  which is a bit basic i guess, but i just cant find a solution!

I am trying to upload a file into alfresco repository trough my java application. For this purposes i am using apache.chemistry libraries 0.8 version. I have also extended my content model with the following lines:

<blockcode>


     
        <type name="my:request">
         <title>Request</title>
         <parent>cm:content</parent>
         <properties>
            <property name="my:firstField">
               <type>d:text</type>
            </property>
            <property name="my:id">
               <type>d:text</type>   
            </property>
            <property name="my:soruceId">
               <type>d:text</type>
            </property>
         </properties>
      </type>   
    


</blockcode>

and Java code that i am using to upload the file is:



ContentStream cs = session.getObjectFactory().createContentStream("testUploadFile", x.length(), "text/xml", bais);
      
      Map<String,Object> folderProps = new HashMap<String, Object>();
      folderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,my:request");
      folderProps.put(PropertyIds.NAME, "testApload");
      folderProps.put("my:firstField", "testAplodFile");
      folderProps.put("my:id", "testAplodFile");
      folderProps.put("my:sourceId", "testAplodFile");
      
      
      org.apache.chemistry.opencmis.client.api.Document doc2 = parrent.createDocument(folderProps, cs, VersioningState.MAJOR);
      



And the exception that i am getting is:


org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Bad Request
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:423)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.read(AbstractAtomPubService.java:554)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.getTypeDefinitionInternal(AbstractAtomPubService.java:821)
   at org.apache.chemistry.opencmis.client.bindings.spi.atompub.RepositoryServiceImpl.getTypeDefinition(RepositoryServiceImpl.java:88)
   at org.apache.chemistry.opencmis.client.bindings.impl.RepositoryServiceImpl.getTypeDefinition(RepositoryServiceImpl.java:137)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.getTypeDefinition(SessionImpl.java:518)
   at org.apache.chemistry.opencmis.client.runtime.repository.ObjectFactoryImpl.convertProperties(ObjectFactoryImpl.java:294)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(SessionImpl.java:726)
   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 Connector.upload(Connector.java:186)
   at TestMain.main(TestMain.java:68)



And i am puzzled a little bit. I have tried different combinations of object type id, and both ways to connect to alfresco (/alfresco/service/cmis and /alfresco/cmisatom) and they both fail.

Has anyone got any idea how to solve this problem?

Thanks in advance
Milos D.

Outcomes