1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.model.Website;
20  import com.liferay.portal.security.permission.ActionKeys;
21  import com.liferay.portal.service.base.WebsiteServiceBaseImpl;
22  import com.liferay.portal.service.permission.CommonPermissionUtil;
23  
24  import java.util.List;
25  
26  /**
27   * <a href="WebsiteServiceImpl.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class WebsiteServiceImpl extends WebsiteServiceBaseImpl {
32  
33      public Website addWebsite(
34              String className, long classPK, String url, int typeId,
35              boolean primary)
36          throws PortalException, SystemException {
37  
38          CommonPermissionUtil.check(
39              getPermissionChecker(), className, classPK, ActionKeys.UPDATE);
40  
41          return websiteLocalService.addWebsite(
42              getUserId(), className, classPK, url, typeId, primary);
43      }
44  
45      public void deleteWebsite(long websiteId)
46          throws PortalException, SystemException {
47  
48          Website website = websitePersistence.findByPrimaryKey(websiteId);
49  
50          CommonPermissionUtil.check(
51              getPermissionChecker(), website.getClassNameId(),
52              website.getClassPK(), ActionKeys.UPDATE);
53  
54          websiteLocalService.deleteWebsite(websiteId);
55      }
56  
57      public Website getWebsite(long websiteId)
58          throws PortalException, SystemException {
59  
60          Website website = websitePersistence.findByPrimaryKey(websiteId);
61  
62          CommonPermissionUtil.check(
63              getPermissionChecker(), website.getClassNameId(),
64              website.getClassPK(), ActionKeys.VIEW);
65  
66          return website;
67      }
68  
69      public List<Website> getWebsites(String className, long classPK)
70          throws PortalException, SystemException {
71  
72          CommonPermissionUtil.check(
73              getPermissionChecker(), className, classPK, ActionKeys.VIEW);
74  
75          return websiteLocalService.getWebsites(
76              getUser().getCompanyId(), className, classPK);
77      }
78  
79      public Website updateWebsite(
80              long websiteId, String url, int typeId, boolean primary)
81          throws PortalException, SystemException {
82  
83          Website website = websitePersistence.findByPrimaryKey(websiteId);
84  
85          CommonPermissionUtil.check(
86              getPermissionChecker(), website.getClassNameId(),
87              website.getClassPK(), ActionKeys.UPDATE);
88  
89          return websiteLocalService.updateWebsite(
90              websiteId, url, typeId, primary);
91      }
92  
93  }