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.portlet.exportimport.lar;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.exception.PortalException;
020    import com.liferay.portal.kernel.repository.model.FileEntry;
021    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
022    import com.liferay.portal.kernel.util.DateRange;
023    import com.liferay.portal.kernel.xml.Document;
024    import com.liferay.portal.kernel.xml.Element;
025    import com.liferay.portal.kernel.zip.ZipWriter;
026    import com.liferay.portal.model.Layout;
027    import com.liferay.portal.model.Portlet;
028    import com.liferay.portal.model.StagedModel;
029    import com.liferay.portal.theme.ThemeDisplay;
030    
031    import java.io.File;
032    
033    import java.util.Calendar;
034    import java.util.List;
035    import java.util.Map;
036    
037    import javax.portlet.PortletPreferences;
038    import javax.portlet.PortletRequest;
039    
040    /**
041     * @author Zsolt Berentey
042     */
043    @ProviderType
044    public class ExportImportHelperUtil {
045    
046            public static long[] getAllLayoutIds(long groupId, boolean privateLayout) {
047                    return getExportImportHelper().getAllLayoutIds(groupId, privateLayout);
048            }
049    
050            public static Map<Long, Boolean> getAllLayoutIdsMap(
051                    long groupId, boolean privateLayout) {
052    
053                    return getExportImportHelper().getAllLayoutIdsMap(
054                            groupId, privateLayout);
055            }
056    
057            /**
058             * @deprecated As of 7.0.0, moved to {@link
059             *             ExportImportDateUtil#getCalendar(PortletRequest, String,
060             *             boolean)}
061             */
062            @Deprecated
063            public static Calendar getCalendar(
064                    PortletRequest portletRequest, String paramPrefix,
065                    boolean timeZoneSensitive) {
066    
067                    return getExportImportHelper().getCalendar(
068                            portletRequest, paramPrefix, timeZoneSensitive);
069            }
070    
071            /**
072             * @deprecated As of 7.0.0, moved to {@link
073             *             ExportImportDateUtil#getDateRange(PortletRequest, long,
074             *             boolean, long, String, String)}
075             */
076            @Deprecated
077            public static DateRange getDateRange(
078                            PortletRequest portletRequest, long groupId, boolean privateLayout,
079                            long plid, String portletId, String defaultRange)
080                    throws Exception {
081    
082                    return getExportImportHelper().getDateRange(
083                            portletRequest, groupId, privateLayout, plid, portletId,
084                            defaultRange);
085            }
086    
087            public static Layout getExportableLayout(ThemeDisplay themeDisplay)
088                    throws PortalException {
089    
090                    return getExportImportHelper().getExportableLayout(themeDisplay);
091            }
092    
093            public static String getExportableRootPortletId(
094                            long companyId, String portletId)
095                    throws Exception {
096    
097                    return getExportImportHelper().getExportableRootPortletId(
098                            companyId, portletId);
099            }
100    
101            public static ExportImportHelper getExportImportHelper() {
102                    PortalRuntimePermission.checkGetBeanProperty(
103                            ExportImportHelperUtil.class);
104    
105                    return _exportImportHelper;
106            }
107    
108            /**
109             * @deprecated As of 7.0.0, replaced by {@link
110             *             #getExportPortletControlsMap(long, String, Map)}
111             */
112            @Deprecated
113            public static boolean[] getExportPortletControls(
114                            long companyId, String portletId,
115                            Map<String, String[]> parameterMap)
116                    throws Exception {
117    
118                    return getExportImportHelper().getExportPortletControls(
119                            companyId, portletId, parameterMap);
120            }
121    
122            /**
123             * @deprecated As of 7.0.0, replaced by {@link
124             *             #getExportPortletControlsMap(long, String, Map, String)}
125             */
126            @Deprecated
127            public static boolean[] getExportPortletControls(
128                            long companyId, String portletId,
129                            Map<String, String[]> parameterMap, String type)
130                    throws Exception {
131    
132                    return getExportImportHelper().getExportPortletControls(
133                            companyId, portletId, parameterMap, type);
134            }
135    
136            public static Map<String, Boolean> getExportPortletControlsMap(
137                            long companyId, String portletId,
138                            Map<String, String[]> parameterMap)
139                    throws Exception {
140    
141                    return getExportImportHelper().getExportPortletControlsMap(
142                            companyId, portletId, parameterMap);
143            }
144    
145            public static Map<String, Boolean> getExportPortletControlsMap(
146                            long companyId, String portletId,
147                            Map<String, String[]> parameterMap, String type)
148                    throws Exception {
149    
150                    return getExportImportHelper().getExportPortletControlsMap(
151                            companyId, portletId, parameterMap, type);
152            }
153    
154            /**
155             * @deprecated As of 7.0.0, replaced by {@link
156             *             #getImportPortletControlsMap(long, String, Map, Element,
157             *             ManifestSummary)}
158             */
159            @Deprecated
160            public static boolean[] getImportPortletControls(
161                            long companyId, String portletId,
162                            Map<String, String[]> parameterMap, Element portletDataElement)
163                    throws Exception {
164    
165                    return getExportImportHelper().getImportPortletControls(
166                            companyId, portletId, parameterMap, portletDataElement);
167            }
168    
169            /**
170             * @deprecated As of 7.0.0, replaced by {@link
171             *             #getImportPortletControlsMap(long, String, Map, Element,
172             *             ManifestSummary)}
173             */
174            @Deprecated
175            public static boolean[] getImportPortletControls(
176                            long companyId, String portletId,
177                            Map<String, String[]> parameterMap, Element portletDataElement,
178                            ManifestSummary manifestSummary)
179                    throws Exception {
180    
181                    return getExportImportHelper().getImportPortletControls(
182                            companyId, portletId, parameterMap, portletDataElement,
183                            manifestSummary);
184            }
185    
186            public static Map<String, Boolean> getImportPortletControlsMap(
187                            long companyId, String portletId,
188                            Map<String, String[]> parameterMap, Element portletDataElement,
189                            ManifestSummary manifestSummary)
190                    throws Exception {
191    
192                    return getExportImportHelper().getImportPortletControlsMap(
193                            companyId, portletId, parameterMap, portletDataElement,
194                            manifestSummary);
195            }
196    
197            public static Map<Long, Boolean> getLayoutIdMap(
198                            PortletRequest portletRequest)
199                    throws PortalException {
200    
201                    return getExportImportHelper().getLayoutIdMap(portletRequest);
202            }
203    
204            public static long[] getLayoutIds(List<Layout> layouts) {
205                    return getExportImportHelper().getLayoutIds(layouts);
206            }
207    
208            public static long[] getLayoutIds(Map<Long, Boolean> layoutIdMap)
209                    throws PortalException {
210    
211                    return getExportImportHelper().getLayoutIds(layoutIdMap);
212            }
213    
214            public static long[] getLayoutIds(
215                            Map<Long, Boolean> layoutIdMap, long targetGroupId)
216                    throws PortalException {
217    
218                    return getExportImportHelper().getLayoutIds(layoutIdMap, targetGroupId);
219            }
220    
221            public static long[] getLayoutIds(PortletRequest portletRequest)
222                    throws PortalException {
223    
224                    return getExportImportHelper().getLayoutIds(portletRequest);
225            }
226    
227            public static long[] getLayoutIds(
228                            PortletRequest portletRequest, long targetGroupId)
229                    throws PortalException {
230    
231                    return getExportImportHelper().getLayoutIds(
232                            portletRequest, targetGroupId);
233            }
234    
235            public static ZipWriter getLayoutSetZipWriter(long groupId) {
236                    return getExportImportHelper().getLayoutSetZipWriter(groupId);
237            }
238    
239            /**
240             * @deprecated As of 7.0.0, replaced by {@link
241             *             #getManifestSummary(PortletDataContext)}
242             */
243            @Deprecated
244            public static ManifestSummary getManifestSummary(
245                            long userId, long groupId, Map<String, String[]> parameterMap,
246                            File file)
247                    throws Exception {
248    
249                    return getExportImportHelper().getManifestSummary(
250                            userId, groupId, parameterMap, file);
251            }
252    
253            public static ManifestSummary getManifestSummary(
254                            long userId, long groupId, Map<String, String[]> parameterMap,
255                            FileEntry fileEntry)
256                    throws Exception {
257    
258                    return getExportImportHelper().getManifestSummary(
259                            userId, groupId, parameterMap, fileEntry);
260            }
261    
262            public static ManifestSummary getManifestSummary(
263                            PortletDataContext portletDataContext)
264                    throws Exception {
265    
266                    return getExportImportHelper().getManifestSummary(portletDataContext);
267            }
268    
269            public static List<Layout> getMissingParentLayouts(
270                            Layout layout, long liveGroupId)
271                    throws PortalException {
272    
273                    return getExportImportHelper().getMissingParentLayouts(
274                            layout, liveGroupId);
275            }
276    
277            public static long getModelDeletionCount(
278                            final PortletDataContext portletDataContext,
279                            final StagedModelType stagedModelType)
280                    throws PortalException {
281    
282                    return getExportImportHelper().getModelDeletionCount(
283                            portletDataContext, stagedModelType);
284            }
285    
286            public static ZipWriter getPortletZipWriter(String portletId) {
287                    return getExportImportHelper().getPortletZipWriter(portletId);
288            }
289    
290            public static String getSelectedLayoutsJSON(
291                    long groupId, boolean privateLayout, String selectedNodes) {
292    
293                    return getExportImportHelper().getSelectedLayoutsJSON(
294                            groupId, privateLayout, selectedNodes);
295            }
296    
297            public static FileEntry getTempFileEntry(
298                            long groupId, long userId, String folderName)
299                    throws PortalException {
300    
301                    return getExportImportHelper().getTempFileEntry(
302                            groupId, userId, folderName);
303            }
304    
305            public static UserIdStrategy getUserIdStrategy(
306                            long userId, String userIdStrategy)
307                    throws PortalException {
308    
309                    return getExportImportHelper().getUserIdStrategy(
310                            userId, userIdStrategy);
311            }
312    
313            public static boolean isReferenceWithinExportScope(
314                    PortletDataContext portletDataContext, StagedModel stagedModel) {
315    
316                    return getExportImportHelper().isReferenceWithinExportScope(
317                            portletDataContext, stagedModel);
318            }
319    
320            /**
321             * @deprecated As of 7.0.0, replaced by {@link
322             *             #replaceExportContentReferences(PortletDataContext,
323             *             StagedModel, String, boolean)}
324             */
325            @Deprecated
326            public static String replaceExportContentReferences(
327                            PortletDataContext portletDataContext,
328                            StagedModel entityStagedModel, Element entityElement,
329                            String content, boolean exportReferencedContent)
330                    throws Exception {
331    
332                    return getExportImportHelper().replaceExportContentReferences(
333                            portletDataContext, entityStagedModel, entityElement, content,
334                            exportReferencedContent);
335            }
336    
337            public static String replaceExportContentReferences(
338                            PortletDataContext portletDataContext,
339                            StagedModel entityStagedModel, String content,
340                            boolean exportReferencedContent)
341                    throws Exception {
342    
343                    return getExportImportHelper().replaceExportContentReferences(
344                            portletDataContext, entityStagedModel, content,
345                            exportReferencedContent);
346            }
347    
348            public static String replaceExportContentReferences(
349                            PortletDataContext portletDataContext,
350                            StagedModel entityStagedModel, String content,
351                            boolean exportReferencedContent, boolean escapeContent)
352                    throws Exception {
353    
354                    return getExportImportHelper().replaceExportContentReferences(
355                            portletDataContext, entityStagedModel, content,
356                            exportReferencedContent, escapeContent);
357            }
358    
359            /**
360             * @deprecated As of 7.0.0, replaced by {@link
361             *             #replaceExportDLReferences(PortletDataContext, StagedModel,
362             *             String, boolean)}
363             */
364            @Deprecated
365            public static String replaceExportDLReferences(
366                            PortletDataContext portletDataContext,
367                            StagedModel entityStagedModel, Element entityElement,
368                            String content, boolean exportReferencedContent)
369                    throws Exception {
370    
371                    return getExportImportHelper().replaceExportDLReferences(
372                            portletDataContext, entityStagedModel, entityElement, content,
373                            exportReferencedContent);
374            }
375    
376            public static String replaceExportDLReferences(
377                            PortletDataContext portletDataContext,
378                            StagedModel entityStagedModel, String content,
379                            boolean exportReferencedContent)
380                    throws Exception {
381    
382                    return getExportImportHelper().replaceExportDLReferences(
383                            portletDataContext, entityStagedModel, content,
384                            exportReferencedContent);
385            }
386    
387            public static String replaceExportLayoutReferences(
388                            PortletDataContext portletDataContext, String content)
389                    throws Exception {
390    
391                    return getExportImportHelper().replaceExportLayoutReferences(
392                            portletDataContext, content);
393            }
394    
395            /**
396             * @deprecated As of 7.0.0, replaced by {@link
397             *             #replaceExportLayoutReferences(PortletDataContext, String)}
398             */
399            @Deprecated
400            public static String replaceExportLayoutReferences(
401                            PortletDataContext portletDataContext, String content,
402                            boolean exportReferencedContent)
403                    throws Exception {
404    
405                    return getExportImportHelper().replaceExportLayoutReferences(
406                            portletDataContext, content, exportReferencedContent);
407            }
408    
409            /**
410             * @deprecated As of 7.0.0, replaced by {@link
411             *             #replaceExportLinksToLayouts(PortletDataContext, StagedModel,
412             *             String)}
413             */
414            @Deprecated
415            public static String replaceExportLinksToLayouts(
416                            PortletDataContext portletDataContext,
417                            StagedModel entityStagedModel, Element entityElement,
418                            String content, boolean exportReferencedContent)
419                    throws Exception {
420    
421                    return getExportImportHelper().replaceExportLinksToLayouts(
422                            portletDataContext, entityStagedModel, entityElement, content,
423                            exportReferencedContent);
424            }
425    
426            public static String replaceExportLinksToLayouts(
427                            PortletDataContext portletDataContext,
428                            StagedModel entityStagedModel, String content)
429                    throws Exception {
430    
431                    return getExportImportHelper().replaceExportLinksToLayouts(
432                            portletDataContext, entityStagedModel, content);
433            }
434    
435            /**
436             * @deprecated As of 7.0.0, replaced by {@link
437             *             #replaceImportContentReferences(PortletDataContext,
438             *             StagedModel, String)}
439             */
440            @Deprecated
441            public static String replaceImportContentReferences(
442                            PortletDataContext portletDataContext, Element entityElement,
443                            String content, boolean importReferencedContent)
444                    throws Exception {
445    
446                    return getExportImportHelper().replaceImportContentReferences(
447                            portletDataContext, entityElement, content,
448                            importReferencedContent);
449            }
450    
451            public static String replaceImportContentReferences(
452                            PortletDataContext portletDataContext,
453                            StagedModel entityStagedModel, String content)
454                    throws Exception {
455    
456                    return getExportImportHelper().replaceImportContentReferences(
457                            portletDataContext, entityStagedModel, content);
458            }
459    
460            /**
461             * @deprecated As of 7.0.0, replaced by {@link
462             *             #replaceImportDLReferences(PortletDataContext, StagedModel,
463             *             String)}
464             */
465            @Deprecated
466            public static String replaceImportDLReferences(
467                            PortletDataContext portletDataContext, Element entityElement,
468                            String content, boolean importReferencedContent)
469                    throws Exception {
470    
471                    return getExportImportHelper().replaceImportDLReferences(
472                            portletDataContext, entityElement, content,
473                            importReferencedContent);
474            }
475    
476            public static String replaceImportDLReferences(
477                            PortletDataContext portletDataContext,
478                            StagedModel entityStagedModel, String content)
479                    throws Exception {
480    
481                    return getExportImportHelper().replaceImportDLReferences(
482                            portletDataContext, entityStagedModel, content);
483            }
484    
485            public static String replaceImportLayoutReferences(
486                            PortletDataContext portletDataContext, String content)
487                    throws Exception {
488    
489                    return getExportImportHelper().replaceImportLayoutReferences(
490                            portletDataContext, content);
491            }
492    
493            /**
494             * @deprecated As of 7.0.0, replaced by {@link
495             *             #replaceImportLayoutReferences(PortletDataContext, String)}
496             */
497            @Deprecated
498            public static String replaceImportLayoutReferences(
499                            PortletDataContext portletDataContext, String content,
500                            boolean importReferencedContent)
501                    throws Exception {
502    
503                    return getExportImportHelper().replaceImportLayoutReferences(
504                            portletDataContext, content, importReferencedContent);
505            }
506    
507            public static String replaceImportLinksToLayouts(
508                            PortletDataContext portletDataContext, String content)
509                    throws Exception {
510    
511                    return getExportImportHelper().replaceImportLinksToLayouts(
512                            portletDataContext, content);
513            }
514    
515            /**
516             * @deprecated As of 7.0.0, replaced by {@link
517             *             #replaceImportLinksToLayouts(PortletDataContext, String)}
518             */
519            @Deprecated
520            public static String replaceImportLinksToLayouts(
521                            PortletDataContext portletDataContext, String content,
522                            boolean importReferencedContent)
523                    throws Exception {
524    
525                    return getExportImportHelper().replaceImportLinksToLayouts(
526                            portletDataContext, content, importReferencedContent);
527            }
528    
529            public static void updateExportPortletPreferencesClassPKs(
530                            PortletDataContext portletDataContext, Portlet portlet,
531                            PortletPreferences portletPreferences, String key, String className)
532                    throws Exception {
533    
534                    getExportImportHelper().updateExportPortletPreferencesClassPKs(
535                            portletDataContext, portlet, portletPreferences, key, className);
536            }
537    
538            /**
539             * @deprecated As of 7.0.0, replaced by {@link
540             *             #updateExportPortletPreferencesClassPKs(PortletDataContext,
541             *             Portlet, PortletPreferences, String, String)}
542             */
543            @Deprecated
544            public static void updateExportPortletPreferencesClassPKs(
545                            PortletDataContext portletDataContext, Portlet portlet,
546                            PortletPreferences portletPreferences, String key, String className,
547                            Element rootElement)
548                    throws Exception {
549    
550                    getExportImportHelper().updateExportPortletPreferencesClassPKs(
551                            portletDataContext, portlet, portletPreferences, key, className,
552                            rootElement);
553            }
554    
555            public static void updateImportPortletPreferencesClassPKs(
556                            PortletDataContext portletDataContext,
557                            PortletPreferences portletPreferences, String key, Class<?> clazz,
558                            long companyGroupId)
559                    throws Exception {
560    
561                    getExportImportHelper().updateImportPortletPreferencesClassPKs(
562                            portletDataContext, portletPreferences, key, clazz, companyGroupId);
563            }
564    
565            /**
566             * @deprecated As of 7.0.0, replaced by {@link
567             *             #validateMissingReferences(PortletDataContext)}
568             */
569            @Deprecated
570            public static MissingReferences validateMissingReferences(
571                            long userId, long groupId, Map<String, String[]> parameterMap,
572                            File file)
573                    throws Exception {
574    
575                    return getExportImportHelper().validateMissingReferences(
576                            userId, groupId, parameterMap, file);
577            }
578    
579            public static MissingReferences validateMissingReferences(
580                            final PortletDataContext portletDataContext)
581                    throws Exception {
582    
583                    return getExportImportHelper().validateMissingReferences(
584                            portletDataContext);
585            }
586    
587            public static void writeManifestSummary(
588                    Document document, ManifestSummary manifestSummary) {
589    
590                    getExportImportHelper().writeManifestSummary(document, manifestSummary);
591            }
592    
593            public void setExportImportHelper(ExportImportHelper exportImportHelper) {
594                    PortalRuntimePermission.checkSetBeanProperty(getClass());
595    
596                    _exportImportHelper = exportImportHelper;
597            }
598    
599            private static ExportImportHelper _exportImportHelper;
600    
601    }