Package com.liferay.portal.model

Examples of com.liferay.portal.model.User


    if (RegEX.contains(url, mastRegEx)) {
      boolean ADMIN_MODE = (session.getAttribute(com.dotmarketing.util.WebKeys.ADMIN_MODE_SESSION) != null);
      boolean EDIT_MODE = ((session.getAttribute(com.dotmarketing.util.WebKeys.EDIT_MODE_SESSION) != null) && ADMIN_MODE);

      Structure structure = null;
      User user = null;
      try {
        user = wuserAPI.getLoggedInUser(request);
      } catch (Exception e1) {
        Logger.error(URLMapFilter.class, e1.getMessage(), e1);
      }
View Full Code Here


    // HttpSession session = request.getSession();
    MyAccountForm form = (MyAccountForm) lf;

    // Getting the user from the session
    User user = (User) request.getSession().getAttribute(WebKeys.CMS_USER);
    String userId = user.getUserId();

    loadUserInfoInRequest(form, userId, request);

    return mapping.findForward("myAccountPage");
  }
View Full Code Here

      // calls the asset factory edit
      boolean editAsset = WebAssetFactory.editAsset(webAsset, user.getUserId());
      if (!editAsset) {
       
        User userMod = null;
        try{
          userMod = APILocator.getUserAPI().loadUserById(webAsset.getModUser(),APILocator.getUserAPI().getSystemUser(),false);
        }catch(Exception ex){
          if(ex instanceof NoSuchUserException){
            try {
              userMod = APILocator.getUserAPI().getSystemUser();
            } catch (DotDataException e) {
              Logger.error(this,e.getMessage(),e);
            }
          }
        }
        if(userMod!=null){
          webAsset.setModUser(userMod.getUserId());
        }

        try {
          Company comp = PublicCompanyFactory.getDefaultCompany();
          String message = LanguageUtil.get(comp.getCompanyId(), user.getLocale(), "message." + webAsset.getType() + ".edit.locked");
          message += " (" + userMod.getEmailAddress() + ")";
          SessionMessages.add(httpReq, "custommessage", message);
        } catch (Exception e) {
          SessionMessages.add(httpReq, "message", "message." + webAsset.getType() + ".edit.locked");
        }
View Full Code Here

    if (request.getSession().getAttribute(WebKeys.CMS_USER) == null) {
      return new ActionForward("/dotCMS/login");
    }

    MyAccountForm form = (MyAccountForm) lf;
    User user = (User) request.getSession().getAttribute(WebKeys.CMS_USER);
    String userId = user.getUserId();

    if (!Validator.validate(request, lf, mapping))
      return mapping.findForward("myAccountPage");

    // Saving Personal Information

    HibernateUtil.startTransaction();

    // User user = PublicUserFactory.getUserByEmail(userEmail);
   
    UserProxy userProxy = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(user,APILocator.getUserAPI().getSystemUser(), false);

    user.setFirstName(form.getFirstName());
    user.setLastName(form.getLastName());

    userProxy.setOrganization(form.getOrganization());
    userProxy.setWebsite(form.getWebsite());
    userProxy.setMailSubscription(form.isMailSubscription());
    userProxy.setPrefix(form.getPrefix());
    userProxy.setSuffix(form.getSuffix());
    userProxy.setTitle(form.getTitle());

    // User Name and password
    if (!form.getNewPassword().equals("")
        || !user.getEmailAddress().equals(form.getEmailAddress())

    ) {
      if (!user.getPassword().equals(
          PublicEncryptionFactory.digestString(form.getPassword()))) {
        ActionErrors errors = new ActionErrors();
        errors.add("password", new ActionMessage(
            "current.usermanager.password.incorrect"));
        saveMessages(request, errors);
        return mapping.findForward("myAccountPage");
      }
      user.setPassword(PublicEncryptionFactory.digestString(form
          .getNewPassword()));
      user.setPasswordEncrypted(true);
      user.setEmailAddress(form.getEmailAddress().trim().toLowerCase());
    }

    APILocator.getUserAPI().save(user,APILocator.getUserAPI().getSystemUser(),false);
    HibernateUtil.saveOrUpdate(userProxy);

    List<TagInode> tags = TagFactory.getTagInodeByInode(userProxy.getInode());
    for (TagInode tag: tags) {
      Tag tempTag = TagFactory.getTagByTagId(tag.getTagId());
      TagFactory.deleteTagInode(tempTag.getTagName(), userProxy.getInode());
    }
    if(tags.size() > 0){
      TagFactory.addTag(form.getTags(), userProxy.getUserId(), userProxy.getInode());
    }
   
    CategoryAPI categoryAPI = APILocator.getCategoryAPI();
    List<Category> myUserCategories = categoryAPI.getChildren(userProxy, APILocator.getUserAPI().getSystemUser(), false);
    for (Object object: myUserCategories) {
      if ((object instanceof Category) && categoryAPI.canUseCategory((Category) object, APILocator.getUserAPI().getSystemUser(), false)) {
        categoryAPI.removeChild(userProxy, (Category) object, APILocator.getUserAPI().getSystemUser(), false);
      }
    }

    if (UtilMethods.isSet(form.getCategory())) {
      Category category;
      for (String categoryId: form.getCategory()) {
        category = categoryAPI.find(categoryId, APILocator.getUserAPI().getSystemUser(), false);
        if(InodeUtils.isSet(category.getInode())) {
          categoryAPI.addChild(userProxy, category, APILocator.getUserAPI().getSystemUser(), false);
        }
      }
    }

    HibernateUtil.commitTransaction();

    loadUserInfoInRequest(form, user.getUserId(), request);

    ActionErrors ae = new ActionErrors();
    ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
        "message.createaccount.success"));
    saveMessages(request, ae);
