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