|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- package org.apache.archiva.repository.base.remote;
-
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
- import org.apache.archiva.repository.EditableRemoteRepository;
- import org.apache.archiva.repository.RemoteRepositoryContent;
- import org.apache.archiva.repository.RepositoryCredentials;
- import org.apache.archiva.repository.RepositoryType;
- import org.apache.archiva.repository.base.AbstractRepository;
- import org.apache.archiva.repository.storage.RepositoryStorage;
-
- import java.net.URI;
- import java.time.Duration;
- import java.util.Collections;
- import java.util.HashMap;
- import java.util.Locale;
- import java.util.Map;
-
- /**
- * Abstract implementation of a remote repository. Abstract classes must implement the
- * features and capabilities by themselves.
- */
- public abstract class AbstractRemoteRepository extends AbstractRepository implements EditableRemoteRepository
- {
-
- private RepositoryCredentials credentials;
- private String checkPath;
- private Map<String,String> extraParameters = new HashMap<>( );
- private Map<String,String> uExtraParameters = Collections.unmodifiableMap( extraParameters );
- private Map<String,String> extraHeaders = new HashMap<>( );
- private Map<String,String> uExtraHeaders = Collections.unmodifiableMap( extraHeaders );
- private Duration timeout = Duration.ofSeconds( 60 );
- private String proxyId;
- private RemoteRepositoryContent content;
-
- public AbstractRemoteRepository( RepositoryType type, String id, String name , RepositoryStorage storage)
- {
- super( type, id, name, storage );
- }
-
- public AbstractRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage storage )
- {
- super( primaryLocale, type, id, name, storage );
- }
-
- @Override
- public void setCredentials( RepositoryCredentials credentials )
- {
- this.credentials = credentials;
- }
-
- @Override
- public void setCheckPath( String path )
- {
- this.checkPath = path;
- }
-
- @Override
- public void setExtraParameters( Map<String, String> params )
- {
- this.extraParameters.clear();
- this.extraParameters.putAll(params);
- }
-
- @Override
- public void addExtraParameter( String key, String value )
- {
- this.extraParameters.put(key, value);
- }
-
- @Override
- public void setExtraHeaders( Map<String, String> headers )
- {
- this.extraHeaders.clear();
- this.extraHeaders.putAll(headers);
- }
-
- @Override
- public void addExtraHeader( String header, String value )
- {
- this.extraHeaders.put(header, value);
- }
-
- @Override
- public void setTimeout( Duration duration )
- {
- this.timeout = duration;
- }
-
- @Override
- public RemoteRepositoryContent getContent( )
- {
- return content;
- }
-
- @Override
- public void setContent(RemoteRepositoryContent content) {
- this.content = content;
- }
-
- @Override
- public RepositoryCredentials getLoginCredentials( )
- {
- return credentials;
- }
-
- @Override
- public String getCheckPath( )
- {
- return checkPath;
- }
-
- @Override
- public Map<String, String> getExtraParameters( )
- {
- return uExtraParameters;
- }
-
- @Override
- public Map<String, String> getExtraHeaders( )
- {
- return uExtraHeaders;
- }
-
- @Override
- public Duration getTimeout( )
- {
- return timeout;
- }
-
- @Override
- public String toString() {
- StringBuilder str = new StringBuilder();
- return str.append("checkPath=").append(checkPath)
- .append(",creds:").append(credentials).toString();
- }
-
- @Override
- public void setLocation(URI location) {
- // Location of remote repositories is not for the local filestore
- super.location = location;
- }
- }
|