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.business.spaces;
35  
36  import fr.paris.lutece.portal.service.rbac.RBACResource;
37  import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupResource;
38  
39  import java.util.ArrayList;
40  
41  /**
42   * A Space to store documents
43   */
44  public class DocumentSpace implements RBACResource, AdminWorkgroupResource
45  {
46      public static final String RESOURCE_TYPE = "DOCUMENT_SPACE";
47  
48      // Variables declarations
49      private int _nIdSpace;
50      private int _nIdParent;
51      private String _strName;
52      private String _strDescription;
53      private String _strViewType;
54      private int _nIdIcon;
55      private String _strIconUrl;
56      private ArrayList<String> _listDocumentType = new ArrayList<String>( );
57      private boolean _bDocumentCreationAllowed;
58      private String _strWorkgroup;
59  
60      /**
61       * Returns the IdSpace
62       *
63       * @return The IdSpace
64       */
65      public int getId( )
66      {
67          return _nIdSpace;
68      }
69  
70      /**
71       * Sets the IdSpace
72       *
73       * @param nIdSpace
74       *            The IdSpace
75       */
76      public void setId( int nIdSpace )
77      {
78          _nIdSpace = nIdSpace;
79      }
80  
81      /**
82       * Returns the IdParent
83       *
84       * @return The IdParent
85       */
86      public int getIdParent( )
87      {
88          return _nIdParent;
89      }
90  
91      /**
92       * Sets the IdParent
93       *
94       * @param nIdParent
95       *            The IdParent
96       */
97      public void setIdParent( int nIdParent )
98      {
99          _nIdParent = nIdParent;
100     }
101 
102     /**
103      * Returns the Name
104      *
105      * @return The Name
106      */
107     public String getName( )
108     {
109         return _strName;
110     }
111 
112     /**
113      * Sets the Name
114      *
115      * @param strName
116      *            The Name
117      */
118     public void setName( String strName )
119     {
120         _strName = strName;
121     }
122 
123     /**
124      * Returns the Description
125      *
126      * @return The Description
127      */
128     public String getDescription( )
129     {
130         return _strDescription;
131     }
132 
133     /**
134      * Sets the Description
135      *
136      * @param strDescription
137      *            The Description
138      */
139     public void setDescription( String strDescription )
140     {
141         _strDescription = strDescription;
142     }
143 
144     /**
145      * Returns the ViewType
146      *
147      * @return The ViewType
148      */
149     public String getViewType( )
150     {
151         return _strViewType;
152     }
153 
154     /**
155      * Sets the ViewType
156      *
157      * @param strViewType
158      *            The ViewType
159      */
160     public void setViewType( String strViewType )
161     {
162         _strViewType = strViewType;
163     }
164 
165     /**
166      * Returns the IdIcon
167      *
168      * @return The IdIcon
169      */
170     public int getIdIcon( )
171     {
172         return _nIdIcon;
173     }
174 
175     /**
176      * Sets the IdIcon
177      *
178      * @param nIdIcon
179      *            The IdIcon
180      */
181     public void setIdIcon( int nIdIcon )
182     {
183         _nIdIcon = nIdIcon;
184     }
185 
186     /**
187      * Returns the IconUrl
188      *
189      * @return The IconUrl
190      */
191     public String getIconUrl( )
192     {
193         return _strIconUrl;
194     }
195 
196     /**
197      * Sets the IconUrl
198      *
199      * @param strIconUrl
200      *            The IconUrl
201      */
202     public void setIconUrl( String strIconUrl )
203     {
204         _strIconUrl = strIconUrl;
205     }
206 
207     /**
208      * Returns whether or not Document Creation is Allowed for this space
209      *
210      * @return True if Document Creation is Allowed
211      */
212     public boolean isDocumentCreationAllowed( )
213     {
214         return _bDocumentCreationAllowed;
215     }
216 
217     /**
218      * Sets whether or not Document Creation is Allowed for this space
219      *
220      * @param bDocumentCreationAllowed
221      *            The DocumentCreationAllowed value
222      */
223     public void setDocumentCreationAllowed( boolean bDocumentCreationAllowed )
224     {
225         _bDocumentCreationAllowed = bDocumentCreationAllowed;
226     }
227 
228     /**
229      * Add allowed document
230      * 
231      * @param strDocumentType
232      *            The document type to allow
233      */
234     public void addAllowedDocumentType( String strDocumentType )
235     {
236         _listDocumentType.add( strDocumentType );
237     }
238 
239     /**
240      * Reset allowed document types list
241      */
242     public void resetAllowedDocumentTypesList( )
243     {
244         _listDocumentType.clear( );
245     }
246 
247     /**
248      * Returns allowed document types
249      * 
250      * @return Allowed document types
251      */
252     public String [ ] getAllowedDocumentTypes( )
253     {
254         String [ ] checkedItems = new String [ _listDocumentType.size( )];
255 
256         int nIndex = 0;
257 
258         for ( String strType : _listDocumentType )
259         {
260             checkedItems [nIndex] = strType;
261             nIndex++;
262         }
263 
264         return checkedItems;
265     }
266 
267     ////////////////////////////////////////////////////////////////////////////
268     // RBAC Resource implementation
269 
270     /**
271      * Returns the Resource Type Code that identify the resource type
272      * 
273      * @return The Resource Type Code
274      */
275     public String getResourceTypeCode( )
276     {
277         return RESOURCE_TYPE;
278     }
279 
280     /**
281      * Returns the resource Id of the current object
282      * 
283      * @return The resource Id of the current object
284      */
285     public String getResourceId( )
286     {
287         return "" + getId( );
288     }
289 
290     /**
291      *
292      * @return the work group associate to the DocumentSpace
293      */
294     public String getWorkgroup( )
295     {
296         return _strWorkgroup;
297     }
298 
299     /**
300      * set the work group associate to the DocumentSpace
301      * 
302      * @param workGroup
303      *            the work group associate to the DocumentSpace
304      */
305     public void setWorkgroup( String workGroup )
306     {
307         _strWorkgroup = workGroup;
308     }
309 }