This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.admin.model.beans;
002/*
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *   http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied.  See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 */
020
021import javax.xml.bind.annotation.XmlRootElement;
022import java.io.Serializable;
023import java.util.ArrayList;
024import java.util.List;
025
026/**
027 * @author Olivier Lamy
028 * @since 1.4-M1
029 */
030@XmlRootElement(name = "repositoryGroup")
031public class RepositoryGroup
032    implements Serializable
033{
034    /**
035     * repository group Id
036     */
037    private String id;
038
039    /**
040     * repositories ids
041     */
042    private List<String> repositories;
043
044    /**
045     * The path of the merged index.
046     */
047    private String mergedIndexPath = "/.indexer";
048
049    /**
050     * The TTL (time to live) of the repo group's merged index.
051     */
052    private int mergedIndexTtl = 30;
053
054    /**
055     * default model value is empty so none
056     * @since 2.0.0
057     */
058    private String cronExpression;
059
060    public RepositoryGroup()
061    {
062        // no op
063    }
064
065    public RepositoryGroup( String id, List<String> repositories )
066    {
067        this.id = id;
068        this.repositories = repositories;
069    }
070
071    /**
072     * Method addRepository.
073     *
074     * @param string
075     */
076    public void addRepository( String string )
077    {
078        getRepositories().add( string );
079    }
080
081    /**
082     * Get the id of the repository group.
083     *
084     * @return String
085     */
086    public String getId()
087    {
088        return this.id;
089    }
090
091    /**
092     * Method getRepositories.
093     *
094     * @return List
095     */
096    public List<String> getRepositories()
097    {
098        if ( this.repositories == null )
099        {
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}