aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/metadata
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2009-11-25 00:45:57 +0000
committerBrett Porter <brett@apache.org>2009-11-25 00:45:57 +0000
commitd9e22fa7781c37b8df8a0a3e358ec0b1ace43451 (patch)
tree197d9214a8c30bf2d254e6a7feb5a18c63da3380 /archiva-modules/metadata
parent627ad47211e5ce1d14218e4ed495f786b4128eac (diff)
downloadarchiva-d9e22fa7781c37b8df8a0a3e358ec0b1ace43451.tar.gz
archiva-d9e22fa7781c37b8df8a0a3e358ec0b1ace43451.zip
[MRM-1282] introduce a metadata resolver API that will allow just-in-time addition to the content repository and the ability to introduce proxying
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@883936 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/metadata')
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java69
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java8
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java34
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryPathTranslator.java29
4 files changed, 133 insertions, 7 deletions
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
new file mode 100644
index 000000000..d7837a8a3
--- /dev/null
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
@@ -0,0 +1,69 @@
+package org.apache.archiva.metadata.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 java.util.Collection;
+
+import org.apache.archiva.metadata.model.ProjectBuildMetadata;
+import org.apache.archiva.metadata.model.ProjectMetadata;
+
+/**
+ * @plexus.component role="org.apache.archiva.metadata.repository.MetadataResolver"
+ */
+public class DefaultMetadataResolver
+ implements MetadataResolver
+{
+ /**
+ * @plexus.requirement
+ */
+ private MetadataRepository metadataRepository;
+
+ /**
+ * TODO: this needs to be configurable based on storage type, and availability of proxy module
+ * TODO: could be a different type since we need methods to modify the storage metadata
+ * @plexus.requirement role-hint="maven2"
+ */
+ private MetadataResolver storageResolver;
+
+ public ProjectMetadata getProject( String repoId, String namespace, String projectId )
+ {
+ // TODO: intercept
+ return metadataRepository.getProject( repoId, namespace, projectId );
+ }
+
+ public ProjectBuildMetadata getProjectBuild( String repoId, String namespace, String projectId, String buildId )
+ {
+ ProjectBuildMetadata metadata = metadataRepository.getProjectBuild( repoId, namespace, projectId, buildId );
+ // TODO: do we want to detect changes as well by comparing timestamps? isProjectBuildNewerThan(updated)
+ // in such cases we might also remove/update stale metadata, including adjusting plugin-based facets
+ if ( metadata == null )
+ {
+ metadata = storageResolver.getProjectBuild( repoId, namespace, projectId, buildId );
+ metadataRepository.updateBuild( repoId, namespace, projectId, metadata );
+ }
+ return metadata;
+ }
+
+ public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String buildId )
+ {
+ // TODO: intercept
+ return metadataRepository.getArtifactVersions( repoId, namespace, projectId, buildId );
+ }
+}
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
index 4440a9e07..6e20282c1 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java
@@ -19,13 +19,12 @@ package org.apache.archiva.metadata.repository;
* under the License.
*/
-import java.util.Collection;
-
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.ProjectBuildMetadata;
import org.apache.archiva.metadata.model.ProjectMetadata;
public interface MetadataRepository
+ extends MetadataResolver
{
/**
* Update metadata for a particular project in the metadata repository, or create it if it does not already exist.
@@ -37,9 +36,4 @@ public interface MetadataRepository
void updateBuild( String repoId, String namespace, String projectId, ProjectBuildMetadata build );
- ProjectMetadata getProject( String repoId, String namespace, String projectId );
-
- ProjectBuildMetadata getProjectBuild( String repoId, String namespace, String projectId, String buildId );
-
- Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String buildId );
}
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java
new file mode 100644
index 000000000..fd2cf83d4
--- /dev/null
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java
@@ -0,0 +1,34 @@
+package org.apache.archiva.metadata.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 java.util.Collection;
+
+import org.apache.archiva.metadata.model.ProjectBuildMetadata;
+import org.apache.archiva.metadata.model.ProjectMetadata;
+
+public interface MetadataResolver
+{
+ ProjectMetadata getProject( String repoId, String namespace, String projectId );
+
+ ProjectBuildMetadata getProjectBuild( String repoId, String namespace, String projectId, String buildId );
+
+ Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String buildId );
+}
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryPathTranslator.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryPathTranslator.java
new file mode 100644
index 000000000..3a581d696
--- /dev/null
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryPathTranslator.java
@@ -0,0 +1,29 @@
+package org.apache.archiva.metadata.repository.storage;
+
+/*
+ * 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 java.io.File;
+
+public interface RepositoryPathTranslator
+{
+ File toFile( File basedir, String namespace, String projectId, String buildId, String filename );
+
+ String toPath( String namespace, String projectId, String buildId, String filename );
+}