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.

Repository.java 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. package org.apache.archiva.repository;
  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. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import org.apache.archiva.indexer.ArchivaIndexingContext;
  21. import org.apache.archiva.repository.features.RepositoryFeature;
  22. import java.net.URI;
  23. import java.nio.file.Path;
  24. import java.util.Locale;
  25. import java.util.Set;
  26. /**
  27. *
  28. * Base interface for repositories.
  29. *
  30. * Created by Martin Stockhammer on 21.09.17.
  31. */
  32. public interface Repository extends RepositoryEventHandler {
  33. /**
  34. * Return the identifier of the repository. Repository identifier should be unique at least
  35. * for the same type.
  36. * @return The identifier.
  37. */
  38. String getId();
  39. /**
  40. * This is the display name of the repository. This string is presented in the user interface.
  41. *
  42. * @return The display name of the repository
  43. */
  44. String getName();
  45. /**
  46. * Returns the name in the given locale.
  47. * @param locale
  48. * @return
  49. */
  50. String getName(Locale locale);
  51. /**
  52. * Returns a description of this repository.
  53. * @return The description.
  54. */
  55. String getDescription();
  56. /**
  57. * Returns the description for the given locale.
  58. * @param locale
  59. * @return
  60. */
  61. String getDescription(Locale locale);
  62. /**
  63. * This identifies the type of repository. Archiva does only support certain types of repositories.
  64. *
  65. * @return A unique identifier for the repository type.
  66. */
  67. RepositoryType getType();
  68. /**
  69. * Returns the location of this repository. For local repositories this might be a file URI, for
  70. * remote repositories a http URL or some very repository specific schemes.
  71. * Each repository has only one unique location.
  72. *
  73. * @return The repository location.
  74. */
  75. URI getLocation();
  76. /**
  77. * Returns the local path that this repository uses, if it stores data locally. You should keep in
  78. * mind, that repository implementations may not store any data in this directory. E.g. if the
  79. * repository data is handled by a database. So the content of this directory is very implementation
  80. * specific. Users of this directory must know about the repository file layout if they use this
  81. * path.
  82. *
  83. * Repository implementations should always return a valid path, even if there is no locally stored data.
  84. *
  85. * Some extensions may use the path to store their own repository specific data, e.g. statistics, metadata,...
  86. *
  87. * @return the filesystem path to the repository.
  88. */
  89. Path getLocalPath();
  90. /**
  91. * A repository may allow additional locations that can be used, if the primary location is not available.
  92. * @return
  93. */
  94. Set<URI> getFailoverLocations();
  95. /**
  96. * True, if this repository is scanned regularly.
  97. */
  98. boolean isScanned();
  99. /**
  100. * Returns the definition, when the repository jobs are executed.
  101. * This must return a valid a cron string.
  102. *
  103. * @See http://www.quartz-scheduler.org/api/2.2.1/org/quartz/CronExpression.html
  104. *
  105. * @return
  106. */
  107. String getSchedulingDefinition();
  108. /**
  109. * Returns true, if this repository has a index available
  110. * @return
  111. */
  112. boolean hasIndex();
  113. /**
  114. * Returns a layout definition. The returned string may be implementation specific and is not
  115. * standardized.
  116. *
  117. * @return
  118. */
  119. String getLayout();
  120. /**
  121. * Returns the capabilities of the repository implementation.
  122. * @return
  123. */
  124. RepositoryCapabilities getCapabilities();
  125. /**
  126. * Extension method that allows to provide different features that are not supported by all
  127. * repository types.
  128. *
  129. * @param clazz The feature class that is requested
  130. * @param <T> This is the class of the feature
  131. * @return The feature implementation for this repository instance, if it is supported
  132. * @throws UnsupportedFeatureException if the feature is not supported by this repository type
  133. */
  134. <T extends RepositoryFeature<T>> RepositoryFeature<T> getFeature(Class<T> clazz) throws UnsupportedFeatureException;
  135. /**
  136. * Returns true, if the requested feature is supported by this repository.
  137. *
  138. * @param clazz The requested feature class
  139. * @param <T> The requested feature class
  140. * @return True, if the feature is supported, otherwise false.
  141. */
  142. <T extends RepositoryFeature<T>> boolean supportsFeature(Class<T> clazz);
  143. /**
  144. * Returns a indexing context.
  145. * @return
  146. * @throws UnsupportedOperationException
  147. */
  148. ArchivaIndexingContext getIndexingContext();
  149. /**
  150. * Closes all resources that are opened by this repository.
  151. */
  152. void close();
  153. }