001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.sites.util;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
020    import com.liferay.portal.model.Group;
021    import com.liferay.portal.model.Layout;
022    import com.liferay.portal.model.LayoutPrototype;
023    import com.liferay.portal.model.LayoutSet;
024    import com.liferay.portal.model.LayoutSetPrototype;
025    import com.liferay.portal.model.User;
026    import com.liferay.portal.security.permission.PermissionChecker;
027    import com.liferay.portal.service.ServiceContext;
028    
029    import java.io.File;
030    import java.io.InputStream;
031    
032    import java.util.List;
033    import java.util.Map;
034    
035    import javax.portlet.ActionRequest;
036    import javax.portlet.ActionResponse;
037    import javax.portlet.PortletPreferences;
038    import javax.portlet.PortletURL;
039    import javax.portlet.RenderRequest;
040    import javax.portlet.RenderResponse;
041    
042    import javax.servlet.http.HttpServletRequest;
043    import javax.servlet.http.HttpServletResponse;
044    
045    /**
046     * @author Raymond Aug??
047     * @author Ryan Park
048     * @author Zsolt Berentey
049     */
050    public class SitesUtil {
051    
052            public static void addMergeFailFriendlyURLLayout(Layout layout)
053                    throws PortalException, SystemException {
054    
055                    getSites().addMergeFailFriendlyURLLayout(layout);
056            }
057    
058            public static void addPortletBreadcrumbEntries(
059                            Group group, HttpServletRequest request,
060                            RenderResponse renderResponse)
061                    throws Exception {
062    
063                    getSites().addPortletBreadcrumbEntries(group, request, renderResponse);
064            }
065    
066            public static void addPortletBreadcrumbEntries(
067                            Group group, String pagesName, PortletURL redirectURL,
068                            HttpServletRequest request, RenderResponse renderResponse)
069                    throws Exception {
070    
071                    getSites().addPortletBreadcrumbEntries(
072                            group, pagesName, redirectURL, request, renderResponse);
073            }
074    
075            public static void applyLayoutPrototype(
076                            LayoutPrototype layoutPrototype, Layout targetLayout,
077                            boolean linkEnabled)
078                    throws Exception {
079    
080                    getSites().applyLayoutPrototype(
081                            layoutPrototype, targetLayout, linkEnabled);
082            }
083    
084            public static void copyLayout(
085                            long userId, Layout sourceLayout, Layout targetLayout,
086                            ServiceContext serviceContext)
087                    throws Exception {
088    
089                    getSites().copyLayout(
090                            userId, sourceLayout, targetLayout, serviceContext);
091            }
092    
093            public static void copyLookAndFeel(Layout targetLayout, Layout sourceLayout)
094                    throws Exception {
095    
096                    getSites().copyLookAndFeel(targetLayout, sourceLayout);
097            }
098    
099            public static void copyPortletPermissions(
100                            Layout targetLayout, Layout sourceLayout)
101                    throws Exception {
102    
103                    getSites().copyPortletPermissions(targetLayout, sourceLayout);
104            }
105    
106            public static void copyPortletSetups(
107                            Layout sourceLayout, Layout targetLayout)
108                    throws Exception {
109    
110                    getSites().copyPortletSetups(sourceLayout, targetLayout);
111            }
112    
113            public static void copyTypeSettings(Group sourceGroup, Group targetGroup)
114                    throws Exception {
115    
116                    getSites().copyTypeSettings(sourceGroup, targetGroup);
117            }
118    
119            public static Object[] deleteLayout(
120                            ActionRequest actionRequest, ActionResponse actionResponse)
121                    throws Exception {
122    
123                    return getSites().deleteLayout(actionRequest, actionResponse);
124            }
125    
126            public static Object[] deleteLayout(
127                            HttpServletRequest request, HttpServletResponse response)
128                    throws Exception {
129    
130                    return getSites().deleteLayout(request, response);
131            }
132    
133            public static void deleteLayout(
134                            RenderRequest renderRequest, RenderResponse renderResponse)
135                    throws Exception {
136    
137                    getSites().deleteLayout(renderRequest, renderResponse);
138            }
139    
140            public static File exportLayoutSetPrototype(
141                            LayoutSetPrototype layoutSetPrototype,
142                            ServiceContext serviceContext)
143                    throws PortalException, SystemException {
144    
145                    return getSites().exportLayoutSetPrototype(
146                            layoutSetPrototype, serviceContext);
147            }
148    
149            public static Long[] filterGroups(List<Group> groups, String[] names) {
150                    return getSites().filterGroups(groups, names);
151            }
152    
153            public static Layout getLayoutSetPrototypeLayout(Layout layout) {
154                    return getSites().getLayoutSetPrototypeLayout(layout);
155            }
156    
157            public static Map<String, String[]> getLayoutSetPrototypeParameters(
158                    ServiceContext serviceContext) {
159    
160                    return getSites().getLayoutSetPrototypeParameters(serviceContext);
161            }
162    
163            public static int getMergeFailCount(LayoutPrototype layoutPrototype)
164                    throws PortalException, SystemException {
165    
166                    return getSites().getMergeFailCount(layoutPrototype);
167            }
168    
169            public static int getMergeFailCount(LayoutSetPrototype layoutSetPrototype)
170                    throws PortalException, SystemException {
171    
172                    return getSites().getMergeFailCount(layoutSetPrototype);
173            }
174    
175            public static List<Layout> getMergeFailFriendlyURLLayouts(
176                            LayoutSet layoutSet)
177                    throws PortalException, SystemException {
178    
179                    return getSites().getMergeFailFriendlyURLLayouts(layoutSet);
180            }
181    
182            public static Sites getSites() {
183                    PortalRuntimePermission.checkGetBeanProperty(SitesUtil.class);
184    
185                    return _sites;
186            }
187    
188            public static void importLayoutSetPrototype(
189                            LayoutSetPrototype layoutSetPrototype, InputStream inputStream,
190                            ServiceContext serviceContext)
191                    throws PortalException, SystemException {
192    
193                    getSites().importLayoutSetPrototype(
194                            layoutSetPrototype, inputStream, serviceContext);
195            }
196    
197            public static boolean isContentSharingWithChildrenEnabled(Group group)
198                    throws SystemException {
199    
200                    return getSites().isContentSharingWithChildrenEnabled(group);
201            }
202    
203            public static boolean isLayoutDeleteable(Layout layout) {
204                    return getSites().isLayoutDeleteable(layout);
205            }
206    
207            public static boolean isLayoutModifiedSinceLastMerge(Layout layout)
208                    throws PortalException, SystemException {
209    
210                    return getSites().isLayoutModifiedSinceLastMerge(layout);
211            }
212    
213            public static boolean isLayoutSetMergeable(Group group, LayoutSet layoutSet)
214                    throws PortalException, SystemException {
215    
216                    return getSites().isLayoutSetMergeable(group, layoutSet);
217            }
218    
219            public static boolean isLayoutSetPrototypeUpdateable(LayoutSet layoutSet) {
220                    return getSites().isLayoutSetPrototypeUpdateable(layoutSet);
221            }
222    
223            public static boolean isLayoutSortable(Layout layout) {
224                    return getSites().isLayoutSortable(layout);
225            }
226    
227            public static boolean isLayoutUpdateable(Layout layout) {
228                    return getSites().isLayoutUpdateable(layout);
229            }
230    
231            public static boolean isOrganizationUser(
232                            long companyId, Group group, User user,
233                            List<String> organizationNames)
234                    throws Exception {
235    
236                    return getSites().isOrganizationUser(
237                            companyId, group, user, organizationNames);
238            }
239    
240            public static boolean isUserGroupLayoutSetViewable(
241                            PermissionChecker permissionChecker, Group userGroupGroup)
242                    throws PortalException, SystemException {
243    
244                    return getSites().isUserGroupLayoutSetViewable(
245                            permissionChecker, userGroupGroup);
246            }
247    
248            public static boolean isUserGroupUser(
249                            long companyId, Group group, User user, List<String> userGroupNames)
250                    throws Exception {
251    
252                    return getSites().isUserGroupUser(
253                            companyId, group, user, userGroupNames);
254            }
255    
256            public static void mergeLayoutPrototypeLayout(Group group, Layout layout)
257                    throws Exception {
258    
259                    getSites().mergeLayoutPrototypeLayout(group, layout);
260            }
261    
262            /**
263             * @deprecated As of 6.2.0, replaced by {@link
264             *             #mergeLayoutPrototypeLayout(Group, Layout)}
265             */
266            public static void mergeLayoutProtypeLayout(Group group, Layout layout)
267                    throws Exception {
268    
269                    getSites().mergeLayoutProtypeLayout(group, layout);
270            }
271    
272            public static void mergeLayoutSetPrototypeLayouts(
273                            Group group, LayoutSet layoutSet)
274                    throws Exception {
275    
276                    getSites().mergeLayoutSetPrototypeLayouts(group, layoutSet);
277            }
278    
279            /**
280             * @deprecated As of 6.2.0, replaced by {@link
281             *             #mergeLayoutSetPrototypeLayouts(Group, LayoutSet)}
282             */
283            public static void mergeLayoutSetProtypeLayouts(
284                            Group group, LayoutSet layoutSet)
285                    throws Exception {
286    
287                    getSites().mergeLayoutSetProtypeLayouts(group, layoutSet);
288            }
289    
290            public static void removeMergeFailFriendlyURLLayouts(LayoutSet layoutSet)
291                    throws SystemException {
292    
293                    getSites().removeMergeFailFriendlyURLLayouts(layoutSet);
294            }
295    
296            public static void resetPrototype(Layout layout)
297                    throws PortalException, SystemException {
298    
299                    getSites().resetPrototype(layout);
300            }
301    
302            public static void resetPrototype(LayoutSet layoutSet)
303                    throws PortalException, SystemException {
304    
305                    getSites().resetPrototype(layoutSet);
306            }
307    
308            public static void setMergeFailCount(
309                            LayoutPrototype layoutPrototype, int newMergeFailCount)
310                    throws PortalException, SystemException {
311    
312                    getSites().setMergeFailCount(layoutPrototype, newMergeFailCount);
313            }
314    
315            public static void setMergeFailCount(
316                            LayoutSetPrototype layoutSetPrototype, int newMergeFailCount)
317                    throws PortalException, SystemException {
318    
319                    getSites().setMergeFailCount(layoutSetPrototype, newMergeFailCount);
320            }
321    
322            public static void updateLayoutScopes(
323                            long userId, Layout sourceLayout, Layout targetLayout,
324                            PortletPreferences sourcePreferences,
325                            PortletPreferences targetPreferences, String sourcePortletId,
326                            String languageId)
327                    throws Exception {
328    
329                    getSites().updateLayoutScopes(
330                            userId, sourceLayout, targetLayout, sourcePreferences,
331                            targetPreferences, sourcePortletId, languageId);
332            }
333    
334            public static void updateLayoutSetPrototypesLinks(
335                            Group group, long publicLayoutSetPrototypeId,
336                            long privateLayoutSetPrototypeId,
337                            boolean publicLayoutSetPrototypeLinkEnabled,
338                            boolean privateLayoutSetPrototypeLinkEnabled)
339                    throws Exception {
340    
341                    getSites().updateLayoutSetPrototypesLinks(
342                            group, publicLayoutSetPrototypeId, privateLayoutSetPrototypeId,
343                            publicLayoutSetPrototypeLinkEnabled,
344                            privateLayoutSetPrototypeLinkEnabled);
345            }
346    
347            public void setSites(Sites sites) {
348                    PortalRuntimePermission.checkSetBeanProperty(getClass());
349    
350                    _sites = sites;
351            }
352    
353            private static Sites _sites;
354    
355    }