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