Package org.jayasoft.woj.common.model

Examples of org.jayasoft.woj.common.model.User


      }
      return display();
    }
   
  public String displayAddUser() {
    User u = (User) getRequest().getAttribute("user"); //$NON-NLS-1$
    //Template info
    if(u==null || u.getId() ==0) {//Add
      getRequest().setAttribute("header.icon", "images/ee/user1_add.png"); //$NON-NLS-1$ //$NON-NLS-2$
      getRequest().setAttribute("header.title", Messages.get("adduser.title", getRequest().getLocale())); //$NON-NLS-1$ //$NON-NLS-2$
    } else {//edit
      getRequest().setAttribute("header.icon", "images/ee/user1_view.png"); //$NON-NLS-1$ //$NON-NLS-2$
      getRequest().setAttribute("header.title", Messages.get("edituser.title", getRequest().getLocale())); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here


  public String createUser(){
      return displayAddUser();
    }
   
  public String saveUser() {
      User user = null;
      String id = getRequest().getParameter(ServletConstants.EE.ADD_USER.ID);
      String login = getRequest().getParameter(ServletConstants.EE.ADD_USER.LOGIN);
      String password = getRequest().getParameter(ServletConstants.EE.ADD_USER.PASSWORD);
      String email = getRequest().getParameter(ServletConstants.EE.ADD_USER.EMAIL);
    user = new User();
    user.setLogin(login);
    user.setPassword(ChecksumUtil.encodeAsString(ChecksumUtil.SHA_1, password));
    user.setEmail(email);
       
    long idLong = StringUtils.isEmpty(id)?0:Long.valueOf(id).longValue();
    user.setId(idLong);
       
      if(StringUtils.isEmpty(login) || StringUtils.isEmpty(email)) {
        addWarning("adduser.warning.fillallfield"); //$NON-NLS-1$
      } else {
        try {
        if(idLong != 0) {
                    // It is an update
                    if (StringUtils.isEmpty(password)) {
                        User userStored = WOJServer.getInstance().getUserManagementService().getUser(login);
                        user.setPassword(userStored.getPassword());
                    }

          WOJServer.getInstance().getUserManagementService().updateUser(new User[]{user});
        } else {
                    // It is a creation
                    if(StringUtils.isEmpty(password)) {
                        addWarning("adduser.warning.fillallfield"); //$NON-NLS-1$
                    } else {
                        WOJServer.getInstance().getUserManagementService().addUser(new User[]{user});
                        //insert ok create new user for form
                        user = new User();
                    }
        }
        return display();
      } catch (IllegalArgumentException e) {
        addError("adduser.error.unabletoadduser", new Object[]{"User with same login or email already exist"}); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

  public String deleteUser(){
    String[] selectedUsersId = getAllChecked("user_id_"); //$NON-NLS-1$
    if(ArrayUtils.isEmpty(selectedUsersId)) {
      addWarning("user.warning.noselection"); //$NON-NLS-1$
    } else {
      User tempUser = new User();
      for (int i = 0; i < selectedUsersId.length; i++) {
        String id = selectedUsersId[i];
        tempUser.setId(Long.valueOf(id).longValue());
        WOJServer.getInstance().getDataService().getUserDao().delete(tempUser);
      }
    }
    return display();
  }
View Full Code Here

      CSVImport imp = new CSVImport(new CSVImport.CSVObjectConstructor() {
        public Object getObjectFromLine(String[] line) {
          if(line.length < 3 || StringUtils.isEmpty(line[0])) {
            return null;
          }
          return new User(line[0],ChecksumUtil.encodeAsString(ChecksumUtil.SHA_1, line[1]), line[2]);
        }
      }, fileToImport.getAbsolutePath());
      Object o []= imp.importEntity(sep != null?sep.charAt(0):';');
      if(ArrayUtils.isEmpty(o)) {
        addWarning("user.nothing.toimport"); //$NON-NLS-1$
View Full Code Here

      } else {
        UserDao userDao = WOJServer.getInstance().getDataService().getUserDao();
        Group g = WOJServer.getInstance().getDataService().getGroupDao().getGroup(groupId);
        for (int i = 0; i < selectedUsersId.length; i++) {
        String userId = selectedUsersId[i];
        User u = userDao.getUserById(Long.valueOf(userId));
                if (u!=null) {
                    u.setGroup(g);
                    userDao.update(u);
                }
      }
      }
      return display();
View Full Code Here

        addWarning("group.emptyselection"); //$NON-NLS-1$
      } else {
        UserDao userDao = WOJServer.getInstance().getDataService().getUserDao();
        for (int i = 0; i < selectedUsersId.length; i++) {
          String userId = selectedUsersId[i];
          User u = userDao.getUserById(Long.valueOf(userId));
                if (u!=null) {
                    u.setGroup(null);
                    userDao.update(u);
                }
        }
      }
      return display();
View Full Code Here

    public Object securedInvoke(UAK uak, Map m) {
        String list = (String) m.get(ServerCommands.ADD_USER.P_LIST);
        if(list != null) {
            Object[] users = (Object[]) ServiceProvider.getDefault().getEncodingService().decode(list);
            UserDao userDao = WOJServer.getInstance().getDataService().getUserDao();
            User uToUpdate;
            for (int i = 0; i < users.length; i++) {
                Object object = users[i];
                if (object instanceof User) {
                    User u = (User)object;
                    uToUpdate = userDao.getUserById(new Long(u.getId()));
                    BeanHelper.copy(object, uToUpdate, User.class);
                    userDao.update(uToUpdate);
                }
            }
        }
View Full Code Here

    public Object securedInvoke(UAK uak, Map m) {
        String list = (String) m.get(ServerCommands.DELETE_USER.P_LIST);
        if(list != null) {
            Object[] users = (Object[]) ServiceProvider.getDefault().getEncodingService().decode(list);
            UserDao userDao = WOJServer.getInstance().getDataService().getUserDao();
            User uToUpdate;
            for (int i = 0; i < users.length; i++) {
                Object object = users[i];
                if (object instanceof User) {
                    User u = (User)object;
                    uToUpdate = userDao.getUserById(new Long(u.getId()));
                    BeanHelper.copy(object, uToUpdate, User.class);
                    userDao.delete(uToUpdate);
                }
            }
        }
View Full Code Here

   

    public String registerUser(String login, String pass, String mail, String firstN, String lastN, String country) {
        try {
            String encodedPassword = ChecksumUtil.SHA_1.computeAsString(new ByteArrayInputStream(pass.getBytes()));
      User newUser = new User(login, encodedPassword, mail);
      newUser.setCountry(country);
      String hostKey = HostUtil.getUniqueHostKey();
      Registration r = ClientPortalServiceProvider.get().getRegistrationService().register(newUser, firstN, lastN, hostKey);
            if(r instanceof RegistrationSuccessfull) {
                return null;
            } else if(r instanceof RegistrationError){
View Full Code Here

            // We retrieve the users to add
            User[] users = _portalSynchronizationService.getUpdatedUsers(since);
            if (users != null) {
                LOGGER.debug(users.length + " users to synchronize.");
                for (int i = 0; i < users.length; i++) {
                    User u = users[i];
                    if (uDao.getUser(u.getLogin()) == null) {
                        uDao.insert(u);
                        LOGGER.debug(u + " has been inserted.");
                    } else {
                        uDao.update(u);
                        LOGGER.debug(u + " has been updated.");
View Full Code Here

TOP

Related Classes of org.jayasoft.woj.common.model.User

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.