示例#1
0
  @Override
  public void activate() throws Exception {

    String listGroup = getProperties().get(PROP_LIST, String.class);

    if (listGroup.equals(PROP_LIST_OPTION1)) {
      UserManager userManager = getResourceResolver().adaptTo(UserManager.class);
      Authorizable opsBluPrintUser = userManager.getAuthorizable(getRequest().getUserPrincipal());
      Iterator<Group> groups = opsBluPrintUser.memberOf();
      for (; groups.hasNext(); ) {
        String groupName = groups.next().getPrincipal().getName();

        if ((groupName.equals(MAKER_GROUP))
            || (groupName.equals(CHECKER_GROUP))
            || (groupName.equals(READER_GROUP))) {
          hiddenFieldValue = groupName;
        }
      }

    } else if (listGroup.equals(PROP_LIST_OPTION2)) {

      hiddenFieldValue = getRequest().getUserPrincipal().getName();
    } else if (listGroup.equals(PROP_LIST_OPTION3)) {
      // to be added

    } else if (listGroup.equals(PROP_LIST_OPTION4)) {
      hiddenFieldValue = getProperties().get(STATIC_VALUE, String.class);
    }
  }
 @Override
 protected TreeMap<String, Group> getGroups(Authorizable member, UserManager userManager)
     throws RepositoryException {
   TreeMap<String, Group> managedGroups = new TreeMap<String, Group>();
   Iterator<Group> allGroupsIter = member.memberOf();
   while (allGroupsIter.hasNext()) {
     Group group = allGroupsIter.next();
     if (group.hasProperty(UserConstants.PROP_MANAGED_GROUP)) {
       Value[] values = group.getProperty(UserConstants.PROP_MANAGED_GROUP);
       if ((values != null) && (values.length == 1)) {
         String managedGroupId = values[0].getString();
         Group managedGroup = (Group) userManager.getAuthorizable(managedGroupId);
         managedGroups.put(managedGroupId, managedGroup);
       }
     }
   }
   return managedGroups;
 }