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.EmailAddress;
027: import com.liferay.portal.service.base.EmailAddressServiceBaseImpl;
028: import com.liferay.portal.service.permission.CommonPermissionUtil;
029:
030: import java.util.List;
031:
032: /**
033: * <a href="EmailAddressServiceImpl.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 EmailAddressServiceImpl extends
040: EmailAddressServiceBaseImpl {
041:
042: public EmailAddress addEmailAddress(String className, long classPK,
043: String address, int typeId, boolean primary)
044: throws PortalException, SystemException {
045:
046: CommonPermissionUtil.check(getPermissionChecker(), className,
047: classPK, ActionKeys.UPDATE);
048:
049: return emailAddressLocalService.addEmailAddress(getUserId(),
050: className, classPK, address, typeId, primary);
051: }
052:
053: public void deleteEmailAddress(long emailAddressId)
054: throws PortalException, SystemException {
055:
056: EmailAddress emailAddress = emailAddressPersistence
057: .findByPrimaryKey(emailAddressId);
058:
059: CommonPermissionUtil.check(getPermissionChecker(), emailAddress
060: .getClassNameId(), emailAddress.getClassPK(),
061: ActionKeys.UPDATE);
062:
063: emailAddressLocalService.deleteEmailAddress(emailAddressId);
064: }
065:
066: public EmailAddress getEmailAddress(long emailAddressId)
067: throws PortalException, SystemException {
068:
069: EmailAddress emailAddress = emailAddressPersistence
070: .findByPrimaryKey(emailAddressId);
071:
072: CommonPermissionUtil.check(getPermissionChecker(), emailAddress
073: .getClassNameId(), emailAddress.getClassPK(),
074: ActionKeys.VIEW);
075:
076: return emailAddress;
077: }
078:
079: public List getEmailAddresses(String className, long classPK)
080: throws PortalException, SystemException {
081:
082: CommonPermissionUtil.check(getPermissionChecker(), className,
083: classPK, ActionKeys.VIEW);
084:
085: return emailAddressLocalService.getEmailAddresses(getUser()
086: .getCompanyId(), className, classPK);
087: }
088:
089: public EmailAddress updateEmailAddress(long emailAddressId,
090: String address, int typeId, boolean primary)
091: throws PortalException, SystemException {
092:
093: EmailAddress emailAddress = emailAddressPersistence
094: .findByPrimaryKey(emailAddressId);
095:
096: CommonPermissionUtil.check(getPermissionChecker(), emailAddress
097: .getClassNameId(), emailAddress.getClassPK(),
098: ActionKeys.UPDATE);
099:
100: return emailAddressLocalService.updateEmailAddress(
101: emailAddressId, address, typeId, primary);
102: }
103:
104: }
|