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.ServiceContext;
023 import com.liferay.portal.service.base.AddressServiceBaseImpl;
024 import com.liferay.portal.service.permission.CommonPermissionUtil;
025
026 import java.util.List;
027
028
032 public class AddressServiceImpl extends AddressServiceBaseImpl {
033
034
039 @Override
040 public Address addAddress(
041 String className, long classPK, String street1, String street2,
042 String street3, String city, String zip, long regionId,
043 long countryId, int typeId, boolean mailing, boolean primary)
044 throws PortalException, SystemException {
045
046 CommonPermissionUtil.check(
047 getPermissionChecker(), className, classPK, ActionKeys.UPDATE);
048
049 return addressLocalService.addAddress(
050 getUserId(), className, classPK, street1, street2, street3, city,
051 zip, regionId, countryId, typeId, mailing, primary);
052 }
053
054 @Override
055 public Address addAddress(
056 String className, long classPK, String street1, String street2,
057 String street3, String city, String zip, long regionId,
058 long countryId, int typeId, boolean mailing, boolean primary,
059 ServiceContext serviceContext)
060 throws PortalException, SystemException {
061
062 CommonPermissionUtil.check(
063 getPermissionChecker(), className, classPK, ActionKeys.UPDATE);
064
065 return addressLocalService.addAddress(
066 getUserId(), className, classPK, street1, street2, street3, city,
067 zip, regionId, countryId, typeId, mailing, primary, serviceContext);
068 }
069
070 @Override
071 public void deleteAddress(long addressId)
072 throws PortalException, SystemException {
073
074 Address address = addressPersistence.findByPrimaryKey(addressId);
075
076 CommonPermissionUtil.check(
077 getPermissionChecker(), address.getClassNameId(),
078 address.getClassPK(), ActionKeys.UPDATE);
079
080 addressLocalService.deleteAddress(addressId);
081 }
082
083 @Override
084 public Address getAddress(long addressId)
085 throws PortalException, SystemException {
086
087 Address address = addressPersistence.findByPrimaryKey(addressId);
088
089 CommonPermissionUtil.check(
090 getPermissionChecker(), address.getClassNameId(),
091 address.getClassPK(), ActionKeys.VIEW);
092
093 return address;
094 }
095
096 @Override
097 public List<Address> getAddresses(String className, long classPK)
098 throws PortalException, SystemException {
099
100 CommonPermissionUtil.check(
101 getPermissionChecker(), className, classPK, ActionKeys.VIEW);
102
103 User user = getUser();
104
105 return addressLocalService.getAddresses(
106 user.getCompanyId(), className, classPK);
107 }
108
109 @Override
110 public Address updateAddress(
111 long addressId, String street1, String street2, String street3,
112 String city, String zip, long regionId, long countryId, int typeId,
113 boolean mailing, boolean primary)
114 throws PortalException, SystemException {
115
116 Address address = addressPersistence.findByPrimaryKey(addressId);
117
118 CommonPermissionUtil.check(
119 getPermissionChecker(), address.getClassNameId(),
120 address.getClassPK(), ActionKeys.UPDATE);
121
122 return addressLocalService.updateAddress(
123 addressId, street1, street2, street3, city, zip, regionId,
124 countryId, typeId, mailing, primary);
125 }
126
127 }