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 Map<String, List<AssetLink>> getAssetLinksMap();
295    
296            public String[] getAssetTagNames(Class<?> clazz, long classPK);
297    
298            public String[] getAssetTagNames(String className, long classPK);
299    
300            public Map<String, String[]> getAssetTagNamesMap();
301    
302            public boolean getBooleanParameter(String namespace, String name);
303    
304            public boolean getBooleanParameter(
305                    String namespace, String name, boolean useDefaultValue);
306    
307            public ClassLoader getClassLoader();
308    
309            /**
310             * @deprecated As of 7.0.0, with no direct replacement
311             */
312            @Deprecated
313            public Map<String, List<MBMessage>> getComments();
314    
315            public long getCompanyGroupId();
316    
317            public long getCompanyId();
318    
319            public String getDataStrategy();
320    
321            public DateRange getDateRange();
322    
323            public Criterion getDateRangeCriteria(String propertyName);
324    
325            public Set<StagedModelType> getDeletionSystemEventStagedModelTypes();
326    
327            public Date getEndDate();
328    
329            public Map<String, List<ExpandoColumn>> getExpandoColumns();
330    
331            public Element getExportDataElement(ClassedModel classedModel);
332    
333            /**
334             * @deprecated As of 7.0.0, replaced by {@link
335             *             #getExportDataElement(ClassedModel, String)}
336             */
337            @Deprecated
338            public Element getExportDataElement(
339                    ClassedModel classedModel, Class<?> modelClass);
340    
341            public Element getExportDataElement(
342                    ClassedModel classedModel, String modelClassSimpleName);
343    
344            public Element getExportDataGroupElement(
345                    Class<? extends StagedModel> clazz);
346    
347            public Element getExportDataRootElement();
348    
349            public long getGroupId();
350    
351            public Element getImportDataElement(StagedModel stagedModel);
352    
353            public Element getImportDataElement(
354                    String name, String attribute, String value);
355    
356            public Element getImportDataGroupElement(
357                    Class<? extends StagedModel> clazz);
358    
359            public Element getImportDataRootElement();
360    
361            public Element getImportDataStagedModelElement(StagedModel stagedModel);
362    
363            /**
364             * @deprecated As of 6.2.0, replaced by {@link
365             *             ExportImportPathUtil#getLayoutPath(PortletDataContext, long)}
366             */
367            @Deprecated
368            public String getLayoutPath(long plid);
369    
370            public Map<String, Lock> getLocks();
371    
372            public ManifestSummary getManifestSummary();
373    
374            public Element getMissingReferencesElement();
375    
376            /**
377             * @deprecated As of 7.0.0, replaced by {@link
378             *             #getNewPrimaryKeysMap(String)}
379             */
380            @Deprecated
381            public List<Layout> getNewLayouts();
382    
383            public Map<?, ?> getNewPrimaryKeysMap(Class<?> clazz);
384    
385            public Map<?, ?> getNewPrimaryKeysMap(String className);
386    
387            public Map<String, Map<?, ?>> getNewPrimaryKeysMaps();
388    
389            /**
390             * @deprecated As of 7.0.0, with no direct replacement
391             */
392            @Deprecated
393            public long getOldPlid();
394    
395            public Map<String, String[]> getParameterMap();
396    
397            public Map<String, List<KeyValuePair>> getPermissions();
398    
399            public long getPlid();
400    
401            public String getPortletId();
402    
403            /**
404             * @deprecated As of 6.2.0, replaced by {@link
405             *             ExportImportPathUtil#getPortletPath(PortletDataContext,
406             *             String)}
407             */
408            @Deprecated
409            public String getPortletPath(String portletId);
410    
411            public Set<String> getPrimaryKeys();
412    
413            /**
414             * @deprecated As of 7.0.0, with no direct replacement
415             */
416            @Deprecated
417            public Map<String, List<RatingsEntry>> getRatingsEntries();
418    
419            public Element getReferenceDataElement(
420                    Element parentElement, Class<?> clazz, long classPK);
421    
422            public Element getReferenceDataElement(
423                    Element parentElement, Class<?> clazz, long groupId, String uuid);
424    
425            public Element getReferenceDataElement(
426                    StagedModel parentStagedModel, Class<?> clazz, long classPK);
427    
428            public Element getReferenceDataElement(
429                    StagedModel parentStagedModel, Class<?> clazz, long groupId,
430                    String uuid);
431    
432            /**
433             * @deprecated As of 7.0.0, with no direct replacement
434             */
435            @Deprecated
436            public List<Element> getReferenceDataElements(
437                    Element parentElement, Class<?> clazz);
438    
439            public List<Element> getReferenceDataElements(
440                    Element parentElement, Class<?> clazz, String referenceType);
441    
442            public List<Element> getReferenceDataElements(
443                    StagedModel parentStagedModel, Class<?> clazz);
444    
445            public List<Element> getReferenceDataElements(
446                    StagedModel parentStagedModel, Class<?> clazz, String referenceType);
447    
448            public Element getReferenceElement(Class<?> clazz, long classPK);
449    
450            public Element getReferenceElement(
451                    Element parentElement, Class<?> clazz, long groupId, String uuid,
452                    String referenceType);
453    
454            public Element getReferenceElement(
455                    StagedModel parentStagedModel, Class<?> clazz, long classPK);
456    
457            public Element getReferenceElement(
458                    StagedModel parentStagedModel, String className, long classPK);
459    
460            public Element getReferenceElement(String className, long classPK);
461    
462            public List<Element> getReferenceElements(
463                    StagedModel parentStagedModel, Class<?> clazz);
464    
465            /**
466             * @deprecated As of 6.2.0, replaced by {@link
467             *             ExportImportPathUtil#getRootPath(PortletDataContext)}
468             */
469            @Deprecated
470            public String getRootPath();
471    
472            public String getRootPortletId();
473    
474            /**
475             * @deprecated As of 7.0.0, with no direct replacement
476             */
477            @Deprecated
478            public Set<String> getScopedPrimaryKeys();
479    
480            public long getScopeGroupId();
481    
482            public String getScopeLayoutUuid();
483    
484            public String getScopeType();
485    
486            public long getSourceCompanyGroupId();
487    
488            public long getSourceCompanyId();
489    
490            public long getSourceGroupId();
491    
492            /**
493             * @deprecated As of 6.2.0, replaced by {@link
494             *             ExportImportPathUtil#getSourceLayoutPath(PortletDataContext,
495             *             long)}
496             */
497            @Deprecated
498            public String getSourceLayoutPath(long layoutId);
499    
500            /**
501             * @deprecated As of 6.2.0, replaced by {@link
502             *             ExportImportPathUtil#getSourcePortletPath(PortletDataContext,
503             *             String)}
504             */
505            @Deprecated
506            public String getSourcePortletPath(String portletId);
507    
508            /**
509             * @deprecated As of 6.2.0, replaced by {@link
510             *             ExportImportPathUtil#getSourceRootPath(PortletDataContext)}
511             */
512            @Deprecated
513            public String getSourceRootPath();
514    
515            public long getSourceUserPersonalSiteGroupId();
516    
517            public Date getStartDate();
518    
519            public long getUserId(String userUuid);
520    
521            public UserIdStrategy getUserIdStrategy();
522    
523            public long getUserPersonalSiteGroupId();
524    
525            /**
526             * @deprecated As of 7.0.0, with no direct replacement
527             */
528            @Deprecated
529            public List<String> getZipEntries();
530    
531            public byte[] getZipEntryAsByteArray(String path);
532    
533            public InputStream getZipEntryAsInputStream(String path);
534    
535            public Object getZipEntryAsObject(Element element, String path);
536    
537            public Object getZipEntryAsObject(String path);
538    
539            public String getZipEntryAsString(String path);
540    
541            /**
542             * @deprecated As of 7.0.0, with no direct replacement
543             */
544            @Deprecated
545            public List<String> getZipFolderEntries();
546    
547            public List<String> getZipFolderEntries(String path);
548    
549            public ZipReader getZipReader();
550    
551            public ZipWriter getZipWriter();
552    
553            public boolean hasDateRange();
554    
555            public boolean hasNotUniquePerLayout(String dataKey);
556    
557            public boolean hasPrimaryKey(Class<?> clazz, String primaryKey);
558    
559            public boolean hasScopedPrimaryKey(Class<?> clazz, String primaryKey);
560    
561            public void importClassedModel(
562                            ClassedModel classedModel, ClassedModel newClassedModel)
563                    throws PortalException;
564    
565            public void importClassedModel(
566                            ClassedModel classedModel, ClassedModel newClassedModel,
567                            Class<?> clazz)
568                    throws PortalException;
569    
570            /**
571             * @deprecated As of 6.2.0, replaced by {@link
572             *             #importClassedModel(ClassedModel, ClassedModel, Class)}
573             */
574            @Deprecated
575            public void importClassedModel(
576                            ClassedModel classedModel, ClassedModel newClassedModel,
577                            Class<?> clazz, String namespace)
578                    throws PortalException;
579    
580            /**
581             * @deprecated As of 6.2.0, replaced by {@link
582             *             #importClassedModel(ClassedModel, ClassedModel)}
583             */
584            @Deprecated
585            public void importClassedModel(
586                            ClassedModel classedModel, ClassedModel newClassedModel,
587                            String namespace)
588                    throws PortalException;
589    
590            /**
591             * @deprecated As of 7.0.0, replaced by {@link
592             *             BaseStagedModelDataHandler#importComments(PortletDataContext,
593             *             StagedModel)}
594             */
595            @Deprecated
596            public void importComments(
597                            Class<?> clazz, long classPK, long newClassPK, long groupId)
598                    throws PortalException;
599    
600            public void importLocks(Class<?> clazz, String key, String newKey)
601                    throws PortalException;
602    
603            public void importPermissions(Class<?> clazz, long classPK, long newClassPK)
604                    throws PortalException;
605    
606            public void importPermissions(
607                            String resourceName, long resourcePK, long newResourcePK)
608                    throws PortalException;
609    
610            public void importPortalPermissions() throws PortalException;
611    
612            public void importPortletPermissions(String resourceName)
613                    throws PortalException;
614    
615            /**
616             * @deprecated As of 7.0.0, replaced by {@link
617             *             BaseStagedModelDataHandler#importRatings(PortletDataContext,
618             *             StagedModel)}
619             */
620            @Deprecated
621            public void importRatingsEntries(
622                            Class<?> clazz, long classPK, long newClassPK)
623                    throws PortalException;
624    
625            public boolean isCompanyStagedGroupedModel(
626                    StagedGroupedModel stagedGroupedModel);
627    
628            public boolean isDataStrategyMirror();
629    
630            public boolean isDataStrategyMirrorWithOverwriting();
631    
632            public boolean isInitialPublication();
633    
634            public boolean isMissingReference(Element referenceElement);
635    
636            public boolean isModelCounted(String className, long classPK);
637    
638            public boolean isPathExportedInScope(String path);
639    
640            /**
641             * @deprecated As of 7.0.0, with no direct replacement
642             */
643            @Deprecated
644            public boolean isPathNotExportedInScope(String path);
645    
646            public boolean isPathNotProcessed(String path);
647    
648            public boolean isPathProcessed(String path);
649    
650            public boolean isPerformDirectBinaryImport();
651    
652            public boolean isPrivateLayout();
653    
654            public boolean isStagedModelCounted(StagedModel stagedModel);
655    
656            public boolean isWithinDateRange(Date modifiedDate);
657    
658            public void putNotUniquePerLayout(String dataKey);
659    
660            public void setClassLoader(ClassLoader classLoader);
661    
662            public void setCompanyGroupId(long companyGroupId);
663    
664            public void setCompanyId(long companyId);
665    
666            public void setDataStrategy(String dataStrategy);
667    
668            public void setEndDate(Date endDate);
669    
670            public void setExportDataRootElement(Element exportDataRootElement);
671    
672            public void setGroupId(long groupId);
673    
674            public void setImportDataRootElement(Element importDataRootElement);
675    
676            public void setManifestSummary(ManifestSummary manifestSummary);
677    
678            public void setMissingReferencesElement(Element missingReferencesElement);
679    
680            public void setNewLayouts(List<Layout> newLayouts);
681    
682            public void setOldPlid(long oldPlid);
683    
684            public void setParameterMap(Map<String, String[]> parameterMap);
685    
686            public void setPlid(long plid);
687    
688            /**
689             * @deprecated As of 7.0.0, with no direct replacement
690             */
691            @Deprecated
692            public void setPortetDataContextListener(
693                    PortletDataContextListener portletDataContextListener);
694    
695            public void setPortletId(String portletId);
696    
697            public void setPrivateLayout(boolean privateLayout);
698    
699            public void setScopeGroupId(long scopeGroupId);
700    
701            public void setScopeLayoutUuid(String scopeLayoutUuid);
702    
703            public void setScopeType(String scopeType);
704    
705            public void setSourceCompanyGroupId(long sourceCompanyGroupId);
706    
707            public void setSourceCompanyId(long sourceCompanyId);
708    
709            public void setSourceGroupId(long sourceGroupId);
710    
711            public void setSourceUserPersonalSiteGroupId(
712                    long sourceUserPersonalSiteGroupId);
713    
714            public void setStartDate(Date startDate);
715    
716            public void setUserIdStrategy(UserIdStrategy userIdStrategy);
717    
718            public void setUserPersonalSiteGroupId(long userPersonalSiteGroupId);
719    
720            public void setZipReader(ZipReader zipReader);
721    
722            public void setZipWriter(ZipWriter zipWriter);
723    
724            public String toXML(Object object);
725    
726    }