cancel
Showing results for 
Search instead for 
Did you mean: 

Facing issue with date as aspect

bindu_k
Champ in-the-making
Champ in-the-making
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
1 REPLY 1

jpotts
World-Class Innovator
World-Class Innovator
You are passing in a Date object to the testCreatedDate property. Is it actually defined as a date in the content model?

Jeff