001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.service.impl;
022:
023: import com.liferay.portal.PortalException;
024: import com.liferay.portal.SystemException;
025: import com.liferay.portal.kernel.security.permission.ActionKeys;
026: import com.liferay.portal.kernel.util.LocaleUtil;
027: import com.liferay.portal.model.Layout;
028: import com.liferay.portal.model.LayoutReference;
029: import com.liferay.portal.model.impl.ThemeImpl;
030: import com.liferay.portal.service.base.LayoutServiceBaseImpl;
031: import com.liferay.portal.service.permission.GroupPermissionUtil;
032: import com.liferay.portal.service.permission.LayoutPermissionUtil;
033:
034: import java.io.File;
035: import java.io.InputStream;
036:
037: import java.util.HashMap;
038: import java.util.Locale;
039: import java.util.Map;
040:
041: /**
042: * <a href="LayoutServiceImpl.java.html"><b><i>View Source</i></b></a>
043: *
044: * @author Brian Wing Shun Chan
045: *
046: */
047: public class LayoutServiceImpl extends LayoutServiceBaseImpl {
048:
049: public Layout addLayout(long groupId, boolean privateLayout,
050: long parentLayoutId, String name, String title,
051: String description, String type, boolean hidden,
052: String friendlyURL) throws PortalException, SystemException {
053:
054: Map localeNamesMap = new HashMap();
055:
056: Locale defaultLocale = LocaleUtil.getDefault();
057:
058: localeNamesMap.put(defaultLocale, name);
059:
060: return addLayout(groupId, privateLayout, parentLayoutId,
061: localeNamesMap, new HashMap(), description, type,
062: hidden, friendlyURL);
063: }
064:
065: public Layout addLayout(long groupId, boolean privateLayout,
066: long parentLayoutId, Map localeNamesMap,
067: Map localeTitlesMap, String description, String type,
068: boolean hidden, String friendlyURL) throws PortalException,
069: SystemException {
070:
071: GroupPermissionUtil.check(getPermissionChecker(), groupId,
072: ActionKeys.MANAGE_LAYOUTS);
073:
074: return layoutLocalService
075: .addLayout(getUserId(), groupId, privateLayout,
076: parentLayoutId, localeNamesMap,
077: localeTitlesMap, description, type, hidden,
078: friendlyURL);
079: }
080:
081: public void deleteLayout(long plid) throws PortalException,
082: SystemException {
083:
084: LayoutPermissionUtil.check(getPermissionChecker(), plid,
085: ActionKeys.DELETE);
086:
087: layoutLocalService.deleteLayout(plid);
088: }
089:
090: public void deleteLayout(long groupId, boolean privateLayout,
091: long layoutId) throws PortalException, SystemException {
092:
093: LayoutPermissionUtil.check(getPermissionChecker(), groupId,
094: privateLayout, layoutId, ActionKeys.DELETE);
095:
096: layoutLocalService.deleteLayout(groupId, privateLayout,
097: layoutId);
098: }
099:
100: public String getLayoutName(long groupId, boolean privateLayout,
101: long layoutId, String languageId) throws PortalException,
102: SystemException {
103:
104: Layout layout = layoutLocalService.getLayout(groupId,
105: privateLayout, layoutId);
106:
107: return layout.getName(languageId);
108: }
109:
110: public LayoutReference[] getLayoutReferences(long companyId,
111: String portletId, String prefsKey, String prefsValue)
112: throws SystemException {
113:
114: return layoutLocalService.getLayouts(companyId, portletId,
115: prefsKey, prefsValue);
116: }
117:
118: public byte[] exportLayouts(long groupId, boolean privateLayout,
119: Map parameterMap) throws PortalException, SystemException {
120:
121: GroupPermissionUtil.check(getPermissionChecker(), groupId,
122: ActionKeys.MANAGE_LAYOUTS);
123:
124: return layoutLocalService.exportLayouts(groupId, privateLayout,
125: parameterMap);
126: }
127:
128: public byte[] exportLayouts(long groupId, boolean privateLayout,
129: long[] layoutIds, Map parameterMap) throws PortalException,
130: SystemException {
131:
132: GroupPermissionUtil.check(getPermissionChecker(), groupId,
133: ActionKeys.MANAGE_LAYOUTS);
134:
135: return layoutLocalService.exportLayouts(groupId, privateLayout,
136: layoutIds, parameterMap);
137: }
138:
139: public byte[] exportPortletInfo(long plid, String portletId,
140: Map parameterMap) throws PortalException, SystemException {
141:
142: Layout layout = layoutLocalService.getLayout(plid);
143:
144: GroupPermissionUtil.check(getPermissionChecker(), layout
145: .getGroupId(), ActionKeys.MANAGE_LAYOUTS);
146:
147: return layoutLocalService.exportPortletInfo(plid, portletId,
148: parameterMap);
149: }
150:
151: public void importLayouts(long groupId, boolean privateLayout,
152: Map parameterMap, File file) throws PortalException,
153: SystemException {
154:
155: GroupPermissionUtil.check(getPermissionChecker(), groupId,
156: ActionKeys.MANAGE_LAYOUTS);
157:
158: layoutLocalService.importLayouts(getUserId(), groupId,
159: privateLayout, parameterMap, file);
160: }
161:
162: public void importLayouts(long groupId, boolean privateLayout,
163: Map parameterMap, InputStream is) throws PortalException,
164: SystemException {
165:
166: GroupPermissionUtil.check(getPermissionChecker(), groupId,
167: ActionKeys.MANAGE_LAYOUTS);
168:
169: layoutLocalService.importLayouts(getUserId(), groupId,
170: privateLayout, parameterMap, is);
171: }
172:
173: public void importPortletInfo(long plid, String portletId,
174: Map parameterMap, File file) throws PortalException,
175: SystemException {
176:
177: Layout layout = layoutLocalService.getLayout(plid);
178:
179: GroupPermissionUtil.check(getPermissionChecker(), layout
180: .getGroupId(), ActionKeys.MANAGE_LAYOUTS);
181:
182: layoutLocalService.importPortletInfo(getUserId(), plid,
183: portletId, parameterMap, file);
184: }
185:
186: public void importPortletInfo(long plid, String portletId,
187: Map parameterMap, InputStream is) throws PortalException,
188: SystemException {
189:
190: Layout layout = layoutLocalService.getLayout(plid);
191:
192: GroupPermissionUtil.check(getPermissionChecker(), layout
193: .getGroupId(), ActionKeys.MANAGE_LAYOUTS);
194:
195: layoutLocalService.importPortletInfo(getUserId(), plid,
196: portletId, parameterMap, is);
197: }
198:
199: public void setLayouts(long groupId, boolean privateLayout,
200: long parentLayoutId, long[] layoutIds)
201: throws PortalException, SystemException {
202:
203: GroupPermissionUtil.check(getPermissionChecker(), groupId,
204: ActionKeys.MANAGE_LAYOUTS);
205:
206: layoutLocalService.setLayouts(groupId, privateLayout,
207: parentLayoutId, layoutIds);
208: }
209:
210: public Layout updateLayout(long groupId, boolean privateLayout,
211: long layoutId, long parentLayoutId, Map localeNamesMap,
212: Map localeTitlesMap, String description, String type,
213: boolean hidden, String friendlyURL) throws PortalException,
214: SystemException {
215:
216: LayoutPermissionUtil.check(getPermissionChecker(), groupId,
217: privateLayout, layoutId, ActionKeys.UPDATE);
218:
219: return layoutLocalService
220: .updateLayout(groupId, privateLayout, layoutId,
221: parentLayoutId, localeNamesMap,
222: localeTitlesMap, description, type, hidden,
223: friendlyURL);
224: }
225:
226: public Layout updateLayout(long groupId, boolean privateLayout,
227: long layoutId, long parentLayoutId, Map localeNamesMap,
228: Map localeTitlesMap, String description, String type,
229: boolean hidden, String friendlyURL, Boolean iconImage,
230: byte[] iconBytes) throws PortalException, SystemException {
231:
232: LayoutPermissionUtil.check(getPermissionChecker(), groupId,
233: privateLayout, layoutId, ActionKeys.UPDATE);
234:
235: return layoutLocalService.updateLayout(groupId, privateLayout,
236: layoutId, parentLayoutId, localeNamesMap,
237: localeTitlesMap, description, type, hidden,
238: friendlyURL, iconImage, iconBytes);
239: }
240:
241: public Layout updateLayout(long groupId, boolean privateLayout,
242: long layoutId, String typeSettings) throws PortalException,
243: SystemException {
244:
245: LayoutPermissionUtil.check(getPermissionChecker(), groupId,
246: privateLayout, layoutId, ActionKeys.UPDATE);
247:
248: return layoutLocalService.updateLayout(groupId, privateLayout,
249: layoutId, typeSettings);
250: }
251:
252: public Layout updateLookAndFeel(long groupId,
253: boolean privateLayout, long layoutId, String themeId,
254: String colorSchemeId, String css, boolean wapTheme)
255: throws PortalException, SystemException {
256:
257: LayoutPermissionUtil.check(getPermissionChecker(), groupId,
258: privateLayout, layoutId, ActionKeys.UPDATE);
259:
260: pluginSettingLocalService.checkPermission(getUserId(), themeId,
261: ThemeImpl.PLUGIN_TYPE);
262:
263: return layoutLocalService.updateLookAndFeel(groupId,
264: privateLayout, layoutId, themeId, colorSchemeId, css,
265: wapTheme);
266: }
267:
268: public Layout updateName(long plid, String name, String languageId)
269: throws PortalException, SystemException {
270:
271: LayoutPermissionUtil.check(getPermissionChecker(), plid,
272: ActionKeys.UPDATE);
273:
274: return layoutLocalService.updateName(plid, name, languageId);
275: }
276:
277: public Layout updateName(long groupId, boolean privateLayout,
278: long layoutId, String name, String languageId)
279: throws PortalException, SystemException {
280:
281: LayoutPermissionUtil.check(getPermissionChecker(), groupId,
282: privateLayout, layoutId, ActionKeys.UPDATE);
283:
284: return layoutLocalService.updateName(groupId, privateLayout,
285: layoutId, name, languageId);
286: }
287:
288: public Layout updateParentLayoutId(long plid, long parentPlid)
289: throws PortalException, SystemException {
290:
291: LayoutPermissionUtil.check(getPermissionChecker(), plid,
292: ActionKeys.UPDATE);
293:
294: return layoutLocalService
295: .updateParentLayoutId(plid, parentPlid);
296: }
297:
298: public Layout updateParentLayoutId(long groupId,
299: boolean privateLayout, long layoutId, long parentLayoutId)
300: throws PortalException, SystemException {
301:
302: LayoutPermissionUtil.check(getPermissionChecker(), groupId,
303: privateLayout, layoutId, ActionKeys.UPDATE);
304:
305: return layoutLocalService.updateParentLayoutId(groupId,
306: privateLayout, layoutId, parentLayoutId);
307: }
308:
309: public Layout updatePriority(long plid, int priority)
310: throws PortalException, SystemException {
311:
312: LayoutPermissionUtil.check(getPermissionChecker(), plid,
313: ActionKeys.UPDATE);
314:
315: return layoutLocalService.updatePriority(plid, priority);
316: }
317:
318: public Layout updatePriority(long groupId, boolean privateLayout,
319: long layoutId, int priority) throws PortalException,
320: SystemException {
321:
322: LayoutPermissionUtil.check(getPermissionChecker(), groupId,
323: privateLayout, layoutId, ActionKeys.UPDATE);
324:
325: return layoutLocalService.updatePriority(groupId,
326: privateLayout, layoutId, priority);
327: }
328:
329: }
|