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