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.model.Portlet; 018 019 import javax.portlet.PortletPreferences; 020 021 /** 022 * A <code>PortletDataHandler</code> is a special class capable of exporting and 023 * importing portlet specific data to a Liferay Archive file (LAR) when a site's 024 * layouts are exported or imported. <code>PortletDataHandler</code>s are 025 * defined by placing a <code>portlet-data-handler-class</code> element in the 026 * <code>portlet</code> section of the <b>liferay-portlet.xml</b> file. 027 * 028 * @author Raymond Aug?? 029 * @author Joel Kozikowski 030 * @author Bruno Farache 031 */ 032 public interface PortletDataHandler { 033 034 /** 035 * Deletes the data created by the portlet. Can optionally return a modified 036 * version of <code>preferences</code> if it contains reference to data that 037 * does not exist anymore. 038 * 039 * @param portletDataContext the context of the data deletion 040 * @param portletId the portlet ID of the portlet 041 * @param portletPreferences the portlet preferences of the portlet 042 * @return A modified version of portlet preferences that should be saved. 043 * <code>Null</code> if the portlet preferences were unmodified by 044 * this data handler. 045 * @throws PortletDataException if a portlet data exception occurred 046 */ 047 public PortletPreferences deleteData( 048 PortletDataContext portletDataContext, String portletId, 049 PortletPreferences portletPreferences) 050 throws PortletDataException; 051 052 /** 053 * Returns a string of data to be placed in the <portlet-data> section 054 * of the LAR file. This data will be passed as the <code>data</code> 055 * parameter of <code>importData()</code>. 056 * 057 * @param portletDataContext the context of the data export 058 * @param portletId the portlet ID of the portlet 059 * @param portletPreferences the portlet preferences of the portlet 060 * @return A string of data to be placed in the LAR. It may be XML, but not 061 * necessarily. <code>Null</code> should be returned if no portlet 062 * data is to be written out. 063 * @throws PortletDataException if a portlet data exception occurred 064 */ 065 public String exportData( 066 PortletDataContext portletDataContext, String portletId, 067 PortletPreferences portletPreferences) 068 throws PortletDataException; 069 070 public DataLevel getDataLevel(); 071 072 /** 073 * Returns an array of the portlet preferences that reference data. These 074 * preferences should only be updated if the referenced data is imported. 075 * 076 * @return A String array 077 */ 078 public String[] getDataPortletPreferences(); 079 080 public StagedModelType[] getDeletionSystemEventStagedModelTypes(); 081 082 public PortletDataHandlerControl[] getExportConfigurationControls( 083 long companyId, long groupId, Portlet portlet, 084 boolean privateLayout) 085 throws Exception; 086 087 public PortletDataHandlerControl[] getExportConfigurationControls( 088 long companyId, long groupId, Portlet portlet, long plid, 089 boolean privateLayout) 090 throws Exception; 091 092 /** 093 * Returns an array of the controls defined for this data handler. These 094 * controls enable the developer to create fine grained controls over export 095 * behavior. The controls are rendered in the export UI. 096 * 097 * @return an array of PortletDataHandlerControls 098 * @throws PortletDataException if a portlet data exception occurred 099 */ 100 public PortletDataHandlerControl[] getExportControls() 101 throws PortletDataException; 102 103 /** 104 * Returns an array of the metadata controls defined for this data handler. 105 * These controls enable the developer to create fine grained controls over 106 * export behavior of metadata such as tags, categories, ratings or 107 * comments. The controls are rendered in the export UI. 108 * 109 * @return an array of PortletDataHandlerControls 110 * @throws PortletDataException if a portlet data exception occurred 111 */ 112 public PortletDataHandlerControl[] getExportMetadataControls() 113 throws PortletDataException; 114 115 public long getExportModelCount(ManifestSummary manifestSummary); 116 117 public PortletDataHandlerControl[] getImportConfigurationControls( 118 Portlet portlet, ManifestSummary manifestSummary); 119 120 public PortletDataHandlerControl[] getImportConfigurationControls( 121 String[] configurationPortletOptions); 122 123 /** 124 * Returns an array of the controls defined for this data handler. These 125 * controls enable the developer to create fine grained controls over import 126 * behavior. The controls are rendered in the import UI. 127 * 128 * @return An array of PortletDataHandlerControls 129 * @throws PortletDataException if a portlet data exception occurred 130 */ 131 public PortletDataHandlerControl[] getImportControls() 132 throws PortletDataException; 133 134 /** 135 * Returns an array of the metadata controls defined for this data handler. 136 * These controls enable the developer to create fine grained controls over 137 * import behavior of metadata such as tags, categories, ratings or 138 * comments. The controls are rendered in the export UI. 139 * 140 * @return an array of PortletDataHandlerControls 141 * @throws PortletDataException if a portlet data exception occurred 142 */ 143 public PortletDataHandlerControl[] getImportMetadataControls() 144 throws PortletDataException; 145 146 public String getPortletId(); 147 148 /** 149 * Handles any special processing of the data when the portlet is imported 150 * into a new layout. Can optionally return a modified version of 151 * <code>preferences</code> to be saved in the new portlet. 152 * 153 * @param portletDataContext the context of the data import 154 * @param portletId the portlet ID of the portlet 155 * @param portletPreferences the portlet preferences of the portlet 156 * @param data the string data that was returned by 157 * <code>exportData()</code> 158 * @return A modified version of portlet preferences that should be saved. 159 * <code>Null</code> if the portlet preferences were unmodified by 160 * this data handler. 161 * @throws PortletDataException if a portlet data exception occurred 162 */ 163 public PortletPreferences importData( 164 PortletDataContext portletDataContext, String portletId, 165 PortletPreferences portletPreferences, String data) 166 throws PortletDataException; 167 168 public boolean isDataLocalized(); 169 170 public boolean isDataPortalLevel(); 171 172 public boolean isDataPortletInstanceLevel(); 173 174 public boolean isDataSiteLevel(); 175 176 public boolean isDisplayPortlet(); 177 178 /** 179 * Returns whether the data exported by this handler should be included by 180 * default when publishing to live. This should only be <code>true</code> 181 * for data that is meant to be managed in an staging environment such as 182 * CMS content, but not for data meant to be input by users such as wiki 183 * pages or message board posts. 184 * 185 * @return <code>true</code> to publish to live by default 186 */ 187 public boolean isPublishToLiveByDefault(); 188 189 public boolean isSupportsDataStrategyCopyAsNew(); 190 191 public void prepareManifestSummary(PortletDataContext portletDataContext) 192 throws PortletDataException; 193 194 public void prepareManifestSummary( 195 PortletDataContext portletDataContext, 196 PortletPreferences portletPreferences) 197 throws PortletDataException; 198 199 public PortletPreferences processExportPortletPreferences( 200 PortletDataContext portletDataContext, String portletId, 201 PortletPreferences portletPreferences) 202 throws PortletDataException; 203 204 public PortletPreferences processImportPortletPreferences( 205 PortletDataContext portletDataContext, String portletId, 206 PortletPreferences portletPreferences) 207 throws PortletDataException; 208 209 public void setPortletId(String portletId); 210 211 }