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.features.RepositoryFeature;
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.
29 * @author Martin Stockhammer <martin_s@apache.org>
31 public interface RepositoryRequestInfo
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.
39 * @param requestPath The path of the web request
40 * @return The artifact reference
41 * @throws LayoutException
43 ArtifactReference toArtifactReference( String requestPath ) throws LayoutException;
47 * Tests the path to see if it conforms to the expectations of a metadata request.
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.
55 * @param requestPath the path to test.
56 * @return true if the requestedPath is likely a metadata request.
58 boolean isMetadata( String requestPath );
61 * Returns true, if the given request points to a archetype catalog.
64 * @return true if the requestedPath is likely an archetype catalog request.
66 boolean isArchetypeCatalog( String requestPath );
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.
74 * May test for certain extensions like <code>.sha1</code>, <code>.md5</code>, <code>.asc</code>, and <code>.php</code>.
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.
82 * @param requestPath the path to test.
83 * @return true if the requestedPath is likely that of a support file request.
85 boolean isSupportFile( String requestPath );
89 * Tests the path to see if it conforms to the expectations of a support file request of the metadata file.
92 * May test for certain extensions like <code>.sha1</code>, <code>.md5</code>, <code>.asc</code>, and <code>.php</code>.
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.
100 * @param requestPath the path to test.
101 * @return true if the requestedPath is likely that of a support file request.
103 boolean isMetadataSupportFile( String requestPath );
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)}
112 String getLayout( String requestPath );
115 * Adjust the requestedPath to conform to the native layout of the provided {@link org.apache.archiva.repository.ManagedRepositoryContent}.
117 * @param requestPath the incoming requested path.
118 * @return the adjusted (to native) path.
119 * @throws LayoutException if the path cannot be parsed.
121 void toNativePath( String requestPath);
124 * Extension method that allows to provide different features that are not supported by all
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
132 <T extends RepositoryFeature<T>> RepositoryFeature<T> getFeature( Class<T> clazz ) throws UnsupportedFeatureException;
136 * Returns true, if the requested feature is supported by this repository.
138 * @param clazz The requested feature class
139 * @param <T> The requested feature class
140 * @return True, if the feature is supported, otherwise false.
142 <T extends RepositoryFeature<T>> boolean supportsFeature( Class<T> clazz );