| PortletDataHandler.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * The contents of this file are subject to the terms of the Liferay Enterprise
5 * Subscription License ("License"). You may not use this file except in
6 * compliance with the License. You can obtain a copy of the License by
7 * contacting Liferay, Inc. See the License for the specific language governing
8 * permissions and limitations under the License, including but not limited to
9 * distribution rights of the Software.
10 *
11 *
12 *
13 */
14
15 package com.liferay.portal.lar;
16
17 import javax.portlet.PortletPreferences;
18
19 /**
20 * <a href="PortletDataHandler.java.html"><b><i>View Source</i></b></a>
21 *
22 * <p>
23 * A <code>PortletDataHandler</code> is a special class capable of exporting and
24 * importing portlet specific data to a Liferay Archive file (LAR) when a
25 * community's layouts are exported or imported.
26 * <code>PortletDataHandler</code>s are defined by placing a
27 * <code>portlet-data-handler-class</code> element in the <code>portlet</code>
28 * section of the <b>liferay-portlet.xml</b> file.
29 * </p>
30 *
31 * @author Raymond Augé
32 * @author Joel Kozikowski
33 * @author Bruno Farache
34 */
35 public interface PortletDataHandler {
36
37 /**
38 * Deletes the data created by the portlet. Can optionally return a modified
39 * version of <code>prefs</code> if it contains reference to data that does
40 * not exist anymore.
41 *
42 * @param context the context of the data deletion
43 * @param portletId the portlet id of the portlet
44 * @param prefs the portlet preferences of the portlet
45 * @return A modified version of prefs that should be saved. Null if
46 * the preferences were unmodified by this data handler.
47 */
48 public PortletPreferences deleteData(
49 PortletDataContext context, String portletId,
50 PortletPreferences prefs)
51 throws PortletDataException;
52
53 /**
54 * Returns a string of data to be placed in the <portlet-data> section
55 * of the LAR file. This data will be passed as the <code>data</code>
56 * parameter of <code>importData()</code>.
57 *
58 * @param context the context of the data export
59 * @param portletId the portlet id of the portlet
60 * @param prefs the portlet preferences of the portlet
61 * @return A string of data to be placed in the LAR. It may be XML,
62 * but not necessarily. Null should be returned if no portlet
63 * data is to be written out.
64 */
65 public String exportData(
66 PortletDataContext context, String portletId,
67 PortletPreferences prefs)
68 throws PortletDataException;
69
70 /**
71 * Returns an array of the controls defined for this data handler. These
72 * controls enable the developer to create fine grained controls over export
73 * behavior. The controls are rendered in the export UI.
74 *
75 * @return an array of PortletDataHandlerControls
76 */
77 public PortletDataHandlerControl[] getExportControls()
78 throws PortletDataException;
79
80 /**
81 * Returns an array of the controls defined for this data handler. These
82 * controls enable the developer to create fine grained controls over import
83 * behavior. The controls are rendered in the import UI.
84 *
85 * @return An array of PortletDataHandlerControls
86 */
87 public PortletDataHandlerControl[] getImportControls()
88 throws PortletDataException;
89
90 /**
91 * Handles any special processing of the data when the portlet is imported
92 * into a new layout. Can optionally return a modified version of
93 * <code>prefs</code> to be saved in the new portlet.
94 *
95 * @param context the context of the data import
96 * @param portletId the portlet id of the portlet
97 * @param prefs the portlet preferences of the portlet
98 * @param data the string data that was returned by
99 * <code>exportData()</code>
100 * @return A modified version of prefs that should be
101 * saved. Null if the preferences were unmodified by this data
102 * handler.
103 */
104 public PortletPreferences importData(
105 PortletDataContext context, String portletId,
106 PortletPreferences prefs, String data)
107 throws PortletDataException;
108
109 /**
110 * Returns whether the data exported by this handler should be included by
111 * default when publishing to live. This should only be true for data that
112 * is meant to be managed in an staging environment such as CMS content, but
113 * not for data meant to be input by users such as wiki pages or message
114 * board posts.
115 *
116 * @return true to publish to live by default
117 */
118 public boolean isPublishToLiveByDefault();
119
120 }