001package org.apache.archiva.repository; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.archiva.model.ArtifactReference; 023import org.apache.archiva.repository.features.RepositoryFeature; 024 025/** 026 * This interface is for mapping web request paths to artifacts. 027 * The file system storage may differ from the paths used for web access. 028 * 029 * @author Martin Stockhammer <martin_s@apache.org> 030 */ 031public interface RepositoryRequestInfo 032{ 033 034 /** 035 * Returns the artifact reference for a given path. 036 * Takes an incoming requested path (in "/" format) and gleans the layout 037 * and ArtifactReference appropriate for that content. 038 * 039 * @param requestPath The path of the web request 040 * @return The artifact reference 041 * @throws LayoutException 042 */ 043 ArtifactReference toArtifactReference( String requestPath ) throws LayoutException; 044 045 /** 046 * <p> 047 * Tests the path to see if it conforms to the expectations of a metadata request. 048 * </p> 049 * <p> 050 * NOTE: The implementation may do only a cursory check on the path's extension. A result of true 051 * from this method is not a guarantee that the support resource is in a valid format, or 052 * that it even contains data. 053 * </p> 054 * 055 * @param requestPath the path to test. 056 * @return true if the requestedPath is likely a metadata request. 057 */ 058 boolean isMetadata( String requestPath ); 059 060 /** 061 * Returns true, if the given request points to a archetype catalog. 062 * 063 * @param requestPath 064 * @return true if the requestedPath is likely an archetype catalog request. 065 */ 066 boolean isArchetypeCatalog( String requestPath ); 067 068 /** 069 * <p> 070 * Tests the path to see if it conforms to the expectations of a support file request. Support files are used 071 * for signing and validating the artifact files. 072 * </p> 073 * <p> 074 * May test for certain extensions like <code>.sha1</code>, <code>.md5</code>, <code>.asc</code>, and <code>.php</code>. 075 * </p> 076 * <p> 077 * NOTE: The implementation may do only a cursory check on the path's extension. A result of true 078 * from this method is not a guarantee that the support resource is in a valid format, or 079 * that it even contains data. 080 * </p> 081 * 082 * @param requestPath the path to test. 083 * @return true if the requestedPath is likely that of a support file request. 084 */ 085 boolean isSupportFile( String requestPath ); 086 087 /** 088 * <p> 089 * Tests the path to see if it conforms to the expectations of a support file request of the metadata file. 090 * </p> 091 * <p> 092 * May test for certain extensions like <code>.sha1</code>, <code>.md5</code>, <code>.asc</code>, and <code>.php</code>. 093 * </p> 094 * <p> 095 * NOTE: The implementation may do only a cursory check on the path's extension. A result of true 096 * from this method is not a guarantee that the support resource is in a valid format, or 097 * that it even contains data. 098 * </p> 099 * 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}