1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.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  }