001
014
015 package com.liferay.portal.service.impl;
016
017 import com.liferay.portal.kernel.dao.orm.QueryUtil;
018 import com.liferay.portal.kernel.exception.PortalException;
019 import com.liferay.portal.kernel.exception.SystemException;
020 import com.liferay.portal.kernel.util.OrderByComparator;
021 import com.liferay.portal.model.LayoutSetPrototype;
022 import com.liferay.portal.model.User;
023 import com.liferay.portal.security.permission.ActionKeys;
024 import com.liferay.portal.service.ServiceContext;
025 import com.liferay.portal.service.base.LayoutSetPrototypeServiceBaseImpl;
026 import com.liferay.portal.service.permission.LayoutSetPrototypePermissionUtil;
027 import com.liferay.portal.service.permission.PortalPermissionUtil;
028
029 import java.util.ArrayList;
030 import java.util.List;
031 import java.util.Locale;
032 import java.util.Map;
033
034
038 public class LayoutSetPrototypeServiceImpl
039 extends LayoutSetPrototypeServiceBaseImpl {
040
041 public LayoutSetPrototype addLayoutSetPrototype(
042 Map<Locale, String> nameMap, String description,
043 boolean active, boolean layoutsUpdateable,
044 ServiceContext serviceContext)
045 throws PortalException, SystemException {
046
047 PortalPermissionUtil.check(
048 getPermissionChecker(), ActionKeys.ADD_LAYOUT_PROTOTYPE);
049
050 User user = getUser();
051
052 return layoutSetPrototypeLocalService.addLayoutSetPrototype(
053 user.getUserId(), user.getCompanyId(), nameMap, description,
054 active, layoutsUpdateable, serviceContext);
055 }
056
057 public void deleteLayoutSetPrototype(long layoutSetPrototypeId)
058 throws PortalException, SystemException {
059
060 LayoutSetPrototypePermissionUtil.check(
061 getPermissionChecker(), layoutSetPrototypeId, ActionKeys.DELETE);
062
063 layoutSetPrototypeLocalService.deleteLayoutSetPrototype(
064 layoutSetPrototypeId);
065 }
066
067 public LayoutSetPrototype getLayoutSetPrototype(long layoutSetPrototypeId)
068 throws PortalException, SystemException {
069
070 LayoutSetPrototypePermissionUtil.check(
071 getPermissionChecker(), layoutSetPrototypeId, ActionKeys.VIEW);
072
073 return layoutSetPrototypeLocalService.getLayoutSetPrototype(
074 layoutSetPrototypeId);
075 }
076
077 public List<LayoutSetPrototype> search(
078 long companyId, Boolean active, OrderByComparator obc)
079 throws PortalException, SystemException {
080
081 List<LayoutSetPrototype> filteredLayoutSetPrototypes =
082 new ArrayList<LayoutSetPrototype>();
083
084 List<LayoutSetPrototype> layoutSetPrototypes =
085 layoutSetPrototypeLocalService.search(
086 companyId, active, QueryUtil.ALL_POS, QueryUtil.ALL_POS, obc);
087
088 for (LayoutSetPrototype layoutSetPrototype : layoutSetPrototypes) {
089 if (LayoutSetPrototypePermissionUtil.contains(
090 getPermissionChecker(),
091 layoutSetPrototype.getLayoutSetPrototypeId(),
092 ActionKeys.VIEW)) {
093
094 filteredLayoutSetPrototypes.add(layoutSetPrototype);
095 }
096 }
097
098 return filteredLayoutSetPrototypes;
099 }
100
101 public LayoutSetPrototype updateLayoutSetPrototype(
102 long layoutSetPrototypeId, Map<Locale, String> nameMap,
103 String description, boolean active, boolean layoutsUpdateable,
104 ServiceContext serviceContext)
105 throws PortalException, SystemException {
106
107 LayoutSetPrototypePermissionUtil.check(
108 getPermissionChecker(), layoutSetPrototypeId, ActionKeys.UPDATE);
109
110 return layoutSetPrototypeLocalService.updateLayoutSetPrototype(
111 layoutSetPrototypeId, nameMap, description, active,
112 layoutsUpdateable, serviceContext);
113 }
114
115 public LayoutSetPrototype updateLayoutSetPrototype(
116 long layoutSetPrototypeId, String settings)
117 throws PortalException, SystemException {
118
119 return layoutSetPrototypeLocalService.updateLayoutSetPrototype(
120 layoutSetPrototypeId, settings);
121 }
122
123 }