1
14
15 package com.liferay.portal.service.impl;
16
17 import com.liferay.portal.kernel.dao.orm.QueryUtil;
18 import com.liferay.portal.kernel.exception.PortalException;
19 import com.liferay.portal.kernel.exception.SystemException;
20 import com.liferay.portal.kernel.util.OrderByComparator;
21 import com.liferay.portal.model.LayoutSetPrototype;
22 import com.liferay.portal.model.User;
23 import com.liferay.portal.security.permission.ActionKeys;
24 import com.liferay.portal.service.base.LayoutSetPrototypeServiceBaseImpl;
25 import com.liferay.portal.service.permission.LayoutSetPrototypePermissionUtil;
26 import com.liferay.portal.service.permission.PortalPermissionUtil;
27
28 import java.util.ArrayList;
29 import java.util.List;
30 import java.util.Locale;
31 import java.util.Map;
32
33
39 public class LayoutSetPrototypeServiceImpl
40 extends LayoutSetPrototypeServiceBaseImpl {
41
42 public LayoutSetPrototype addLayoutSetPrototype(
43 Map<Locale, String> nameMap, String description,
44 boolean active)
45 throws PortalException, SystemException {
46
47 User user = getUser();
48
49 PortalPermissionUtil.check(
50 getPermissionChecker(), ActionKeys.ADD_LAYOUT_PROTOTYPE);
51
52 return layoutSetPrototypeLocalService.addLayoutSetPrototype(
53 user.getUserId(), user.getCompanyId(), nameMap, description,
54 active);
55 }
56
57 public void deleteLayoutSetPrototype(long layoutSetPrototypeId)
58 throws PortalException, SystemException {
59
60 LayoutSetPrototypePermissionUtil.check(
61 getPermissionChecker(), layoutSetPrototypeId, ActionKeys.DELETE);
62
63 layoutSetPrototypeLocalService.deleteLayoutSetPrototype(
64 layoutSetPrototypeId);
65 }
66
67 public LayoutSetPrototype getLayoutSetPrototype(long layoutSetPrototypeId)
68 throws PortalException, SystemException {
69
70 LayoutSetPrototypePermissionUtil.check(
71 getPermissionChecker(), layoutSetPrototypeId, ActionKeys.VIEW);
72
73 return layoutSetPrototypeLocalService.getLayoutSetPrototype(
74 layoutSetPrototypeId);
75 }
76
77 public List<LayoutSetPrototype> search(
78 long companyId, Boolean active, OrderByComparator obc)
79 throws PortalException, SystemException {
80
81 List<LayoutSetPrototype> filteredLayoutSetPrototypes =
82 new ArrayList<LayoutSetPrototype>();
83
84 List<LayoutSetPrototype> layoutSetPrototypes =
85 layoutSetPrototypeLocalService.search(
86 companyId, active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, obc);
87
88 for (LayoutSetPrototype layoutSetPrototype : layoutSetPrototypes) {
89 if (LayoutSetPrototypePermissionUtil.contains(
90 getPermissionChecker(),
91 layoutSetPrototype.getLayoutSetPrototypeId(),
92 ActionKeys.VIEW)) {
93
94 filteredLayoutSetPrototypes.add(layoutSetPrototype);
95 }
96 }
97
98 return filteredLayoutSetPrototypes;
99 }
100
101 public LayoutSetPrototype updateLayoutSetPrototype(
102 long layoutSetPrototypeId, Map<Locale, String> nameMap,
103 String description, boolean active)
104 throws PortalException, SystemException {
105
106 LayoutSetPrototypePermissionUtil.check(
107 getPermissionChecker(), layoutSetPrototypeId, ActionKeys.UPDATE);
108
109 return layoutSetPrototypeLocalService.updateLayoutSetPrototype(
110 layoutSetPrototypeId, nameMap, description, active);
111 }
112
113 }