cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco 5.0 CMIS call property with java

mperk
Champ in-the-making
Champ in-the-making
I am using alfresco 5.0.b community. I use my custom type, custom aspect, custom property. Please help me
I always this exception:

Exception in thread "main" java.lang.IllegalArgumentException: Property 'P:kb:Aciklama' is not valid for this type!
   at org.apache.chemistry.opencmis.client.runtime.repository.ObjectFactoryImpl.convertProperties(ObjectFactoryImpl.java:318)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createFolder(SessionImpl.java:703)
   at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createFolder(FolderImpl.java:129)
   at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createFolder(FolderImpl.java:453)
   at com.alfresco.cmis.my.Main.main(Main.java:47)


Main method:

      Map<String, String> parameter = new HashMap<String, String>();

      parameter.put(SessionParameter.USER, "admin");
      parameter.put(SessionParameter.PASSWORD, "admin");

      parameter.put(SessionParameter.ATOMPUB_URL, "http://192.168.22.100:8090/alfresco/api/-default-/public/cmis/versions/1.0/atom");
      parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());

      parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");

      SessionFactory factory = SessionFactoryImpl.newInstance();
      Session session = factory.getRepositories(parameter).get(0).createSession();
      
      Map<String, Object> properties = new HashMap<String, Object>();
      properties.put(PropertyIds.NAME, "My folder");
      properties.put(PropertyIds.OBJECT_TYPE_ID, "F:kb:irhDosya");
      properties.put("P:kb:Aciklama", "My description");
      
      Folder folder = session.getRootFolder().createFolder(properties);

      System.out.println("Başarılı");


Also I attachment the AlfrescoObjectFactoryImpl
1 REPLY 1

mperk
Champ in-the-making
Champ in-the-making
I fix it. My solution:
CMIS 1.0 is not support aspect. Therefore I use CMIS 1.1 and this my code:


      Map<String, String> parameter = new HashMap<String, String>();

      parameter.put(SessionParameter.USER, "admin");
      parameter.put(SessionParameter.PASSWORD, "admin");
      parameter.put(SessionParameter.ATOMPUB_URL, "http://192.168.22.100:8090/alfresco/api/-default-/public/cmis/versions/1.0/atom");
      parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
      parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
      SessionFactory factory = SessionFactoryImpl.newInstance();
      Session session = factory.getRepositories(parameter).get(0).createSession();
      Map<String, Object> properties = new HashMap<String, Object>();
      Map<String, Object> updProps = new HashMap<String, Object>();
      
      properties.put(PropertyIds.NAME, "My folder");
      properties.put(PropertyIds.OBJECT_TYPE_ID, "F:kb:irhDosya");
      updProps.put("P:kb:Aciklama", "My description");
      Folder folder = session.getRootFolder().createFolder(properties);
      folder.updateProperties(updProps);
      System.out.println("Başarılı");