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 026import static org.apache.archiva.indexer.ArchivaIndexManager.DEFAULT_INDEX_PATH; 027 028/** 029 * @author Olivier Lamy 030 * @since 1.4-M1 031 */ 032@XmlRootElement(name = "repositoryGroup") 033public class RepositoryGroup 034 implements Serializable 035{ 036 /** 037 * repository group Id 038 */ 039 private String id; 040 041 /** 042 * repositories ids 043 */ 044 private List<String> repositories; 045 046 /** 047 * The path of the merged index. 048 */ 049 private String mergedIndexPath = DEFAULT_INDEX_PATH; 050 051 /** 052 * The TTL (time to live) of the repo group's merged index. 053 */ 054 private int mergedIndexTtl = 30; 055 056 /** 057 * default model value is empty so none 058 * @since 2.0.0 059 */ 060 private String cronExpression; 061 062 public RepositoryGroup() 063 { 064 // no op 065 } 066 067 public RepositoryGroup( String id, List<String> repositories ) 068 { 069 this.id = id; 070 this.repositories = repositories; 071 } 072 073 /** 074 * Method addRepository. 075 * 076 * @param string 077 */ 078 public void addRepository( String string ) 079 { 080 getRepositories().add( string ); 081 } 082 083 /** 084 * Get the id of the repository group. 085 * 086 * @return String 087 */ 088 public String getId() 089 { 090 return this.id; 091 } 092 093 /** 094 * Method getRepositories. 095 * 096 * @return List 097 */ 098 public List<String> getRepositories() 099 { 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 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}