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