001
014
015 package com.liferay.portal.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.model.Address;
020 import com.liferay.portal.model.User;
021 import com.liferay.portal.security.permission.ActionKeys;
022 import com.liferay.portal.service.base.AddressServiceBaseImpl;
023 import com.liferay.portal.service.permission.CommonPermissionUtil;
024
025 import java.util.List;
026
027
031 public class AddressServiceImpl extends AddressServiceBaseImpl {
032
033 @Override
034 public Address addAddress(
035 String className, long classPK, String street1, String street2,
036 String street3, String city, String zip, long regionId,
037 long countryId, int typeId, boolean mailing, boolean primary)
038 throws PortalException, SystemException {
039
040 CommonPermissionUtil.check(
041 getPermissionChecker(), className, classPK, ActionKeys.UPDATE);
042
043 return addressLocalService.addAddress(
044 getUserId(), className, classPK, street1, street2, street3, city,
045 zip, regionId, countryId, typeId, mailing, primary);
046 }
047
048 @Override
049 public void deleteAddress(long addressId)
050 throws PortalException, SystemException {
051
052 Address address = addressPersistence.findByPrimaryKey(addressId);
053
054 CommonPermissionUtil.check(
055 getPermissionChecker(), address.getClassNameId(),
056 address.getClassPK(), ActionKeys.UPDATE);
057
058 addressLocalService.deleteAddress(addressId);
059 }
060
061 @Override
062 public Address getAddress(long addressId)
063 throws PortalException, SystemException {
064
065 Address address = addressPersistence.findByPrimaryKey(addressId);
066
067 CommonPermissionUtil.check(
068 getPermissionChecker(), address.getClassNameId(),
069 address.getClassPK(), ActionKeys.VIEW);
070
071 return address;
072 }
073
074 @Override
075 public List<Address> getAddresses(String className, long classPK)
076 throws PortalException, SystemException {
077
078 CommonPermissionUtil.check(
079 getPermissionChecker(), className, classPK, ActionKeys.VIEW);
080
081 User user = getUser();
082
083 return addressLocalService.getAddresses(
084 user.getCompanyId(), className, classPK);
085 }
086
087 @Override
088 public Address updateAddress(
089 long addressId, String street1, String street2, String street3,
090 String city, String zip, long regionId, long countryId, int typeId,
091 boolean mailing, boolean primary)
092 throws PortalException, SystemException {
093
094 Address address = addressPersistence.findByPrimaryKey(addressId);
095
096 CommonPermissionUtil.check(
097 getPermissionChecker(), address.getClassNameId(),
098 address.getClassPK(), ActionKeys.UPDATE);
099
100 return addressLocalService.updateAddress(
101 addressId, street1, street2, street3, city, zip, regionId,
102 countryId, typeId, mailing, primary);
103 }
104
105 }