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.5KB

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