cancel
Showing results for 
Search instead for 
Did you mean: 

Web Services API

mikool74321
Champ in-the-making
Champ in-the-making
Hi, I am trying to utilize the web service api to access the alfresco repository. Alfresco and the WCM extension work great, however; I am having problems with the web service samples for Java.

Here is my sample scenario:
1.  In Data Dictionary, created a new space (Create Space) called "Articles".
2.  Under "Articles", I added two text files as content (Add Content)

I want to be able to use the web services client api to query the "Articles" node and have it list its children. Using the web services client samples, I tried a few things but could not get it to work.

In the example below, the only path that I could get to return something was ""/app:company_home".  All other paths throw exceptions.

public class TestQuery extends SamplesBase {
   
    public void test()
    {
        List<ContentResult> results = new ArrayList<ContentResult>();
       
        String spaceName = "";
       
        try
        {
            AuthenticationUtils.startSession(USERNAME, PASSWORD);
            try
            {           
                RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();      
               
                // Get a reference to the space we have named
               
                String path = "/app:company_home/*[@cm:name=\"" + spaceName + "\"]";
                String path2 = "/app:company_home/*[@cm:name=\"SpacesStore\"]";
                String path3 = "/app:company_home";
                String path4 = "/app:company_home/*";
             
                Reference reference = new Reference(STORE, null, path4);
                //Reference reference = new Reference(STORE, null, );
                Predicate predicate = new Predicate(new Reference[]{reference}, null, null);       
                Node[] nodes = repositoryService.get(predicate);
                …
}


I then decided to try to use a Query instead.  The constructor of the Query object is languageSmiley Frustratedtring, statementSmiley Frustratedtring.  What should the language string be?  This is not clear, but I think I want it to be XPATH, but there is nothing in Constants such as Constants.QUERY_LANG_XPATH.   Also, if I do get past the language parameter, what would the XPATH actually be?  I cannot figure out what the schema of the structure is.  For example, would it be "//app:company_home/cm:data_dictionary/*[@name="Articles]/*"   I cannot find what the actual schema the nodes are stored under.
4 REPLIES 4

zaizi
Champ in-the-making
Champ in-the-making
Data dictionary is a system folder. XPATH for it is /app:company_home/app:dictionary. So your files will be under /app:company_home/app:dictionary/cm:articles.

By the way, why are you creating spaces within the Data dictionary?

prateekgoyal
Champ in-the-making
Champ in-the-making
Hello All,

I have similar problem,i want to get the refrence of space within Data Dictionary for e.g (Models).
The XPath for accessing is  "/app:company_home/app:dictionary/cm:Models" but it is not returning it.
Is their any other way of accessing the folders withn Data Dictionary ?

Thanks,

mrogers
Star Contributor
Star Contributor
This is the correct XPATH for my instance of alfesco.

/app:company_home/app:dictionary/app:models

I suggest you use the node browser built into Alfresco Explorer to investigate and double check your queries.

prateekgoyal
Champ in-the-making
Champ in-the-making
Hi,
Thanks for the reply, it worked for me.
Also can you tell me how to check for the XPATH using node browser or create an XPATH for any other node, like i am creating an XPATH for "web client extension" node in Data Dictionary as "/app:company_home/app:dictionary/app:web client extension", but it giving an exception

"org.alfresco.service.cmr.repository.XPathException: 06070008 Error executing xpath:
   xpath: /app:company_home/app:dictionary/app:web client extension"

Thanks,