AnsweredAssumed Answered

Facing issue with date as aspect

Question asked by bindu_k on Jun 10, 2016
Latest reply on Jun 13, 2016 by jpotts
HI
I'm new to alfresco.
i was checking some examples and trying.
Im trying to create document through java code using open cmis createDocument method.

properties.put(PropertyIds.OBJECT_TYPE_ID,
                  "D:test:TestDoc,P:test:createdDate,P:test:createdBy");
      
      properties.put(PropertyIds.NAME, name);
      properties.put("test:userid", 23);
      properties.put("test:userName", "EmpDoc");
      properties.put("test:createdDate", new Date());
      properties.put("test:createdBy", "test1");
      Document Doc = null;
      // content
      try {
         File f = new File("G:\\Hello.pdf");
         InputStream stream = new FileInputStream(f);
         // byte[] content = contentString.getBytes();
         // InputStream stream = new ByteArrayInputStream(content);
         ContentStream contentStream = new ContentStreamImpl(name,
               BigInteger.valueOf(f.length()), mimeType, stream);
         Doc = parentFolder.createDocument(properties, contentStream,
               VersioningState.MAJOR);
      }
         
In the above code createdDate and createdBy are aspects.
for createdDate im getting the below error

java.lang.IllegalArgumentException: Invalid aspect value!
   at org.alfresco.cmis.client.impl.AlfrescoUtils.convertAspectPropertyValue(AlfrescoUtils.java:244)
   at org.alfresco.cmis.client.impl.AlfrescoUtils.createAspectPropertyExtension(AlfrescoUtils.java:216)
   at org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl.convertProperties(AlfrescoObjectFactoryImpl.java:230)
   at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(SessionImpl.java:751)
   at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:95)
   at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:469)
   at com.tcs.abs.webscripts.UploadContent.createContent(UploadContent.java:185)
   at com.tcs.abs.webscripts.UploadContent.main(UploadContent.java:56)
   
   
If i comment createdDateit is working properly and also if i give createdDate as normal property(not as an aspect) then also it is working fine.
Please help me how to fix this

Outcomes