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