aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-repository-api
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2020-02-01 00:41:34 +0100
committerMartin Stockhammer <martin_s@apache.org>2020-02-01 00:41:34 +0100
commit865e3fef2449f093ddfb6c133563de0a0b5d4659 (patch)
tree38975ae0f82f587a49df840346012dc87f650283 /archiva-modules/archiva-base/archiva-repository-api
parent5fe962ccce28d60c2745343e0174fed42bd5e2b5 (diff)
downloadarchiva-865e3fef2449f093ddfb6c133563de0a0b5d4659.tar.gz
archiva-865e3fef2449f093ddfb6c133563de0a0b5d4659.zip
Adding metadatareader interface
Diffstat (limited to 'archiva-modules/archiva-base/archiva-repository-api')
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/pom.xml4
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java33
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/metadata/MetadataReader.java55
3 files changed, 92 insertions, 0 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-api/pom.xml b/archiva-modules/archiva-base/archiva-repository-api/pom.xml
index 1c7675b95..584375efd 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/pom.xml
+++ b/archiva-modules/archiva-base/archiva-repository-api/pom.xml
@@ -64,6 +64,10 @@
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.archiva.components.registry</groupId>
<artifactId>archiva-components-spring-registry-api</artifactId>
</dependency>
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java
index fec96f6c7..bb6bbc98b 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java
@@ -27,6 +27,8 @@ import org.apache.archiva.configuration.RepositoryGroupConfiguration;
import org.apache.archiva.event.EventSource;
import org.apache.archiva.indexer.ArchivaIndexManager;
import org.apache.archiva.indexer.IndexUpdateFailedException;
+import org.apache.archiva.repository.metadata.MetadataReader;
+import org.apache.archiva.repository.storage.StorageAsset;
import java.util.Collection;
@@ -41,12 +43,36 @@ import java.util.Collection;
*/
public interface RepositoryRegistry extends EventSource
{
+ /**
+ * Set the configuration for the registry
+ * @param archivaConfiguration
+ */
void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration );
+ /**
+ * Return the index manager for the given repository type
+ * @param type the repository type
+ * @return the index manager, if it exists
+ */
ArchivaIndexManager getIndexManager( RepositoryType type );
+ /**
+ * Returns the metadatareader for the given repository type
+ * @param type the repository type
+ * @return the metadata reader instance
+ */
+ MetadataReader getMetadataReader(RepositoryType type) throws UnsupportedRepositoryTypeException;
+
+ /**
+ * Returns all registered repositories
+ * @return the list of repositories
+ */
Collection<Repository> getRepositories( );
+ /**
+ * Returns all managed repositories
+ * @return the list of managed repositories
+ */
Collection<ManagedRepository> getManagedRepositories( );
Collection<RemoteRepository> getRemoteRepositories( );
@@ -106,4 +132,11 @@ public interface RepositoryRegistry extends EventSource
<T extends Repository> Repository clone( T repo, String newId ) throws RepositoryException;
RemoteRepository clone( RemoteRepository repo, String newId ) throws RepositoryException;
+
+ /**
+ * Return the repository that stores the given asset.
+ * @param asset the asset
+ * @return the repository or <code>null</code> if no matching repository is found
+ */
+ Repository getRepositoryOfAsset( StorageAsset asset );
}
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/metadata/MetadataReader.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/metadata/MetadataReader.java
new file mode 100644
index 000000000..74bacb7d6
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/metadata/MetadataReader.java
@@ -0,0 +1,55 @@
+package org.apache.archiva.repository.metadata;
+
+/*
+ * 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.ArchivaRepositoryMetadata;
+import org.apache.archiva.repository.RepositoryType;
+import org.apache.archiva.repository.storage.StorageAsset;
+
+/**
+ * Interface for reading metadata from a given file
+ */
+public interface MetadataReader
+{
+ /**
+ * Reads the given metadata file and returns the corresponding metadata object.
+ * @param asset The asset where the metadata should be read from
+ * @return The parsed metadata
+ * @throws RepositoryMetadataException if the metadata could not be read
+ */
+ ArchivaRepositoryMetadata read( StorageAsset asset ) throws RepositoryMetadataException;
+
+ /**
+ * Returns <code>true</code>, if the given path is a valid path for a metadata file, otherwise <code>false</code>
+ * The implementation should not access the file directly, just use the path for validation.
+ * @param path the path to the metadata file / asset
+ * @return <code>true</code>, if the path is valid for a metadata file otherwise <code>false</code>
+ */
+ boolean isValidMetadataPath(String path);
+
+ /**
+ * Returns <code>true</code>, if this metadata reader instance can be used to read metadata for the
+ * given repository type, otherwise <code>false</code>.
+ *
+ * @param repositoryType the repository type to check for
+ * @return <code>true</code>, if this is a implementation for the given type, otherwise <code>false</code>
+ */
+ boolean isValidForType(RepositoryType repositoryType);
+}