Below I wrote a simple program to get all workspace-id under my custom space(Amitspace). But I am unable to navigate till my custom space. Kindly let me know that with what should I replace query string (which I marked red in color in my program) to reach up to my custom space. Please get me out of this small issue. Will be kind! —————————————————————————————– package org.alfresco.sample;
Finally got a solution here for this problem. Below I am sharing my code to navigate till my custom space Amit-2 and to get all contents from there.
——————————————————————————
public class FirstJCRClient { public static void main(String[] args) { try{ ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml"); Repository repository = (Repository)context.getBean("JCR.Repository"); SearchService searchService1=(SearchService)context.getBean("SearchService"); // login to workspace (here we rely on the default workspace defined by JCR.Repository bean) Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray())); //getting StoreRef StoreRef SR=new StoreRef("workspace://SpacesStore"); //Querying to go upto custom space ResultSet results = searchService1.query(SR, SearchService.LANGUAGE_LUCENE, "+PATH:\"/app:company_home/cm:Amitspace/cm:Amit-2/*\""); //iterating for(ResultSetRow row : results) { //getting noderef of content and space NodeRef currentNodeRef = row.getNodeRef(); System.out.println(currentNodeRef.toString()); } if(results != null) { results.close(); } session.logout(); }catch (Exception exp ){ System.out.println (" Caught exception " + exp); exp.printStackTrace(); } finally { System.exit(0); } }
} —————————————————————————————
But at same time I want to take 1 more idea from you all that is there any way to get all contents inside a space, considering the parent space consists of child space and in a single shot is there any way to get all data from both parent and child space?
Please suggest.
Thanks
Amit ————————————————————————————— [size=85]Please give appropriate rating if you find above post to be helpful[/size]