1 package org.apache.archiva.rest.api.v2.model;/*
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
20 * Licensed to the Apache Software Foundation (ASF) under one
21 * or more contributor license agreements. See the NOTICE file
22 * distributed with this work for additional information
23 * regarding copyright ownership. The ASF licenses this file
24 * to you under the Apache License, Version 2.0 (the
25 * "License"); you may not use this file except in compliance
26 * with the License. You may obtain a copy of the License at
28 * http://www.apache.org/licenses/LICENSE-2.0
29 * Unless required by applicable law or agreed to in writing,
30 * software distributed under the License is distributed on an
31 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
32 * KIND, either express or implied. See the License for the
33 * specific language governing permissions and limitations
37 import io.swagger.v3.oas.annotations.media.Schema;
38 import org.apache.archiva.repository.Repository;
39 import org.apache.archiva.repository.features.IndexCreationFeature;
41 import javax.xml.bind.annotation.XmlRootElement;
42 import java.io.Serializable;
43 import java.util.ArrayList;
44 import java.util.List;
45 import java.util.stream.Collectors;
48 * @author Martin Stockhammer <martin_s@apache.org>
50 @XmlRootElement(name="repositoryGroup")
51 @Schema(name="RepositoryGroup", description = "Information about a repository group, which combines multiple repositories as one virtual repository.")
52 public class RepositoryGroup implements Serializable, RestModel
54 private static final long serialVersionUID = -7319687481737616081L;
57 private List<String> repositories = new ArrayList<>( );
58 private String location;
59 MergeConfiguration mergeConfiguration;
61 public RepositoryGroup( )
65 public RepositoryGroup(String id) {
69 public static RepositoryGroup of( org.apache.archiva.repository.RepositoryGroup modelObj ) {
70 RepositoryGroup result = new RepositoryGroup( );
71 MergeConfiguration mergeConfig = new MergeConfiguration( );
72 result.setMergeConfiguration( mergeConfig );
73 result.setId( modelObj.getId() );
74 result.setName( modelObj.getName() );
75 result.setLocation( modelObj.getLocation().toString() );
76 result.setRepositories( modelObj.getRepositories().stream().map( Repository::getId ).collect( Collectors.toList()) );
77 if (modelObj.supportsFeature( IndexCreationFeature.class )) {
78 IndexCreationFeature icf = modelObj.getFeature( IndexCreationFeature.class ).get();
79 mergeConfig.setMergedIndexPath( icf.getIndexPath( ).toString() );
80 mergeConfig.setMergedIndexTtlMinutes( modelObj.getMergedIndexTTL( ) );
81 mergeConfig.setIndexMergeSchedule( modelObj.getSchedulingDefinition() );
86 @Schema(description = "The unique id of the repository group.")
87 public String getId( )
92 public void setId( String id )
97 @Schema(description = "The list of ids of repositories which are member of the repository group.")
98 public List<String> getRepositories( )
103 public void setRepositories( List<String> repositories )
105 this.repositories = new ArrayList<>( repositories );
108 public void addRepository(String repositoryId) {
109 if (!this.repositories.contains( repositoryId )) {
110 this.repositories.add( repositoryId );
114 @Schema(name="merge_configuration",description = "The configuration for index merge.")
115 public MergeConfiguration getMergeConfiguration( )
117 return mergeConfiguration;
120 public void setMergeConfiguration( MergeConfiguration mergeConfiguration )
122 this.mergeConfiguration = mergeConfiguration;
125 @Schema(description = "The storage location of the repository. The merged index is stored relative to this location.")
126 public String getLocation( )
131 public void setLocation( String location )
133 this.location = location;
136 @Schema(description = "The name of the repository group")
137 public String getName( )
142 public void setName( String name )
148 public boolean equals( Object o )
150 if ( this == o ) return true;
151 if ( o == null || getClass( ) != o.getClass( ) ) return false;
153 RepositoryGroup that = (RepositoryGroup) o;
155 return id.equals( that.id );
159 public int hashCode( )
161 return id.hashCode( );
165 public String toString( )
167 final StringBuilder sb = new StringBuilder( "RepositoryGroup{" );
168 sb.append( "id='" ).append( id ).append( '\'' );
169 sb.append( ", name='" ).append( name ).append( '\'' );
170 sb.append( ", repositories=" ).append( repositories );
171 sb.append( ", location='" ).append( location ).append( '\'' );
172 sb.append( ", mergeConfiguration=" ).append( mergeConfiguration );
174 return sb.toString( );