Esempio n. 1
0
 public void execute(Event<UIUserInGroup> event) throws Exception {
   UIUserInGroup uiUserInGroup = event.getSource();
   String id = event.getRequestContext().getRequestParameter(OBJECTID);
   OrganizationService service =
       uiUserInGroup.getApplicationComponent(OrganizationService.class);
   MembershipHandler handler = service.getMembershipHandler();
   handler.removeMembership(id, true);
   uiUserInGroup.refresh();
   event
       .getRequestContext()
       .addUIComponentToUpdateByAjax(uiUserInGroup.getChild(UIGridUser.class));
 }
Esempio n. 2
0
 public void execute(Event<UIUserInGroup> event) throws Exception {
   UIUserInGroup uiUserInGroup = event.getSource();
   String id = event.getRequestContext().getRequestParameter(OBJECTID);
   OrganizationService service =
       uiUserInGroup.getApplicationComponent(OrganizationService.class);
   MembershipHandler handler = service.getMembershipHandler();
   UIPopupWindow uiPopup = uiUserInGroup.getChild(UIPopupWindow.class);
   UIGroupEditMembershipForm uiEditMemberShip =
       uiUserInGroup.createUIComponent(UIGroupEditMembershipForm.class, null, null);
   uiEditMemberShip.setValue(handler.findMembership(id), uiUserInGroup.getSelectedGroup());
   uiPopup.setUIComponent(uiEditMemberShip);
   uiPopup.setShow(true);
 }
Esempio n. 3
0
  public void setValues(Group group) throws Exception {
    PageList pageList = null;
    if (group == null) {
      pageList = EmptySerializablePageList.get();
    } else {
      OrganizationService service = getApplicationComponent(OrganizationService.class);
      MembershipHandler handler = service.getMembershipHandler();
      ListAccess<?> list = handler.findAllMembershipsByGroup(group);
      pageList =
          new FindMembershipByGroupPageList(
              group.getId(), list.getSize() > 10 ? list.getSize() : 10);
    }
    UIGridUser uiGrid = getChild(UIGridUser.class);
    pageList.setPageSize(5);

    UIPageIterator pageIterator = uiGrid.getUIPageIterator();
    /** We keep the currently selected page index * */
    int backupPageIndex = pageIterator.getCurrentPage();
    pageIterator.setPageList(pageList);

    if (group != null) {
      String groupId = group.getId();
      String currentUser = Util.getPortalRequestContext().getRemoteUser();

      // show action if user is administrator or manager of current group
      boolean showAction =
          GroupManagement.isAdministrator(currentUser)
              || GroupManagement.isManagerOfGroup(currentUser, groupId);

      if (!showAction) {
        pageList.setPageSize(10);
        if (getChild(UIGroupMembershipForm.class) != null) removeChild(UIGroupMembershipForm.class);
        uiGrid.configure("id", USER_BEAN_FIELD, null);
      } else {
        pageList.setPageSize(5);
        uiGrid.configure("id", USER_BEAN_FIELD, USER_ACTION);
        if (getChild(UIGroupMembershipForm.class) == null)
          addChild(UIGroupMembershipForm.class, null, null);
      }
    } else {
      pageList.setPageSize(10);
      if (getChild(UIGroupMembershipForm.class) != null) removeChild(UIGroupMembershipForm.class);
    }

    /** Reset the selected page index * */
    if (backupPageIndex > pageIterator.getAvailablePage()) {
      backupPageIndex = pageIterator.getAvailablePage();
    }
    pageIterator.setCurrentPage(backupPageIndex);
  }
Esempio n. 4
0
 /**
  * gets memberships of a user in a space.
  *
  * @param userName
  * @return string of membership name
  * @throws Exception
  */
 @SuppressWarnings("unchecked")
 public String getMemberships(String userName) throws Exception {
   String memberShip = null;
   OrganizationService orgService = getApplicationComponent(OrganizationService.class);
   MembershipHandler memberShipHandler = orgService.getMembershipHandler();
   Collection<Membership> memberShips =
       memberShipHandler.findMembershipsByUserAndGroup(userName, getSpace().getGroupId());
   for (Membership aaa : memberShips) {
     if (memberShip == null) {
       memberShip = aaa.getMembershipType();
     } else {
       memberShip += "," + aaa.getMembershipType();
     }
   }
   return memberShip;
 }
Esempio n. 5
0
    public void execute(Event<UISelectUserForm> event) throws Exception {
      UISelectUserForm uiForm = event.getSource();
      OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
      String keyword = uiForm.getUIStringInput(FIELD_KEYWORD).getValue();
      String filter = uiForm.getUIFormSelectBox(FIELD_FILTER).getValue();
      // uiForm.groupId_ = null ;
      // uiForm.setSelectedGroup(null) ;
      if (CalendarUtils.isEmpty(keyword)) {
        uiForm.init(uiForm.pars_);
      } else {
        keyword = "*" + keyword + "*";
        Query q = new Query();
        if (USER_NAME.equals(filter)) {
          q.setUserName(keyword);
        }
        if (LAST_NAME.equals(filter)) {
          q.setLastName(keyword);
        }
        if (FIRST_NAME.equals(filter)) {
          q.setFirstName(keyword);
        }
        if (EMAIL.equals(filter)) {
          q.setEmail(keyword);
        }
        List results = new CopyOnWriteArrayList();
        results.addAll(service.getUserHandler().findUsers(q).getAll());

        MembershipHandler memberShipHandler = service.getMembershipHandler();
        String groupId = uiForm.getSelectedGroup();
        if (groupId != null && groupId.trim().length() != 0) {
          for (Object user : results) {
            if (memberShipHandler
                    .findMembershipsByUserAndGroup(((User) user).getUserName(), groupId)
                    .size()
                == 0) {
              results.remove(user);
            }
          }
        }
        // ObjectPageList objPageList = new ObjectPageList(results, 10) ;
        LazyPageList<User> pageList =
            new LazyPageList<User>(new ListAccessImpl<User>(User.class, results), 10);
        uiForm.uiIterator_.setPageList(pageList);
      }
      event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
    }
Esempio n. 6
0
  public void search(String keyword, String filter, String groupId) throws Exception {
    OrganizationService service = getApplicationComponent(OrganizationService.class);
    Query q = new Query();
    if (keyword != null && (keyword = keyword.trim()).length() != 0) {
      if (keyword.indexOf("*") < 0) {
        if (keyword.charAt(0) != '*') keyword = "*" + keyword;
        if (keyword.charAt(keyword.length() - 1) != '*') keyword += "*";
      }
      keyword = keyword.replace('?', '_');
      if (USER_NAME.equals(filter)) {
        q.setUserName(keyword);
      }
      if (LAST_NAME.equals(filter)) {
        q.setLastName(keyword);
      }
      if (FIRST_NAME.equals(filter)) {
        q.setFirstName(keyword);
      }
      if (EMAIL.equals(filter)) {
        q.setEmail(keyword);
      }
    }
    List results = new CopyOnWriteArrayList();
    results.addAll(service.getUserHandler().findUsers(q).getAll());
    // remove if user doesn't exist in selected group
    MembershipHandler memberShipHandler = service.getMembershipHandler();

    if (groupId != null && (groupId = groupId.trim()).length() != 0) {
      for (Object user : results) {
        if (memberShipHandler
                .findMembershipsByUserAndGroup(((User) user).getUserName(), groupId)
                .size()
            == 0) {
          results.remove(user);
        }
      }
    }
    PageList objPageList = new SerializablePageList(new ListAccessImpl(User.class, results), 10);
    uiIterator_.setPageList(objPageList);
  }