001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
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.Website;
020    import com.liferay.portal.security.permission.ActionKeys;
021    import com.liferay.portal.service.base.WebsiteServiceBaseImpl;
022    import com.liferay.portal.service.permission.CommonPermissionUtil;
023    
024    import java.util.List;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class WebsiteServiceImpl extends WebsiteServiceBaseImpl {
030    
031            public Website addWebsite(
032                            String className, long classPK, String url, int typeId,
033                            boolean primary)
034                    throws PortalException, SystemException {
035    
036                    CommonPermissionUtil.check(
037                            getPermissionChecker(), className, classPK, ActionKeys.UPDATE);
038    
039                    return websiteLocalService.addWebsite(
040                            getUserId(), className, classPK, url, typeId, primary);
041            }
042    
043            public void deleteWebsite(long websiteId)
044                    throws PortalException, SystemException {
045    
046                    Website website = websitePersistence.findByPrimaryKey(websiteId);
047    
048                    CommonPermissionUtil.check(
049                            getPermissionChecker(), website.getClassNameId(),
050                            website.getClassPK(), ActionKeys.UPDATE);
051    
052                    websiteLocalService.deleteWebsite(websiteId);
053            }
054    
055            public Website getWebsite(long websiteId)
056                    throws PortalException, SystemException {
057    
058                    Website website = websitePersistence.findByPrimaryKey(websiteId);
059    
060                    CommonPermissionUtil.check(
061                            getPermissionChecker(), website.getClassNameId(),
062                            website.getClassPK(), ActionKeys.VIEW);
063    
064                    return website;
065            }
066    
067            public List<Website> getWebsites(String className, long classPK)
068                    throws PortalException, SystemException {
069    
070                    CommonPermissionUtil.check(
071                            getPermissionChecker(), className, classPK, ActionKeys.VIEW);
072    
073                    return websiteLocalService.getWebsites(
074                            getUser().getCompanyId(), className, classPK);
075            }
076    
077            public Website updateWebsite(
078                            long websiteId, String url, int typeId, boolean primary)
079                    throws PortalException, SystemException {
080    
081                    Website website = websitePersistence.findByPrimaryKey(websiteId);
082    
083                    CommonPermissionUtil.check(
084                            getPermissionChecker(), website.getClassNameId(),
085                            website.getClassPK(), ActionKeys.UPDATE);
086    
087                    return websiteLocalService.updateWebsite(
088                            websiteId, url, typeId, primary);
089            }
090    
091    }