cancel
Showing results for 
Search instead for 
Did you mean: 

Move a content to a space - moveNode()

redbull
Champ in-the-making
Champ in-the-making
Hi all.
I need to move the content of one space to another space.
I tried this (from http://alfrescotips.wordpress.com/)

NodeRef target = new NodeRef(new StoreRef("workspace://SpacesStore"), target.getUUID());
this.nodeService.moveNode(source, target, ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CHILDREN);
but target.getUUID() is not correct.
any suggestion?
thanks.
13 REPLIES 13

redbull
Champ in-the-making
Champ in-the-making
No.
How can I proceed? At what level I do it? Some code snippet would help me.
Thanks!

billerby
Champ on-the-rise
Champ on-the-rise
You have to declare SearchService in you spring bean configuration file (the xml-file, ending -context.xml)

Like this:


   <bean id="format" class="my.company.alfresco.action.MyActionExecuter"
      parent="action-executer">
      <property name="searchService">
         <ref bean="SearchService" />
      </property>
      <property name="nodeService">
         <ref bean="NodeService"></ref>
      </property>
   </bean>

When you start Alfresco the SearchService will be injected into you class via the setSearchService that you should have declared in your ActionExecuter.

redbull
Champ in-the-making
Champ in-the-making
Erik, after your suggest the SearchService is now injected!
Which is the correct syntax of the "query string" parameter if my target node name is selectedDocs according to the following path:
- Company Home
….WorkingSpaces
….selectedDocs  <——
….deletedDocs
     

results = searchService.query(workspaceStore, SearchService.LANGUAGE_XPATH, ?????????????);

I found some samples for the root ("/app:company_home") but not for the spaces leaves.
thank you very much!

redbull
Champ in-the-making
Champ in-the-making
I solved!
I use Search Service with the LUCENE query language:

results = searchService.query(workspaceStore, SearchService.LANGUAGE_LUCENE, "+PATH:\"/app:company_home/cm:selectedDocs\"");

Thanks.