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