Package evolaris.framework.um.business

Examples of evolaris.framework.um.business.UserSetManager


        }
      }
    }
       
    UserManager userMgr = new UserManager(locale, session);
    UserSetManager userSetMgr = new UserSetManager(locale, session);
   
    permissionMgr.setAnonymousPermissions(entry, anonymousPermissions.toArray(new Long[0]));
    for (Iterator<Map.Entry<Long, Set<Long>>> iter = rolePermissions.entrySet().iterator(); iter.hasNext();) {
      Map.Entry<Long, Set<Long>> element = iter.next();
      Role role = userMgr.getRole(element.getKey());
      permissionMgr.setRolePermissions(entry, role, element.getValue().toArray(new Long[0]));
    }
    for (Iterator<Map.Entry<Long, Set<Long>>> iter = userSetPermissions.entrySet().iterator(); iter.hasNext();) {
      Map.Entry<Long, Set<Long>> element = iter.next();
      UserSet userSet = userSetMgr.getUserSet(element.getKey());
      permissionMgr.setUserSetPermissions(entry, userSet, element.getValue().toArray(new Long[0]));
    }
    for (Iterator<Map.Entry<Long, Set<Long>>> iter = userPermissions.entrySet().iterator(); iter.hasNext();) {
      Map.Entry<Long, Set<Long>> element = iter.next();
      User user = userMgr.getUserDetails(element.getKey());
View Full Code Here


   *
   * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    Group groupToDisplay = this.getCurrentGroup(req);
    UserSetManager userSetMgm = new UserSetManager(locale,session);
    UserSet[] userSets = userSetMgm.getUserSets(groupToDisplay);
    List<UserSetListEntry> userSetList = new LinkedList<UserSetListEntry>();
    for (int i = 0; i < userSets.length; i++) {
      UserSet set = userSets[i];
      userSetList.add(new UserSetListEntry(set.getId(),set.getName(),set.getDescription(),set.getUsers().size()));
    }
View Full Code Here

  /**
   * Deletes the user set
   */
  public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    UserSetListForm userSetListForm = (UserSetListForm) form;
    UserSetManager userSetManager = new UserSetManager(locale,session);
    String[] ids = userSetListForm.getChoosen();
    if (ids != null) {
      for (String id : ids) {
        UserSet userSet = userSetManager.getUserSet(Long.parseLong(id));
        if (userSet != null) {
          // security check
          if (UserManager.isUserInRole(webUser, UserManagerBase.ADMINISTRATOR)
            || (UserManager.isUserInRole(webUser, UserManagerBase.GROUP_ADMINISTRATOR)
              && userSet.getGroup().equals(webUser.getGroup()))) {
            userSetManager.deleteUserSet(userSet,false);
          } else {
            throw new BugException("illegal role");
          }
        }       
      }
View Full Code Here

  }

  private void prepareContentForUserSetList(ActionForm form, HttpServletRequest req, Session session,String filter) {
    UserSetAssignmentListForm userSetAssignmentListForm = (UserSetAssignmentListForm) form;

    UserSetManager userSetManager = new UserSetManager(locale, session);

    UserSet userSet = userSetManager.getUserSet(userSetAssignmentListForm.getUserSetId());
    if (userSet == null) {
      String msg = getResources(req).getMessage("um.userSetNotFound", req.getParameter("id"));
      LOGGER.error(msg);
      throw new InputException(msg);
    }
    if (!userSet.getGroup().equals(getCurrentGroup(req))) {
      // due to global group selection, userset should be in current group
      throw new InputException(getResources(req).getMessage("um.userSetNotInCurrentGroup"));
    }
    checkAccessRights(req, userSet.getGroup());
    Group currentGroup = getCurrentGroup(req);
   
    // fetch the list of users
    int pageNumber = 1; // default page size
    if(req.getParameter("page") != null){
      pageNumber = Integer.parseInt(req.getParameter("page"));
    }
   
    String sortCriterion = "username"; // default sort criterion
    if(req.getParameter("sort") != null){
      sortCriterion = req.getParameter("sort");
    }
   
    SortOrderEnum sortOrderDisplayTag = SortOrderEnum.ASCENDING; // default
    evolaris.framework.database.util.SortOrderEnum sortOrderDb = evolaris.framework.database.util.SortOrderEnum.asc;
    if(req.getParameter("dir") != null){
      String order = req.getParameter("dir");
      if("asc".equals(order)){
        sortOrderDisplayTag = SortOrderEnum.ASCENDING;
        sortOrderDb = evolaris.framework.database.util.SortOrderEnum.asc;
      } else {
        sortOrderDisplayTag = SortOrderEnum.DESCENDING;
        sortOrderDb = evolaris.framework.database.util.SortOrderEnum.desc;
      }
    }
   
    User[] users = null;
    int listFullSize = 0; // the size of the complete result list used for paging

    Hibernate.initialize(userSet); // used to fetch the data from db
    userSetAssignmentListForm.setUserSetName(userSet.getName());
    userSetAssignmentListForm.setUserSetId(userSet.getId());
 
     
    String[] choosenUsers = null;
    if(userSetAssignmentListForm.getDisplayAll() != null && userSetAssignmentListForm.getDisplayAll()){
      GroupManager groupMgm = new GroupManager(locale,session);
      users = groupMgm.getUsers(currentGroup, pageNumber, PAGE_SIZE, sortCriterion, sortOrderDb,true,filter);
      listFullSize = groupMgm.getUsers(currentGroup,true,filter).length;
      // create a list containing all users for which the check box should be selected
      choosenUsers = new String[users.length];
      for(int i=0;i<users.length;i++){
        if(userSetManager.isUserInUserset(userSet, users[i])){
          choosenUsers[i]= String.valueOf(users[i].getId());
        }
      }
    } else {
      users = userSetManager.getUsers(userSet, pageNumber, PAGE_SIZE, sortCriterion, sortOrderDb,filter);
      listFullSize = userSetManager.getUsers(userSet,filter).length;
      // create a list containing all users for which the check box should be selected
      choosenUsers = new String[users.length];
      for(int i=0;i<users.length;i++){
        choosenUsers[i]= String.valueOf(users[i].getId());
      }
View Full Code Here

    LOGGER.info("User " + req.getUserPrincipal().getName().toLowerCase() + ": Modify request with user set ID `" + userSetId + "`");

    if (userSetId == null){
      throw new BugException("missing user set id");
    }
    UserSetManager userSetManager = new UserSetManager(locale,session);
    UserSet userSet = userSetManager.getUserSet(userSetId);
    checkAccessRights(req, userSet.getGroup());
    String[] choosen = userSetAssociationListForm.getChoosen();
    Long[] userIds = userSetAssociationListForm.getUserId();   
    if (userIds != null) {
      UserManager userManager = new UserManager(locale,session);
      for (Long userId : userIds) {
        User user = userManager.getUserDetails(userId);
        checkAccessRights(req, user.getGroup());       
        if (Arrays.asList(choosen).contains(userId.toString())) {  // in list and checked
          userSet.getUsers().add(user);              // don't care if already there, as it's a set.
        } else {                          // in list and not checked
          userSet.getUsers().remove(user);            // remove from userset, don't mind if it's not there
        }
      }
    }
    userSetManager.modifyUserSet(userSet);
    userSetAssociationListForm.setDisplayAll(false)// show only selected for the user to see the difference
    prepareContentForUserSetList(form,req,session,userSetAssociationListForm.getFilterString());
    logProcessingTime("Updating the user to set relation");
    return mapping.findForward("modified");
  }
View Full Code Here

    UserManager userManager = new UserManager(locale,session);
    userManager.createUser(user,user.getPassword());
   
    // store new references
    Set<UserSet> newUserSets = user.getUserSets();
    UserSetManager userSetManager = new UserSetManager(locale,session);
    for (Iterator iterator = newUserSets.iterator(); iterator.hasNext();) {
      UserSet userSet = (UserSet) iterator.next();
      userSet.getUsers().add(user);
      userSetManager.modifyUserSet(userSet);
    }
  }
View Full Code Here

   * @see evolaris.framework.sys.web.form.EnterEditDuplicateForm#modifyEntry(java.lang.Object, java.util.Locale, org.hibernate.Session)
   */
  @Override
  public void modifyEntry(User entry, Locale locale, Session session) {
       
    UserSetManager userSetManager = new UserSetManager(locale,session);
   
    // store new references
    Set<UserSet> newUserSets = entry.getUserSets();
    for (Iterator iterator = newUserSets.iterator(); iterator.hasNext();) {
      UserSet userSet = (UserSet) iterator.next();
      userSet.getUsers().add(entry);
      userSetManager.modifyUserSet(userSet);
    }
   
    UserManager userManager = new UserManager(locale,session);
    userManager.modifyUser(entry);
  }
View Full Code Here

      user.setLocale(null);
    }
    user.setUnlimitedRedemptions(f.getUnlimitedRedemptions() ? 1 : 0);
    user.setGroup(new GroupManager(locale,session).getGroup(f.getGroupId()));
   
    UserSetManager userSetMgr = new UserSetManager(locale, session);
    Set<UserSet> userSets = new HashSet<UserSet>();
    if (f.getUserSets() != null) {
      for (Long id : f.getUserSets()) {
        UserSet userSet = userSetMgr.getUserSet(id);
        if (userSet == null || userSet.getGroup() != group) {
          throw new InputException(resources.getMessage("um.userSetNotFound", id));         
        }
        userSets.add(userSet);
      }
View Full Code Here

  // Creates duplicated user set with or without users
  private ActionForward createWithOrWithoutUsers(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp, boolean includeUserAssignments) {
    UserSetEnterOrEditForm userSetEnterOrEditForm = (UserSetEnterOrEditForm) form;
    long originalUserSetId = userSetEnterOrEditForm.getOriginalId();
    UserSetManager userSetManager = new UserSetManager(locale,session);
    UserSet originalUserSet = userSetManager.getUserSet(originalUserSetId);
    if (originalUserSet == null){
      throw new InputException(getResources(req).getMessage(locale, "um.userSetNotFound",  originalUserSetId));
    }
    checkAccessRights(req, originalUserSet.getGroup());
    Group group = new GroupManager(locale,session).getGroup(userSetEnterOrEditForm.getGroupId());
    boolean differentGroup = group != originalUserSet.getGroup();
    if (includeUserAssignments && differentGroup && !userSetEnterOrEditForm.isConfirmationPending() && originalUserSet.getUsers().size() >= 1){
      userSetEnterOrEditForm.setConfirmationPending(true);
      String reallyDuplicate1 = getResources(req).getMessage(locale,"um.reallyDuplicate1");
      String reallyDuplicate2 = getResources(req).getMessage(locale,"um.reallyDuplicate2");
      req.setAttribute("generalError",reallyDuplicate1 + " " + originalUserSet.getUsers().size() + " " + reallyDuplicate2);
      return mapping.findForward("confirm");
    }
    userSetEnterOrEditForm.setConfirmationPending(false);
    UserSet newUserSet = userSetManager.duplicate(originalUserSet,group,userSetEnterOrEditForm.getUserSetName(),includeUserAssignments);
    checkAccessRights(req, newUserSet.getGroup());
    newUserSet.setDescription(userSetEnterOrEditForm.getDescription());
    newUserSet.setHidden(userSetEnterOrEditForm.getHidden()==true?1:0);
    userSetManager.modifyUserSet(newUserSet);
    setCurrentGroup(req, resp, group); // switch group in global group selection
    return mapping.findForward("created");
  }
View Full Code Here

   *      javax.servlet.http.HttpServletRequest,
   *      javax.servlet.http.HttpServletResponse)
   */
  public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    GroupManager groupManager = new GroupManager(locale,session);
    UserSetManager userSetManager = new UserSetManager(locale,session);
    UserSetEnterOrEditForm userSetEnterOrEditForm = (UserSetEnterOrEditForm) form;
    if (!userSetEnterOrEditForm.isConfirmationPending()){
      String idParameter = req.getParameter("id");
      long id = Long.valueOf(idParameter);
      UserSet userSet = userSetManager.getUserSet(id);
      if (userSet == null){
        throw new InputException(getResources(req).getMessage(locale, "um.userSetNotFound",  id));
      }
      checkAccessRights(req,userSet.getGroup());
      userSetEnterOrEditForm.setOriginalId(id);
View Full Code Here

TOP

Related Classes of evolaris.framework.um.business.UserSetManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.