Package com.dotmarketing.portlets.usermanager.struts

Examples of com.dotmarketing.portlets.usermanager.struts.UserManagerForm


        setForward(req, "portlet.ext.usermanager.edit_usermanager");
        return;
      } else {
        try {
          String userId = _save(form, req, res);
          UserManagerForm userForm = (UserManagerForm)form;
          if(!UtilMethods.isSet(userForm.getUserID())){
            httpReq.getSession().setAttribute("userID", userId);
          }
          _editUserManager(userId,form, req, res, "");

          _sendToReferral(req,res,referer);
          return;
        } catch (Exception e) {
          _handleException(e, req);
        }
      }
    } else

      // Delete usermanager
      if (com.liferay.portal.util.Constants.DELETE.equals(cmd)) {
        try {
          _delete(form, req, res);
        } catch (Exception e) {
          _handleException(e, req);
        }
        _sendToReferral(req,res,referer);
        return;

      } else

//        Save / Update registeruser
        if ("save_register_user".equals(cmd)) {
          UserManagerForm userForm = (UserManagerForm) form;
          ActionErrors ae = new ActionErrors ();

          Logger.debug(this, "Saving UserInfo");
         
          if(!_isNewUser(userForm.getUserID())){
            ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.userExists",""));
            req.setAttribute(Globals.ERROR_KEY,ae);
            setForward(req, "portlet.ext.usermanager.register_user");
            HibernateUtil.commitTransaction();
            return;
          }

          ///Validate Form
          if (!Validator.validate(req, form, mapping)) {
            Logger.debug(this, "Form Validation Failed");
            req.setAttribute(WebKeys.USERMANAGER_EDIT_FORM, form);
           
            setForward(req, "portlet.ext.usermanager.register_user");
            return;
          } else {
            try {
              userForm = (UserManagerForm) form;
              ae = new ActionErrors ();
              if(!UtilMethods.isSet(userForm.getUserID()))
              {
                if(!validateUniqueEmail(userForm.getEmailAddress()))
                {
                  ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.forgotPasswordClickHere","javascript:forgotPassword();"));
                }
              }
View Full Code Here


  //  get user profile
  private void _editUserManager(String userId,ActionForm form, ActionRequest req, ActionResponse res, String cmd)
  throws Exception {

    UserManagerForm userForm = (UserManagerForm) form;

    String companyId = com.dotmarketing.cms.factories.PublicCompanyFactory.getDefaultCompany().getCompanyId();
    if(!UtilMethods.isSet(userId))
      userId = req.getParameter("userID");
    User user = APILocator.getUserAPI().loadUserById(userId,APILocator.getUserAPI().getSystemUser(),false);

    if (user.getUserId() != null && !com.liferay.portal.util.Constants.SAVE.equals(cmd)) {

      // Retriving info from db
      UserProxy userProxy = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(user,APILocator.getUserAPI().getSystemUser(), false);

      Address address = retrieveAddress(user.getUserId());

      // Copy the attributes
      BeanUtils.copyProperties(form, user);

      if(!UtilMethods.isSet(userProxy.getPrefix())){
        userProxy.setPrefix("other");
      }

      BeanUtils.copyProperties(form, userProxy);

      if(!UtilMethods.isSet(address.getDescription())){
        address.setDescription("other");
      }

      BeanUtils.copyProperties(form, address);

      // Extra user info
      userForm.setUserID(user.getUserId());


      List<Category> oldcategories = InodeFactory.getChildrenClass(userProxy,Category.class);

//      Add User Categories
View Full Code Here

  //Deleting User manager
  private void _delete(ActionForm form, ActionRequest req, ActionResponse res)
  throws Exception {

    UserManagerForm userForm = (UserManagerForm) form;
    String userId = userForm.getUserID();

    //Saving Personal Information
    String companyId = com.dotmarketing.cms.factories.PublicCompanyFactory.getDefaultCompany().getCompanyId();
    User user = APILocator.getUserAPI().loadUserById(userId,APILocator.getUserAPI().getSystemUser(),false);
    UserProxy userProxy = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(user,APILocator.getUserAPI().getSystemUser(), false);
View Full Code Here

  private String _save(ActionForm form, ActionRequest req, ActionResponse res)
  throws Exception {

    User adminUser = _getUser(req);
   
    UserManagerForm userForm = (UserManagerForm) form;
    String userId = userForm.getUserID();

    //Saving Personal Information
    String companyId = com.dotmarketing.cms.factories.PublicCompanyFactory.getDefaultCompany().getCompanyId();

    User user = null;

    try {
      user = APILocator.getUserAPI().loadUserById(userId,APILocator.getUserAPI().getSystemUser(),false);
    } catch (Exception e) {
    }

    if (user == null)
      user = retrieveMember(userId, userForm);

    UserProxy userProxy = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(user,APILocator.getUserAPI().getSystemUser(), false);

    user.setFirstName(userForm.getFirstName());

    if (userForm.getMiddleName() != null)
      user.setMiddleName(userForm.getMiddleName());

    user.setLastName(userForm.getLastName());

    if (userForm.getDateOfBirthDate() != null)
      user.setBirthday(userForm.getDateOfBirthDate());

    if (userForm.getNickName() != null)
      user.setNickName(userForm.getNickName());

    if (userForm.getSex() != null)
      user.setMale(userForm.getSex().equalsIgnoreCase("M") ? true : false);

    if(UtilMethods.isSet(userForm.getChallengeQuestionId()) && UtilMethods.isInt(userForm.getChallengeQuestionId())){
      userProxy.setChallengeQuestionId(userForm.getChallengeQuestionId());
    }
    if(UtilMethods.isSet(userForm.getChallengeQuestionAnswer())){
      userProxy.setChallengeQuestionAnswer(userForm.getChallengeQuestionAnswer());
    }
    if (!userForm.getPrefix().equals("other"))
      userProxy.setPrefix(userForm.getPrefix());
    else
      userProxy.setPrefix(userForm.getOtherPrefix());

    userProxy.setSuffix(userForm.getSuffix());
    userProxy.setTitle(userForm.getTitle());
    userProxy.setCompany(companyId);

    if (userForm.getSchool() != null)
      userProxy.setSchool(userForm.getSchool());

    if (0 < userForm.getGraduation_year())
      userProxy.setGraduation_year(userForm.getGraduation_year());

    // User Name and password
    if (!UtilMethods.isSet(user.getEmailAddress()) || !user.getEmailAddress().equals(userForm.getEmailAddress()))
      user.setEmailAddress(userForm.getEmailAddress().trim().toLowerCase());

    if ((userForm.getNewPassword() != null) && (!userForm.getNewPassword().equals(""))) {
      user.setPassword(PublicEncryptionFactory.digestString(userForm.getNewPassword()));
      user.setPasswordEncrypted(true);
    }

    if (user.isNew() || userForm.getPassChanged().equals("true")) {
      user.setPassword(PublicEncryptionFactory.digestString(userForm.getPassword()));
      user.setPasswordEncrypted(true);
    }

    APILocator.getUserAPI().save(user,APILocator.getUserAPI().getSystemUser(),false);
       
    _setRolePermission(userProxy, req);
   
    if(!InodeUtils.isSet(userProxy.getInode()) ){
      userProxy.setUserId(user.getUserId());
      userProxy.setChallengeQuestionId("0");
      com.dotmarketing.business.APILocator.getUserProxyAPI().saveUserProxy(userProxy,APILocator.getUserAPI().getSystemUser(), false);
    } else {
      com.dotmarketing.business.APILocator.getUserProxyAPI().saveUserProxy(userProxy,APILocator.getUserAPI().getSystemUser(), false);

    }

    //Saving User Address Information
    Address address = retrieveAddress(user.getUserId());

    address.setUserName(user.getFullName());
    address.setClassName(user.getClass().getName());
    address.setClassPK(user.getUserId());
    address.setDescription(userForm.getDescription());
    address.setStreet1(userForm.getStreet1());
    address.setStreet2(userForm.getStreet2());
    address.setCity(userForm.getCity());
    address.setState(userForm.getState());
    address.setZip(userForm.getZip());
    address.setPhone(userForm.getPhone());
    address.setFax(userForm.getFax());

    if (userForm.getCountry() != null)
      address.setCountry(userForm.getCountry());

    address.setCell(userForm.getCell());
    PublicAddressFactory.save(address);

    //    Add User Categories
    if(userForm.getCategory() != null){
      String[] categories = userForm.getCategory();
      for(int i = 0 ; i < categories.length ;++i){
        Category cat = categoryAPI.find(categories[i], adminUser, false);
        categoryAPI.addChild(userProxy, cat, adminUser, false);
      }
    }
View Full Code Here

    return user.getUserId();
  }

  private void _updateUserProxy(ActionForm form, ActionRequest req, ActionResponse res){

    UserManagerForm userForm = new UserManagerForm();
    try {
      BeanUtils.copyProperties(userForm,form);

      UserProxy userProxy = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(userForm.getUserID(),APILocator.getUserAPI().getSystemUser(), false);

      if (!userForm.getPrefix().equals("other"))
        userProxy.setPrefix(userForm.getPrefix());
      else
        userProxy.setPrefix(userForm.getOtherPrefix());

      userProxy.setSuffix(userForm.getSuffix());
      userProxy.setTitle(userForm.getTitle());
      userProxy.setSchool(userForm.getSchool());
      userProxy.setGraduation_year(userForm.getGraduation_year());

      HibernateUtil.saveOrUpdate(userProxy);

    } catch (IllegalAccessException e) {
      Logger.error(this,e.getMessage(),e);
View Full Code Here

    return member;
  }

  private void _forgotPassword(ActionForm form, ActionRequest request, ActionResponse res) throws Exception
  {
    UserManagerForm userForm = (UserManagerForm) form;
    //if we have some errors
    ActionErrors aes = new ActionErrors();

    User user = APILocator.getUserAPI().loadByUserByEmail(userForm.getEmailAddress(), APILocator.getUserAPI().getSystemUser(), false);
    if(user.isNew())
    {
      aes = new ActionErrors();
      aes.add(Globals.ERROR_KEY, new ActionMessage("error.forgotPasswordUserNotFound"));
      request.setAttribute(Globals.ERROR_KEY,aes);
View Full Code Here

  public void processAction(ActionMapping mapping, ActionForm form, PortletConfig config, ActionRequest req, ActionResponse res) throws Exception {

    HibernateUtil.startTransaction();
    String cmd = req.getParameter(com.liferay.portal.util.Constants.CMD);
    String referer = req.getParameter("referer");
    UserManagerForm userForm = (UserManagerForm) form;
    req.setAttribute(WebKeys.USERMANAGER_EDIT_FORM, form);

    Logger.debug(this, "Saving UserInfo");

   
     
    try {
      _updateUserProxy(form, req, res);

    } catch (Exception e) {
      _handleException(e, req);
    }

    _sendToReferral(
        req,
        res,
        "/c/portal/layout?p_l_id=1&p_p_id=EXT_USERMANAGER&p_p_action=1&p_p_state=maximized&p_p_mode=view&_EXT_USERMANAGER_struts_action=%2Fadmin%2Fedit_user_profile&_EXT_USERMANAGER_p_u_e_a="
            + userForm.getEmailAddress());
    // setForward(req, "portlet.my_account.edit_profile");
    HibernateUtil.commitTransaction();
  }
View Full Code Here

  /* Private Methods */

  private void _updateUserProxy(ActionForm form, ActionRequest req, ActionResponse res) {

    UserManagerForm userForm = new UserManagerForm();
    try {
      BeanUtils.copyProperties(userForm, form);

      UserProxy userProxy = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(userForm.getUserID(),APILocator.getUserAPI().getSystemUser(), false);
      if (!userForm.getPrefix().equals("other"))
        userProxy.setPrefix(userForm.getPrefix());
      else
        userProxy.setPrefix(userForm.getOtherPrefix());

      userProxy.setSuffix(userForm.getSuffix());
      userProxy.setTitle(userForm.getTitle());
      userProxy.setSchool(userForm.getSchool());
      userProxy.setGraduation_year(userForm.getGraduation_year());
      userProxy.setCompany(userForm.getCompany());
      userProxy.setWebsite(userForm.getWebsite());
      userProxy.setHowHeard(userForm.getHowHeard());
      userProxy.setChapterOfficer(userForm.getChapterOfficer());

      HibernateUtil.saveOrUpdate(userProxy);

    } catch (IllegalAccessException e) {
      // TODO Auto-generated catch block
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.usermanager.struts.UserManagerForm

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.