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