View Javadoc
1   /*
2    * Copyright (c) 2002-2021, 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.releaser.business;
35  
36  import javax.validation.constraints.*;
37  
38  import org.hibernate.validator.constraints.*;
39  
40  import fr.paris.lutece.portal.service.rbac.RBACResource;
41  
42  import java.io.Serializable;
43  import java.util.ArrayList;
44  import java.util.HashMap;
45  import java.util.List;
46  
47  // TODO: Auto-generated Javadoc
48  /**
49   * This is the business class for the object Site.
50   */
51  public class Site extends AbstractReleaserResource implements RBACResource, Serializable
52  {
53  
54      // RBAC management
55      public static final String RESOURCE_TYPE = "site";
56  
57      // site Permissions
58      public static final String PERMISSION_RELEASE_SITE = "releaseSitePermission";
59      public static final String PERMISSION_MODIFY_SITE = "modifySitePermission";
60      public static final String PERMISSION_DELETE_SITE = "deleteSitePermission";
61  
62      private HashMap<String, Boolean> permissions;
63  
64      /** The Constant serialVersionUID. */
65      private static final long serialVersionUID = 1L;
66  
67      /** The n id. */
68      // Variables declarations
69      private int _nId;
70  
71      /** The str artifact id. */
72      @NotEmpty( message = "#i18n{releaser.validation.site.ArtifactId.notEmpty}" )
73      @Size( max = 50, message = "#i18n{releaser.validation.site.ArtifactId.size}" )
74      private String _strArtifactId;
75  
76      /** The n id cluster. */
77      private int _nIdCluster;
78  
79      /** The str scm url. */
80      @URL( message = "#i18n{portal.validation.message.url}" )
81      @NotEmpty( message = "#i18n{releaser.validation.site.ScmUrl.notEmpty}" )
82      @Size( max = 255, message = "#i18n{releaser.validation.site.ScmUrl.size}" )
83      private String _strScmUrl;
84  
85      /** The str name. */
86      @NotEmpty( message = "#i18n{releaser.validation.site.Name.notEmpty}" )
87      @Size( max = 50, message = "#i18n{releaser.validation.site.Name.size}" )
88      private String _strName;
89  
90      /** The str description. */
91      @NotEmpty( message = "#i18n{releaser.validation.site.Description.notEmpty}" )
92      @Size( max = 255, message = "#i18n{releaser.validation.site.Description.size}" )
93      private String _strDescription;
94  
95      /** The str jira key. */
96      @Size( max = 50, message = "#i18n{releaser.validation.site.JiraKey.size}" )
97      private String _strJiraKey;
98  
99      /** The str tag information. */
100     private String _strTagInformation;
101 
102     /** The str cluster. */
103     private String _strCluster;
104 
105     /** The list current dependencies. */
106     private List<Dependency> _listCurrentDependencies = new ArrayList<>( );
107 
108     /** The list components. */
109     private List<Component> _listComponents = new ArrayList<>( );
110 
111     /** The str current version. */
112     private String _strCurrentVersion;
113 
114     /** The str last release version. */
115     private String _strLastReleaseVersion;
116 
117     /** The str next release version. */
118     private String _strNextReleaseVersion;
119 
120     /** The list target versions. */
121     private List<String> _listTargetVersions;
122 
123     /** The n target version index. */
124     private int _nTargetVersionIndex;
125 
126     /** The str next snapshot version. */
127     private String _strNextSnapshotVersion;
128 
129     /** The str group id. */
130     private String _strGroupId;
131 
132     /** The b theme. */
133     private boolean _bTheme;
134 
135     /** The list of component branches. */
136     private List<String> _listBranches;
137 
138     /** The branch to release. */
139     private String _strBranchReleaseFrom;
140 
141     /**
142      * Returns the Id.
143      *
144      * @return The Id
145      */
146     public int getId( )
147     {
148         return _nId;
149     }
150 
151     /**
152      * Sets the Id.
153      *
154      * @param nId
155      *            The Id
156      */
157     public void setId( int nId )
158     {
159         _nId = nId;
160     }
161 
162     /**
163      * Returns the ArtifactId.
164      *
165      * @return The ArtifactId
166      */
167     public String getArtifactId( )
168     {
169         return _strArtifactId;
170     }
171 
172     /**
173      * Sets the ArtifactId.
174      *
175      * @param strArtifactId
176      *            The ArtifactId
177      */
178     public void setArtifactId( String strArtifactId )
179     {
180         _strArtifactId = strArtifactId;
181     }
182 
183     /**
184      * Returns the IdCluster.
185      *
186      * @return The IdCluster
187      */
188     public int getIdCluster( )
189     {
190         return _nIdCluster;
191     }
192 
193     /**
194      * Sets the IdCluster.
195      *
196      * @param nIdCluster
197      *            The IdCluster
198      */
199     public void setIdCluster( int nIdCluster )
200     {
201         _nIdCluster = nIdCluster;
202     }
203 
204     /**
205      * Returns the ScmUrl.
206      *
207      * @return The ScmUrl
208      */
209     public String getScmUrl( )
210     {
211         return _strScmUrl;
212     }
213 
214     /**
215      * Sets the ScmUrl.
216      *
217      * @param strScmUrl
218      *            The ScmUrl
219      */
220     public void setScmUrl( String strScmUrl )
221     {
222         _strScmUrl = strScmUrl;
223     }
224 
225     /**
226      * Returns the Name.
227      *
228      * @return The Name
229      */
230     public String getName( )
231     {
232         return _strName;
233     }
234 
235     /**
236      * Sets the Name.
237      *
238      * @param strName
239      *            The Name
240      */
241     public void setName( String strName )
242     {
243         _strName = strName;
244     }
245 
246     /**
247      * Returns the Description.
248      *
249      * @return The Description
250      */
251     public String getDescription( )
252     {
253         return _strDescription;
254     }
255 
256     /**
257      * Sets the Description.
258      *
259      * @param strDescription
260      *            The Description
261      */
262     public void setDescription( String strDescription )
263     {
264         _strDescription = strDescription;
265     }
266 
267     /**
268      * Returns the JiraKey.
269      *
270      * @return The JiraKey
271      */
272     public String getJiraKey( )
273     {
274         return _strJiraKey;
275     }
276 
277     /**
278      * Sets the JiraKey.
279      *
280      * @param strJiraKey
281      *            The JiraKey
282      */
283     public void setJiraKey( String strJiraKey )
284     {
285         _strJiraKey = strJiraKey;
286     }
287 
288     /**
289      * Adds the current dependency.
290      *
291      * @param dependency
292      *            the dependency
293      */
294     public void addCurrentDependency( Dependency dependency )
295     {
296         _listCurrentDependencies.add( dependency );
297     }
298 
299     /**
300      * Gets the current dependencies.
301      *
302      * @return getCurrentDependencies
303      */
304     public List<Dependency> getCurrentDependencies( )
305     {
306         return _listCurrentDependencies;
307     }
308 
309     /**
310      * Adds the component.
311      *
312      * @param component
313      *            the component
314      */
315     public void addComponent( Component component )
316     {
317         _listComponents.add( component );
318     }
319 
320     /**
321      * Gets the components.
322      *
323      * @return getComponents
324      */
325     public List<Component> getComponents( )
326     {
327         return _listComponents;
328     }
329 
330     /**
331      * Returns the Version.
332      *
333      * @return The Version
334      */
335     public String getVersion( )
336     {
337         return _strCurrentVersion;
338     }
339 
340     /**
341      * Sets the Version.
342      *
343      * @param strVersion
344      *            The Version
345      */
346     public void setVersion( String strVersion )
347     {
348         _strCurrentVersion = strVersion;
349     }
350 
351     /**
352      * Returns the Cluster.
353      *
354      * @return The Cluster
355      */
356     public String getCluster( )
357     {
358         return _strCluster;
359     }
360 
361     /**
362      * Sets the Cluster.
363      *
364      * @param strCluster
365      *            The Cluster
366      */
367     public void setCluster( String strCluster )
368     {
369         _strCluster = strCluster;
370     }
371 
372     /**
373      * Returns the Last Release Version.
374      *
375      * @return The Release Version
376      */
377     public String getLastReleaseVersion( )
378     {
379         return _strLastReleaseVersion;
380     }
381 
382     /**
383      * Sets the Last Release Version.
384      *
385      * @param strLastReleaseVersion
386      *            The Release Version
387      */
388     public void setLastReleaseVersion( String strLastReleaseVersion )
389     {
390         _strLastReleaseVersion = strLastReleaseVersion;
391     }
392 
393     /**
394      * Returns the Next Release Version.
395      *
396      * @return The Release Version
397      */
398     public String getNextReleaseVersion( )
399     {
400         return _strNextReleaseVersion;
401     }
402 
403     /**
404      * Sets the Next Release Version.
405      *
406      * @param strNextReleaseVersion
407      *            The Release Version
408      */
409     public void setNextReleaseVersion( String strNextReleaseVersion )
410     {
411         _strNextReleaseVersion = strNextReleaseVersion;
412     }
413 
414     /**
415      * Returns the NextSnapshotVersion.
416      *
417      * @return The NextSnapshotVersion
418      */
419     public String getNextSnapshotVersion( )
420     {
421         return _strNextSnapshotVersion;
422     }
423 
424     /**
425      * Sets the NextSnapshotVersion.
426      *
427      * @param strNextSnapshotVersion
428      *            The NextSnapshotVersion
429      */
430     public void setNextSnapshotVersion( String strNextSnapshotVersion )
431     {
432         _strNextSnapshotVersion = strNextSnapshotVersion;
433     }
434 
435     /**
436      * Set target versions list.
437      *
438      * @param listTargetVersions
439      *            The target versions list
440      */
441     public void setTargetVersions( List<String> listTargetVersions )
442     {
443         _listTargetVersions = listTargetVersions;
444     }
445 
446     /**
447      * Gets the target versions list.
448      *
449      * @return the target versions list
450      */
451     public List<String> getTargetVersions( )
452     {
453         return _listTargetVersions;
454     }
455 
456     /**
457      * Set the target version index.
458      *
459      * @param nIndex
460      *            the target version index
461      */
462     public void setTargetVersionIndex( int nIndex )
463     {
464         _nTargetVersionIndex = nIndex;
465     }
466 
467     /**
468      * Get the target version index.
469      *
470      * @return the target version index
471      */
472     public int getTargetVersionIndex( )
473     {
474         return _nTargetVersionIndex;
475     }
476 
477     /**
478      * Gets the tag information.
479      *
480      * @return getTagInformation
481      */
482     public String getTagInformation( )
483     {
484         return _strTagInformation;
485     }
486 
487     /**
488      * Sets the tag information.
489      *
490      * @param _strTagInfotmation
491      *            the new tag information
492      */
493     public void setTagInformation( String _strTagInfotmation )
494     {
495         this._strTagInformation = _strTagInfotmation;
496     }
497 
498     /**
499      * Gets the group id.
500      *
501      * @return getGroupId
502      */
503     public String getGroupId( )
504     {
505         return _strGroupId;
506     }
507 
508     /**
509      * Sets the group id.
510      *
511      * @param _strGroupId
512      *            the new group id
513      */
514     public void setGroupId( String _strGroupId )
515     {
516         this._strGroupId = _strGroupId;
517     }
518 
519     /**
520      * Checks if is theme.
521      *
522      * @return isTheme
523      */
524     public boolean isTheme( )
525     {
526         return _bTheme;
527     }
528 
529     /**
530      * Sets the theme.
531      *
532      * @param _bTheme
533      *            the new theme
534      */
535     public void setTheme( boolean _bTheme )
536     {
537         this._bTheme = _bTheme;
538     }
539 
540     public List<String> getBranches( )
541     {
542         return _listBranches;
543     }
544 
545     public void setBranches( List<String> listBranches )
546     {
547         _listBranches = listBranches;
548     }
549 
550     public String getBranchReleaseFrom( )
551     {
552         return _strBranchReleaseFrom;
553     }
554 
555     public void setBranchReleaseFrom( String _strBranchReleaseFrom )
556     {
557         this._strBranchReleaseFrom = _strBranchReleaseFrom;
558     }
559 
560     /**
561      * Gets the target version.
562      *
563      * @return the target version
564      */
565     @Override
566     public String getTargetVersion( )
567     {
568         // TODO Auto-generated method stub
569         return getNextReleaseVersion( );
570     }
571 
572     /**
573      * RBAC resource implementation
574      * 
575      * @return The resource type code
576      */
577     @Override
578     public String getResourceTypeCode( )
579     {
580         return RESOURCE_TYPE;
581     }
582 
583     /**
584      * RBAC resource implementation
585      * 
586      * @return The resourceId
587      */
588     @Override
589     public String getResourceId( )
590     {
591         return String.valueOf( _nId );
592     }
593 
594     public HashMap<String, Boolean> getPermissions( )
595     {
596         return permissions;
597     }
598 
599     public void setPermissions( HashMap<String, Boolean> permissions )
600     {
601         if ( this.permissions == null )
602             this.permissions = new HashMap<String, Boolean>( );
603         else
604             this.permissions.clear( );
605 
606         if ( permissions != null )
607         {
608             this.permissions.putAll( permissions );
609         }
610     }
611 
612 }