1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
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.Website;
29  import com.liferay.portal.service.WebsiteLocalServiceUtil;
30  import com.liferay.portal.service.WebsiteService;
31  import com.liferay.portal.service.permission.CommonPermissionUtil;
32  import com.liferay.portal.service.persistence.WebsiteUtil;
33  
34  import java.util.List;
35  
36  /**
37   * <a href="WebsiteServiceImpl.java.html"><b><i>View Source</i></b></a>
38   *
39   * @author Brian Wing Shun Chan
40   *
41   */
42  public class WebsiteServiceImpl
43      extends PrincipalBean implements WebsiteService {
44  
45      public Website addWebsite(
46              String className, long classPK, String url, int typeId,
47              boolean primary)
48          throws PortalException, SystemException {
49  
50          CommonPermissionUtil.checkPermission(
51              getPermissionChecker(), className, classPK, ActionKeys.UPDATE);
52  
53          return WebsiteLocalServiceUtil.addWebsite(
54              getUserId(), className, classPK, url, typeId, primary);
55      }
56  
57      public void deleteWebsite(long websiteId)
58          throws PortalException, SystemException {
59  
60          Website website = WebsiteUtil.findByPrimaryKey(websiteId);
61  
62          CommonPermissionUtil.checkPermission(
63              getPermissionChecker(), website.getClassNameId(),
64              website.getClassPK(), ActionKeys.UPDATE);
65  
66          WebsiteLocalServiceUtil.deleteWebsite(websiteId);
67      }
68  
69      public Website getWebsite(long websiteId)
70          throws PortalException, SystemException {
71  
72          Website website = WebsiteUtil.findByPrimaryKey(websiteId);
73  
74          CommonPermissionUtil.checkPermission(
75              getPermissionChecker(), website.getClassNameId(),
76              website.getClassPK(), ActionKeys.VIEW);
77  
78          return website;
79      }
80  
81      public List getWebsites(String className, long classPK)
82          throws PortalException, SystemException {
83  
84          CommonPermissionUtil.checkPermission(
85              getPermissionChecker(), className, classPK, ActionKeys.VIEW);
86  
87          return WebsiteLocalServiceUtil.getWebsites(
88              getUser().getCompanyId(), className, classPK);
89      }
90  
91      public Website updateWebsite(
92              long websiteId, String url, int typeId, boolean primary)
93          throws PortalException, SystemException {
94  
95          Website website = WebsiteUtil.findByPrimaryKey(websiteId);
96  
97          CommonPermissionUtil.checkPermission(
98              getPermissionChecker(), website.getClassNameId(),
99              website.getClassPK(), ActionKeys.UPDATE);
100 
101         return WebsiteLocalServiceUtil.updateWebsite(
102             websiteId, url, typeId, primary);
103     }
104 
105 }