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