1 package org.apache.archiva.repository;
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.content.RepositoryStorage;
25 import java.nio.file.Path;
26 import java.time.Duration;
27 import java.util.Collections;
28 import java.util.HashMap;
29 import java.util.Locale;
33 * Abstract implementation of a remote repository. Abstract classes must implement the
34 * features and capabilities by themselves.
36 public abstract class AbstractRemoteRepository extends AbstractRepository implements EditableRemoteRepository
39 private RepositoryCredentials credentials;
40 private String checkPath;
41 private Map<String,String> extraParameters = new HashMap<>( );
42 private Map<String,String> uExtraParameters = Collections.unmodifiableMap( extraParameters );
43 private Map<String,String> extraHeaders = new HashMap<>( );
44 private Map<String,String> uExtraHeaders = Collections.unmodifiableMap( extraHeaders );
45 private Duration timeout = Duration.ofSeconds( 60 );
46 private String proxyId;
47 private RemoteRepositoryContent content;
49 public AbstractRemoteRepository(RepositoryType type, String id, String name , RepositoryStorage storage)
51 super( type, id, name, storage );
54 public AbstractRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage storage )
56 super( primaryLocale, type, id, name, storage );
60 public void setCredentials( RepositoryCredentials credentials )
62 this.credentials = credentials;
66 public void setCheckPath( String path )
68 this.checkPath = path;
72 public void setExtraParameters( Map<String, String> params )
74 this.extraParameters.clear();
75 this.extraParameters.putAll(params);
79 public void addExtraParameter( String key, String value )
81 this.extraParameters.put(key, value);
85 public void setExtraHeaders( Map<String, String> headers )
87 this.extraHeaders.clear();
88 this.extraHeaders.putAll(headers);
92 public void addExtraHeader( String header, String value )
94 this.extraHeaders.put(header, value);
98 public void setTimeout( Duration duration )
100 this.timeout = duration;
104 public RemoteRepositoryContent getContent( )
110 public void setContent(RemoteRepositoryContent content) {
111 this.content = content;
115 public RepositoryCredentials getLoginCredentials( )
121 public String getCheckPath( )
127 public Map<String, String> getExtraParameters( )
129 return uExtraParameters;
133 public Map<String, String> getExtraHeaders( )
135 return uExtraHeaders;
139 public Duration getTimeout( )
145 * Remote repositories resolve always relative to the base directory.
149 public Path getLocalPath() {
150 return getStorage().getAsset("").getFilePath();
154 public String toString() {
155 StringBuilder str = new StringBuilder();
156 return str.append("checkPath=").append(checkPath)
157 .append(",creds:").append(credentials).toString();