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.

RepositoryRequestInfo.java 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.model.ArtifactReference;
  21. import org.apache.archiva.repository.features.RepositoryFeature;
  22. /**
  23. * This interface is for mapping web request paths to artifacts.
  24. * The file system storage may differ from the paths used for web access.
  25. *
  26. * @author Martin Stockhammer <martin_s@apache.org>
  27. */
  28. public interface RepositoryRequestInfo
  29. {
  30. /**
  31. * Returns the artifact reference for a given path.
  32. * Takes an incoming requested path (in "/" format) and gleans the layout
  33. * and ArtifactReference appropriate for that content.
  34. *
  35. * @param requestPath The path of the web request
  36. * @return The artifact reference
  37. * @throws LayoutException
  38. */
  39. ArtifactReference toArtifactReference( String requestPath ) throws LayoutException;
  40. /**
  41. * <p>
  42. * Tests the path to see if it conforms to the expectations of a metadata request.
  43. * </p>
  44. * <p>
  45. * NOTE: The implementation may do only a cursory check on the path's extension. A result of true
  46. * from this method is not a guarantee that the support resource is in a valid format, or
  47. * that it even contains data.
  48. * </p>
  49. *
  50. * @param requestPath the path to test.
  51. * @return true if the requestedPath is likely a metadata request.
  52. */
  53. boolean isMetadata( String requestPath );
  54. /**
  55. * Returns true, if the given request points to a archetype catalog.
  56. *
  57. * @param requestPath
  58. * @return true if the requestedPath is likely an archetype catalog request.
  59. */
  60. boolean isArchetypeCatalog( String requestPath );
  61. /**
  62. * <p>
  63. * Tests the path to see if it conforms to the expectations of a support file request. Support files are used
  64. * for signing and validating the artifact files.
  65. * </p>
  66. * <p>
  67. * May test for certain extensions like <code>.sha1</code>, <code>.md5</code>, <code>.asc</code>, and <code>.php</code>.
  68. * </p>
  69. * <p>
  70. * NOTE: The implementation may do only a cursory check on the path's extension. A result of true
  71. * from this method is not a guarantee that the support resource is in a valid format, or
  72. * that it even contains data.
  73. * </p>
  74. *
  75. * @param requestPath the path to test.
  76. * @return true if the requestedPath is likely that of a support file request.
  77. */
  78. boolean isSupportFile( String requestPath );
  79. /**
  80. * <p>
  81. * Tests the path to see if it conforms to the expectations of a support file request of the metadata file.
  82. * </p>
  83. * <p>
  84. * May test for certain extensions like <code>.sha1</code>, <code>.md5</code>, <code>.asc</code>, and <code>.php</code>.
  85. * </p>
  86. * <p>
  87. * NOTE: The implementation may do only a cursory check on the path's extension. A result of true
  88. * from this method is not a guarantee that the support resource is in a valid format, or
  89. * that it even contains data.
  90. * </p>
  91. *
  92. * @param requestPath the path to test.
  93. * @return true if the requestedPath is likely that of a support file request.
  94. */
  95. boolean isMetadataSupportFile( String requestPath );
  96. /**
  97. * Returns the likely layout type for the given request.
  98. * Implementations may only check the path elements for this. To make sure, the path is valid,
  99. * you should call {@link #toArtifactReference(String)}
  100. *
  101. * @return
  102. */
  103. String getLayout( String requestPath );
  104. /**
  105. * Adjust the requestedPath to conform to the native layout of the provided {@link org.apache.archiva.repository.ManagedRepositoryContent}.
  106. *
  107. * @param requestPath the incoming requested path.
  108. * @return the adjusted (to native) path.
  109. * @throws LayoutException if the path cannot be parsed.
  110. */
  111. String toNativePath( String requestPath) throws LayoutException;
  112. /**
  113. * Extension method that allows to provide different features that are not supported by all
  114. * repository types.
  115. *
  116. * @param clazz The feature class that is requested
  117. * @param <T> This is the class of the feature
  118. * @return The feature implementation for this repository instance, if it is supported
  119. * @throws UnsupportedFeatureException if the feature is not supported by this repository type
  120. */
  121. <T extends RepositoryFeature<T>> RepositoryFeature<T> getFeature( Class<T> clazz ) throws UnsupportedFeatureException;
  122. /**
  123. * Returns true, if the requested feature is supported by this repository.
  124. *
  125. * @param clazz The requested feature class
  126. * @param <T> The requested feature class
  127. * @return True, if the feature is supported, otherwise false.
  128. */
  129. <T extends RepositoryFeature<T>> boolean supportsFeature( Class<T> clazz );
  130. }