AnsweredAssumed Answered

get List User by Group Name !!!

Question asked by chtquoc on Oct 3, 2008
i want to creat custom class in alfresco.

in this class i have a function getUserGroup and this function will return List user.

After that i tested but it was error. my funtion return null

this is my code

package org.alfresco.repo.workflow.jbpm;

import java.util.Collection;
import org.alfresco.model.ContentModel;

import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;

public class ivb {
   private SearchService searchService;
   private NodeService nodeService;

   public String[] getUserGroup(String groupName) {
      String[] userList = null;
      System.out.println("groupName =" + groupName);
        String searchQuery = "TYPE:\"{}authorityContainer\"  +@usr\\:authorityName:\"GROUP_" + groupName + "\"";
      StoreRef storeRef = new StoreRef("user", "alfrescoUserStore");
      ResultSet resultSet = searchService.query(storeRef,
            SearchService.LANGUAGE_LUCENE, searchQuery);
      System.out.println("groupName 1 =" + groupName);
      if (resultSet.length() == 0) {

         return null;
      } else {
         NodeRef groupNode = resultSet.getNodeRef(0);

         Collection<String> memberCollection = DefaultTypeConverter.INSTANCE
               .getCollection(String.class, nodeService.getProperty(
                     groupNode, ContentModel.PROP_MEMBERS));
         userList = new String[memberCollection.size()];
         int i = 0;
         for (String user : memberCollection) {
            userList[i++] = user;

      return userList;


some body know please help me. i think error in variable searchService

any idea please help me

thanks a lot