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