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  import static org.apache.archiva.indexer.ArchivaIndexManager.DEFAULT_INDEX_PATH;
27  
28  /**
29   * @author Olivier Lamy
30   * @since 1.4-M1
31   */
32  @XmlRootElement(name = "repositoryGroup")
33  public class RepositoryGroup
34      implements Serializable
35  {
36      /**
37       * repository group Id
38       */
39      private String id;
40  
41      /**
42       * repositories ids
43       */
44      private List<String> repositories;
45  
46      /**
47       * The path of the merged index.
48       */
49      private String mergedIndexPath = DEFAULT_INDEX_PATH;
50  
51      /**
52       * The TTL (time to live) of the repo group's merged index.
53       */
54      private int mergedIndexTtl = 30;
55  
56      /**
57       * default model value is empty so none
58       * @since 2.0.0
59       */
60      private String cronExpression;
61  
62      public RepositoryGroup()
63      {
64          // no op
65      }
66  
67      public RepositoryGroup( String id, List<String> repositories )
68      {
69          this.id = id;
70          this.repositories = repositories;
71      }
72  
73      /**
74       * Method addRepository.
75       *
76       * @param string
77       */
78      public void addRepository( String string )
79      {
80          getRepositories().add( string );
81      }
82  
83      /**
84       * Get the id of the repository group.
85       *
86       * @return String
87       */
88      public String getId()
89      {
90          return this.id;
91      }
92  
93      /**
94       * Method getRepositories.
95       *
96       * @return List
97       */
98      public List<String> getRepositories()
99      {
100         if ( this.repositories == null )
101         {
102             this.repositories = new ArrayList<>( 0 );
103         }
104 
105         return this.repositories;
106     }
107 
108     /**
109      * Method removeRepository.
110      *
111      * @param string
112      */
113     public void removeRepository( String string )
114     {
115         getRepositories().remove( string );
116     }
117 
118     /**
119      * Set the id of the repository group.
120      *
121      * @param id
122      */
123     public void setId( String id )
124     {
125         this.id = id;
126     }
127 
128     /**
129      * Set the list of repository ids under the group.
130      *
131      * @param repositories
132      */
133     public void setRepositories( List<String> repositories )
134     {
135         this.repositories = repositories;
136     }
137 
138     public String getMergedIndexPath()
139     {
140         return mergedIndexPath;
141     }
142 
143     public void setMergedIndexPath( String mergedIndexPath )
144     {
145         this.mergedIndexPath = mergedIndexPath;
146     }
147 
148     public int getMergedIndexTtl() {
149         return mergedIndexTtl;
150     }
151 
152     /**
153      * Set the TTL of the repo group's merged index.
154      *
155      * @param mergedIndexTtl
156      */
157     public void setMergedIndexTtl(int mergedIndexTtl) {
158         this.mergedIndexTtl = mergedIndexTtl;
159     }
160 
161     public RepositoryGroup mergedIndexPath( String mergedIndexPath ) {
162         this.mergedIndexPath = mergedIndexPath;
163         return this;
164     }
165 
166     public RepositoryGroup mergedIndexTtl( int mergedIndexTtl ) {
167         this.mergedIndexTtl = mergedIndexTtl;
168         return this;
169     }
170 
171     public String getCronExpression()
172     {
173         return cronExpression;
174     }
175 
176     public void setCronExpression( String cronExpression )
177     {
178         this.cronExpression = cronExpression;
179     }
180 
181     public RepositoryGroup cronExpression( String mergedIndexCronExpression )
182     {
183         this.cronExpression = mergedIndexCronExpression;
184         return this;
185     }
186 
187     @Override
188     public boolean equals( Object other )
189     {
190         if ( this == other )
191         {
192             return true;
193         }
194 
195         if ( !( other instanceof RepositoryGroup ) )
196         {
197             return false;
198         }
199 
200         RepositoryGroup./../../../org/apache/archiva/admin/model/beans/RepositoryGroup.html#RepositoryGroup">RepositoryGroup that = (RepositoryGroup) other;
201         boolean result = true;
202         result = result && ( getId() == null ? that.getId() == null : getId().equals( that.getId() ) );
203         return result;
204     }
205 
206     @Override
207     public int hashCode()
208     {
209         int result = 17;
210         result = 37 * result + ( id != null ? id.hashCode() : 0 );
211         return result;
212     }
213 
214     @Override
215     public String toString()
216     {
217         final StringBuilder sb = new StringBuilder( "RepositoryGroup{" );
218         sb.append( "id='" ).append( id ).append( '\'' );
219         sb.append( ", repositories=" ).append( repositories );
220         sb.append( ", mergedIndexPath='" ).append( mergedIndexPath ).append( '\'' );
221         sb.append( ", mergedIndexTtl=" ).append( mergedIndexTtl );
222         sb.append( ", cronExpression='" ).append( cronExpression ).append( '\'' );
223         sb.append( '}' );
224         return sb.toString();
225     }
226 }