Package evolaris.platform.um.web.form

Examples of evolaris.platform.um.web.form.UserImportForm


   *
   * @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 enter(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
   
    UserImportForm userImportForm = (UserImportForm) form;
    if(userImportForm.getMergeSelection() == null || userImportForm.getMergeSelection().equals("")){
      userImportForm.setMergeSelection("none"); // initial setzp
    }
    Group groups[] = null;
    Group groupToDisplay = null;
   
    if (UserManager.isUserInRole(webUser, UserManagerBase.ADMINISTRATOR)) {
      GroupManager groupMgm = new GroupManager(locale,session);
      Long selectedGroupId = userImportForm.getGroupId();
      if (selectedGroupId == null) {
        // set the group name of the administrator group
        groupToDisplay = webUser.getGroup();
      } else {
        groupToDisplay = groupMgm.getGroup(selectedGroupId);
      }
      // set an array of groups into the request
      groups = groupMgm.getGroups();
    } else if (UserManager.isUserInRole(webUser, UserManagerBase.GROUP_ADMINISTRATOR)) {
      // this is a security aspect - > group administartors can only display its own group
      groups = new Group[1];
      Group gr = webUser.getGroup();
      Hibernate.initialize(gr);
      groupToDisplay = webUser.getGroup();
      groups[0] = groupToDisplay;
    } else { // role user - must not be allowed in struts-config
      throw new BugException("illegal role");
    }
   
    req.getSession().setAttribute("groups", groups);
    userImportForm.setGroupId(groupToDisplay.getId());
    userImportForm.setGroupName(groupToDisplay.getGroupname());
   
    if(userImportForm.getDelimiter() == null){
      userImportForm.setDelimiter(DEFAULT_DELIMITER);
    }
   
    Hibernate.initialize(groupToDisplay); // used to fetch  the data from db
    UserSetManager userSetMgm = new UserSetManager(locale,session);
    UserSet[] userSets = userSetMgm.getUserSets(groupToDisplay,false);
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 importFile(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
   
   
    UserImportForm userImportForm = (UserImportForm) form;
    MessageResources resources = getResources(req);
   
    Long userSetId = userImportForm.getUserSetId();
   
    if(userSetId == null){
      throw new InputException(resources.getMessage(locale, "smssvc.missingUserSetSelection"));
    }
    UserSetManager userSetMgm = new UserSetManager(locale,session);
    UserSet userSet = userSetMgm.getUserSet(userSetId);
   
    if(userSet == null){
      throw new InputException(resources.getMessage(locale, "um.userSetNotFound",userSetId));
    }
   
    checkAccessRights(req, userSet.getGroup());
   
    FormFile csvFile = userImportForm.getCsvFile();
    if (csvFile != null && csvFile.getFileName() != null && csvFile.getFileName().length() != 0){
      try {
        InputStream inputStream = csvFile.getInputStream();
        UserManager userManager = new UserManager(locale,session);
       
        UserImportResult importResult = userManager.importData(inputStream, userImportForm.getCharacterSet(), userImportForm.getDelimiter(),userSet,
            userImportForm.getMergeSelection().equals("userName"),
            userImportForm.getMergeSelection().equals("msisdn"),
            userImportForm.getMergeSelection().equals("personnelNumber"));
        inputStream.close();
       
        req.setAttribute("userImportCounter", importResult.getUsersCreated());
        req.setAttribute("userUpdateCounter", importResult.getUsersUpdated());
        req.setAttribute("userIgnoreCounter", importResult.getUsersIgnored());
View Full Code Here

TOP

Related Classes of evolaris.platform.um.web.form.UserImportForm

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.