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