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.dao.orm.Criterion;
020    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
021    import com.liferay.portal.kernel.exception.PortalException;
022    import com.liferay.portal.kernel.lock.Lock;
023    import com.liferay.portal.kernel.util.DateRange;
024    import com.liferay.portal.kernel.util.KeyValuePair;
025    import com.liferay.portal.kernel.xml.Element;
026    import com.liferay.portal.kernel.zip.ZipReader;
027    import com.liferay.portal.kernel.zip.ZipWriter;
028    import com.liferay.portal.model.ClassedModel;
029    import com.liferay.portal.model.Layout;
030    import com.liferay.portal.model.StagedGroupedModel;
031    import com.liferay.portal.model.StagedModel;
032    import com.liferay.portal.service.ServiceContext;
033    import com.liferay.portlet.asset.model.AssetLink;
034    import com.liferay.portlet.expando.model.ExpandoColumn;
035    import com.liferay.portlet.messageboards.model.MBMessage;
036    import com.liferay.portlet.ratings.model.RatingsEntry;
037    
038    import java.io.InputStream;
039    import java.io.Serializable;
040    
041    import java.util.Date;
042    import java.util.List;
043    import java.util.Map;
044    import java.util.Set;
045    
046    /**
047     * <p>
048     * Holds context information that is used during exporting and importing portlet
049     * data.
050     * </p>
051     *
052     * @author Brian Wing Shun Chan
053     * @author Raymond Aug??
054     * @author Mate Thurzo
055     */
056    @ProviderType
057    public interface PortletDataContext extends Serializable {
058    
059            public static final String REFERENCE_TYPE_CHILD = "child";
060    
061            public static final String REFERENCE_TYPE_DEPENDENCY = "dependency";
062    
063            public static final String REFERENCE_TYPE_DEPENDENCY_DISPOSABLE =
064                    "disposable_dependency";
065    
066            public static final String REFERENCE_TYPE_EMBEDDED = "embedded";
067    
068            public static final String REFERENCE_TYPE_PARENT = "parent";
069    
070            public static final String REFERENCE_TYPE_STRONG = "strong";
071    
072            public static final String REFERENCE_TYPE_WEAK = "weak";
073    
074            /**
075             * @deprecated As of 6.2.0, replaced by {@link
076             *             ExportImportPathUtil#PATH_PREFIX_GROUP}
077             */
078            @Deprecated
079            public static final String ROOT_PATH_GROUPS = "/groups/";
080    
081            /**
082             * @deprecated As of 6.2.0, replaced by {@link
083             *             ExportImportPathUtil#PATH_PREFIX_LAYOUT}
084             */
085            @Deprecated
086            public static final String ROOT_PATH_LAYOUTS = "/layouts/";
087    
088            /**
089             * @deprecated As of 6.2.0, replaced by {@link
090             *             ExportImportPathUtil#PATH_PREFIX_PORTLET}
091             */
092            @Deprecated
093            public static final String ROOT_PATH_PORTLETS = "/portlets/";
094    
095            /**
096             * @deprecated As of 7.0.0, replaced by {@link
097             *             BaseStagedModelDataHandler#exportAssetCategories(
098             *             PortletDataContext, StagedModel)}
099             */
100            @Deprecated
101            public void addAssetCategories(Class<?> clazz, long classPK);
102    
103            public void addAssetCategories(
104                    String className, long classPK, long[] assetCategoryIds);
105    
106            public void addAssetTags(Class<?> clazz, long classPK);
107    
108            public void addAssetTags(
109                    String className, long classPK, String[] assetTagNames);
110    
111            public void addClassedModel(
112                            Element element, String path, ClassedModel classedModel)
113                    throws PortalException;
114    
115            public void addClassedModel(
116                            Element element, String path, ClassedModel classedModel,
117                            Class<?> clazz)
118                    throws PortalException;
119    
120            /**
121             * @deprecated As of 6.2.0, replaced by {@link #addClassedModel(Element,
122             *             String, ClassedModel, Class)}
123             */
124            @Deprecated
125            public void addClassedModel(
126                            Element element, String path, ClassedModel classedModel,
127                            Class<?> clazz, String namespace)
128                    throws PortalException;
129    
130            /**
131             * @deprecated As of 6.2.0, replaced by {@link #addClassedModel(Element,
132             *             String, ClassedModel)}
133             */
134            @Deprecated
135            public void addClassedModel(
136                            Element element, String path, ClassedModel classedModel,
137                            String namespace)
138                    throws PortalException;
139    
140            /**
141             * @deprecated As of 7.0.0, replaced by {@link
142             *             BaseStagedModelDataHandler#exportComments(PortletDataContext,
143             *             StagedModel)}
144             */
145            @Deprecated
146            public void addComments(Class<?> clazz, long classPK);
147    
148            /**
149             * @deprecated As of 7.0.0, replaced by {@link
150             *             BaseStagedModelDataHandler#exportComments(PortletDataContext,
151             *             StagedModel)}
152             */
153            @Deprecated
154            public void addComments(
155                    String className, long classPK, List<MBMessage> messages);
156    
157            public void addDateRangeCriteria(
158                    DynamicQuery dynamicQuery, String propertyName);
159    
160            public void addDeletionSystemEventStagedModelTypes(
161                    StagedModelType... stagedModelTypes);
162    
163            public void addExpando(
164                            Element element, String path, ClassedModel classedModel)
165                    throws PortalException;
166    
167            public void addLocks(Class<?> clazz, String key) throws PortalException;
168    
169            public void addLocks(String className, String key, Lock lock);
170    
171            public void addPermissions(Class<?> clazz, long classPK)
172                    throws PortalException;
173    
174            public void addPermissions(String resourceName, long resourcePK)
175                    throws PortalException;
176    
177            public void addPermissions(
178                    String resourceName, long resourcePK, List<KeyValuePair> permissions);
179    
180            public void addPortalPermissions() throws PortalException;
181    
182            public void addPortletPermissions(String resourceName)
183                    throws PortalException;
184    
185            public boolean addPrimaryKey(Class<?> clazz, String primaryKey);
186    
187            /**
188             * @deprecated As of 7.0.0, replaced by {@link
189             *             BaseStagedModelDataHandler#exportRatings(PortletDataContext,
190             *             StagedModel)}
191             */
192            @Deprecated
193            public void addRatingsEntries(Class<?> clazz, long classPK);
194    
195            /**
196             * @deprecated As of 7.0.0, replaced by {@link
197             *             BaseStagedModelDataHandler#exportRatings(PortletDataContext,
198             *             StagedModel)}
199             */
200            @Deprecated
201            public void addRatingsEntries(
202                    String className, long classPK, List<RatingsEntry> ratingsEntries);
203    
204            /**
205             * @deprecated As of 7.0.0, with no direct replacement
206             */
207            @Deprecated
208            public Element addReferenceElement(
209                    ClassedModel referrerClassedModel, Element element,
210                    ClassedModel classedModel, Class<?> clazz, String referenceType,
211                    boolean missing);
212    
213            public Element addReferenceElement(
214                    ClassedModel referrerClassedModel, Element element,
215                    ClassedModel classedModel, String referenceType, boolean missing);
216    
217            public Element addReferenceElement(
218                    ClassedModel referrerClassedModel, Element element,
219                    ClassedModel classedModel, String binPath, String referenceType,
220                    boolean missing);
221    
222            public Element addReferenceElement(
223                    ClassedModel referrerClassedModel, Element element,
224                    ClassedModel classedModel, String className, String binPath,
225                    String referenceType, boolean missing);
226    
227            public boolean addScopedPrimaryKey(Class<?> clazz, String primaryKey);
228    
229            public void addZipEntry(String path, byte[] bytes);
230    
231            public void addZipEntry(String path, InputStream is);
232    
233            public void addZipEntry(String path, Object object);
234    
235            public void addZipEntry(String path, String s);
236    
237            public void addZipEntry(String name, StringBuilder sb);
238    
239            public void cleanUpMissingReferences(ClassedModel classedModel);
240    
241            public void clearScopedPrimaryKeys();
242    
243            public ServiceContext createServiceContext(
244                    Element element, ClassedModel classedModel);
245    
246            /**
247             * @deprecated As of 6.2.0, replaced by {@link
248             *             #createServiceContext(Element, ClassedModel)}
249             */
250            @Deprecated
251            public ServiceContext createServiceContext(
252                    Element element, ClassedModel classedModel, String namespace);
253    
254            public ServiceContext createServiceContext(StagedModel stagedModel);
255    
256            public ServiceContext createServiceContext(
257                    StagedModel stagedModel, Class<?> clazz);
258    
259            public ServiceContext createServiceContext(
260                    String path, ClassedModel classedModel);
261    
262            /**
263             * @deprecated As of 6.2.0, replaced by {@link #createServiceContext(String,
264             *             ClassedModel)}
265             */
266            @Deprecated
267            public ServiceContext createServiceContext(
268                    String path, ClassedModel classedModel, String namespace);
269    
270            public Object fromXML(byte[] bytes);
271    
272            public Object fromXML(String xml);
273    
274            public long[] getAssetCategoryIds(Class<?> clazz, long classPK);
275    
276            /**
277             * @deprecated As of 7.0.0
278             */
279            @Deprecated
280            public Map<String, long[]> getAssetCategoryIdsMap();
281    
282            /**
283             * @deprecated As of 7.0.0, with no direct replacement
284             */
285            @Deprecated
286            public Map<String, String[]> getAssetCategoryUuidsMap();
287    
288            public Map<String, List<AssetLink>> getAssetLinksMap();
289    
290            public String[] getAssetTagNames(Class<?> clazz, long classPK);
291    
292            public String[] getAssetTagNames(String className, long classPK);
293    
294            public Map<String, String[]> getAssetTagNamesMap();
295    
296            public boolean getBooleanParameter(String namespace, String name);
297    
298            public boolean getBooleanParameter(
299                    String namespace, String name, boolean useDefaultValue);
300    
301            public ClassLoader getClassLoader();
302    
303            /**
304             * @deprecated As of 7.0.0, with no direct replacement
305             */
306            @Deprecated
307            public Map<String, List<MBMessage>> getComments();
308    
309            public long getCompanyGroupId();
310    
311            public long getCompanyId();
312    
313            public String getDataStrategy();
314    
315            public DateRange getDateRange();
316    
317            public Criterion getDateRangeCriteria(String propertyName);
318    
319            public Set<StagedModelType> getDeletionSystemEventStagedModelTypes();
320    
321            public Date getEndDate();
322    
323            public Map<String, List<ExpandoColumn>> getExpandoColumns();
324    
325            public Element getExportDataElement(ClassedModel classedModel);
326    
327            /**
328             * @deprecated As of 7.0.0, replaced by {@link
329             *             #getExportDataElement(ClassedModel, String)}
330             */
331            @Deprecated
332            public Element getExportDataElement(
333                    ClassedModel classedModel, Class<?> modelClass);
334    
335            public Element getExportDataElement(
336                    ClassedModel classedModel, String modelClassSimpleName);
337    
338            public Element getExportDataGroupElement(
339                    Class<? extends StagedModel> clazz);
340    
341            public Element getExportDataRootElement();
342    
343            public long getGroupId();
344    
345            public Element getImportDataElement(StagedModel stagedModel);
346    
347            public Element getImportDataElement(
348                    String name, String attribute, String value);
349    
350            public Element getImportDataGroupElement(
351                    Class<? extends StagedModel> clazz);
352    
353            public Element getImportDataRootElement();
354    
355            public Element getImportDataStagedModelElement(StagedModel stagedModel);
356    
357            /**
358             * @deprecated As of 6.2.0, replaced by {@link
359             *             ExportImportPathUtil#getLayoutPath(PortletDataContext, long)}
360             */
361            @Deprecated
362            public String getLayoutPath(long plid);
363    
364            public Map<String, Lock> getLocks();
365    
366            public ManifestSummary getManifestSummary();
367    
368            public Element getMissingReferencesElement();
369    
370            /**
371             * @deprecated As of 7.0.0, replaced by {@link
372             *             #getNewPrimaryKeysMap(String)}
373             */
374            @Deprecated
375            public List<Layout> getNewLayouts();
376    
377            public Map<?, ?> getNewPrimaryKeysMap(Class<?> clazz);
378    
379            public Map<?, ?> getNewPrimaryKeysMap(String className);
380    
381            public Map<String, Map<?, ?>> getNewPrimaryKeysMaps();
382    
383            /**
384             * @deprecated As of 7.0.0, with no direct replacement
385             */
386            @Deprecated
387            public long getOldPlid();
388    
389            public Map<String, String[]> getParameterMap();
390    
391            public Map<String, List<KeyValuePair>> getPermissions();
392    
393            public long getPlid();
394    
395            public String getPortletId();
396    
397            /**
398             * @deprecated As of 6.2.0, replaced by {@link
399             *             ExportImportPathUtil#getPortletPath(PortletDataContext,
400             *             String)}
401             */
402            @Deprecated
403            public String getPortletPath(String portletId);
404    
405            public Set<String> getPrimaryKeys();
406    
407            /**
408             * @deprecated As of 7.0.0, with no direct replacement
409             */
410            @Deprecated
411            public Map<String, List<RatingsEntry>> getRatingsEntries();
412    
413            public Element getReferenceDataElement(
414                    Element parentElement, Class<?> clazz, long classPK);
415    
416            public Element getReferenceDataElement(
417                    Element parentElement, Class<?> clazz, long groupId, String uuid);
418    
419            public Element getReferenceDataElement(
420                    StagedModel parentStagedModel, Class<?> clazz, long classPK);
421    
422            public Element getReferenceDataElement(
423                    StagedModel parentStagedModel, Class<?> clazz, long groupId,
424                    String uuid);
425    
426            /**
427             * @deprecated As of 7.0.0, with no direct replacement
428             */
429            @Deprecated
430            public List<Element> getReferenceDataElements(
431                    Element parentElement, Class<?> clazz);
432    
433            public List<Element> getReferenceDataElements(
434                    Element parentElement, Class<?> clazz, String referenceType);
435    
436            public List<Element> getReferenceDataElements(
437                    StagedModel parentStagedModel, Class<?> clazz);
438    
439            public List<Element> getReferenceDataElements(
440                    StagedModel parentStagedModel, Class<?> clazz, String referenceType);
441    
442            public Element getReferenceElement(
443                    Element parentElement, Class<?> clazz, long groupId, String uuid,
444                    String referenceType);
445    
446            public Element getReferenceElement(
447                    StagedModel parentStagedModel, Class<?> clazz, long classPK);
448    
449            public Element getReferenceElement(
450                    StagedModel parentStagedModel, String className, long classPK);
451    
452            public List<Element> getReferenceElements(
453                    StagedModel parentStagedModel, Class<?> clazz);
454    
455            /**
456             * @deprecated As of 6.2.0, replaced by {@link
457             *             ExportImportPathUtil#getRootPath(PortletDataContext)}
458             */
459            @Deprecated
460            public String getRootPath();
461    
462            public String getRootPortletId();
463    
464            /**
465             * @deprecated As of 7.0.0, with no direct replacement
466             */
467            @Deprecated
468            public Set<String> getScopedPrimaryKeys();
469    
470            public long getScopeGroupId();
471    
472            public String getScopeLayoutUuid();
473    
474            public String getScopeType();
475    
476            public long getSourceCompanyGroupId();
477    
478            public long getSourceCompanyId();
479    
480            public long getSourceGroupId();
481    
482            /**
483             * @deprecated As of 6.2.0, replaced by {@link
484             *             ExportImportPathUtil#getSourceLayoutPath(PortletDataContext,
485             *             long)}
486             */
487            @Deprecated
488            public String getSourceLayoutPath(long layoutId);
489    
490            /**
491             * @deprecated As of 6.2.0, replaced by {@link
492             *             ExportImportPathUtil#getSourcePortletPath(PortletDataContext,
493             *             String)}
494             */
495            @Deprecated
496            public String getSourcePortletPath(String portletId);
497    
498            /**
499             * @deprecated As of 6.2.0, replaced by {@link
500             *             ExportImportPathUtil#getSourceRootPath(PortletDataContext)}
501             */
502            @Deprecated
503            public String getSourceRootPath();
504    
505            public long getSourceUserPersonalSiteGroupId();
506    
507            public Date getStartDate();
508    
509            public long getUserId(String userUuid);
510    
511            public UserIdStrategy getUserIdStrategy();
512    
513            public long getUserPersonalSiteGroupId();
514    
515            /**
516             * @deprecated As of 7.0.0, with no direct replacement
517             */
518            @Deprecated
519            public List<String> getZipEntries();
520    
521            public byte[] getZipEntryAsByteArray(String path);
522    
523            public InputStream getZipEntryAsInputStream(String path);
524    
525            public Object getZipEntryAsObject(Element element, String path);
526    
527            public Object getZipEntryAsObject(String path);
528    
529            public String getZipEntryAsString(String path);
530    
531            /**
532             * @deprecated As of 7.0.0, with no direct replacement
533             */
534            @Deprecated
535            public List<String> getZipFolderEntries();
536    
537            public List<String> getZipFolderEntries(String path);
538    
539            public ZipReader getZipReader();
540    
541            public ZipWriter getZipWriter();
542    
543            public boolean hasDateRange();
544    
545            public boolean hasNotUniquePerLayout(String dataKey);
546    
547            public boolean hasPrimaryKey(Class<?> clazz, String primaryKey);
548    
549            public boolean hasScopedPrimaryKey(Class<?> clazz, String primaryKey);
550    
551            public void importClassedModel(
552                            ClassedModel classedModel, ClassedModel newClassedModel)
553                    throws PortalException;
554    
555            public void importClassedModel(
556                            ClassedModel classedModel, ClassedModel newClassedModel,
557                            Class<?> clazz)
558                    throws PortalException;
559    
560            /**
561             * @deprecated As of 6.2.0, replaced by {@link
562             *             #importClassedModel(ClassedModel, ClassedModel, Class)}
563             */
564            @Deprecated
565            public void importClassedModel(
566                            ClassedModel classedModel, ClassedModel newClassedModel,
567                            Class<?> clazz, String namespace)
568                    throws PortalException;
569    
570            /**
571             * @deprecated As of 6.2.0, replaced by {@link
572             *             #importClassedModel(ClassedModel, ClassedModel)}
573             */
574            @Deprecated
575            public void importClassedModel(
576                            ClassedModel classedModel, ClassedModel newClassedModel,
577                            String namespace)
578                    throws PortalException;
579    
580            /**
581             * @deprecated As of 7.0.0, replaced by {@link
582             *             BaseStagedModelDataHandler#importComments(PortletDataContext,
583             *             StagedModel)}
584             */
585            @Deprecated
586            public void importComments(
587                            Class<?> clazz, long classPK, long newClassPK, long groupId)
588                    throws PortalException;
589    
590            public void importLocks(Class<?> clazz, String key, String newKey)
591                    throws PortalException;
592    
593            public void importPermissions(Class<?> clazz, long classPK, long newClassPK)
594                    throws PortalException;
595    
596            public void importPermissions(
597                            String resourceName, long resourcePK, long newResourcePK)
598                    throws PortalException;
599    
600            public void importPortalPermissions() throws PortalException;
601    
602            public void importPortletPermissions(String resourceName)
603                    throws PortalException;
604    
605            /**
606             * @deprecated As of 7.0.0, replaced by {@link
607             *             BaseStagedModelDataHandler#importRatings(PortletDataContext,
608             *             StagedModel)}
609             */
610            @Deprecated
611            public void importRatingsEntries(
612                            Class<?> clazz, long classPK, long newClassPK)
613                    throws PortalException;
614    
615            public boolean isCompanyStagedGroupedModel(
616                    StagedGroupedModel stagedGroupedModel);
617    
618            public boolean isDataStrategyMirror();
619    
620            public boolean isDataStrategyMirrorWithOverwriting();
621    
622            public boolean isInitialPublication();
623    
624            public boolean isModelCounted(String className, long classPK);
625    
626            public boolean isPathExportedInScope(String path);
627    
628            /**
629             * @deprecated As of 7.0.0, with no direct replacement
630             */
631            @Deprecated
632            public boolean isPathNotExportedInScope(String path);
633    
634            public boolean isPathNotProcessed(String path);
635    
636            public boolean isPathProcessed(String path);
637    
638            public boolean isPerformDirectBinaryImport();
639    
640            public boolean isPrivateLayout();
641    
642            public boolean isStagedModelCounted(StagedModel stagedModel);
643    
644            public boolean isWithinDateRange(Date modifiedDate);
645    
646            public void putNotUniquePerLayout(String dataKey);
647    
648            public void setClassLoader(ClassLoader classLoader);
649    
650            public void setCompanyGroupId(long companyGroupId);
651    
652            public void setCompanyId(long companyId);
653    
654            public void setDataStrategy(String dataStrategy);
655    
656            public void setEndDate(Date endDate);
657    
658            public void setExportDataRootElement(Element exportDataRootElement);
659    
660            public void setGroupId(long groupId);
661    
662            public void setImportDataRootElement(Element importDataRootElement);
663    
664            public void setManifestSummary(ManifestSummary manifestSummary);
665    
666            public void setMissingReferencesElement(Element missingReferencesElement);
667    
668            public void setNewLayouts(List<Layout> newLayouts);
669    
670            public void setOldPlid(long oldPlid);
671    
672            public void setParameterMap(Map<String, String[]> parameterMap);
673    
674            public void setPlid(long plid);
675    
676            /**
677             * @deprecated As of 7.0.0, with no direct replacement
678             */
679            @Deprecated
680            public void setPortetDataContextListener(
681                    PortletDataContextListener portletDataContextListener);
682    
683            public void setPortletId(String portletId);
684    
685            public void setPrivateLayout(boolean privateLayout);
686    
687            public void setScopeGroupId(long scopeGroupId);
688    
689            public void setScopeLayoutUuid(String scopeLayoutUuid);
690    
691            public void setScopeType(String scopeType);
692    
693            public void setSourceCompanyGroupId(long sourceCompanyGroupId);
694    
695            public void setSourceCompanyId(long sourceCompanyId);
696    
697            public void setSourceGroupId(long sourceGroupId);
698    
699            public void setSourceUserPersonalSiteGroupId(
700                    long sourceUserPersonalSiteGroupId);
701    
702            public void setStartDate(Date startDate);
703    
704            public void setUserIdStrategy(UserIdStrategy userIdStrategy);
705    
706            public void setUserPersonalSiteGroupId(long userPersonalSiteGroupId);
707    
708            public void setZipReader(ZipReader zipReader);
709    
710            public void setZipWriter(ZipWriter zipWriter);
711    
712            public String toXML(Object object);
713    
714    }