You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractRemoteRepository.java 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. package org.apache.archiva.repository.base.remote;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. import org.apache.archiva.repository.EditableRemoteRepository;
  20. import org.apache.archiva.repository.RemoteRepositoryContent;
  21. import org.apache.archiva.repository.RepositoryCredentials;
  22. import org.apache.archiva.repository.RepositoryType;
  23. import org.apache.archiva.repository.base.AbstractRepository;
  24. import org.apache.archiva.repository.storage.RepositoryStorage;
  25. import java.net.URI;
  26. import java.time.Duration;
  27. import java.util.Collections;
  28. import java.util.HashMap;
  29. import java.util.Locale;
  30. import java.util.Map;
  31. /**
  32. * Abstract implementation of a remote repository. Abstract classes must implement the
  33. * features and capabilities by themselves.
  34. */
  35. public abstract class AbstractRemoteRepository extends AbstractRepository implements EditableRemoteRepository
  36. {
  37. private RepositoryCredentials credentials;
  38. private String checkPath;
  39. private Map<String,String> extraParameters = new HashMap<>( );
  40. private Map<String,String> uExtraParameters = Collections.unmodifiableMap( extraParameters );
  41. private Map<String,String> extraHeaders = new HashMap<>( );
  42. private Map<String,String> uExtraHeaders = Collections.unmodifiableMap( extraHeaders );
  43. private Duration timeout = Duration.ofSeconds( 60 );
  44. private String proxyId;
  45. private RemoteRepositoryContent content;
  46. public AbstractRemoteRepository( RepositoryType type, String id, String name , RepositoryStorage storage)
  47. {
  48. super( type, id, name, storage );
  49. }
  50. public AbstractRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage storage )
  51. {
  52. super( primaryLocale, type, id, name, storage );
  53. }
  54. @Override
  55. public void setCredentials( RepositoryCredentials credentials )
  56. {
  57. this.credentials = credentials;
  58. }
  59. @Override
  60. public void setCheckPath( String path )
  61. {
  62. this.checkPath = path;
  63. }
  64. @Override
  65. public void setExtraParameters( Map<String, String> params )
  66. {
  67. this.extraParameters.clear();
  68. this.extraParameters.putAll(params);
  69. }
  70. @Override
  71. public void addExtraParameter( String key, String value )
  72. {
  73. this.extraParameters.put(key, value);
  74. }
  75. @Override
  76. public void setExtraHeaders( Map<String, String> headers )
  77. {
  78. this.extraHeaders.clear();
  79. this.extraHeaders.putAll(headers);
  80. }
  81. @Override
  82. public void addExtraHeader( String header, String value )
  83. {
  84. this.extraHeaders.put(header, value);
  85. }
  86. @Override
  87. public void setTimeout( Duration duration )
  88. {
  89. this.timeout = duration;
  90. }
  91. @Override
  92. public RemoteRepositoryContent getContent( )
  93. {
  94. return content;
  95. }
  96. @Override
  97. public void setContent(RemoteRepositoryContent content) {
  98. this.content = content;
  99. }
  100. @Override
  101. public RepositoryCredentials getLoginCredentials( )
  102. {
  103. return credentials;
  104. }
  105. @Override
  106. public String getCheckPath( )
  107. {
  108. return checkPath;
  109. }
  110. @Override
  111. public Map<String, String> getExtraParameters( )
  112. {
  113. return uExtraParameters;
  114. }
  115. @Override
  116. public Map<String, String> getExtraHeaders( )
  117. {
  118. return uExtraHeaders;
  119. }
  120. @Override
  121. public Duration getTimeout( )
  122. {
  123. return timeout;
  124. }
  125. @Override
  126. public String toString() {
  127. StringBuilder str = new StringBuilder();
  128. return str.append("checkPath=").append(checkPath)
  129. .append(",creds:").append(credentials).toString();
  130. }
  131. @Override
  132. public void setLocation(URI location) {
  133. // Location of remote repositories is not for the local filestore
  134. super.location = location;
  135. }
  136. }