001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.service.impl;
022:
023: import com.liferay.portal.PortalException;
024: import com.liferay.portal.SystemException;
025: import com.liferay.portal.kernel.security.permission.ActionKeys;
026: import com.liferay.portal.model.Address;
027: import com.liferay.portal.service.base.AddressServiceBaseImpl;
028: import com.liferay.portal.service.permission.CommonPermissionUtil;
029:
030: import java.util.List;
031:
032: /**
033: * <a href="AddressServiceImpl.java.html"><b><i>View Source</i></b></a>
034: *
035: * @author Brian Wing Shun Chan
036: * @author Alexander Chow
037: *
038: */
039: public class AddressServiceImpl extends AddressServiceBaseImpl {
040:
041: public Address addAddress(String className, long classPK,
042: String street1, String street2, String street3,
043: String city, String zip, long regionId, long countryId,
044: int typeId, boolean mailing, boolean primary)
045: throws PortalException, SystemException {
046:
047: CommonPermissionUtil.check(getPermissionChecker(), className,
048: classPK, ActionKeys.UPDATE);
049:
050: return addressLocalService.addAddress(getUserId(), className,
051: classPK, street1, street2, street3, city, zip,
052: regionId, countryId, typeId, mailing, primary);
053: }
054:
055: public void deleteAddress(long addressId) throws PortalException,
056: SystemException {
057:
058: Address address = addressPersistence
059: .findByPrimaryKey(addressId);
060:
061: CommonPermissionUtil.check(getPermissionChecker(), address
062: .getClassNameId(), address.getClassPK(),
063: ActionKeys.UPDATE);
064:
065: addressLocalService.deleteAddress(addressId);
066: }
067:
068: public Address getAddress(long addressId) throws PortalException,
069: SystemException {
070:
071: Address address = addressPersistence
072: .findByPrimaryKey(addressId);
073:
074: CommonPermissionUtil.check(getPermissionChecker(), address
075: .getClassNameId(), address.getClassPK(),
076: ActionKeys.VIEW);
077:
078: return address;
079: }
080:
081: public List getAddresses(String className, long classPK)
082: throws PortalException, SystemException {
083:
084: CommonPermissionUtil.check(getPermissionChecker(), className,
085: classPK, ActionKeys.VIEW);
086:
087: return addressLocalService.getAddresses(getUser()
088: .getCompanyId(), className, classPK);
089: }
090:
091: public Address updateAddress(long addressId, String street1,
092: String street2, String street3, String city, String zip,
093: long regionId, long countryId, int typeId, boolean mailing,
094: boolean primary) throws PortalException, SystemException {
095:
096: Address address = addressPersistence
097: .findByPrimaryKey(addressId);
098:
099: CommonPermissionUtil.check(getPermissionChecker(), address
100: .getClassNameId(), address.getClassPK(),
101: ActionKeys.UPDATE);
102:
103: return addressLocalService.updateAddress(addressId, street1,
104: street2, street3, city, zip, regionId, countryId,
105: typeId, mailing, primary);
106: }
107:
108: }
|