1
22
23 package com.liferay.portal.service.impl;
24
25 import com.liferay.portal.PortalException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.security.permission.ActionKeys;
28 import com.liferay.portal.model.Address;
29 import com.liferay.portal.service.AddressLocalServiceUtil;
30 import com.liferay.portal.service.AddressService;
31 import com.liferay.portal.service.permission.CommonPermissionUtil;
32 import com.liferay.portal.service.persistence.AddressUtil;
33
34 import java.util.List;
35
36
43 public class AddressServiceImpl
44 extends PrincipalBean implements AddressService {
45
46 public Address addAddress(
47 String className, long classPK, String street1, String street2,
48 String street3, String city, String zip, long regionId,
49 long countryId, int typeId, boolean mailing, boolean primary)
50 throws PortalException, SystemException {
51
52 CommonPermissionUtil.checkPermission(
53 getPermissionChecker(), className, classPK, ActionKeys.UPDATE);
54
55 return AddressLocalServiceUtil.addAddress(
56 getUserId(), className, classPK, street1, street2, street3, city,
57 zip, regionId, countryId, typeId, mailing, primary);
58 }
59
60 public void deleteAddress(long addressId)
61 throws PortalException, SystemException {
62
63 Address address = AddressUtil.findByPrimaryKey(addressId);
64
65 CommonPermissionUtil.checkPermission(
66 getPermissionChecker(), address.getClassNameId(),
67 address.getClassPK(), ActionKeys.UPDATE);
68
69 AddressLocalServiceUtil.deleteAddress(addressId);
70 }
71
72 public Address getAddress(long addressId)
73 throws PortalException, SystemException {
74
75 Address address = AddressUtil.findByPrimaryKey(addressId);
76
77 CommonPermissionUtil.checkPermission(
78 getPermissionChecker(), address.getClassNameId(),
79 address.getClassPK(), ActionKeys.VIEW);
80
81 return address;
82 }
83
84 public List getAddresses(String className, long classPK)
85 throws PortalException, SystemException {
86
87 CommonPermissionUtil.checkPermission(
88 getPermissionChecker(), className, classPK, ActionKeys.VIEW);
89
90 return AddressLocalServiceUtil.getAddresses(
91 getUser().getCompanyId(), className, classPK);
92 }
93
94 public Address updateAddress(
95 long addressId, String street1, String street2, String street3,
96 String city, String zip, long regionId, long countryId, int typeId,
97 boolean mailing, boolean primary)
98 throws PortalException, SystemException {
99
100 Address address = AddressUtil.findByPrimaryKey(addressId);
101
102 CommonPermissionUtil.checkPermission(
103 getPermissionChecker(), address.getClassNameId(),
104 address.getClassPK(), ActionKeys.UPDATE);
105
106 return AddressLocalServiceUtil.updateAddress(
107 addressId, street1, street2, street3, city, zip, regionId,
108 countryId, typeId, mailing, primary);
109 }
110
111 }