This is an automated email from the ASF dual-hosted git repository.

martin_s pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/archiva.git


The following commit(s) were added to refs/heads/master by this push:
     new 79c7713  Adding interface for request path handling.
79c7713 is described below

commit 79c77136b99e4b7b06fad7c8d6e92d38d37a187f
Author: Martin Stockhammer <[email protected]>
AuthorDate: Thu May 9 09:40:15 2019 +0200

    Adding interface for request path handling.
---
 .../repository/ManagedRepositoryContent.java       |   2 +
 .../archiva/repository/RepositoryRequestInfo.java  | 145 +++++++++++++++++++++
 2 files changed, 147 insertions(+)

diff --git 
a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java
 
b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java
index bf47b47..816b577 100644
--- 
a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java
+++ 
b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java
@@ -30,6 +30,8 @@ import java.util.Set;
 /**
  * ManagedRepositoryContent interface for interacting with a managed 
repository in an abstract way,
  * without the need for processing based on filesystem paths, or working with 
the database.
+ *
+ * This interface
  */
 public interface ManagedRepositoryContent extends RepositoryContent
 {
diff --git 
a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryRequestInfo.java
 
b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryRequestInfo.java
new file mode 100644
index 0000000..043c09c
--- /dev/null
+++ 
b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryRequestInfo.java
@@ -0,0 +1,145 @@
+package org.apache.archiva.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.archiva.model.ArtifactReference;
+import org.apache.archiva.repository.features.RepositoryFeature;
+
+/**
+ * This interface is for mapping web request paths to artifacts.
+ * The file system storage may differ from the paths used for web access.
+ *
+ * @author Martin Stockhammer <[email protected]>
+ */
+public interface RepositoryRequestInfo
+{
+
+    /**
+     * Returns the artifact reference for a given path.
+     * Takes an incoming requested path (in "/" format) and gleans the layout
+     * and ArtifactReference appropriate for that content.
+     *
+     * @param requestPath The path of the web request
+     * @return The artifact reference
+     * @throws LayoutException
+     */
+    ArtifactReference toArtifactReference( String requestPath ) throws 
LayoutException;
+
+    /**
+     * <p>
+     * Tests the path to see if it conforms to the expectations of a metadata 
request.
+     * </p>
+     * <p>
+     * NOTE: The implementation may do only a cursory check on the path's 
extension.  A result of true
+     * from this method is not a guarantee that the support resource is in a 
valid format, or
+     * that it even contains data.
+     * </p>
+     *
+     * @param requestPath the path to test.
+     * @return true if the requestedPath is likely a metadata request.
+     */
+    boolean isMetadata( String requestPath );
+
+    /**
+     * Returns true, if the given request points to a archetype catalog.
+     *
+     * @param requestPath
+     * @return true if the requestedPath is likely an archetype catalog 
request.
+     */
+    boolean isArchetypeCatalog( String requestPath );
+
+    /**
+     * <p>
+     * Tests the path to see if it conforms to the expectations of a support 
file request. Support files are used
+     * for signing and validating the artifact files.
+     * </p>
+     * <p>
+     * May test for certain extensions like <code>.sha1</code>, 
<code>.md5</code>, <code>.asc</code>, and <code>.php</code>.
+     * </p>
+     * <p>
+     * NOTE: The implementation may do only a cursory check on the path's 
extension.  A result of true
+     * from this method is not a guarantee that the support resource is in a 
valid format, or
+     * that it even contains data.
+     * </p>
+     *
+     * @param requestPath the path to test.
+     * @return true if the requestedPath is likely that of a support file 
request.
+     */
+    boolean isSupportFile( String requestPath );
+
+    /**
+     * <p>
+     * Tests the path to see if it conforms to the expectations of a support 
file request of the metadata file.
+     * </p>
+     * <p>
+     * May test for certain extensions like <code>.sha1</code>, 
<code>.md5</code>, <code>.asc</code>, and <code>.php</code>.
+     * </p>
+     * <p>
+     * NOTE: The implementation may do only a cursory check on the path's 
extension.  A result of true
+     * from this method is not a guarantee that the support resource is in a 
valid format, or
+     * that it even contains data.
+     * </p>
+     *
+     * @param requestPath the path to test.
+     * @return true if the requestedPath is likely that of a support file 
request.
+     */
+    boolean isMetadataSupportFile( String requestPath );
+
+    /**
+     * Returns the likely layout type for the given request.
+     * Implementations may only check the path elements for this.  To make 
sure, the path is valid,
+     * you should call {@link #toArtifactReference(String)}
+     *
+     * @return
+     */
+    String getLayout( String requestPath );
+
+    /**
+     * Adjust the requestedPath to conform to the native layout of the 
provided {@link org.apache.archiva.repository.ManagedRepositoryContent}.
+     *
+     * @param requestPath the incoming requested path.
+     * @return the adjusted (to native) path.
+     * @throws LayoutException if the path cannot be parsed.
+     */
+    void toNativePath( String requestPath);
+
+    /**
+     * Extension method that allows to provide different features that are not 
supported by all
+     * repository types.
+     *
+     * @param clazz The feature class that is requested
+     * @param <T>   This is the class of the feature
+     * @return The feature implementation for this repository instance, if it 
is supported
+     * @throws UnsupportedFeatureException if the feature is not supported by 
this repository type
+     */
+    <T extends RepositoryFeature<T>> RepositoryFeature<T> getFeature( Class<T> 
clazz ) throws UnsupportedFeatureException;
+
+
+    /**
+     * Returns true, if the requested feature is supported by this repository.
+     *
+     * @param clazz The requested feature class
+     * @param <T>   The requested feature class
+     * @return True, if the feature is supported, otherwise false.
+     */
+    <T extends RepositoryFeature<T>> boolean supportsFeature( Class<T> clazz );
+
+
+}

Reply via email to