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.List;
033    import java.util.Map;
034    
035    import javax.portlet.PortletPreferences;
036    import javax.portlet.PortletRequest;
037    
038    /**
039     * @author Zsolt Berentey
040     */
041    public class ExportImportHelperUtil {
042    
043            public static Calendar getCalendar(
044                    PortletRequest portletRequest, String paramPrefix,
045                    boolean timeZoneSensitive) {
046    
047                    return getExportImportHelper().getCalendar(
048                            portletRequest, paramPrefix, timeZoneSensitive);
049            }
050    
051            public static void reindex(
052                            PortletDataContext portletDataContext, long userId)
053                    throws PortalException, SystemException {
054    
055                    getExportImportHelper().reindex(portletDataContext, userId);
056            }
057    
058            public static DateRange getDateRange(
059                            PortletRequest portletRequest, long groupId, boolean privateLayout,
060                            long plid, String portletId, String defaultRange)
061                    throws Exception {
062    
063                    return getExportImportHelper().getDateRange(
064                            portletRequest, groupId, privateLayout, plid, portletId,
065                            defaultRange);
066            }
067    
068            public static Layout getExportableLayout(ThemeDisplay themeDisplay)
069                    throws PortalException, SystemException {
070    
071                    return getExportImportHelper().getExportableLayout(themeDisplay);
072            }
073    
074            public static String getExportableRootPortletId(
075                            long companyId, String portletId)
076                    throws Exception {
077    
078                    return getExportImportHelper().getExportableRootPortletId(
079                            companyId, portletId);
080            }
081    
082            public static ExportImportHelper getExportImportHelper() {
083                    PortalRuntimePermission.checkGetBeanProperty(
084                            ExportImportHelperUtil.class);
085    
086                    return _exportImportHelper;
087            }
088    
089            public static Map<Long, Boolean> getLayoutIdMap(
090                            PortletRequest portletRequest)
091                    throws Exception {
092    
093                    return getExportImportHelper().getLayoutIdMap(portletRequest);
094            }
095    
096            public static long[] getLayoutIds(List<Layout> layouts) {
097                    return getExportImportHelper().getLayoutIds(layouts);
098            }
099    
100            public static ManifestSummary getManifestSummary(
101                            long userId, long groupId, Map<String, String[]> parameterMap,
102                            File file)
103                    throws Exception {
104    
105                    return getExportImportHelper().getManifestSummary(
106                            userId, groupId, parameterMap, file);
107            }
108    
109            public static ManifestSummary getManifestSummary(
110                            long userId, long groupId, Map<String, String[]> parameterMap,
111                            FileEntry fileEntry)
112                    throws Exception {
113    
114                    return getExportImportHelper().getManifestSummary(
115                            userId, groupId, parameterMap, fileEntry);
116            }
117    
118            public static long getModelDeletionCount(
119                            final PortletDataContext portletDataContext,
120                            final StagedModelType stagedModelType)
121                    throws PortalException, SystemException {
122    
123                    return getExportImportHelper().getModelDeletionCount(
124                            portletDataContext, stagedModelType);
125            }
126    
127            public static String getSelectedLayoutsJSON(
128                            long groupId, boolean privateLayout, String selectedNodes)
129                    throws SystemException {
130    
131                    return getExportImportHelper().getSelectedLayoutsJSON(
132                            groupId, privateLayout, selectedNodes);
133            }
134    
135            public static FileEntry getTempFileEntry(
136                            long groupId, long userId, String folderName)
137                    throws PortalException, SystemException {
138    
139                    return getExportImportHelper().getTempFileEntry(
140                            groupId, userId, folderName);
141            }
142    
143            public static String replaceExportContentReferences(
144                            PortletDataContext portletDataContext,
145                            StagedModel entityStagedModel, Element entityElement,
146                            String content, boolean exportReferencedContent)
147                    throws Exception {
148    
149                    return getExportImportHelper().replaceExportContentReferences(
150                            portletDataContext, entityStagedModel, entityElement, content,
151                            exportReferencedContent);
152            }
153    
154            public static String replaceExportDLReferences(
155                            PortletDataContext portletDataContext,
156                            StagedModel entityStagedModel, Element entityElement,
157                            String content, boolean exportReferencedContent)
158                    throws Exception {
159    
160                    return getExportImportHelper().replaceExportDLReferences(
161                            portletDataContext, entityStagedModel, entityElement, content,
162                            exportReferencedContent);
163            }
164    
165            public static String replaceExportLayoutReferences(
166                            PortletDataContext portletDataContext, String content,
167                            boolean exportReferencedContent)
168                    throws Exception {
169    
170                    return getExportImportHelper().replaceExportLayoutReferences(
171                            portletDataContext, content, exportReferencedContent);
172            }
173    
174            public static String replaceExportLinksToLayouts(
175                            PortletDataContext portletDataContext,
176                            StagedModel entityStagedModel, Element entityElement,
177                            String content, boolean exportReferencedContent)
178                    throws Exception {
179    
180                    return getExportImportHelper().replaceExportLinksToLayouts(
181                            portletDataContext, entityStagedModel, entityElement, content,
182                            exportReferencedContent);
183            }
184    
185            public static String replaceImportContentReferences(
186                            PortletDataContext portletDataContext, Element entityElement,
187                            String content, boolean importReferencedContent)
188                    throws Exception {
189    
190                    return getExportImportHelper().replaceImportContentReferences(
191                            portletDataContext, entityElement, content,
192                            importReferencedContent);
193            }
194    
195            public static String replaceImportDLReferences(
196                            PortletDataContext portletDataContext, Element entityElement,
197                            String content, boolean importReferencedContent)
198                    throws Exception {
199    
200                    return getExportImportHelper().replaceImportDLReferences(
201                            portletDataContext, entityElement, content,
202                            importReferencedContent);
203            }
204    
205            public static String replaceImportLayoutReferences(
206                            PortletDataContext portletDataContext, String content,
207                            boolean importReferencedContent)
208                    throws Exception {
209    
210                    return getExportImportHelper().replaceImportLayoutReferences(
211                            portletDataContext, content, importReferencedContent);
212            }
213    
214            public static String replaceImportLinksToLayouts(
215                            PortletDataContext portletDataContext, String content,
216                            boolean importReferencedContent)
217                    throws Exception {
218    
219                    return getExportImportHelper().replaceImportLinksToLayouts(
220                            portletDataContext, content, importReferencedContent);
221            }
222    
223            public static void updateExportPortletPreferencesClassPKs(
224                            PortletDataContext portletDataContext, Portlet portlet,
225                            PortletPreferences portletPreferences, String key, String className,
226                            Element rootElement)
227                    throws Exception {
228    
229                    getExportImportHelper().updateExportPortletPreferencesClassPKs(
230                            portletDataContext, portlet, portletPreferences, key, className,
231                            rootElement);
232            }
233    
234            public static void updateImportPortletPreferencesClassPKs(
235                            PortletDataContext portletDataContext,
236                            PortletPreferences portletPreferences, String key, Class<?> clazz,
237                            long companyGroupId)
238                    throws Exception {
239    
240                    getExportImportHelper().updateImportPortletPreferencesClassPKs(
241                            portletDataContext, portletPreferences, key, clazz, companyGroupId);
242            }
243    
244            public static MissingReferences validateMissingReferences(
245                            long userId, long groupId, Map<String, String[]> parameterMap,
246                            File file)
247                    throws Exception {
248    
249                    return getExportImportHelper().validateMissingReferences(
250                            userId, groupId, parameterMap, file);
251            }
252    
253            public static void writeManifestSummary(
254                    Document document, ManifestSummary manifestSummary) {
255    
256                    getExportImportHelper().writeManifestSummary(document, manifestSummary);
257            }
258    
259            public void setExportImportHelper(ExportImportHelper exportImportHelper) {
260                    PortalRuntimePermission.checkSetBeanProperty(getClass());
261    
262                    _exportImportHelper = exportImportHelper;
263            }
264    
265            private static ExportImportHelper _exportImportHelper;
266    
267    }