1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.shopping.service.impl;
21  
22  import com.liferay.portal.PortalException;
23  import com.liferay.portal.SystemException;
24  import com.liferay.portal.security.permission.ActionKeys;
25  import com.liferay.portlet.shopping.model.ShoppingCategory;
26  import com.liferay.portlet.shopping.service.base.ShoppingCategoryServiceBaseImpl;
27  import com.liferay.portlet.shopping.service.permission.ShoppingCategoryPermission;
28  
29  /**
30   * <a href="ShoppingCategoryServiceImpl.java.html"><b><i>View Source</i></b></a>
31   *
32   * @author Brian Wing Shun Chan
33   *
34   */
35  public class ShoppingCategoryServiceImpl
36      extends ShoppingCategoryServiceBaseImpl {
37  
38      public ShoppingCategory addCategory(
39              long plid, long parentCategoryId, String name, String description,
40              boolean addCommunityPermissions, boolean addGuestPermissions)
41          throws PortalException, SystemException {
42  
43          ShoppingCategoryPermission.check(
44              getPermissionChecker(), plid, parentCategoryId,
45              ActionKeys.ADD_CATEGORY);
46  
47          return shoppingCategoryLocalService.addCategory(
48              getUserId(), plid, parentCategoryId, name, description,
49              addCommunityPermissions, addGuestPermissions);
50      }
51  
52      public ShoppingCategory addCategory(
53              long plid, long parentCategoryId, String name, String description,
54              String[] communityPermissions, String[] guestPermissions)
55          throws PortalException, SystemException {
56  
57          ShoppingCategoryPermission.check(
58              getPermissionChecker(), plid, parentCategoryId,
59              ActionKeys.ADD_CATEGORY);
60  
61          return shoppingCategoryLocalService.addCategory(
62              getUserId(), plid, parentCategoryId, name, description,
63              communityPermissions, guestPermissions);
64      }
65  
66      public void deleteCategory(long categoryId)
67          throws PortalException, SystemException {
68  
69          ShoppingCategoryPermission.check(
70              getPermissionChecker(), categoryId, ActionKeys.DELETE);
71  
72          shoppingCategoryLocalService.deleteCategory(categoryId);
73      }
74  
75      public ShoppingCategory getCategory(long categoryId)
76          throws PortalException, SystemException {
77  
78          ShoppingCategoryPermission.check(
79              getPermissionChecker(), categoryId, ActionKeys.VIEW);
80  
81          return shoppingCategoryLocalService.getCategory(categoryId);
82      }
83  
84      public ShoppingCategory updateCategory(
85              long categoryId, long parentCategoryId, String name,
86              String description, boolean mergeWithParentCategory)
87          throws PortalException, SystemException {
88  
89          ShoppingCategoryPermission.check(
90              getPermissionChecker(), categoryId, ActionKeys.UPDATE);
91  
92          return shoppingCategoryLocalService.updateCategory(
93              categoryId, parentCategoryId, name, description,
94              mergeWithParentCategory);
95      }
96  
97  }