001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.kernel.lar;
022:
023: import javax.portlet.PortletPreferences;
024:
025: /**
026: * <a href="PortletDataHandler.java.html"><b><i>View Source</i></b></a>
027: *
028: * <p>
029: * A <code>PortletDataHandler</code> is a special class capable of exporting and
030: * importing portlet specific data to a Liferay Archive file (LAR) when a
031: * community's layouts are exported or imported.
032: * <code>PortletDataHandler</code>s are defined by placing a
033: * <code>portlet-data-handler-class</code> element in the <code>portlet</code>
034: * section of the <b>liferay-portlet.xml</b> file.
035: * </p>
036: *
037: * @author Raymond Augé
038: * @author Joel Kozikowski
039: * @author Bruno Farache
040: *
041: */
042: public interface PortletDataHandler {
043:
044: /**
045: * Deletes the data created by the portlet. Can optionally return a modified
046: * version of <code>prefs</code> if it contains reference to data that
047: * does not exist anymore.
048: *
049: * @param context the context of the data deletion
050: * @param portletId the portlet id of the portlet
051: * @param prefs the portlet preferences of the portlet
052: *
053: * @return A modified version of prefs that should be saved. Null if
054: * the preferences were unmodified by this data handler.
055: * @throws PortletDataException
056: */
057: public PortletPreferences deleteData(PortletDataContext context,
058: String portletId, PortletPreferences prefs)
059: throws PortletDataException;
060:
061: /**
062: * Returns a string of data to be placed in the <portlet-data> section
063: * of the LAR file. This data will be passed as the <code>data</code>
064: * parameter of <code>importData()</code>.
065: *
066: * @param context the context of the data export
067: * @param portletId the portlet id of the portlet
068: * @param prefs the portlet preferences of the portlet
069: * @return A string of data to be placed in the LAR. It may be XML,
070: * but not necessarily. Null should be returned if no portlet
071: * data is to be written out.
072: * @throws PortletDataException
073: */
074: public String exportData(PortletDataContext context,
075: String portletId, PortletPreferences prefs)
076: throws PortletDataException;
077:
078: /**
079: * Returns an array of the controls defined for this data handler. These
080: * controls enable the developer to create fine grained controls over export
081: * behavior. The controls are rendered in the export UI.
082: *
083: * @return an array of PortletDataHandlerControls
084: */
085: public PortletDataHandlerControl[] getExportControls()
086: throws PortletDataException;
087:
088: /**
089: * Returns an array of the controls defined for this data handler. These
090: * controls enable the developer to create fine grained controls over import
091: * behavior. The controls are rendered in the import UI.
092: *
093: * @return An array of PortletDataHandlerControls
094: */
095: public PortletDataHandlerControl[] getImportControls()
096: throws PortletDataException;
097:
098: /**
099: * Handles any special processing of the data when the portlet is imported
100: * into a new layout. Can optionally return a modified version of
101: * <code>prefs</code> to be saved in the new portlet.
102: *
103: * @param context the context of the data import
104: * @param portletId the portlet id of the portlet
105: * @param prefs the portlet preferences of the portlet
106: * @param data the string data that was returned by
107: * <code>exportData()</code>
108: * @return A modified version of prefs that should be
109: * saved. Null if the preferences were unmodified by this data
110: * handler.
111: * @throws PortletDataException
112: */
113: public PortletPreferences importData(PortletDataContext context,
114: String portletId, PortletPreferences prefs, String data)
115: throws PortletDataException;
116:
117: }
|