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