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.portal.business.file;
35  
36  import fr.paris.lutece.portal.business.physicalfile.PhysicalFile;
37  
38  import java.io.Serializable;
39  import java.sql.Timestamp;
40  
41  import com.fasterxml.jackson.annotation.JsonIgnore;
42  
43  /**
44   *
45   * class File
46   *
47   */
48  public class File implements Serializable
49  {
50      private static final long serialVersionUID = -2014847000871390972L;
51      private String _strFileKey;
52      private PhysicalFile _physicalFile;
53      private String _strTitle;
54      private int _nSize;
55      private String _strExtension;
56      private String _strMimeType;
57      private Timestamp _dateCreation;
58      private String _url;
59      private String _strOrigin;
60  
61      /**
62       * get file key
63       * @return the key
64       */
65      public String getFileKey() {
66          return _strFileKey;
67      }
68  
69      /**
70       * set file key
71       * 
72       * @param strFileKey 
73       */
74      public void setFileKey(String strFileKey) {
75          this._strFileKey = strFileKey;
76      }
77  
78      /**
79       * This method should be used for backward compatibility only,
80       * and could throw NumberFormatException if the key is not numeric
81       * 
82       * @return the id of the file
83       */
84      @JsonIgnore
85      @Deprecated
86      public int getIdFile( )
87      {
88          return Integer.parseInt( _strFileKey );
89      }
90  
91      /**
92       *  This method should be used for backward compatibility only
93       * 
94       * @param idFile
95       *            id of the file
96       */
97      @JsonIgnore
98      @Deprecated
99      public void setIdFile( int idFile )
100     {
101         _strFileKey = String.valueOf( idFile );
102     }
103 
104     /**
105      *
106      * @return the title of the file
107      */
108     public String getTitle( )
109     {
110         return _strTitle;
111     }
112 
113     /**
114      * set the title of the file
115      * 
116      * @param title
117      *            the title of the file
118      */
119     public void setTitle( String title )
120     {
121         _strTitle = title;
122     }
123 
124     /**
125      *
126      * @return the size of the file
127      */
128     public int getSize( )
129     {
130         return _nSize;
131     }
132 
133     /**
134      * set the size of the file
135      * 
136      * @param size
137      *            the size of the file
138      */
139     public void setSize( int size )
140     {
141         _nSize = size;
142     }
143 
144     /**
145      *
146      * @return the extension of the file
147      */
148     public String getExtension( )
149     {
150         return _strExtension;
151     }
152 
153     /**
154      * set the extension of the file
155      * 
156      * @param extension
157      *            the title of the file
158      */
159     public void setExtension( String extension )
160     {
161         _strExtension = extension;
162     }
163 
164     /**
165      *
166      * @return the extension of the file
167      */
168     public String getMimeType( )
169     {
170         return _strMimeType;
171     }
172 
173     /**
174      * set the mime type of the file
175      * 
176      * @param mimeType
177      *            the mime type of the file
178      */
179     public void setMimeType( String mimeType )
180     {
181         _strMimeType = mimeType;
182     }
183 
184     /**
185      *
186      * @return the PhysicalFile associate to the file
187      */
188     public PhysicalFile getPhysicalFile( )
189     {
190         return _physicalFile;
191     }
192 
193     /**
194      * set the PhysicalFile associate to the file
195      * 
196      * @param file
197      *            PhysicalFile
198      */
199     public void setPhysicalFile( PhysicalFile file )
200     {
201         _physicalFile = file;
202     }
203 
204     /**
205      *
206      * @return the creation date of the file
207      */
208     public Timestamp getDateCreation( )
209     {
210         return _dateCreation;
211     }
212 
213     /**
214      * set the creation date of the file
215      * 
216      * @param dateCreation
217      *            the creation date of the file
218      */
219     public void setDateCreation( Timestamp dateCreation )
220     {
221         _dateCreation = dateCreation;
222     }
223 
224     /**
225      * get url
226      * 
227      * @return  the url
228      */
229     public String getUrl() {
230         return _url;
231     }
232 
233     /**
234      * set url
235      * 
236      * @param strUrl the url to set
237      */
238     public void setUrl(String strUrl) {
239         this._url = strUrl;
240     }
241 
242     /**
243      * get origin
244      * 
245      * @return the origin
246      */
247 	public String getOrigin( ) 
248 	{
249 		return _strOrigin;
250 	}
251 
252 	/**
253 	 * set origin
254 	 * 
255 	 * @param _strOrigin
256 	 */
257 	public void setOrigin( String strOrigin ) 
258 	{
259 		this._strOrigin = strOrigin;
260 	}
261 
262 }