Exemple #1
0
  public UserVO createUser(UserVO vo) throws MSMApplicationException {
    UserVO newUser = null;
    NdgUser userPending = findNdgUserByName(vo.getUsername());
    UserVO userByEmail = getUserByEmail(vo.getEmail());

    if (userPending != null) {
      throw new UserAlreadyExistException();
    } else if (userByEmail != null) {
      throw new EmailAlreadyExistException();
    } else {
      userPending = new NdgUser();
      try {
        userPending.setPassword(MD5.createMD5(vo.getPassword()));
      } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
      }
      userPending.setUsername(vo.getUsername());
      userPending.setFirstName(vo.getFirstName());
      userPending.setLastName(vo.getLastName());
      userPending.setEmail(vo.getEmail());

      userPending.setPhoneNumber(vo.getPhoneNumber());
      userPending.setAreaCode(vo.getAreaCode());
      userPending.setCountryCode(vo.getCountryCode());

      NdgRole role = findNdgRoleByName(vo.getRole().getName());
      if (role != null) {
        userPending.setRole(role);
      }
      NdgUser userAdmin = findNdgUserByName(vo.getUserAdmin());
      if (userPending != null) {
        userPending.setUserAdmin(userAdmin.getUsername());
        userPending.setCompany(userAdmin.getCompany());
        userPending.setEmailPreferences(userAdmin.getEmailPreferences());
        userPending.setWhoUseIt(userAdmin.getWhoUseIt());
      }

      userPending.setValidationKey(generateValidationKey(vo.getEmail()));
      userPending.setHasFullPermissions(vo.getHasFullPermissions());
      userPending.setUserValidated('Y');
      userPending.setHowDoYouPlanUseNdg("");
      userPending.setFirstTimeUse('Y');

      manager.persist(userPending);

      newUser = userPojoToVo(userPending);
    }

    return newUser;
  }
Exemple #2
0
  @Override
  public UserVO requestAccess(UserVO vo) throws MSMApplicationException, MSMSystemException {
    idSimpleSurvey = MD5.createIdSurvey();

    userDirectories =
        properties.getProperty(PropertiesUtil.SURVEY_ROOT)
            + SystemUtils.FILE_SEP
            + vo.getUsername()
            + SystemUtils.FILE_SEP
            + "survey"
            + idSimpleSurvey;

    UserVO newUser = null;

    NdgUser userPending = findNdgUserByName(vo.getUsername());
    if (userPending != null) {
      throw new UserAlreadyExistException();
    }
    UserVO userByEmail = getUserByEmail(vo.getEmail());
    if (userByEmail != null) {
      throw new EmailAlreadyExistException();
    }

    userPending = new NdgUser();
    userPending.setUsername(vo.getUsername());
    try {
      userPending.setPassword(MD5.createMD5(vo.getPassword()));
    } catch (NoSuchAlgorithmException e) {
      e.printStackTrace();
      userPending.setPassword(vo.getPassword());
    }

    userPending.setFirstName(vo.getFirstName());
    userPending.setLastName(vo.getLastName());
    userPending.setEmail(vo.getEmail());
    userPending.setWhoUseIt(vo.getWhoUseIt());
    userPending.setPhoneNumber(vo.getPhoneNumber());

    NdgRole role = findNdgRoleByName(vo.getRole().getName());
    if (role != null) {
      userPending.setRole(role);
    }

    Company company = findCompanyByName(vo.getCompany().getCompanyName());
    if (company != null) {
      userPending.setCompany(company);
    } else {
      Company newCompany = new Company();
      newCompany.setCompanyName(vo.getCompany().getCompanyName());
      newCompany.setCompanyType(vo.getCompany().getCompanyType());
      newCompany.setCompanyCountry(vo.getCompany().getCompanyCountry());
      newCompany.setCompanyIndustry(vo.getCompany().getCompanyIndustry());
      newCompany.setCompanySize(vo.getCompany().getCompanySize());
      userPending.setCompany(newCompany);
    }

    userPending.setAreaCode(vo.getAreaCode());
    userPending.setCountryCode(vo.getCountryCode());
    userPending.setEmailPreferences(vo.getEmailPreferences());
    userPending.setHowDoYouPlanUseNdg(vo.getHowDoYouPlanUseNdg());
    userPending.setValidationKey(generateValidationKey(vo.getEmail()));
    userPending.setUserValidated(vo.getUserValidated());
    userPending.setUserAdmin(userPending.getUsername());
    userPending.setFirstTimeUse(vo.getFirstTimeUse());
    userPending.setHasFullPermissions(vo.getHasFullPermissions());

    manager.persist(userPending);
    createUserFile(vo.getUsername());
    newUser = userPojoToVo(userPending);

    return newUser;
  }