1 package org.apache.archiva.repository.base;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
23 import org.apache.archiva.repository.EditableRemoteRepository;
24 import org.apache.archiva.repository.RemoteRepositoryContent;
25 import org.apache.archiva.repository.RepositoryCredentials;
26 import org.apache.archiva.repository.RepositoryType;
27 import org.apache.archiva.repository.storage.RepositoryStorage;
30 import java.time.Duration;
31 import java.util.Collections;
32 import java.util.HashMap;
33 import java.util.Locale;
37 * Abstract implementation of a remote repository. Abstract classes must implement the
38 * features and capabilities by themselves.
40 public abstract class AbstractRemoteRepository extends AbstractRepository implements EditableRemoteRepository
43 private RepositoryCredentials credentials;
44 private String checkPath;
45 private Map<String,String> extraParameters = new HashMap<>( );
46 private Map<String,String> uExtraParameters = Collections.unmodifiableMap( extraParameters );
47 private Map<String,String> extraHeaders = new HashMap<>( );
48 private Map<String,String> uExtraHeaders = Collections.unmodifiableMap( extraHeaders );
49 private Duration timeout = Duration.ofSeconds( 60 );
50 private String proxyId;
51 private RemoteRepositoryContent content;
53 public AbstractRemoteRepository( RepositoryType type, String id, String name , RepositoryStorage storage)
55 super( type, id, name, storage );
58 public AbstractRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage storage )
60 super( primaryLocale, type, id, name, storage );
64 public void setCredentials( RepositoryCredentials credentials )
66 this.credentials = credentials;
70 public void setCheckPath( String path )
72 this.checkPath = path;
76 public void setExtraParameters( Map<String, String> params )
78 this.extraParameters.clear();
79 this.extraParameters.putAll(params);
83 public void addExtraParameter( String key, String value )
85 this.extraParameters.put(key, value);
89 public void setExtraHeaders( Map<String, String> headers )
91 this.extraHeaders.clear();
92 this.extraHeaders.putAll(headers);
96 public void addExtraHeader( String header, String value )
98 this.extraHeaders.put(header, value);
102 public void setTimeout( Duration duration )
104 this.timeout = duration;
108 public RemoteRepositoryContent getContent( )
114 public void setContent(RemoteRepositoryContent content) {
115 this.content = content;
119 public RepositoryCredentials getLoginCredentials( )
125 public String getCheckPath( )
131 public Map<String, String> getExtraParameters( )
133 return uExtraParameters;
137 public Map<String, String> getExtraHeaders( )
139 return uExtraHeaders;
143 public Duration getTimeout( )
149 public String toString() {
150 StringBuilder str = new StringBuilder();
151 return str.append("checkPath=").append(checkPath)
152 .append(",creds:").append(credentials).toString();
156 public void setLocation(URI location) {
157 // Location of remote repositories is not for the local filestore
158 super.location = location;