1 package org.apache.archiva.repository;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import org.apache.archiva.model.ArtifactReference;
23 import org.apache.archiva.repository.content.ItemSelector;
24 import org.apache.archiva.repository.features.RepositoryFeature;
27 * This interface is for mapping web request paths to artifacts.
28 * The file system storage may differ from the paths used for web access.
30 * @author Martin Stockhammer <martin_s@apache.org>
32 public interface RepositoryRequestInfo
36 * Returns the artifact reference for a given path.
37 * Takes an incoming requested path (in "/" format) and gleans the layout
38 * and ArtifactReference appropriate for that content.
40 * @param requestPath The path of the web request
41 * @return The artifact reference
42 * @throws LayoutException
44 ArtifactReference toArtifactReference( String requestPath ) throws LayoutException;
48 * Returns the item selector that matches the given path.
49 * @param requestPath the request path which may be different from the filesystem structure
50 * @return the item selector
51 * @throws LayoutException if the path is not valid for the given repository layout
53 ItemSelector toItemSelector( String requestPath ) throws LayoutException;
57 * Tests the path to see if it conforms to the expectations of a metadata request.
60 * NOTE: The implementation may do only a cursory check on the path's extension. A result of true
61 * from this method is not a guarantee that the support resource is in a valid format, or
62 * that it even contains data.
65 * @param requestPath the path to test.
66 * @return true if the requestedPath is likely a metadata request.
68 boolean isMetadata( String requestPath );
71 * Returns true, if the given request points to a archetype catalog.
74 * @return true if the requestedPath is likely an archetype catalog request.
76 boolean isArchetypeCatalog( String requestPath );
80 * Tests the path to see if it conforms to the expectations of a support file request. Support files are used
81 * for signing and validating the artifact files.
84 * May test for certain extensions like <code>.sha1</code>, <code>.md5</code>, <code>.asc</code>, and <code>.php</code>.
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.
92 * @param requestPath the path to test.
93 * @return true if the requestedPath is likely that of a support file request.
95 boolean isSupportFile( String requestPath );
99 * Tests the path to see if it conforms to the expectations of a support file request of the metadata file.
102 * May test for certain extensions like <code>.sha1</code>, <code>.md5</code>, <code>.asc</code>, and <code>.php</code>.
105 * NOTE: The implementation may do only a cursory check on the path's extension. A result of true
106 * from this method is not a guarantee that the support resource is in a valid format, or
107 * that it even contains data.
110 * @param requestPath the path to test.
111 * @return true if the requestedPath is likely that of a support file request.
113 boolean isMetadataSupportFile( String requestPath );
116 * Returns the likely layout type for the given request.
117 * Implementations may only check the path elements for this. To make sure, the path is valid,
118 * you should call {@link #toArtifactReference(String)}
122 String getLayout( String requestPath );
125 * Adjust the requestedPath to conform to the native layout of the provided {@link BaseRepositoryContentLayout}.
127 * @param requestPath the incoming requested path.
128 * @return the adjusted (to native) path.
129 * @throws LayoutException if the path cannot be parsed.
131 String toNativePath( String requestPath) throws LayoutException;
134 * Extension method that allows to provide different features that are not supported by all
137 * @param clazz The feature class that is requested
138 * @param <T> This is the class of the feature
139 * @return The feature implementation for this repository instance, if it is supported
140 * @throws UnsupportedFeatureException if the feature is not supported by this repository type
142 <T extends RepositoryFeature<T>> RepositoryFeature<T> getFeature( Class<T> clazz ) throws UnsupportedFeatureException;
146 * Returns true, if the requested feature is supported by this repository.
148 * @param clazz The requested feature class
149 * @param <T> The requested feature class
150 * @return True, if the feature is supported, otherwise false.
152 <T extends RepositoryFeature<T>> boolean supportsFeature( Class<T> clazz );