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.commons.lang.StringUtils;
25 import java.nio.file.Path;
26 import java.nio.file.Paths;
27 import java.time.Duration;
28 import java.util.Collections;
29 import java.util.HashMap;
30 import java.util.Locale;
34 * Abstract implementation of a remote repository. Abstract classes must implement the
35 * features and capabilities by themselves.
37 public abstract class AbstractRemoteRepository extends AbstractRepository implements EditableRemoteRepository
40 private RepositoryCredentials credentials;
41 private String checkPath;
42 private Map<String,String> extraParameters = new HashMap<>( );
43 private Map<String,String> uExtraParameters = Collections.unmodifiableMap( extraParameters );
44 private Map<String,String> extraHeaders = new HashMap<>( );
45 private Map<String,String> uExtraHeaders = Collections.unmodifiableMap( extraHeaders );
46 private Duration timeout = Duration.ofSeconds( 60 );
47 private String proxyId;
48 private RemoteRepositoryContent content;
50 public AbstractRemoteRepository( RepositoryType type, String id, String name , Path repositoryBase)
52 super( type, id, name, repositoryBase );
55 public AbstractRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name, Path repositoryBase )
57 super( primaryLocale, type, id, name, repositoryBase );
61 public void setCredentials( RepositoryCredentials credentials )
63 this.credentials = credentials;
67 public void setCheckPath( String path )
69 this.checkPath = path;
73 public void setExtraParameters( Map<String, String> params )
75 this.extraParameters.clear();
76 this.extraParameters.putAll(params);
80 public void addExtraParameter( String key, String value )
82 this.extraParameters.put(key, value);
86 public void setExtraHeaders( Map<String, String> headers )
88 this.extraHeaders.clear();
89 this.extraHeaders.putAll(headers);
93 public void addExtraHeader( String header, String value )
95 this.extraHeaders.put(header, value);
99 public void setTimeout( Duration duration )
101 this.timeout = duration;
105 public RemoteRepositoryContent getContent( )
111 public void setContent(RemoteRepositoryContent content) {
112 this.content = content;
116 public RepositoryCredentials getLoginCredentials( )
122 public String getCheckPath( )
128 public Map<String, String> getExtraParameters( )
130 return uExtraParameters;
134 public Map<String, String> getExtraHeaders( )
136 return uExtraHeaders;
140 public Duration getTimeout( )
146 * Remote repositories resolve always relative to the base directory.
150 public Path getLocalPath() {
151 return repositoryBase.resolve(getId());