This project has retired. For details please refer to its Attic page.
RepositoryGroup xref
View Javadoc
1   package org.apache.archiva.admin.model.beans;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  import javax.xml.bind.annotation.XmlRootElement;
22  import java.io.Serializable;
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  /**
27   * @author Olivier Lamy
28   * @since 1.4-M1
29   */
30  @XmlRootElement(name = "repositoryGroup")
31  public class RepositoryGroup
32      implements Serializable
33  {
34      /**
35       * repository group Id
36       */
37      private String id;
38  
39      /**
40       * repositories ids
41       */
42      private List<String> repositories;
43  
44      /**
45       * The path of the merged index.
46       */
47      private String mergedIndexPath = "/.indexer";
48  
49      /**
50       * The TTL (time to live) of the repo group's merged index.
51       */
52      private int mergedIndexTtl = 30;
53  
54      /**
55       * default model value is empty so none
56       * @since 2.0.0
57       */
58      private String cronExpression;
59  
60      public RepositoryGroup()
61      {
62          // no op
63      }
64  
65      public RepositoryGroup( String id, List<String> repositories )
66      {
67          this.id = id;
68          this.repositories = repositories;
69      }
70  
71      /**
72       * Method addRepository.
73       *
74       * @param string
75       */
76      public void addRepository( String string )
77      {
78          getRepositories().add( string );
79      }
80  
81      /**
82       * Get the id of the repository group.
83       *
84       * @return String
85       */
86      public String getId()
87      {
88          return this.id;
89      }
90  
91      /**
92       * Method getRepositories.
93       *
94       * @return List
95       */
96      public List<String> getRepositories()
97      {
98          if ( this.repositories == null )
99          {
100             this.repositories = new ArrayList<>( 0 );
101         }
102 
103         return this.repositories;
104     }
105 
106     /**
107      * Method removeRepository.
108      *
109      * @param string
110      */
111     public void removeRepository( String string )
112     {
113         getRepositories().remove( string );
114     }
115 
116     /**
117      * Set the id of the repository group.
118      *
119      * @param id
120      */
121     public void setId( String id )
122     {
123         this.id = id;
124     }
125 
126     /**
127      * Set the list of repository ids under the group.
128      *
129      * @param repositories
130      */
131     public void setRepositories( List<String> repositories )
132     {
133         this.repositories = repositories;
134     }
135 
136     public String getMergedIndexPath()
137     {
138         return mergedIndexPath;
139     }
140 
141     public void setMergedIndexPath( String mergedIndexPath )
142     {
143         this.mergedIndexPath = mergedIndexPath;
144     }
145 
146     public int getMergedIndexTtl() {
147         return mergedIndexTtl;
148     }
149 
150     /**
151      * Set the TTL of the repo group's merged index.
152      *
153      * @param mergedIndexTtl
154      */
155     public void setMergedIndexTtl(int mergedIndexTtl) {
156         this.mergedIndexTtl = mergedIndexTtl;
157     }
158 
159     public RepositoryGroup mergedIndexPath( String mergedIndexPath ) {
160         this.mergedIndexPath = mergedIndexPath;
161         return this;
162     }
163 
164     public RepositoryGroup mergedIndexTtl( int mergedIndexTtl ) {
165         this.mergedIndexTtl = mergedIndexTtl;
166         return this;
167     }
168 
169     public String getCronExpression()
170     {
171         return cronExpression;
172     }
173 
174     public void setCronExpression( String cronExpression )
175     {
176         this.cronExpression = cronExpression;
177     }
178 
179     public RepositoryGroup cronExpression( String mergedIndexCronExpression )
180     {
181         this.cronExpression = mergedIndexCronExpression;
182         return this;
183     }
184 
185     @Override
186     public boolean equals( Object other )
187     {
188         if ( this == other )
189         {
190             return true;
191         }
192 
193         if ( !( other instanceof RepositoryGroup ) )
194         {
195             return false;
196         }
197 
198         RepositoryGroup that = (RepositoryGroup) other;
199         boolean result = true;
200         result = result && ( getId() == null ? that.getId() == null : getId().equals( that.getId() ) );
201         return result;
202     }
203 
204     @Override
205     public int hashCode()
206     {
207         int result = 17;
208         result = 37 * result + ( id != null ? id.hashCode() : 0 );
209         return result;
210     }
211 
212     @Override
213     public String toString()
214     {
215         final StringBuilder sb = new StringBuilder( "RepositoryGroup{" );
216         sb.append( "id='" ).append( id ).append( '\'' );
217         sb.append( ", repositories=" ).append( repositories );
218         sb.append( ", mergedIndexPath='" ).append( mergedIndexPath ).append( '\'' );
219         sb.append( ", mergedIndexTtl=" ).append( mergedIndexTtl );
220         sb.append( ", cronExpression='" ).append( cronExpression ).append( '\'' );
221         sb.append( '}' );
222         return sb.toString();
223     }
224 }