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