001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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 void copyFromLive(PortletRequest PortletRequest)
041                    throws Exception {
042    
043                    getStaging().copyFromLive(PortletRequest);
044            }
045    
046            public static void copyFromLive(
047                            PortletRequest PortletRequest, Portlet portlet)
048                    throws Exception {
049    
050                    getStaging().copyFromLive(PortletRequest, portlet);
051            }
052    
053            public static void copyPortlet(
054                            PortletRequest PortletRequest, long sourceGroupId,
055                            long targetGroupId, long sourcePlid, long targetPlid,
056                            String portletId)
057                    throws Exception {
058    
059                    getStaging().copyPortlet(
060                            PortletRequest, sourceGroupId, targetGroupId, sourcePlid,
061                            targetPlid, portletId);
062            }
063    
064            public static void copyRemoteLayouts(
065                            long sourceGroupId, boolean privateLayout,
066                            Map<Long, Boolean> layoutIdMap, Map<String, String[]> parameterMap,
067                            String remoteAddress, int remotePort, boolean secureConnection,
068                            long remoteGroupId, boolean remotePrivateLayout, Date startDate,
069                            Date endDate)
070                    throws Exception {
071    
072                    getStaging().copyRemoteLayouts(
073                            sourceGroupId, privateLayout, layoutIdMap, parameterMap,
074                            remoteAddress, remotePort, secureConnection, remoteGroupId,
075                            remotePrivateLayout, startDate, endDate);
076            }
077    
078            public static void deleteLastImportSettings(
079                            Group liveGroup, boolean privateLayout)
080                    throws Exception {
081    
082                    getStaging().deleteLastImportSettings(liveGroup, privateLayout);
083            }
084    
085            public static void deleteRecentLayoutRevisionId(
086                            HttpServletRequest request, long layoutSetBranchId, long plid)
087                    throws SystemException {
088    
089                    getStaging().deleteRecentLayoutRevisionId(
090                            request, layoutSetBranchId, plid);
091            }
092    
093            public static void deleteRecentLayoutRevisionId(
094                            User user, long layoutSetBranchId, long plid)
095                    throws SystemException {
096    
097                    getStaging().deleteRecentLayoutRevisionId(
098                            user, layoutSetBranchId, plid);
099            }
100    
101            public static void disableStaging(
102                            Group scopeGroup, Group liveGroup, ServiceContext serviceContext)
103                    throws Exception {
104    
105                    getStaging().disableStaging(scopeGroup, liveGroup, serviceContext);
106            }
107    
108            public static void disableStaging(
109                            PortletRequest portletRequest, Group scopeGroup, Group liveGroup,
110                            ServiceContext serviceContext)
111                    throws Exception {
112    
113                    getStaging().disableStaging(
114                            portletRequest, scopeGroup, liveGroup, serviceContext);
115            }
116    
117            public static void enableLocalStaging(
118                            long userId, Group scopeGroup, Group liveGroup,
119                            boolean branchingPublic, boolean branchingPrivate,
120                            ServiceContext serviceContext)
121                    throws Exception {
122    
123                    getStaging().enableLocalStaging(
124                            userId, scopeGroup, liveGroup, branchingPublic, branchingPrivate,
125                            serviceContext);
126            }
127    
128            public static void enableRemoteStaging(
129                            long userId, Group scopeGroup, Group liveGroup,
130                            boolean branchingPublic, boolean branchingPrivate,
131                            String remoteAddress, long remoteGroupId, int remotePort,
132                            boolean secureConnection, ServiceContext serviceContext)
133                    throws Exception {
134    
135                    getStaging().enableRemoteStaging(
136                            userId, scopeGroup, liveGroup, branchingPublic, branchingPrivate,
137                            remoteAddress, remoteGroupId, remotePort, secureConnection,
138                            serviceContext);
139            }
140    
141            public static List<Layout> getMissingParentLayouts(
142                            Layout layout, long liveGroupId)
143                    throws Exception {
144    
145                    return getStaging().getMissingParentLayouts(layout, liveGroupId);
146            }
147    
148            public static long getRecentLayoutRevisionId(
149                            HttpServletRequest request, long layoutSetBranchId, long plid)
150                    throws PortalException, SystemException{
151    
152                    return getStaging().getRecentLayoutRevisionId(
153                            request, layoutSetBranchId, plid);
154            }
155    
156            public static long getRecentLayoutRevisionId(
157                            User user, long layoutSetBranchId, long plid)
158                    throws PortalException, SystemException {
159    
160                    return getStaging().getRecentLayoutRevisionId(
161                            user, layoutSetBranchId, plid);
162            }
163    
164            public static long getRecentLayoutSetBranchId(
165                    HttpServletRequest request, long layoutSetId) {
166    
167                    return getStaging().getRecentLayoutSetBranchId(request, layoutSetId);
168            }
169    
170            public static long getRecentLayoutSetBranchId(User user, long layoutSetId)
171                    throws SystemException {
172    
173                    return getStaging().getRecentLayoutSetBranchId(user, layoutSetId);
174            }
175    
176            public static String getSchedulerGroupName(
177                    String destinationName, long groupId) {
178    
179                    return getStaging().getSchedulerGroupName(destinationName, groupId);
180            }
181    
182            public static Staging getStaging() {
183                    return _staging;
184            }
185    
186            public static Map<String, String[]> getStagingParameters() {
187                    return getStaging().getStagingParameters();
188            }
189    
190            public static Map<String, String[]> getStagingParameters(
191                    PortletRequest PortletRequest) {
192    
193                    return getStaging().getStagingParameters(PortletRequest);
194            }
195    
196            public static boolean isIncomplete(Layout layout, long layoutSetBranchId) {
197                    return getStaging().isIncomplete(layout, layoutSetBranchId);
198            }
199    
200            public static void publishLayout(
201                            long userId, long plid, long liveGroupId, boolean includeChildren)
202                    throws Exception {
203    
204                    getStaging().publishLayout(userId, plid, liveGroupId, includeChildren);
205            }
206    
207            public static void publishLayouts(
208                            long userId, long sourceGroupId, long targetGroupId,
209                            boolean privateLayout, long[] layoutIds,
210                            Map<String, String[]> parameterMap, Date startDate, Date endDate)
211                    throws Exception {
212    
213                    getStaging().publishLayouts(
214                            userId, sourceGroupId, targetGroupId, privateLayout, layoutIds,
215                            parameterMap, startDate, endDate);
216            }
217    
218            public static void publishLayouts(
219                            long userId, long sourceGroupId, long targetGroupId,
220                            boolean privateLayout, Map<Long, Boolean> layoutIdMap,
221                            Map<String, String[]> parameterMap, Date startDate, Date endDate)
222                    throws Exception {
223    
224                    getStaging().publishLayouts(
225                            userId, sourceGroupId, targetGroupId, privateLayout, layoutIdMap,
226                            parameterMap, startDate, endDate);
227            }
228    
229            public static void publishLayouts(
230                            long userId, long sourceGroupId, long targetGroupId,
231                            boolean privateLayout, Map<String, String[]> parameterMap,
232                            Date startDate, Date endDate)
233                    throws Exception {
234    
235                    getStaging().publishLayouts(
236                            userId, sourceGroupId, targetGroupId, privateLayout, parameterMap,
237                            startDate, endDate);
238            }
239    
240            public static void publishToLive(PortletRequest PortletRequest)
241                    throws Exception {
242    
243                    getStaging().publishToLive(PortletRequest);
244            }
245    
246            public static void publishToLive(
247                            PortletRequest PortletRequest, Portlet portlet)
248                    throws Exception {
249    
250                    getStaging().publishToLive(PortletRequest, portlet);
251            }
252    
253            public static void publishToRemote(PortletRequest PortletRequest)
254                    throws Exception {
255    
256                    getStaging().publishToRemote(PortletRequest);
257            }
258    
259            public static void scheduleCopyFromLive(PortletRequest PortletRequest)
260                    throws Exception {
261    
262                    getStaging().scheduleCopyFromLive(PortletRequest);
263            }
264    
265            public static void schedulePublishToLive(PortletRequest PortletRequest)
266                    throws Exception {
267    
268                    getStaging().schedulePublishToLive(PortletRequest);
269            }
270    
271            public static void schedulePublishToRemote(PortletRequest PortletRequest)
272                    throws Exception {
273    
274                    getStaging().schedulePublishToRemote(PortletRequest);
275            }
276    
277            public static void setRecentLayoutBranchId(
278                    HttpServletRequest request, long layoutSetBranchId, long plid,
279                    long layoutBranchId)
280                    throws SystemException {
281    
282                    getStaging().setRecentLayoutBranchId(
283                            request, layoutSetBranchId, plid, layoutBranchId);
284            }
285    
286            public static void setRecentLayoutBranchId(
287                    User user, long layoutSetBranchId, long plid, long layoutBranchId)
288                    throws SystemException {
289    
290                    getStaging().setRecentLayoutBranchId(
291                            user, layoutSetBranchId, plid, layoutBranchId);
292            }
293    
294            public static void setRecentLayoutRevisionId(
295                            HttpServletRequest request, long layoutSetBranchId, long plid,
296                            long layoutRevisionId)
297                    throws SystemException {
298    
299                    getStaging().setRecentLayoutRevisionId(
300                            request, layoutSetBranchId, plid, layoutRevisionId);
301            }
302    
303            public static void setRecentLayoutRevisionId(
304                            User user, long layoutSetBranchId, long plid, long layoutRevisionId)
305                    throws SystemException {
306    
307                    getStaging().setRecentLayoutRevisionId(
308                            user, layoutSetBranchId, plid, layoutRevisionId);
309            }
310    
311            public static void setRecentLayoutSetBranchId(
312                    HttpServletRequest request, long layoutSetId, long layoutSetBranchId) {
313    
314                    getStaging().setRecentLayoutSetBranchId(
315                            request, layoutSetId, layoutSetBranchId);
316            }
317    
318            public static void setRecentLayoutSetBranchId(
319                            User user, long layoutSetId, long layoutSetBranchId)
320                    throws SystemException {
321    
322                    getStaging().setRecentLayoutSetBranchId(
323                            user, layoutSetId, layoutSetBranchId);
324            }
325    
326            public static void unscheduleCopyFromLive(PortletRequest PortletRequest)
327                    throws Exception {
328    
329                    getStaging().unscheduleCopyFromLive(PortletRequest);
330            }
331    
332            public static void unschedulePublishToLive(PortletRequest PortletRequest)
333                    throws Exception {
334    
335                    getStaging().unschedulePublishToLive(PortletRequest);
336            }
337    
338            public static void unschedulePublishToRemote(PortletRequest PortletRequest)
339                    throws Exception {
340    
341                    getStaging().unschedulePublishToRemote(PortletRequest);
342            }
343    
344            public static void updateLastImportSettings(
345                            Element layoutElement, Layout layout,
346                            PortletDataContext portletDataContext)
347                    throws Exception {
348    
349                    getStaging().updateLastImportSettings(
350                            layoutElement, layout, portletDataContext);
351            }
352    
353            public static void updateStaging(
354                            PortletRequest PortletRequest, Group liveGroup)
355                    throws Exception {
356    
357                    getStaging().updateStaging(PortletRequest, liveGroup);
358            }
359    
360            public void setStaging(Staging staging) {
361                    _staging = staging;
362            }
363    
364            private static Staging _staging;
365    
366    }