AnsweredAssumed Answered

AuthorityService to NodeRef

Question asked by joksy on Apr 15, 2009
Hi Guys,

I Use the AuthorityService Inrerface to fetch all groups/person in alfresco. That is pretty good for the view part, but now i found another problem
Is there a way to fetch the nodeRef refer to the result?? Or the only way is to query lucene.

I post my simpe class


public class GroupPicker extends AbstractPicker {
   public GroupPicker(AuthorityType t) {
      super(t);
   }

   public SelectItem[] picker(AuthorityService service) {
      
      SelectItem[] gropusItems = new SelectItem[service.getAllAuthorities(type).size()];
      Iterator<String> iterator = service.getAllAuthorities(type).iterator();
      
   
      for (int i = 0;iterator.hasNext();i++) {
         String value = iterator.next();
         gropusItems[i] = new SelectItem(value,value);
      }
      
      
      
      return getFiltered(gropusItems);
   }

   
   private SelectItem[] getFiltered(SelectItem[] items){
      String GAA = "GROUP_ALFRESCO_ADMINISTRATORS";
      String GEC = "GROUP_EMAIL_CONTRIBUTORS";      
      
      SelectItem[] tmp = new SelectItem[items.length-2];
      for (int i = 0,x = 0; i < items.length; i++) {
         if(! (items[i].getLabel().equals(GEC) || items[i].getLabel().equals(GAA))){
            tmp[x] = items[i];
            x++;
         }
      }
      
      tmp = removeGroupSuffix(tmp);
      
       
      return sort(tmp);
   }

   private SelectItem[] removeGroupSuffix(SelectItem[] tmp) {
      for (SelectItem selectItem : tmp) {
         selectItem.setLabel(selectItem.getLabel().substring("GROUP_".length(), selectItem.getLabel().length()));
      }
      return tmp;
   }
   

}



(the sort method is on the Ab class because is used also for users.)

Ok Now i retrieve the group using "service.getAllAuthorities(type)" where type is AuthorityType.GROUP and from this i create the selectItem object.

Now form the string that the Set return me is there the way to get the NodeRef???

Many Thanks guys.

Outcomes