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.User;
020 import com.liferay.portal.model.Website;
021 import com.liferay.portal.security.permission.ActionKeys;
022 import com.liferay.portal.service.base.WebsiteServiceBaseImpl;
023 import com.liferay.portal.service.permission.CommonPermissionUtil;
024
025 import java.util.List;
026
027
030 public class WebsiteServiceImpl extends WebsiteServiceBaseImpl {
031
032 @Override
033 public Website addWebsite(
034 String className, long classPK, String url, int typeId,
035 boolean primary)
036 throws PortalException, SystemException {
037
038 CommonPermissionUtil.check(
039 getPermissionChecker(), className, classPK, ActionKeys.UPDATE);
040
041 return websiteLocalService.addWebsite(
042 getUserId(), className, classPK, url, typeId, primary);
043 }
044
045 @Override
046 public void deleteWebsite(long websiteId)
047 throws PortalException, SystemException {
048
049 Website website = websitePersistence.findByPrimaryKey(websiteId);
050
051 CommonPermissionUtil.check(
052 getPermissionChecker(), website.getClassNameId(),
053 website.getClassPK(), ActionKeys.UPDATE);
054
055 websiteLocalService.deleteWebsite(websiteId);
056 }
057
058 @Override
059 public Website getWebsite(long websiteId)
060 throws PortalException, SystemException {
061
062 Website website = websitePersistence.findByPrimaryKey(websiteId);
063
064 CommonPermissionUtil.check(
065 getPermissionChecker(), website.getClassNameId(),
066 website.getClassPK(), ActionKeys.VIEW);
067
068 return website;
069 }
070
071 @Override
072 public List<Website> getWebsites(String className, long classPK)
073 throws PortalException, SystemException {
074
075 CommonPermissionUtil.check(
076 getPermissionChecker(), className, classPK, ActionKeys.VIEW);
077
078 User user = getUser();
079
080 return websiteLocalService.getWebsites(
081 user.getCompanyId(), className, classPK);
082 }
083
084 @Override
085 public Website updateWebsite(
086 long websiteId, String url, int typeId, boolean primary)
087 throws PortalException, SystemException {
088
089 Website website = websitePersistence.findByPrimaryKey(websiteId);
090
091 CommonPermissionUtil.check(
092 getPermissionChecker(), website.getClassNameId(),
093 website.getClassPK(), ActionKeys.UPDATE);
094
095 return websiteLocalService.updateWebsite(
096 websiteId, url, typeId, primary);
097 }
098
099 }