View Full Code Here

   * @return
   */
  protected User _getUser(ActionRequest req) {

    // get the user
    User user = null;
    try {
      user = com.liferay.portal.util.PortalUtil.getUser(req);
    } catch (Exception e) {
      _handleException(e, req);
    }
View Full Code Here

   * @return
   */
  protected User _getUser(RenderRequest req) {

    // get the user
    User user = null;
    try {
      user = com.liferay.portal.util.PortalUtil.getUser(req);
    } catch (Exception e) {
      req.setAttribute(PageContext.EXCEPTION, e);
      return null;
View Full Code Here

  }

  private void loadUserInfoInRequest(MyAccountForm form, String userId,
      HttpServletRequest request) throws Exception {

    User user = APILocator.getUserAPI().loadUserById(userId,APILocator.getUserAPI().getSystemUser(),false);

    // Retriving info from db
    UserProxy userProxy = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(user,APILocator.getUserAPI().getSystemUser(), false);
    Address address = null;
    if (UtilMethods.isSet(form.getAddressID())) {
      address = PublicAddressFactory.getAddressById(form.getAddressID());
      if(address != null && address.getUserId() != null && !address.getUserId().equals(userId)){
        address = null;
      }
    }
    int addrId = 0;
    try{
      addrId = Integer.parseInt(form.getAddressID());
    }
    catch(Exception e){}

    if (addrId > 0) {
      address = PublicAddressFactory.getAddressById(form.getAddressID());
      if(address != null && address.getUserId() != null && !address.getUserId().equals(userId)){
        address = null;
      }
    }
    if (address == null) {
      address = PublicAddressFactory.getInstance();
      address.setUserId(userId);
      address.setCompanyId(PublicCompanyFactory.getDefaultCompanyId());
    }
    if (!InodeUtils.isSet(userProxy.getInode())) {
      userProxy.setUserId(user.getUserId());
      HibernateUtil.saveOrUpdate(userProxy);
    }

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

    // Extra user info
    form.setEmailAddress(user.getEmailAddress());

    List<TagInode> tags = TagFactory.getTagInodeByInode(userProxy.getInode());
    StringBuilder tagsString = new StringBuilder(128);
    tagsString.ensureCapacity(32);
    for (TagInode tag: tags) {
View Full Code Here

    // HttpSession session = request.getSession();
    MyAccountForm form = (MyAccountForm) lf;

    // Getting the user from the session
    User user = (User) request.getSession().getAttribute(WebKeys.CMS_USER);
    String userId = user.getUserId();

    loadUserInfoInRequest(form, userId, request);

    return mapping.findForward("myAccountPage");
  }
View Full Code Here

    if (request.getSession().getAttribute(WebKeys.CMS_USER) == null) {
      return new ActionForward("/dotCMS/login");
    }

    // Getting the user from the session
    User user = (User) request.getSession().getAttribute(WebKeys.CMS_USER);
    String userId = user.getUserId();

    MyAccountForm form = (MyAccountForm) lf;
    loadUserInfoInRequest(form, userId, request);
    return mapping.findForward("editUserCategoriesPage");
  }
View Full Code Here

    if (request.getSession().getAttribute(WebKeys.CMS_USER) == null) {
      return new ActionForward("/dotCMS/login");
    }

    // Getting the user from the session
    User user = (User) request.getSession().getAttribute(WebKeys.CMS_USER);
    String userId = user.getUserId();

    MyAccountForm form = (MyAccountForm) lf;

    loadUserInfoInRequest(form, userId, request);
    return mapping.findForward("editUserAddressPage");
View Full Code Here

TOP

Related Classes of com.liferay.portal.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.