View Javadoc
1   /*
2    * Copyright (c) 2002-2023, 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.document.service;
35  
36  import fr.paris.lutece.plugins.document.business.Document;
37  import fr.paris.lutece.plugins.document.business.attributes.AttributeTypeParameter;
38  import fr.paris.lutece.plugins.document.business.attributes.DocumentAttribute;
39  
40  import java.util.List;
41  import java.util.Locale;
42  
43  import javax.servlet.http.HttpServletRequest;
44  
45  
46  /**
47   * Define the interface for attribute's specific behavior
48   */
49  public interface AttributeManager
50  {
51      /**
52       * Define the attribute Type code
53       * @param strCode The Attribute Type Code
54       */
55      void setAttributeTypeCode( String strCode );
56  
57      /**
58       * Return the attribute Type code
59       * @return The Attribute Type Code
60       */
61      String getAttributeTypeCode(  );
62  
63      /**
64       * Gets the part of an HTML form to enter attribute data
65       * @param attribute The attribute
66       * @param locale The current Locale
67       * @param strBaseUrl the base url
68       * @return A part of the HTML form
69       */
70      String getCreateFormHtml( DocumentAttribute attribute, Locale locale, String strBaseUrl );
71  
72      /**
73       * Gets the part of an HTML form to modify attribute data
74       * @param attribute The attribute
75       * @param document The attribute document
76       * @param locale The current Locale
77       * @param strBaseUrl The base url
78       * @return A part of the HTML form
79       */
80      String getModifyFormHtml( DocumentAttribute attribute, Document document, Locale locale, String strBaseUrl );
81  
82      /**
83       * Gets the part of an HTML form to enter parameters data
84       * @param locale The current Locale
85       * @return A part of the HTML form
86       */
87      String getCreateParametersFormHtml( Locale locale );
88  
89      /**
90       * Gets the part of an HTML form to enter parameters data
91       * @param listParameters list attribute type parameters
92       * @param locale The current Locale
93       * @return A part of the HTML form
94       */
95      String getCreateParametersFormHtml( List<AttributeTypeParameter> listParameters, Locale locale );
96  
97      /**
98       * Gets the part of an HTML form to modify parameters data
99       * @param locale The current Locale
100      * @param nAttributeId Attribute Id
101      * @return A part of the HTML form
102      */
103     String getModifyParametersFormHtml( Locale locale, int nAttributeId );
104 
105     /**
106      * Gets extra parameters for the attribute
107      * @param locale The current Locale
108      * @return A collection of attribute parameters
109      */
110     List<AttributeTypeParameter> getExtraParameters( Locale locale );
111 
112     /**
113      * Gets extra parameters values for the attribute
114      * @param locale The current Locale
115      * @param nAttributeId
116      * @return The extra parameters values for the attribute
117      */
118     List<AttributeTypeParameter> getExtraParametersValues( Locale locale, int nAttributeId );
119 
120     /**
121      * Validate the value for the attribute
122      * @param nAttributeId The attribute identifier
123      * @param strValue The value to check
124      * @param locale The current Locale
125      * @return null if valid, otherwise error message
126      */
127     String validateValue( int nAttributeId, String strValue, Locale locale );
128 
129     /**
130      * Validate the value for the parameters
131      * @param listParameters The list of parameters to check
132      * @param locale The locale
133      * @return null if valid, otherwise message property
134      */
135     String validateValueParameters( List<AttributeTypeParameter> listParameters, Locale locale );
136 
137     /**
138      * Get the XML data corresponding to the attribute to build the docuemnt XML
139      * content
140      * @param document The document
141      * @param attribute The attribute
142      * @return The XML value of the attribute
143      */
144     String getAttributeXmlValue( Document document, DocumentAttribute attribute );
145 
146     /**
147      * Tells if the attrubute can be used as Thumbnail (image)
148      * @return true if the attrubute can be used as Thumbnail, otherwise false
149      */
150     boolean canBeUsedAsThumbnail(  );
151 
152     /**
153      * Get the value parameters
154      * @param request the HTTP request
155      * @param locale the locale
156      * @return a list of {@link AttributeTypeParameter}
157      */
158     List<AttributeTypeParameter> getValueParameters( HttpServletRequest request, Locale locale );
159 }