001    /**
002     * Copyright (c) 2000-2012 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.portal.kernel.staging;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.lar.PortletDataContext;
020    import com.liferay.portal.kernel.xml.Element;
021    import com.liferay.portal.model.Group;
022    import com.liferay.portal.model.Layout;
023    import com.liferay.portal.model.Portlet;
024    import com.liferay.portal.model.User;
025    import com.liferay.portal.service.ServiceContext;
026    
027    import java.util.Date;
028    import java.util.List;
029    import java.util.Map;
030    
031    import javax.portlet.PortletRequest;
032    
033    import javax.servlet.http.HttpServletRequest;
034    
035    /**
036     * @author Raymond Augé
037     */
038    public class StagingUtil {
039    
040            public static String buildRemoteURL(
041                    String remoteAddress, int remotePort, boolean secureConnection,
042                    long remoteGroupId, boolean privateLayout) {
043    
044                    return getStaging().buildRemoteURL(
045                            remoteAddress, remotePort, secureConnection, remoteGroupId,
046                            privateLayout);
047            }
048    
049            public static void copyFromLive(PortletRequest PortletRequest)
050                    throws Exception {
051    
052                    getStaging().copyFromLive(PortletRequest);
053            }
054    
055            public static void copyFromLive(
056                            PortletRequest PortletRequest, Portlet portlet)
057                    throws Exception {
058    
059                    getStaging().copyFromLive(PortletRequest, portlet);
060            }
061    
062            public static void copyPortlet(
063                            PortletRequest PortletRequest, long sourceGroupId,
064                            long targetGroupId, long sourcePlid, long targetPlid,
065                            String portletId)
066                    throws Exception {
067    
068                    getStaging().copyPortlet(
069                            PortletRequest, sourceGroupId, targetGroupId, sourcePlid,
070                            targetPlid, portletId);
071            }
072    
073            public static void copyRemoteLayouts(
074                            long sourceGroupId, boolean privateLayout,
075                            Map<Long, Boolean> layoutIdMap, Map<String, String[]> parameterMap,
076                            String remoteAddress, int remotePort, boolean secureConnection,
077                            long remoteGroupId, boolean remotePrivateLayout, Date startDate,
078                            Date endDate)
079                    throws Exception {
080    
081                    getStaging().copyRemoteLayouts(
082                            sourceGroupId, privateLayout, layoutIdMap, parameterMap,
083                            remoteAddress, remotePort, secureConnection, remoteGroupId,
084                            remotePrivateLayout, startDate, endDate);
085            }
086    
087            public static void deleteLastImportSettings(
088                            Group liveGroup, boolean privateLayout)
089                    throws Exception {
090    
091                    getStaging().deleteLastImportSettings(liveGroup, privateLayout);
092            }
093    
094            public static void deleteRecentLayoutRevisionId(
095                            HttpServletRequest request, long layoutSetBranchId, long plid)
096                    throws SystemException {
097    
098                    getStaging().deleteRecentLayoutRevisionId(
099                            request, layoutSetBranchId, plid);
100            }
101    
102            public static void deleteRecentLayoutRevisionId(
103                            User user, long layoutSetBranchId, long plid)
104                    throws SystemException {
105    
106                    getStaging().deleteRecentLayoutRevisionId(
107                            user, layoutSetBranchId, plid);
108            }
109    
110            public static void disableStaging(
111                            Group scopeGroup, Group liveGroup, ServiceContext serviceContext)
112                    throws Exception {
113    
114                    getStaging().disableStaging(scopeGroup, liveGroup, serviceContext);
115            }
116    
117            public static void disableStaging(
118                            PortletRequest portletRequest, Group scopeGroup, Group liveGroup,
119                            ServiceContext serviceContext)
120                    throws Exception {
121    
122                    getStaging().disableStaging(
123                            portletRequest, scopeGroup, liveGroup, serviceContext);
124            }
125    
126            public static void enableLocalStaging(
127                            long userId, Group scopeGroup, Group liveGroup,
128                            boolean branchingPublic, boolean branchingPrivate,
129                            ServiceContext serviceContext)
130                    throws Exception {
131    
132                    getStaging().enableLocalStaging(
133                            userId, scopeGroup, liveGroup, branchingPublic, branchingPrivate,
134                            serviceContext);
135            }
136    
137            public static void enableRemoteStaging(
138                            long userId, Group scopeGroup, Group liveGroup,
139                            boolean branchingPublic, boolean branchingPrivate,
140                            String remoteAddress, long remoteGroupId, int remotePort,
141                            boolean secureConnection, ServiceContext serviceContext)
142                    throws Exception {
143    
144                    getStaging().enableRemoteStaging(
145                            userId, scopeGroup, liveGroup, branchingPublic, branchingPrivate,
146                            remoteAddress, remoteGroupId, remotePort, secureConnection,
147                            serviceContext);
148            }
149    
150            public static Group getLiveGroup(long groupId)
151                    throws PortalException, SystemException {
152    
153                    return getStaging().getLiveGroup(groupId);
154            }
155    
156            public static long getLiveGroupId(long groupId)
157                    throws PortalException, SystemException {
158    
159                    return getStaging().getLiveGroupId(groupId);
160            }
161    
162            public static List<Layout> getMissingParentLayouts(
163                            Layout layout, long liveGroupId)
164                    throws Exception {
165    
166                    return getStaging().getMissingParentLayouts(layout, liveGroupId);
167            }
168    
169            public static long getRecentLayoutRevisionId(
170                            HttpServletRequest request, long layoutSetBranchId, long plid)
171                    throws PortalException, SystemException{
172    
173                    return getStaging().getRecentLayoutRevisionId(
174                            request, layoutSetBranchId, plid);
175            }
176    
177            public static long getRecentLayoutRevisionId(
178                            User user, long layoutSetBranchId, long plid)
179                    throws PortalException, SystemException {
180    
181                    return getStaging().getRecentLayoutRevisionId(
182                            user, layoutSetBranchId, plid);
183            }
184    
185            public static long getRecentLayoutSetBranchId(
186                    HttpServletRequest request, long layoutSetId) {
187    
188                    return getStaging().getRecentLayoutSetBranchId(request, layoutSetId);
189            }
190    
191            public static long getRecentLayoutSetBranchId(User user, long layoutSetId)
192                    throws SystemException {
193    
194                    return getStaging().getRecentLayoutSetBranchId(user, layoutSetId);
195            }
196    
197            public static String getSchedulerGroupName(
198                    String destinationName, long groupId) {
199    
200                    return getStaging().getSchedulerGroupName(destinationName, groupId);
201            }
202    
203            public static Staging getStaging() {
204                    return _staging;
205            }
206    
207            public static Map<String, String[]> getStagingParameters() {
208                    return getStaging().getStagingParameters();
209            }
210    
211            public static Map<String, String[]> getStagingParameters(
212                    PortletRequest PortletRequest) {
213    
214                    return getStaging().getStagingParameters(PortletRequest);
215            }
216    
217            public static boolean isIncomplete(Layout layout, long layoutSetBranchId) {
218                    return getStaging().isIncomplete(layout, layoutSetBranchId);
219            }
220    
221            public static void publishLayout(
222                            long userId, long plid, long liveGroupId, boolean includeChildren)
223                    throws Exception {
224    
225                    getStaging().publishLayout(userId, plid, liveGroupId, includeChildren);
226            }
227    
228            public static void publishLayouts(
229                            long userId, long sourceGroupId, long targetGroupId,
230                            boolean privateLayout, long[] layoutIds,
231                            Map<String, String[]> parameterMap, Date startDate, Date endDate)
232                    throws Exception {
233    
234                    getStaging().publishLayouts(
235                            userId, sourceGroupId, targetGroupId, privateLayout, layoutIds,
236                            parameterMap, startDate, endDate);
237            }
238    
239            public static void publishLayouts(
240                            long userId, long sourceGroupId, long targetGroupId,
241                            boolean privateLayout, Map<Long, Boolean> layoutIdMap,
242                            Map<String, String[]> parameterMap, Date startDate, Date endDate)
243                    throws Exception {
244    
245                    getStaging().publishLayouts(
246                            userId, sourceGroupId, targetGroupId, privateLayout, layoutIdMap,
247                            parameterMap, startDate, endDate);
248            }
249    
250            public static void publishLayouts(
251                            long userId, long sourceGroupId, long targetGroupId,
252                            boolean privateLayout, Map<String, String[]> parameterMap,
253                            Date startDate, Date endDate)
254                    throws Exception {
255    
256                    getStaging().publishLayouts(
257                            userId, sourceGroupId, targetGroupId, privateLayout, parameterMap,
258                            startDate, endDate);
259            }
260    
261            public static void publishToLive(PortletRequest PortletRequest)
262                    throws Exception {
263    
264                    getStaging().publishToLive(PortletRequest);
265            }
266    
267            public static void publishToLive(
268                            PortletRequest PortletRequest, Portlet portlet)
269                    throws Exception {
270    
271                    getStaging().publishToLive(PortletRequest, portlet);
272            }
273    
274            public static void publishToRemote(PortletRequest PortletRequest)
275                    throws Exception {
276    
277                    getStaging().publishToRemote(PortletRequest);
278            }
279    
280            public static void scheduleCopyFromLive(PortletRequest PortletRequest)
281                    throws Exception {
282    
283                    getStaging().scheduleCopyFromLive(PortletRequest);
284            }
285    
286            public static void schedulePublishToLive(PortletRequest PortletRequest)
287                    throws Exception {
288    
289                    getStaging().schedulePublishToLive(PortletRequest);
290            }
291    
292            public static void schedulePublishToRemote(PortletRequest PortletRequest)
293                    throws Exception {
294    
295                    getStaging().schedulePublishToRemote(PortletRequest);
296            }
297    
298            public static void setRecentLayoutBranchId(
299                    HttpServletRequest request, long layoutSetBranchId, long plid,
300                    long layoutBranchId)
301                    throws SystemException {
302    
303                    getStaging().setRecentLayoutBranchId(
304                            request, layoutSetBranchId, plid, layoutBranchId);
305            }
306    
307            public static void setRecentLayoutBranchId(
308                    User user, long layoutSetBranchId, long plid, long layoutBranchId)
309                    throws SystemException {
310    
311                    getStaging().setRecentLayoutBranchId(
312                            user, layoutSetBranchId, plid, layoutBranchId);
313            }
314    
315            public static void setRecentLayoutRevisionId(
316                            HttpServletRequest request, long layoutSetBranchId, long plid,
317                            long layoutRevisionId)
318                    throws SystemException {
319    
320                    getStaging().setRecentLayoutRevisionId(
321                            request, layoutSetBranchId, plid, layoutRevisionId);
322            }
323    
324            public static void setRecentLayoutRevisionId(
325                            User user, long layoutSetBranchId, long plid, long layoutRevisionId)
326                    throws SystemException {
327    
328                    getStaging().setRecentLayoutRevisionId(
329                            user, layoutSetBranchId, plid, layoutRevisionId);
330            }
331    
332            public static void setRecentLayoutSetBranchId(
333                    HttpServletRequest request, long layoutSetId, long layoutSetBranchId) {
334    
335                    getStaging().setRecentLayoutSetBranchId(
336                            request, layoutSetId, layoutSetBranchId);
337            }
338    
339            public static void setRecentLayoutSetBranchId(
340                            User user, long layoutSetId, long layoutSetBranchId)
341                    throws SystemException {
342    
343                    getStaging().setRecentLayoutSetBranchId(
344                            user, layoutSetId, layoutSetBranchId);
345            }
346    
347            public static void unscheduleCopyFromLive(PortletRequest PortletRequest)
348                    throws Exception {
349    
350                    getStaging().unscheduleCopyFromLive(PortletRequest);
351            }
352    
353            public static void unschedulePublishToLive(PortletRequest PortletRequest)
354                    throws Exception {
355    
356                    getStaging().unschedulePublishToLive(PortletRequest);
357            }
358    
359            public static void unschedulePublishToRemote(PortletRequest PortletRequest)
360                    throws Exception {
361    
362                    getStaging().unschedulePublishToRemote(PortletRequest);
363            }
364    
365            public static void updateLastImportSettings(
366                            Element layoutElement, Layout layout,
367                            PortletDataContext portletDataContext)
368                    throws Exception {
369    
370                    getStaging().updateLastImportSettings(
371                            layoutElement, layout, portletDataContext);
372            }
373    
374            public static void updateStaging(
375                            PortletRequest PortletRequest, Group liveGroup)
376                    throws Exception {
377    
378                    getStaging().updateStaging(PortletRequest, liveGroup);
379            }
380    
381            public void setStaging(Staging staging) {
382                    _staging = staging;
383            }
384    
385            private static Staging _staging;
386    
387    }