001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.lar;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.repository.model.FileEntry;
020    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
021    import com.liferay.portal.kernel.util.DateRange;
022    import com.liferay.portal.kernel.xml.Document;
023    import com.liferay.portal.kernel.xml.Element;
024    import com.liferay.portal.model.Layout;
025    import com.liferay.portal.model.Portlet;
026    import com.liferay.portal.model.StagedModel;
027    import com.liferay.portal.theme.ThemeDisplay;
028    
029    import java.io.File;
030    
031    import java.util.Calendar;
032    import java.util.Map;
033    
034    import javax.portlet.PortletPreferences;
035    import javax.portlet.PortletRequest;
036    
037    /**
038     * @author Zsolt Berentey
039     */
040    public class ExportImportHelperUtil {
041    
042            public static Calendar getCalendar(
043                    PortletRequest portletRequest, String paramPrefix,
044                    boolean timeZoneSensitive) {
045    
046                    return getExportImportHelper().getCalendar(
047                            portletRequest, paramPrefix, timeZoneSensitive);
048            }
049    
050            public static DateRange getDateRange(
051                            PortletRequest portletRequest, long groupId, boolean privateLayout,
052                            long plid, String portletId)
053                    throws Exception {
054    
055                    return getExportImportHelper().getDateRange(
056                            portletRequest, groupId, privateLayout, plid, portletId);
057            }
058    
059            public static Layout getExportableLayout(ThemeDisplay themeDisplay)
060                    throws PortalException, SystemException {
061    
062                    return getExportImportHelper().getExportableLayout(themeDisplay);
063            }
064    
065            public static String getExportableRootPortletId(
066                            long companyId, String portletId)
067                    throws Exception {
068    
069                    return getExportImportHelper().getExportableRootPortletId(
070                            companyId, portletId);
071            }
072    
073            public static ExportImportHelper getExportImportHelper() {
074                    PortalRuntimePermission.checkGetBeanProperty(
075                            ExportImportHelperUtil.class);
076    
077                    return _exportImportHelper;
078            }
079    
080            public static ManifestSummary getManifestSummary(
081                            long userId, long groupId, Map<String, String[]> parameterMap,
082                            File file)
083                    throws Exception {
084    
085                    return getExportImportHelper().getManifestSummary(
086                            userId, groupId, parameterMap, file);
087            }
088    
089            public static ManifestSummary getManifestSummary(
090                            long userId, long groupId, Map<String, String[]> parameterMap,
091                            FileEntry fileEntry)
092                    throws Exception {
093    
094                    return getExportImportHelper().getManifestSummary(
095                            userId, groupId, parameterMap, fileEntry);
096            }
097    
098            public static long getModelDeletionCount(
099                            final PortletDataContext portletDataContext,
100                            final StagedModelType stagedModelType)
101                    throws PortalException, SystemException {
102    
103                    return getExportImportHelper().getModelDeletionCount(
104                            portletDataContext, stagedModelType);
105            }
106    
107            public static FileEntry getTempFileEntry(
108                            long groupId, long userId, String folderName)
109                    throws PortalException, SystemException {
110    
111                    return getExportImportHelper().getTempFileEntry(
112                            groupId, userId, folderName);
113            }
114    
115            public static String replaceExportContentReferences(
116                            PortletDataContext portletDataContext,
117                            StagedModel entityStagedModel, Element entityElement,
118                            String content, boolean exportReferencedContent)
119                    throws Exception {
120    
121                    return getExportImportHelper().replaceExportContentReferences(
122                            portletDataContext, entityStagedModel, entityElement, content,
123                            exportReferencedContent);
124            }
125    
126            public static String replaceExportDLReferences(
127                            PortletDataContext portletDataContext,
128                            StagedModel entityStagedModel, Element entityElement,
129                            String content, boolean exportReferencedContent)
130                    throws Exception {
131    
132                    return getExportImportHelper().replaceExportDLReferences(
133                            portletDataContext, entityStagedModel, entityElement, content,
134                            exportReferencedContent);
135            }
136    
137            public static String replaceExportLayoutReferences(
138                            PortletDataContext portletDataContext, String content,
139                            boolean exportReferencedContent)
140                    throws Exception {
141    
142                    return getExportImportHelper().replaceExportLayoutReferences(
143                            portletDataContext, content, exportReferencedContent);
144            }
145    
146            public static String replaceExportLinksToLayouts(
147                            PortletDataContext portletDataContext,
148                            StagedModel entityStagedModel, Element entityElement,
149                            String content, boolean exportReferencedContent)
150                    throws Exception {
151    
152                    return getExportImportHelper().replaceExportLinksToLayouts(
153                            portletDataContext, entityStagedModel, entityElement, content,
154                            exportReferencedContent);
155            }
156    
157            public static String replaceImportContentReferences(
158                            PortletDataContext portletDataContext, Element entityElement,
159                            String content, boolean importReferencedContent)
160                    throws Exception {
161    
162                    return getExportImportHelper().replaceImportContentReferences(
163                            portletDataContext, entityElement, content,
164                            importReferencedContent);
165            }
166    
167            public static String replaceImportDLReferences(
168                            PortletDataContext portletDataContext, Element entityElement,
169                            String content, boolean importReferencedContent)
170                    throws Exception {
171    
172                    return getExportImportHelper().replaceImportDLReferences(
173                            portletDataContext, entityElement, content,
174                            importReferencedContent);
175            }
176    
177            public static String replaceImportLayoutReferences(
178                            PortletDataContext portletDataContext, String content,
179                            boolean importReferencedContent)
180                    throws Exception {
181    
182                    return getExportImportHelper().replaceImportLayoutReferences(
183                            portletDataContext, content, importReferencedContent);
184            }
185    
186            public static String replaceImportLinksToLayouts(
187                            PortletDataContext portletDataContext, String content,
188                            boolean importReferencedContent)
189                    throws Exception {
190    
191                    return getExportImportHelper().replaceImportLinksToLayouts(
192                            portletDataContext, content, importReferencedContent);
193            }
194    
195            public static void updateExportPortletPreferencesClassPKs(
196                            PortletDataContext portletDataContext, Portlet portlet,
197                            PortletPreferences portletPreferences, String key, String className,
198                            Element rootElement)
199                    throws Exception {
200    
201                    getExportImportHelper().updateExportPortletPreferencesClassPKs(
202                            portletDataContext, portlet, portletPreferences, key, className,
203                            rootElement);
204            }
205    
206            public static void updateImportPortletPreferencesClassPKs(
207                            PortletDataContext portletDataContext,
208                            PortletPreferences portletPreferences, String key, Class<?> clazz,
209                            long companyGroupId)
210                    throws Exception {
211    
212                    getExportImportHelper().updateImportPortletPreferencesClassPKs(
213                            portletDataContext, portletPreferences, key, clazz, companyGroupId);
214            }
215    
216            public static MissingReferences validateMissingReferences(
217                            long userId, long groupId, Map<String, String[]> parameterMap,
218                            File file)
219                    throws Exception {
220    
221                    return getExportImportHelper().validateMissingReferences(
222                            userId, groupId, parameterMap, file);
223            }
224    
225            public static void writeManifestSummary(
226                    Document document, ManifestSummary manifestSummary) {
227    
228                    getExportImportHelper().writeManifestSummary(document, manifestSummary);
229            }
230    
231            public void setExportImportHelper(ExportImportHelper exportImportHelper) {
232                    PortalRuntimePermission.checkSetBeanProperty(getClass());
233    
234                    _exportImportHelper = exportImportHelper;
235            }
236    
237            private static ExportImportHelper _exportImportHelper;
238    
239    }