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