cancel
Showing results for 
Search instead for 
Did you mean: 

Add IMAP aspect to a document

chicco0386
Champ on-the-rise
Champ on-the-rise
I all,
I try to work with the Ws API and now I create a content, but I look like to add the IMAP aspect to this content.
My code look like this:
public static void createContent(Reference reference, File file) throws IOException {
      byte[] contentToWrite = FileUtils.readFileToByteArray(file);
      String contentName = file.getName();
      ParentReference parentReference2 = new ParentReference(reference.getStore(), null, reference.getPath(), Constants.ASSOC_CONTAINS, Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, contentName));

      // Create content
      NamedValue[] properties2 = new NamedValue[] { Utils.createNamedValue(Constants.PROP_NAME, contentName) };
      CMLCreate create2 = new CMLCreate("1", parentReference2, null, null, null, Constants.TYPE_CONTENT, properties2);
      CMLAddAspect addAspect = new CMLAddAspect("{http://www.alfresco.org/model/content/1.0}emailed", null, null, null);
      log.info(addAspect.getAspect());
      CML cml2 = new CML();
      cml2.setCreate(new CMLCreate[] { create2 });
                cml2.setAddAspect(new CMLAddAspect[]{addAspect});
      UpdateResult[] results2 = WebServiceFactory.getRepositoryService().update(cml2);

      // Set content
      ContentFormat format = new ContentFormat(Constants.MIMETYPE_TEXT_PLAIN, "UTF-8");
      byte[] content = "This is some test content provided by the Alfresco development team!".getBytes();
      WebServiceFactory.getContentService().write(results2[0].getDestination(), Constants.PROP_CONTENT, content, format);
      log.info("createContent, contenuto creato correttamente con nome [" + contentName + "]");
   }

If I run it without the CMLAddAspect it's work fine, so it create the content, naturally without the Email aspect.
When I run the entire code (also with CMLAddAspect) I've a null pointer when I call the update command.
2010-08-24 15:02:24,123 INFO  [it.mytria.soa.esb.test.utils.RepositoryUtils] {http://www.alfresco.org/model/content/1.0}emailed
2010-08-24 15:02:24,232 ERROR [STDERR] AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString:
faultActor:
faultNode:
faultDetail:
   {http://www.alfresco.org/ws/service/repository/1.0}RepositoryFault:<ns1:errorCode>0</ns1:errorCode><ns1:message>java.lang.NullPointerException</ns1:message>
   {http://xml.apache.org/axis/}exceptionName:org.alfresco.repo.webservice.repository.RepositoryFault
   {http://xml.apache.org/axis/}stackTrace:
   at org.alfresco.repo.webservice.repository.RepositoryWebService.update(RepositoryWebService.java:335)
   at sun.reflect.GeneratedMethodAccessor1508.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
   at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
   at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
   at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
   at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
   at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
   at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Thread.java:619)

   {http://xml.apache.org/axis/}hostname:triadt007
2010-08-24 15:02:24,248 ERROR [STDERR]    at sun.reflect.GeneratedConstructorAccessor591.newInstance(Unknown Source)
2010-08-24 15:02:24,248 ERROR [STDERR]    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
2010-08-24 15:02:24,248 ERROR [STDERR]    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
2010-08-24 15:02:24,248 ERROR [STDERR]    at java.lang.Class.newInstance0(Class.java:355)
2010-08-24 15:02:24,248 ERROR [STDERR]    at java.lang.Class.newInstance(Class.java:308)
2010-08-24 15:02:24,248 ERROR [STDERR]    at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:104)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:90)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.alfresco.webservice.repository.RepositoryFault.getDeserializer(RepositoryFault.java:146)
2010-08-24 15:02:24,263 ERROR [STDERR]    at sun.reflect.GeneratedMethodAccessor1534.invoke(Unknown Source)
2010-08-24 15:02:24,263 ERROR [STDERR]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2010-08-24 15:02:24,263 ERROR [STDERR]    at java.lang.reflect.Method.invoke(Method.java:597)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.axis.encoding.ser.BaseDeserializerFactory.getSpecialized(BaseDeserializerFactory.java:154)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.axis.encoding.ser.BaseDeserializerFactory.getDeserializerAs(BaseDeserializerFactory.java:84)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.axis.encoding.DeserializationContext.getDeserializer(DeserializationContext.java:464)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.axis.encoding.DeserializationContext.getDeserializerForType(DeserializationContext.java:547)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.axis.message.SOAPFaultDetailsBuilder.onStartChild(SOAPFaultDetailsBuilder.java:157)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
2010-08-24 15:02:24,263 ERROR [STDERR]    at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
2010-08-24 15:02:24,263 ERROR [STDERR]    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.apache.axis.client.Call.invoke(Call.java:2767)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.apache.axis.client.Call.invoke(Call.java:2443)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.apache.axis.client.Call.invoke(Call.java:2366)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.apache.axis.client.Call.invoke(Call.java:1812)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub.update(RepositoryServiceSoapBindingStub.java:986)
2010-08-24 15:02:24,279 ERROR [STDERR]    at it.mytria.soa.esb.test.utils.RepositoryUtils.createContent(RepositoryUtils.java:144)
2010-08-24 15:02:24,279 ERROR [STDERR]    at it.mytria.soa.esb.test.action.GetStoreAction.process(GetStoreAction.java:64)
2010-08-24 15:02:24,279 ERROR [STDERR]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2010-08-24 15:02:24,279 ERROR [STDERR]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2010-08-24 15:02:24,279 ERROR [STDERR]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2010-08-24 15:02:24,279 ERROR [STDERR]    at java.lang.reflect.Method.invoke(Method.java:597)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.jboss.soa.esb.listeners.message.ActionProcessorMethodInfo.processMethods(ActionProcessorMethodInfo.java:102)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.jboss.soa.esb.listeners.message.OverriddenActionLifecycleProcessor.process(OverriddenActionLifecycleProcessor.java:74)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:520)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:392)
2010-08-24 15:02:24,279 ERROR [STDERR]    at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:538)
2010-08-24 15:02:24,279 ERROR [STDERR]    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
2010-08-24 15:02:24,279 ERROR [STDERR]    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
2010-08-24 15:02:24,279 ERROR [STDERR]    at java.lang.Thread.run(Thread.java:619)

Can you help me please?
I look also the CMLUpdate example but it seams to be the same of my.

THANK YOU
1 REPLY 1

chicco0386
Champ on-the-rise
Champ on-the-rise
I've solved…
I miss the where or where-id during the CMLAddAspect creation…
Now the code look like this:
NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, System.currentTimeMillis() + "_WebServiceSample4.txt")};
            CMLCreate create = new CMLCreate("id1", parentReference, null, null, null, Constants.TYPE_CONTENT, properties);       
            CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_VERSIONABLE, null, null, "id1");

How you can see I insert the same id of the creation (id1), now I must to populate this aspect.

THANK YOU