cancel
Showing results for 
Search instead for 
Did you mean: 

NodeRef to Node and Exception

avware
Champ in-the-making
Champ in-the-making
Hello,
I am adding a new feature to my version of Alfresco. I would like to see a list of all the discussions to which I was invited.

Then you have to be authenticated by the session and services from the repository. I can run the query through lucene to extract all discussions (identified by fm: discussion).

Now I need to point the child next to the node fm: discussion and find the information (see title of the discussion, creator and our link), but I can not convert a NodeRef in javax.jcr.Node.

This is the code that I am using that goes in with exception:
Net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext

The code:



User user = (User) session.getAttribute(AuthenticationHelper.AUTHENTICATION_USER);

if (user == null) {
  response.sendRedirect(request.getContextPath() + "/faces/jsp/login.jsp");
}

if (user != null) {

  WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(session.getServletContext());
  final ServiceRegistry serviceRegistry = (ServiceRegistry) context.getBean(ServiceRegistry.SERVICE_REGISTRY);

  SearchService searchService = serviceRegistry.getSearchService();
  NodeService nodeService = serviceRegistry.getNodeService();
 
  StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
  ResultSet resultSet = searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, "PATH:\"/*\" TEXT:\"/fm:discussion\"");

  for (ResultSetRow row : resultSet) {
     NodeRef nodeRef = row.getNodeRef();
    if ( nodeService.exists(nodeRef) ) {

        // todo: Node node = new Node(nodeRef);
       // NodeIterator iterator = node.getNodes();
       // scroll to child and print some data
    }

  }
  resultSet.close();
 
}

1 REPLY 1

avware
Champ in-the-making
Champ in-the-making
I think I have to be more precise. I found a way to iterare nodes in the repository through JCR, or run a query through SearchService.

JCR is too slow: To see the list of all the discussions (topic) on a set of a few nodes, took almost 3 minutes.

With SearchService run a query with Lucene result but I am ResultSet / ResultSetRow of nodes that are not compatible with JCR.

What relationship exists between nodes and nodes JCR Alfresco? More specifically, between NodeRef (returned by the ResultSet) and the Node interface of JCR? I can not make a cast from one to another, and vice versa.

Also my page will be added as a feature inside Alfresco and I can not use authentication JCR (Repository.login (…)) because I can not extract username and password from the user session (jsp). I'm too confused … Smiley Happy

Tnx!