AnsweredAssumed Answered

Property 'pos:empCode' is not valid for this type or one of the secondary types! error setting custom object in cmis

Question asked by sharmaprashant239 on Mar 15, 2018

When I am adding my custom object in map, it gives me error. java.lang.IllegalArgumentException: Property 'pos:empCode' is not valid for this type or one of the secondary types! at org.apache.chemistry.opencmis.client.runtime.repository.ObjectFactoryImpl.conver tProperties(ObjectFactoryImpl.java:426) at

org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(Session Impl.java:1091) at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImp l.java:77)

My code is: Map metaData = new HashMap(0);

    metaData.put(DocumentConstants.EMPCODE, empCode); //  metaData.put(DocumentConstants.TYPE, Constants.EMP_FILE_UPLOAD); //  metaData.put(DocumentConstants.SUBTYPE, Constants.ADD);     docService.uploadDocumentsForAlfresco(metaData, byteArray, fileName);

DocService:

    public Boolean uploadDocumentsForAlfresco(Map<String, Object> metaData,      byte[] data, String name) {         Session session = connect();         String folderPath = null;         folderPath = cmisSite.concat(cmisPath).concat("documentlibrary/");        //       String path =      "DATAFILES/".concat(metaData.get(DocumentConstants.EMPCODE).toString());     String path = "DATAFILES/".concat("6");     folderPath = folderPath.concat(path);     Folder folder = createFolder(session, folderPath);  // metaData.put(PropertyIds.OBJECT_TYPE_ID, "D:ebs:bulkUploadDoc");     metaData.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");     // set the alfresco object factory      metaData.put(PropertyIds.NAME, name);     ByteArrayInputStream input = new ByteArrayInputStream(data);     ContentStream contentStream =     session.getObjectFactory().createContentStream(name, data.length,     "application/octet-stream", input);     try {             folder.createDocument(metaData, contentStream,      VersioningState.MAJOR);             return true;     } catch (Exception ex) {    //log.error("exception while uploading document",ex);         ex.printStackTrace();         return false;     }   }

added dependency in pom.xml

   <dependency>         <groupId>org.alfresco.cmis.client</groupId>         <artifactId>alfresco-opencmis-extension</artifactId>         <version>0.3</version>     </dependency>     <dependency>         <groupId>org.apache.chemistry.opencmis</groupId>         <artifactId>chemistry-opencmis-client-impl</artifactId>         <version>0.13.0</version>     </dependency>

Outcomes