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