Package com.liferay.portal.model

Examples of com.liferay.portal.model.Address


  }

  private Address retrieveAddress(String userID) throws Exception {
    String companyId = com.dotmarketing.cms.factories.PublicCompanyFactory.getDefaultCompany().getCompanyId();

    Address address = null;
    if (UtilMethods.isSet(userID)) {
      List addresses = PublicAddressFactory.getAddressesByUserId(userID);
      if (addresses.size() == 0) {
        address = PublicAddressFactory.getInstance();
        address.setCompanyId(companyId);
        address.setUserId(userID);
      } else {
        address = (Address) addresses.get(0);
      }
    } else {
      address = PublicAddressFactory.getInstance();
      address.setCompanyId(companyId);
      address.setCreateDate(new java.util.Date());
      address.setNew(true);
      address.setUserId(userID);
    }
    return address;
  }
View Full Code Here


      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();
View Full Code Here

    {
      if(UtilMethods.isSet(ad.getAddressId())) {
        AddressLocalManagerUtil.updateAddress(ad.getAddressId(), ad.getDescription(), ad.getStreet1(), ad.getStreet2(), ad.getCity(), ad.getState(),
            ad.getZip(), ad.getCountry(), ad.getPhone(), ad.getFax(), ad.getCell());
      } else {
        Address newAddress = AddressLocalManagerUtil.addAddress(user.getUserId(), user.getClass().getName(), user.getUserId(), ad.getDescription(), ad.getStreet1(),
            ad.getStreet2(), ad.getCity(), ad.getState(), ad.getZip(), ad.getCountry(), ad.getPhone(), ad.getFax(), ad.getCell());
        ad.setAddressId(newAddress.getAddressId());
      }
      ad.setNew(false);
     
    } catch (PortalException e) {
      Logger.error(this, e.getMessage(), e);
View Full Code Here

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

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

            List<Address> addresses = user.getAddresses();
            Address address = null;
            if (addresses.size() > 0) {
                address = (Address) addresses.get(0);
            }
            matchesArray[i][0] = (userId == null) ? "" : userId;
            matchesArray[i][1] = (user.getFirstName() == null) ? "" : user.getFirstName();
            matchesArray[i][2] = (user.getMiddleName() == null) ? "" : user.getMiddleName();
            matchesArray[i][3] = (user.getLastName() == null) ? "" : user.getLastName();
            matchesArray[i][4] = (user.getEmailAddress() == null) ? "" : user.getEmailAddress();
            matchesArray[i][5] = (address == null) ? "" : address.getStreet1();
            matchesArray[i][6] = (address == null) ? "" : address.getStreet2();
            matchesArray[i][7] = (address == null) ? "" : address.getCity();
            matchesArray[i][8] = (address == null) ? "" : address.getState();
            matchesArray[i][9] = (address == null) ? "" : address.getZip();
            matchesArray[i][10] = (address == null) ? "" : address.getCountry();
            matchesArray[i][11] = (address == null) ? "" : address.getPhone();
            matchesArray[i][12] = UtilMethods.htmlDateToHTMLTime(user.getCreateDate());

            if (!isUserManagerAdmin) {
                // adding read permission
                try {
View Full Code Here

                } catch (ActionException ae) {
                    continue;
                }

                List addresses = user.getAddresses();
                Address address = null;
                if (addresses.size() > 0) {
                    address = (Address) addresses.get(0);
                }

                matchesArray[i][0] = userId;
                matchesArray[i][1] = (user.getFirstName() == null) ? "" : user.getFirstName();
                matchesArray[i][2] = (user.getMiddleName() == null) ? "" : user.getMiddleName();
                matchesArray[i][3] = (user.getLastName() == null) ? "" : user.getLastName();
                matchesArray[i][4] = (user.getEmailAddress() == null) ? "" : user.getEmailAddress();
                matchesArray[i][5] = (user.getPassword() == null) ? "" : user.getPassword();
                matchesArray[i][6] = UtilMethods.htmlDateToHTMLTime(user.getBirthday());
                matchesArray[i][7] = (address == null) ? "" : address.getStreet1();
                matchesArray[i][8] = (address == null) ? "" : address.getStreet2();
                matchesArray[i][9] = (address == null) ? "" : address.getCity();
                matchesArray[i][10] = (address == null) ? "" : address.getState();
                matchesArray[i][11] = (address == null) ? "" : address.getZip();
                matchesArray[i][12] = (address == null) ? "" : address.getCountry();
                matchesArray[i][13] = (address == null) ? "" : address.getPhone();
                matchesArray[i][14] = (address == null) ? "" : address.getFax();
                matchesArray[i][15] = (address == null) ? "" : address.getCell();

                for (int j = 1; j <= numberGenericVariables; j++) {
                    matchesArray[i][15 + j] = (userProxy.getVar(j) == null) ? "" : userProxy.getVar(j);
                }
            }
View Full Code Here

                                    }
                                }

                                Date today = new Date();

                                Address address = PublicAddressFactory.getInstance();
                                address.setUserName(user.getFullName());
                                address.setCompanyId(companyId);
                                address.setUserId(user.getUserId());
                                address.setCreateDate(today);
                                address.setModifiedDate(today);
                                address.setPriority(1);
                                address.setClassName(user.getClass().getName());
                                address.setClassPK(user.getUserId());
                                address.setDescription("Primary");
                                address.setStreet1(street1);
                                address.setStreet2(street2);
                                address.setCountry(country);
                                address.setCity(city);
                                address.setState(state);
                                address.setZip(zip);
                                address.setPhone(phone);
                                address.setFax(fax);
                                address.setCell(cell);

                                PublicAddressFactory.save(address);

                                // creating tag users
                                if (UtilMethods.isSet(userForm.getTagName())) {
                                    StringTokenizer tagNameToken = new StringTokenizer(userForm.getTagName(), ",");
                                    if (tagNameToken.hasMoreTokens()) {
                                        for (; tagNameToken.hasMoreTokens();) {
                                            String tagTokenized = tagNameToken.nextToken().trim();
                                            TagFactory.addTag(tagTokenized, user.getUserId(),"");
                                        }
                                    }
                                }


                                for (String roleId : roles) {
                                    com.dotmarketing.business.APILocator.getRoleAPI().addRoleToUser(roleId, user);
                                }

                                userCreated++;
                                userTaged++;

                                arrayUserIds.add(user.getUserId());

                            } else {
                                // email duplicated

                                if (userForm.isUpdateDuplicatedUsers()) {
                                    if (UtilMethods.isSet(firstName))
                                        userDuplicated.setFirstName(firstName);

                                    if (UtilMethods.isSet(middleName))
                                        userDuplicated.setMiddleName(middleName);

                                    if (UtilMethods.isSet(lastName))
                                        userDuplicated.setLastName(lastName);

                                    userDuplicated
                                            .setGreeting("Welcome, " + userDuplicated.getFirstName() + " " + userDuplicated.getLastName() + "!");

                                    if (UtilMethods.isSet(email))
                                        userDuplicated.setEmailAddress(email.trim().toLowerCase());

                                    if (UtilMethods.isSet(birthday))
                                        userDuplicated.setBirthday(birthday);

                                    if (UtilMethods.isSet(password)) {
                                        userDuplicated.setPassword(PublicEncryptionFactory.digestString(password));
                                        userDuplicated.setPasswordEncrypted(true);
                                    }

                                    APILocator.getUserAPI().save(userDuplicated,APILocator.getUserAPI().getSystemUser(),false);

                                    UserProxy userProxy = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(userDuplicated,APILocator.getUserAPI().getSystemUser(), false);
                                    // getting and saving the user
                                    // additional info
                                    String userAdditionalInfo = "";
                                    for (int j = 1; j <= numberGenericVariables; j++) {
                                        try {
                                            userAdditionalInfo = lineTok[i++];
                                        } catch (Exception e) {
                                            userAdditionalInfo = "";
                                        }
                                        if (!userAdditionalInfo.equalsIgnoreCase("")) {
                                            userProxy.setVar(j, userAdditionalInfo);
                                        }
                                    }

                                    com.dotmarketing.business.APILocator.getUserProxyAPI().saveUserProxy(userProxy,APILocator.getUserAPI().getSystemUser(), false);

                                   String userProxyInode = userProxy.getInode();

                                   permissionAPI.removePermissions(userProxy);

                                    // adding roles to user
                                    if (readPermissions != null) {
                                        for (int n = 0; n < readPermissions.length; n++) {
                                            permissionAPI.save(new Permission(userProxyInode, readPermissions[n], PERMISSION_READ), userProxy, systemUser, false);
                                        }
                                    }

                                    if (writePermissions != null) {
                                        for (int n = 0; n < writePermissions.length; n++) {
                                            permissionAPI.save(new Permission(userProxyInode, writePermissions[n], PERMISSION_WRITE), userProxy, systemUser, false);
                                        }
                                    }

                                    Address address = null;
                                    List<Address> addresses = PublicAddressFactory.getAddressesByUserId(userDuplicated.getUserId());
                                    for (int pos = 0; pos < addresses.size(); ++pos) {
                                        if ((addresses.get(pos).getDescription() != null) && (addresses.get(pos).getDescription().equals("Primary"))) {
                                            address = addresses.get(pos);
                                            break;
                                        }
                                    }

                                    Date today = new Date();

                                    if (address == null) {
                                        address = PublicAddressFactory.getInstance();
                                        address.setUserName(userDuplicated.getFullName());
                                        address.setCompanyId(companyId);
                                        address.setUserId(userDuplicated.getUserId());
                                        address.setCreateDate(today);
                                        address.setModifiedDate(today);
                                        address.setPriority(1);
                                        address.setClassName(userDuplicated.getClass().getName());
                                        address.setClassPK(userDuplicated.getUserId());
                                        address.setDescription("Primary");
                                        address.setStreet1(street1);
                                        address.setStreet2(street2);
                                        address.setCountry(country);
                                        address.setCity(city);
                                        address.setState(state);
                                        address.setZip(zip);
                                        address.setPhone(phone);
                                        address.setFax(fax);
                                        address.setCell(cell);
                                    } else {
                                        address.setModifiedDate(today);

                                        if (UtilMethods.isSet(street1))
                                            address.setStreet1(street1);

                                        if (UtilMethods.isSet(street2))
                                            address.setStreet2(street2);

                                        if (UtilMethods.isSet(country))
                                            address.setCountry(country);

                                        if (UtilMethods.isSet(city))
                                            address.setCity(city);

                                        if (UtilMethods.isSet(state))
                                            address.setState(state);

                                        if (UtilMethods.isSet(zip))
                                            address.setZip(zip);

                                        if (UtilMethods.isSet(phone))
                                            address.setPhone(phone);

                                        if (UtilMethods.isSet(fax))
                                            address.setFax(fax);

                                        if (UtilMethods.isSet(cell))
                                            address.setCell(cell);
                                    }

                                    PublicAddressFactory.save(address);

                                    for (String roleId : roles) {
View Full Code Here

    } catch (DotSecurityException e) {
      Logger.error(this, e.getMessage(), e);
      throw new DotDataException(e.getMessage(), e);
    }

    Address ad = new Address();
    ad.setDescription(addressDescription);
    ad.setStreet1(street1);
    ad.setStreet2(street2);
    ad.setCity(city);
    ad.setState(state);
    ad.setZip(zip);
    ad.setCountry(country);
    ad.setPhone(phone);
    ad.setFax(fax);
    ad.setCell(cell);

    try {
      uAPI.saveAddress(user, ad, uWebAPI.getLoggedInUser(request), !uWebAPI.isLoggedToBackend(request));
    } catch (DotDataException e) {
      throw new DotDataException(e.getCause().toString(), e);
    } catch (DotRuntimeException e) {
      Logger.error(this, e.getMessage(), e);
      throw new DotDataException(e.getMessage(), e);
    } catch (PortalException e) {
      Logger.error(this, e.getMessage(), e);
      throw new DotDataException(e.getMessage(), e);
    } catch (SystemException e) {
      Logger.error(this, e.getMessage(), e);
      throw new DotDataException(e.getMessage(), e);
    } catch (DotSecurityException e) {
      Logger.error(this, e.getMessage(), e);
      throw new DotDataException(e.getMessage(), e);
    }

    return ad.toMap();

  }
View Full Code Here

    } catch (DotSecurityException e) {
      Logger.error(this, e.getMessage(), e);
      throw new DotDataException(e.getMessage(), e);
    }

    Address ad = new Address();
    ad.setAddressId(addressId);
    ad.setDescription(addressDescription);
    ad.setStreet1(street1);
    ad.setStreet2(street2);
    ad.setCity(city);
    ad.setState(state);
    ad.setZip(zip);
    ad.setCountry(country);
    ad.setPhone(phone);
    ad.setFax(fax);
    ad.setCell(cell);

    try {
      uAPI.saveAddress(user, ad, uWebAPI.getLoggedInUser(request), !uWebAPI.isLoggedToBackend(request));
    } catch (DotRuntimeException e) {
      Logger.error(this, e.getMessage(), e);
      throw new DotDataException(e.getMessage(), e);
    } catch (PortalException e) {
      Logger.error(this, e.getMessage(), e);
      throw new DotDataException(e.getMessage(), e);
    } catch (SystemException e) {
      Logger.error(this, e.getMessage(), e);
      throw new DotDataException(e.getMessage(), e);
    } catch (DotSecurityException e) {
      Logger.error(this, e.getMessage(), e);
      throw new DotDataException(e.getMessage(), e);
    }

    return ad.toMap();

  }
View Full Code Here

    UserAPI uAPI = APILocator.getUserAPI();
    UserWebAPI uWebAPI = WebAPILocator.getUserWebAPI();
    WebContext ctx = WebContextFactory.get();
    HttpServletRequest request = ctx.getHttpServletRequest();

    Address ad;
    try {
      ad = uAPI.loadAddressById(addressId, uWebAPI.getLoggedInUser(request), !uWebAPI.isLoggedToBackend(request));
      uAPI.deleteAddress(ad, uWebAPI.getLoggedInUser(request), !uWebAPI.isLoggedToBackend(request));
    } catch (DotRuntimeException e) {
      Logger.error(this, e.getMessage(), e);
View Full Code Here

    _user = user;

    List addresses = user.getAddresses();

    for (int i = 0; i < addresses.size(); i++) {
      Address address = (Address)addresses.get(i);

      if (address.getDescription().equalsIgnoreCase("home")) {
        _homeAddress = address;
      }
      else if (address.getDescription().equalsIgnoreCase("business")) {
        _bizAddress = address;
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.liferay.portal.model.Address

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.