cancel
Showing results for 
Search instead for 
Did you mean: 

Node service

aznk
Champ in-the-making
Champ in-the-making
Hi,

I'm just trying to perform a query on nodes to get its properties. I looked at the sdk web service samples, and tried with this code :

public class Tag extends SamplesBase
{
   static FacesContext context = FacesContext.getCurrentInstance();
   static NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();

   //static NodeService nodeService;
   static StoreRef storeRef;
   
    public static void main(String[] args)
        throws Exception
    {
        // Start the session
        AuthenticationUtils.startSession(USERNAME, PASSWORD);
       
        try
        {       
            // Make sure smaple data has been created
            createSampleData();
           
            NodeRef nodeRef = nodeService.getRootNode(storeRef);
           
            NodeRef categoryRef = (NodeRef)nodeService.getProperty(nodeRef, QName.createQName("{extension.tags}", "tags"));
        }
        finally
        {
            // End the session
            AuthenticationUtils.endSession();
        }
    }

but I can't make it work, I guess because I can't initialize NodeService, in this case I get this exception :
java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException
   at org.springframework.web.jsf.FacesContextUtils.getWebApplicationContext(FacesContextUtils.java:47)
   at org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:77)
   at org.alfresco.web.bean.repository.Repository.getServiceRegistry(Repository.java:404)
   at org.alfresco.sample.webservice.Tag.<clinit>(Tag.java:61)
Exception in thread "main"

Any help is much appreciated.
2 REPLIES 2

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

I think you may have got a little confused here as you are mixing Java API code with web service calls.

If you want to access node information via the web service API you should be using the RepositoryWebService, not the node service directly (the node service is part of our native Java API).

Cheers,
Roy

aznk
Champ in-the-making
Champ in-the-making
Hi Roy,
Thanks for your answer.
Someone advised me to create a component generator that performs my query (get property values of an aspect).
Could you give me some guidelines ? I am a bit confused about all this…