1 package org.apache.archiva.rest.api.model.v2;/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
19 import io.swagger.v3.oas.annotations.media.Schema;
21 import javax.xml.bind.annotation.XmlRootElement;
22 import java.io.Serializable;
23 import java.util.ArrayList;
24 import java.util.List;
25 import java.util.Objects;
28 * @author Martin Stockhammer <martin_s@apache.org>
30 @XmlRootElement(name="repositoryGroup")
31 @Schema(name="RepositoryGroup", description = "Information about a repository group, which combines multiple repositories as one virtual repository.")
32 public class RepositoryGroup implements Serializable
34 private static final long serialVersionUID = -7319687481737616081L;
36 private final List<String> repositories = new ArrayList<>( );
37 private String location;
38 MergeConfiguration mergeConfiguration;
40 public RepositoryGroup( )
44 public RepositoryGroup(String id) {
48 public static RepositoryGroup of( org.apache.archiva.admin.model.beans.RepositoryGroup modelObj ) {
49 RepositoryGroup result = new RepositoryGroup( );
50 MergeConfiguration mergeConfig = new MergeConfiguration( );
51 result.setMergeConfiguration( mergeConfig );
52 result.setId( modelObj.getId() );
53 result.setLocation( modelObj.getLocation() );
54 result.setRepositories( modelObj.getRepositories() );
55 mergeConfig.setMergedIndexPath( modelObj.getMergedIndexPath() );
56 mergeConfig.setMergedIndexTtlMinutes( modelObj.getMergedIndexTtl( ) );
57 mergeConfig.setIndexMergeSchedule( modelObj.getCronExpression( ) );
61 @Schema(description = "The unique id of the repository group.")
62 public String getId( )
67 public void setId( String id )
72 @Schema(description = "The list of ids of repositories which are member of the repository group.")
73 public List<String> getRepositories( )
78 public void setRepositories( List<String> repositories )
80 this.repositories.clear();
81 this.repositories.addAll( repositories );
84 public void addRepository(String repositoryId) {
85 if (!this.repositories.contains( repositoryId )) {
86 this.repositories.add( repositoryId );
90 @Schema(name="merge_configuration",description = "The configuration for index merge.")
91 public MergeConfiguration getMergeConfiguration( )
93 return mergeConfiguration;
96 public void setMergeConfiguration( MergeConfiguration mergeConfiguration )
98 this.mergeConfiguration = mergeConfiguration;
101 @Schema(description = "The storage location of the repository. The merged index is stored relative to this location.")
102 public String getLocation( )
107 public void setLocation( String location )
109 this.location = location;
113 public boolean equals( Object o )
115 if ( this == o ) return true;
116 if ( o == null || getClass( ) != o.getClass( ) ) return false;
118 RepositoryGroup that = (RepositoryGroup) o;
120 if ( !Objects.equals( id, that.id ) ) return false;
121 if ( !repositories.equals( that.repositories ) )
123 if ( !Objects.equals( location, that.location ) ) return false;
124 return Objects.equals( mergeConfiguration, that.mergeConfiguration );
128 public int hashCode( )
130 int result = id != null ? id.hashCode( ) : 0;
131 result = 31 * result + repositories.hashCode( );
132 result = 31 * result + ( location != null ? location.hashCode( ) : 0 );
133 result = 31 * result + ( mergeConfiguration != null ? mergeConfiguration.hashCode( ) : 0 );
137 @SuppressWarnings( "StringBufferReplaceableByString" )
139 public String toString( )
141 final StringBuilder sb = new StringBuilder( "RepositoryGroup{" );
142 sb.append( "id='" ).append( id ).append( '\'' );
143 sb.append( ", repositories=" ).append( repositories );
144 sb.append( ", location='" ).append( location ).append( '\'' );
145 sb.append( ", mergeConfiguration=" ).append( mergeConfiguration );
147 return sb.toString( );