You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RepositoryGroup.java 5.2KB

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