View Javadoc
1   /*
2    * Copyright (c) 2002-2022, City of Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.genericattributes.service.entrytype;
35  
36  import fr.paris.lutece.plugins.genericattributes.business.Entry;
37  import fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError;
38  import fr.paris.lutece.plugins.genericattributes.business.Response;
39  import fr.paris.lutece.plugins.genericattributes.service.anonymization.IEntryAnonymizationType;
40  import fr.paris.lutece.portal.service.plugin.Plugin;
41  import fr.paris.lutece.util.ReferenceList;
42  
43  import org.apache.commons.fileupload.FileItem;
44  
45  import java.util.List;
46  import java.util.Locale;
47  
48  import javax.servlet.http.HttpServletRequest;
49  
50  /**
51   * Interface for entry type services
52   */
53  public interface IEntryTypeService
54  {
55      // parameters Entry
56      String PARAMETER_MAX_FILES = "max_files";
57      String PARAMETER_FILE_MAX_SIZE = "file_max_size";
58      String PARAMETER_EXPORT_BINARY = "export_binary";
59      String PARAMETER_ENTRY_CODE = "entry_code";
60      String PARAMETER_TITLE = "title";
61      String PARAMETER_HELP_MESSAGE = "help_message";
62      String PARAMETER_COMMENT = "comment";
63      String PARAMETER_MANDATORY = "mandatory";
64      String PARAMETER_FIELD_IN_LINE = "field_in_line";
65      String PARAMETER_HEIGHT = "height";
66      String PARAMETER_WIDTH = "width";
67      String PARAMETER_VALUE = "value";
68      String PARAMETER_MAX_SIZE_ENTER = "max_size_enter";
69      String PARAMETER_CONFIRM_FIELD = "confirm_field";
70      String PARAMETER_CONFIRM_FIELD_TITLE = "confirm_field_title";
71      String SUFFIX_CONFIRM_FIELD = "_confirm_field";
72      String PREFIX_ATTRIBUTE = "attribute";
73      String PREFIX_ITERATION_ATTRIBUTE = "nIt";
74      String PARAMETER_UNIQUE = "unique_field";
75      String PARAMETER_CSS_CLASS = "css_class";
76      String PARAMETER_ERROR_MESSAGE = "errorMessage";
77      String PARAMETER_NUMBER_ROWS = "num_row";
78      String PARAMETER_NUMBER_COLUMNS = "num_column";
79      String PARAMETER_ONLY_DISPLAY_IN_BACK = "only_display_in_back";
80      String PARAMETER_MAX_IMAGE_SIZE = "maxImageSize";
81      String PARAMETER_IMAGE_TYPE = "image_type";
82      String PARAMETER_INDEXED = "is_indexed";
83      String PARAMETER_EXPORTABLE = "exportable";
84      String PARAMETER_EXPORTABLE_PDF = "exportable_pdf";
85      String PARAMETER_PUBLISHED = "published";
86      String PARAMETER_DISPLAY_BO = "display_in_bo";
87      String PARAMETER_FILE = "file";
88      String PARAMETER_MIN = "min";
89      String PARAMETER_MAX = "max";
90      String PARAMETER_ANONYMIZABLE = "anonymizable";
91      String PARAMETER_ANONYMIZE_PATTERN = "anonymize_pattern";
92      String PARAMETER_USE_REF_LIST = "use_ref_list";
93      String PARAMETER_REF_LIST_SELECT = "select_ref_list";
94      String PARAMETER_PLACEHOLDER = "placeholder";
95      String PARAMETER_ILLUSTRATION_IMAGE = "illustration_image";
96      String PARAMETER_DISABLED = "disabled";
97  
98      // Fields codes
99      String FIELD_DATE_VALUE = "default_date_value";
100     String FIELD_PROVIDER = "provider";
101     String FIELD_EDIT_MODE = "editMode";
102     String FIELD_VIEW_NUMBER = "viewNumber";
103     String FIELD_ID_ADDRESS = "idAddress";
104     String FIELD_ADDRESS = "address";
105     String FIELD_ADDITIONAL_ADDRESS = "additionalAddress";
106     String FIELD_X = "X";
107     String FIELD_Y = "Y";
108     String FIELD_GEOMETRY = "geometry";
109     String FIELD_PREFIX = "prefix";
110     String FIELD_SUFFIX = "suffix";
111     String FIELD_FILE_MAX_SIZE = "file_max_size";
112     String FIELD_MAX_FILES = "max_files";
113     String FIELD_FILE_BINARY = "export_binary";
114     String FIELD_FILE_TYPE = "file_type";
115     String FIELD_ANSWER_CHOICE = "answer_choice";
116     String FIELD_ARRAY_CELL = "array_cell";
117     String FIELD_ATTRIBUTE_NAME = "attribute_name";
118     String FIELD_CONFIRM = "confirm_field";
119     String FIELD_MYLUTECE_ATTRIBUTE_NAME_CODE = "attribute_name";
120     String FIELD_ARRAY_ROW = "array_row";
121     String FIELD_ARRAY_COLUMN = "array_column";
122     String FIELD_IMAGE_TYPE = "image_type";
123     String FIELD_WIDTH = "width";
124     String FIELD_HEIGHT = "height";
125     String FIELD_MAX = "max";
126     String FIELD_MIN = "min";
127     String FIELD_MAX_SIZE = "max_size";
128     String FIELD_TEXT_CONF = "text_config";
129     String FIELD_EXPORTABLE = "exportable";
130     String FIELD_EXPORTABLE_PDF = "exportable_pdf";
131     String FIELD_PUBLISHED = "published";
132     String FIELD_RICHTEXT = "richtext";
133     String FIELD_DISPLAY_BO = PARAMETER_DISPLAY_BO;
134     String FIELD_DOWNLOADABLE_FILE = "downloadable_file";
135     String FIELD_USE_REF_LIST = "use_ref_list";
136     String FIELD_ANONYMIZABLE = "anonymizable";
137     String FIELD_PLACEHOLDER = "placeholder";
138     String FIELD_ILLUSTRATION_IMAGE = "illustration_image";
139     String FIELD_GEOJSON = "coordinates_geojson";
140     String FIELD_ID_LAYER = "DataLayer";
141     String FIELD_DISABLED = "disabled";
142 
143     // attribute
144     String ATTRIBUTE_RESPONSE_ITERATION_NUMBER = "response_iteration_number";
145 
146     // message
147     String MESSAGE_MANDATORY_FIELD = "portal.util.message.mandatoryField";
148     String MESSAGE_NUMERIC_FIELD = "genericattributes.message.numeric.field";
149     String MESSAGE_CONFIRM_FIELD = "genericattributes.message.errorConfirmField";
150     String MESSAGE_UNIQUE_FIELD = "genericattributes.message.errorUniqueField";
151     String MESSAGE_XSS_FIELD = "genericattributes.message.errorXssField";
152     String MESSAGE_MAXLENGTH = "genericattributes.message.maxLength";
153     String MESSAGE_INVALID_SQL_QUERY = "genericattributes.message.invalidSqlQuery";
154     String MESSAGE_MYLUTECE_AUTHENTIFICATION_REQUIRED = "genericattributes.message.myLuteceAuthentificationRequired";
155     String ERROR_FIELD_TITLE = "genericattributes.createEntry.labelTitle";
156     String ERROR_FIELD_MAX_FILES = "genericattributes.createEntry.labelMaxFiles";
157     String ERROR_FIELD_FILE_MAX_SIZE = "genericattributes.createEntry.labelFileMaxSize";
158     String FIELD_INSERT_GROUP = "genericattributes.labelInsertGroup";
159     String FIELD_COMMENT = "genericattributes.createEntry.labelComment";
160     String ERROR_FIELD_WIDTH = "genericattributes.createEntry.labelWidth";
161     String ERROR_FIELD_HEIGHT = "genericattributes.createEntry.labelHeight";
162     String FIELD_MAX_SIZE_ENTER = "genericattributes.createEntry.labelMaxSizeEnter";
163     String FIELD_NUMBER_ROWS = "genericattributes.createEntry.labelNumberRows";
164     String FIELD_NUMBER_COLUMNS = "genericattributes.createEntry.labelNumberColumns";
165     String FIELD_CONFIRM_FIELD_TITLE = "genericattributes.createEntry.labelConfirmFieldTitle";
166     String ERROR_FIELD_FILE_TYPE = "genericattributes.createEntry.fileType";
167     String ERROR_FIELD_REF_LIST = "genericattributes.createEntry.labelUseRefListSelect";
168 
169     String MESSAGE_ERROR_IMPOSSIBLE_SLOT = "genericattributes.message.error.impossibleSlot";
170 
171     String MESSAGE_ERROR_SLOT = "genericattributes.message.error.slot";
172 
173     /**
174      * Get the template to display the creation or modification form of an entry of this entry type
175      * 
176      * @param entry
177      *            The entry
178      * @param bDisplayFront
179      *            True if the template will be used to display content in Front Office, false if it will be used to display content in back office
180      * @return the HtmlCode of the entry
181      */
182     String getTemplateHtmlForm( Entry entry, boolean bDisplayFront );
183 
184     /**
185      * Get template create URL of the entry
186      * 
187      * @param entry
188      *            The entry
189      * @param bDisplayFront
190      *            True if the template will be used to display content in Front Office, false if it will be used to display content in back office
191      * @return template create URL of the entry
192      */
193     String getTemplateCreate( Entry entry, boolean bDisplayFront );
194 
195     /**
196      * Get the template modify URL of the entry
197      * 
198      * @param entry
199      *            The entry
200      * @param bDisplayFront
201      *            True if the template will be used to display content in Front Office, false if it will be used to display content in back office
202      * @return template modify URL of the entry
203      */
204     String getTemplateModify( Entry entry, boolean bDisplayFront );
205 
206     /**
207      * Get the request data
208      * 
209      * @param entry
210      *            The entry
211      * @param request
212      *            HttpRequest
213      * @param locale
214      *            the locale
215      * @return null if all data required are in the request else the url of jsp error
216      */
217     String getRequestData( Entry entry, HttpServletRequest request, Locale locale );
218 
219     /**
220      * Generate the list of responses associated with the given entry from the request, and saved it into the Entry object.
221      * 
222      * @param entry
223      *            The entry
224      * @param request
225      *            HttpRequest
226      * @param listResponse
227      *            the list of response associate to the entry. Newly created response will be inserted in this list.
228      * @param locale
229      *            the locale
230      * @return a GenericAttributeError object if there is an error in the response
231      */
232     GenericAttributeError getResponseData( Entry entry, HttpServletRequest request, List<Response> listResponse, Locale locale );
233 
234     /**
235      * Get the list of regular expression who is use in the template modify of the entry
236      * 
237      * @param entry
238      *            the entry
239      * @param plugin
240      *            the plugin
241      * @return the regular expression list who is use in the template modify of the entry
242      */
243     ReferenceList getReferenceListRegularExpression( Entry entry, Plugin plugin );
244 
245     /**
246      * Get the response value associate to the entry to export in the file export
247      * 
248      * @param entry
249      *            The entry
250      * @param response
251      *            the response associate to the entry
252      * @param locale
253      *            the locale
254      * @param request
255      *            the request
256      * @return the response value associate to the entry to export in the file export
257      */
258     String getResponseValueForExport( Entry entry, HttpServletRequest request, Response response, Locale locale );
259 
260     /**
261      * Get the response value associate to the entry to write in the recap
262      * 
263      * @param entry
264      *            The entry
265      * @param response
266      *            the response associate to the entry
267      * @param locale
268      *            the locale
269      * @param request
270      *            the request
271      * @return the response value associate to the entry to write in the recap
272      */
273     String getResponseValueForRecap( Entry entry, HttpServletRequest request, Response response, Locale locale );
274 
275     /**
276      * Check if the file can be uploaded or not. This method will check the size of each file and the number max of files that can be uploaded.
277      * 
278      * @param entry
279      *            The entry
280      * @param listUploadedFileItems
281      *            the list of uploaded files
282      * @param listFileItemsToUpload
283      *            the list of files to upload
284      * @param locale
285      *            the locale
286      * @return The error if there is any
287      */
288     GenericAttributeError canUploadFiles( Entry entry, List<FileItem> listUploadedFileItems, List<FileItem> listFileItemsToUpload, Locale locale );
289 
290     /**
291      * Sets the string value of the response
292      * 
293      * @param entry
294      *            The entry
295      * @param response
296      *            the response
297      * @param locale
298      *            the locale - will use a default one if not specified
299      */
300     void setResponseToStringValue( Entry entry, Response response, Locale locale );
301 
302     /**
303      * Return the iteration number for a response from the request
304      * 
305      * @param request
306      *            the request to retrieve the iteration number of the response from
307      * @return the value of the iteration number
308      */
309     int getResponseIterationValue( HttpServletRequest request );
310 
311     /**
312      * Return the template associated to an EntryType for read only uses
313      * 
314      * @return the template associated to an EntryType for read only uses
315      */
316     String getTemplateEntryReadOnly( );
317 
318     /**
319      * Return the template associated to an EntryType for read only uses
320      * 
321      * @param bDisplayFront
322      *            true
323      * @return the template associated to an EntryType for read only uses
324      */
325     String getTemplateEntryReadOnly( boolean bDisplayFront );
326 
327     /**
328      * Creates the help message for the enrty anonymisation config.
329      * 
330      * @param locale
331      * @return
332      */
333     String getAnonymizationHelpMessage( Locale locale );
334 
335     /**
336      * get the list of valids wildcard for the entry
337      * 
338      * @return
339      */
340     List<IEntryAnonymizationType> getValidWildcards( );
341 }