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