AnsweredAssumed Answered

Move content inside web project..

Question asked by naveenkumar on Oct 4, 2007
Hi all,
  For my application i need to move the content based on the expiration date, so i thought for schedular job to run based on lucene query see this link: http://forums.alfresco.com/viewtopic.php?t=7787&highlight=naveen
But i didnt make it up, Then i found CMLmove type from this forum: http://forums.alfresco.com/viewtopic.php?t=2695 Able to move the content which is available in non web project folders…

Here is the code its working fine:

ParentReference dossierDestinationParentRef = new ParentReference(); 
        dossierDestinationParentRef.setStore(STORE);        
        dossierDestinationParentRef.setPath("/app:company_home/cm:Projects/cm:DML/cm:RssIn");
              dossierDestinationParentRef.setAssociationType(Constants.ASSOC_CONTAINS);
        dossierDestinationParentRef.setChildName("News.xml");       
       
       Reference sourceRef = new Reference();
        sourceRef.setStore(STORE);
        sourceRef.setUuid("b1c87cd5-6bae-11dc-9ef6-e92956759fd1");
                /** Move */
        CMLMove deplacer = new CMLMove();
        /** destination folder : */
        deplacer.setTo(dossierDestinationParentRef);
        /** element to move */
        deplacer.setWhere(new Predicate(new Reference[]{sourceRef}, null, null));
        /** Execute command */
        CML cmlDeplacer = new CML();
        cmlDeplacer.setMove(new CMLMove[]{deplacer});
        UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cmlDeplacer);


For a content inside web project we dont have uuid property:When i try to get uuid it shows unknown,
{http://www.alfresco.org/model/system/1.0}node-uuid = UNKNOWN

I modified above code for web project:

ParentReference dossierDestinationParentRef = new ParentReference(); 
        dossierDestinationParentRef.setStore(STORE);
        dossierDestinationParentRef.setPath("/cm:www/cm:avm_webapps/cm:ROOT/cm:DmlArchive");
                    dossierDestinationParentRef.setAssociationType(Constants.ASSOC_CONTAINS);
        dossierDestinationParentRef.setChildName("News.xml");
       
       
        /** Create the ref of the element to move */
        Reference sourceRef = new Reference();
        sourceRef.setStore(STORE);
        sourceRef.setPath("/cm:www/cm:avm_webapps/cm:ROOT/cm:News.xml");
//Uuid is unknown for this content…….. So i given the path…

           /** Move */
        CMLMove deplacer = new CMLMove();
        /** destination folder : */
        deplacer.setTo(dossierDestinationParentRef);
        /** element to move */
        deplacer.setWhere(new Predicate(new Reference[]{sourceRef}, null, null));
        /** Execute command */
        CML cmlDeplacer = new CML();
        cmlDeplacer.setMove(new CMLMove[]{deplacer});
        UpdateResult[] results = WebServiceFactory.getRepositoryService().update(cmlDeplacer);

When i run my code getting an error:
Exception in thread "main" 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>Node does not exist: avm://Dml/-1;www;avm_webapps;ROOT;DmlArchive</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:517)
   at sun.reflect.GeneratedMethodAccessor725.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   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:710)
   at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
   at java.lang.Thread.run(Thread.java:595)

   {http://xml.apache.org/axis/}hostname:PC021328


   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
   at java.lang.reflect.Constructor.newInstance(Unknown Source)
   at java.lang.Class.newInstance0(Unknown Source)
   at java.lang.Class.newInstance(Unknown Source)
   at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:104)
   at org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:90)
   at org.alfresco.webservice.repository.RepositoryFault.getDeserializer(RepositoryFault.java:146)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.apache.axis.encoding.ser.BaseDeserializerFactory.getSpecialized(BaseDeserializerFactory.java:154)
   at org.apache.axis.encoding.ser.BaseDeserializerFactory.getDeserializerAs(BaseDeserializerFactory.java:84)
   at org.apache.axis.encoding.DeserializationContext.getDeserializer(DeserializationContext.java:464)
   at org.apache.axis.encoding.DeserializationContext.getDeserializerForType(DeserializationContext.java:547)
   at org.apache.axis.message.SOAPFaultDetailsBuilder.onStartChild(SOAPFaultDetailsBuilder.java:157)
   at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
   at javax.xml.parsers.SAXParser.parse(Unknown Source)
   at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
   at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
   at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
   at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
   at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
   at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
   at org.apache.axis.client.Call.invoke(Call.java:2767)
   at org.apache.axis.client.Call.invoke(Call.java:2443)
   at org.apache.axis.client.Call.invoke(Call.java:2366)
   at org.apache.axis.client.Call.invoke(Call.java:1812)
   at org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub.update(RepositoryServiceSoapBindingStub.java:986)
   at org.alfresco.sample.webservice.Query1.copy(Query1.java:211)
   at org.alfresco.sample.webservice.Query1.main(Query1.java:73)

Is that possible to move a content which is available inside the web projects??

Thanks
Naveen

Outcomes