1 package org.apache.archiva.repository; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import org.apache.archiva.model.ArtifactReference; 23 import org.apache.archiva.repository.features.RepositoryFeature; 24 25 /** 26 * This interface is for mapping web request paths to artifacts. 27 * The file system storage may differ from the paths used for web access. 28 * 29 * @author Martin Stockhammer <martin_s@apache.org> 30 */ 31 public interface RepositoryRequestInfo 32 { 33 34 /** 35 * Returns the artifact reference for a given path. 36 * Takes an incoming requested path (in "/" format) and gleans the layout 37 * and ArtifactReference appropriate for that content. 38 * 39 * @param requestPath The path of the web request 40 * @return The artifact reference 41 * @throws LayoutException 42 */ 43 ArtifactReference toArtifactReference( String requestPath ) throws LayoutException; 44 45 /** 46 * <p> 47 * Tests the path to see if it conforms to the expectations of a metadata request. 48 * </p> 49 * <p> 50 * NOTE: The implementation may do only a cursory check on the path's extension. A result of true 51 * from this method is not a guarantee that the support resource is in a valid format, or 52 * that it even contains data. 53 * </p> 54 * 55 * @param requestPath the path to test. 56 * @return true if the requestedPath is likely a metadata request. 57 */ 58 boolean isMetadata( String requestPath ); 59 60 /** 61 * Returns true, if the given request points to a archetype catalog. 62 * 63 * @param requestPath 64 * @return true if the requestedPath is likely an archetype catalog request. 65 */ 66 boolean isArchetypeCatalog( String requestPath ); 67 68 /** 69 * <p> 70 * Tests the path to see if it conforms to the expectations of a support file request. Support files are used 71 * for signing and validating the artifact files. 72 * </p> 73 * <p> 74 * May test for certain extensions like <code>.sha1</code>, <code>.md5</code>, <code>.asc</code>, and <code>.php</code>. 75 * </p> 76 * <p> 77 * NOTE: The implementation may do only a cursory check on the path's extension. A result of true 78 * from this method is not a guarantee that the support resource is in a valid format, or 79 * that it even contains data. 80 * </p> 81 * 82 * @param requestPath the path to test. 83 * @return true if the requestedPath is likely that of a support file request. 84 */ 85 boolean isSupportFile( String requestPath ); 86 87 /** 88 * <p> 89 * Tests the path to see if it conforms to the expectations of a support file request of the metadata file. 90 * </p> 91 * <p> 92 * May test for certain extensions like <code>.sha1</code>, <code>.md5</code>, <code>.asc</code>, and <code>.php</code>. 93 * </p> 94 * <p> 95 * NOTE: The implementation may do only a cursory check on the path's extension. A result of true 96 * from this method is not a guarantee that the support resource is in a valid format, or 97 * that it even contains data. 98 * </p> 99 * 100 * @param requestPath the path to test. 101 * @return true if the requestedPath is likely that of a support file request. 102 */ 103 boolean isMetadataSupportFile( String requestPath ); 104 105 /** 106 * Returns the likely layout type for the given request. 107 * Implementations may only check the path elements for this. To make sure, the path is valid, 108 * you should call {@link #toArtifactReference(String)} 109 * 110 * @return 111 */ 112 String getLayout( String requestPath ); 113 114 /** 115 * Adjust the requestedPath to conform to the native layout of the provided {@link org.apache.archiva.repository.ManagedRepositoryContent}. 116 * 117 * @param requestPath the incoming requested path. 118 * @return the adjusted (to native) path. 119 * @throws LayoutException if the path cannot be parsed. 120 */ 121 String toNativePath( String requestPath) throws LayoutException; 122 123 /** 124 * Extension method that allows to provide different features that are not supported by all 125 * repository types. 126 * 127 * @param clazz The feature class that is requested 128 * @param <T> This is the class of the feature 129 * @return The feature implementation for this repository instance, if it is supported 130 * @throws UnsupportedFeatureException if the feature is not supported by this repository type 131 */ 132 <T extends RepositoryFeature<T>> RepositoryFeature<T> getFeature( Class<T> clazz ) throws UnsupportedFeatureException; 133 134 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 145 }