cancel
Showing results for 
Search instead for 
Did you mean: 

getID CompanyHome NodeRef by GET

geyson_santana
Champ in-the-making
Champ in-the-making
Hello,

I want GetId of company_home nodeRef, but, i get this error:

{
    "status" :
  {
    "code" : 500,
    "name" : "Internal Error",
    "description" : "An error inside the HTTP server which prevented it from fulfilling the request."
  }, 
 
  "message" : "08250012 Wrapped Exception (with status template): No NodeLocator is registered with name: company_home", 
  "exception" : "org.springframework.extensions.webscripts.WebScriptException - 08250012 Wrapped Exception (with status template): No NodeLocator is registered with name: company_home",
 
  "callstack" :
  [
       ""      ,"java.lang.IllegalArgumentException: No NodeLocator is registered with name: company_home"
      ,"org.alfresco.repo.nodelocator.NodeLocatorServiceImpl.getNode(NodeLocatorServiceImpl.java:56)"
      ,"org.alfresco.repo.web.scripts.nodelocator.NodeLocatorGet.executeImpl(NodeLocatorGet.java:75)"
      ,"org.springframework.extensions.webscripts.DeclarativeWebScript.executeImpl(DeclarativeWebScript.java:235)"
      ,"org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:64)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:426)"
      ,"org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:433)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:495)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:533)"
      ,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:349)"
      ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:377)"
      ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)"
      ,"org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)"
      ,"javax.servlet.http.HttpServlet.service(HttpServlet.java:722)"
      ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)"
      ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)"
      ,"org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)"
      ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)"
      ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)"
      ,"org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)"
      ,"org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)"
      ,"org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)"
      ,"org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)"
      ,"org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)"
      ,"org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)"
      ,"org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)"
      ,"org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)"
      ,"org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)"
      ,"org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)"
      ,"org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1813)"
      ,"java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)"
      ,"java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)"
      ,"java.lang.Thread.run(Thread.java:722)"
      ,"org.springframework.extensions.webscripts.WebScriptException: 08250012 Wrapped Exception (with status template): No NodeLocator is registered with name: company_home"
      ,"org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1067)"

  ],
 
  "server" : "Community v4.2.0 (4576) schema 6,022",
  "time" : "Sep 25, 2013 12:10:44 PM"
}

java.lang.NullPointerException


My Code is:

private String obterCompanyHome(String authTicket) throws IOException {
            String urlString = "http://127.0.0.1:8080/alfresco/service/api/nodelocator/company_home?alf_ticket=" + authTicket;

            HttpClient client = new HttpClient();
            GetMethod mGet = new GetMethod(urlString);

            int status = client.executeMethod(mGet);
            System.out.println("client.execute: " + status + "\r\n" + mGet.getResponseBodyAsString());

            StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
            ResultSet rs = searchService.query(storeRef, SearchService.LANGUAGE_XPATH, "/app:company_home");

            try {
                if (rs.length() == 0) {
                    throw new AlfrescoRuntimeException("Didn't find Company Home");
                }
                companyHomeNodeRef = rs.getNodeRef(0);
            } finally {
                rs.close();
            }
            return companyHomeNodeRef.getId().toString();
        }

Someone, can help me? Thanks!
2 REPLIES 2

arnoldschrijve1
Champ on-the-rise
Champ on-the-rise
Hi,

You are using the wrong name for the nodelocator. There should be no underscore in the name. Try again with this URL:

<java>
String urlString = "http://127.0.0.1:8080/alfresco/service/api/nodelocator/companyhome?alf_ticket=" + authTicket;
</java>

You can find all registered nodelocators by looking into the context file node-locator-context.xml which is located in webapps/alfresco/WEB-INF/classes/alfresco and then opening the Java class that is registered in the various beans (if you have the sourcecode available). Of course there is also documentation on the wiki and in Docs:

https://wiki.alfresco.com/wiki/NodeLocatorService
http://docs.alfresco.com/4.1/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Fnode-locato...

Thanks!

I used this code and worked fine:

public String buscaParent() {

        RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
        try {
            Store spacesStore = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
            String luceneQuery = "PATH:\"/app:company_home\"";
            Query query = new Query(Constants.QUERY_LANG_LUCENE, luceneQuery);
            QueryResult queryResult = repositoryService.query(spacesStore, query, false);
            ResultSet resultSet = queryResult.getResultSet();
            ResultSetRow[] results = resultSet.getRows();

            for (ResultSetRow resultRow : results) {
                ResultSetRowNode nodeResult = resultRow.getNode();
                idCompanyHome = nodeResult.getId();
            }
        } catch (RemoteException e) {
            adicionaTextoLog("Erro de busca: " + e.getMessage().toString());
        }
        return idCompanyHome;
    }

I hope what help anyone in the future…
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.