summaryrefslogtreecommitdiffstats
path: root/archiva-modules/metadata
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-02-04 22:14:00 +0000
committerOlivier Lamy <olamy@apache.org>2012-02-04 22:14:00 +0000
commitcc81e0172276af7046d6da7cf75a605ad4d49766 (patch)
treefc61dfe781d75cc90cae25c1d88f6cd11e6e22f3 /archiva-modules/metadata
parent5d6774f5f2560c02911c6e9846eccd08a12b86a8 (diff)
downloadarchiva-cc81e0172276af7046d6da7cf75a605ad4d49766.tar.gz
archiva-cc81e0172276af7046d6da7cf75a605ad4d49766.zip
[MRM-1599] NTLM proxy no longer works
change for metadata resolver too using ntlm proxy take the opportunity to use repo admin api rather than archivaconfiguration directly/ git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1240625 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.java303
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java15
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorageRuntimeException.java38
3 files changed, 215 insertions, 141 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
index f56d72c16..0d99110a3 100644
--- 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
@@ -19,7 +19,6 @@ package org.apache.archiva.metadata.repository;
* under the License.
*/
-import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
@@ -28,6 +27,7 @@ import org.apache.archiva.metadata.repository.filter.ExcludesFilter;
import org.apache.archiva.metadata.repository.storage.RepositoryStorage;
import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataInvalidException;
import org.apache.archiva.metadata.repository.storage.RepositoryStorageMetadataNotFoundException;
+import org.apache.archiva.metadata.repository.storage.RepositoryStorageRuntimeException;
import org.apache.archiva.repository.events.RepositoryListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -135,22 +135,23 @@ public class DefaultMetadataResolver
}
throw new MetadataResolutionException( e.getMessage(), e );
}
- catch ( RepositoryAdminException e )
+ catch ( RepositoryStorageMetadataNotFoundException e )
{
for ( RepositoryListener listener : listeners )
{
listener.addArtifactProblem( session, repoId, namespace, projectId, projectVersion, e );
}
- throw new MetadataResolutionException( e.getMessage(), e );
+ // no need to rethrow - return null
}
- catch ( RepositoryStorageMetadataNotFoundException e )
+ catch ( RepositoryStorageRuntimeException e )
{
for ( RepositoryListener listener : listeners )
{
listener.addArtifactProblem( session, repoId, namespace, projectId, projectVersion, e );
}
- // no need to rethrow - return null
+ throw new MetadataResolutionException( e.getMessage(), e );
}
+
}
return metadata;
}
@@ -169,198 +170,234 @@ public class DefaultMetadataResolver
public Collection<String> resolveRootNamespaces( RepositorySession session, String repoId )
throws MetadataResolutionException
{
- MetadataRepository metadataRepository = session.getRepository();
- Collection<String> namespaces = metadataRepository.getRootNamespaces( repoId );
- Collection<String> storageNamespaces =
- repositoryStorage.listRootNamespaces( repoId, new ExcludesFilter<String>( namespaces ) );
- if ( storageNamespaces != null && !storageNamespaces.isEmpty() )
+ try
{
- if ( log.isDebugEnabled() )
- {
- log.debug( "Resolved root namespaces from storage: " + storageNamespaces );
- }
- for ( String n : storageNamespaces )
+ MetadataRepository metadataRepository = session.getRepository();
+ Collection<String> namespaces = metadataRepository.getRootNamespaces( repoId );
+ Collection<String> storageNamespaces =
+ repositoryStorage.listRootNamespaces( repoId, new ExcludesFilter<String>( namespaces ) );
+ if ( storageNamespaces != null && !storageNamespaces.isEmpty() )
{
- try
+ if ( log.isDebugEnabled() )
{
- metadataRepository.updateNamespace( repoId, n );
+ log.debug( "Resolved root namespaces from storage: " + storageNamespaces );
}
- catch ( MetadataRepositoryException e )
+ for ( String n : storageNamespaces )
{
- log.warn( "Unable to persist resolved information: " + e.getMessage(), e );
+ try
+ {
+ metadataRepository.updateNamespace( repoId, n );
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ log.warn( "Unable to persist resolved information: " + e.getMessage(), e );
+ }
}
- }
- session.markDirty();
+ session.markDirty();
- namespaces = new ArrayList<String>( namespaces );
- namespaces.addAll( storageNamespaces );
+ namespaces = new ArrayList<String>( namespaces );
+ namespaces.addAll( storageNamespaces );
+ }
+ return namespaces;
+ }
+ catch ( RepositoryStorageRuntimeException e )
+ {
+ throw new MetadataResolutionException( e.getMessage(), e );
}
- return namespaces;
}
public Collection<String> resolveNamespaces( RepositorySession session, String repoId, String namespace )
throws MetadataResolutionException
{
- MetadataRepository metadataRepository = session.getRepository();
- Collection<String> namespaces = metadataRepository.getNamespaces( repoId, namespace );
- Collection<String> exclusions = new ArrayList<String>( namespaces );
- exclusions.addAll( metadataRepository.getProjects( repoId, namespace ) );
- Collection<String> storageNamespaces =
- repositoryStorage.listNamespaces( repoId, namespace, new ExcludesFilter<String>( exclusions ) );
- if ( storageNamespaces != null && !storageNamespaces.isEmpty() )
+ try
{
- if ( log.isDebugEnabled() )
- {
- log.debug( "Resolved namespaces from storage: " + storageNamespaces );
- }
- for ( String n : storageNamespaces )
+ MetadataRepository metadataRepository = session.getRepository();
+ Collection<String> namespaces = metadataRepository.getNamespaces( repoId, namespace );
+ Collection<String> exclusions = new ArrayList<String>( namespaces );
+ exclusions.addAll( metadataRepository.getProjects( repoId, namespace ) );
+ Collection<String> storageNamespaces =
+ repositoryStorage.listNamespaces( repoId, namespace, new ExcludesFilter<String>( exclusions ) );
+ if ( storageNamespaces != null && !storageNamespaces.isEmpty() )
{
- try
- {
- metadataRepository.updateNamespace( repoId, namespace + "." + n );
- }
- catch ( MetadataRepositoryException e )
+
+ log.debug( "Resolved namespaces from storage: {}", storageNamespaces );
+ for ( String n : storageNamespaces )
{
- log.warn( "Unable to persist resolved information: " + e.getMessage(), e );
+ try
+ {
+ metadataRepository.updateNamespace( repoId, namespace + "." + n );
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ log.warn( "Unable to persist resolved information: " + e.getMessage(), e );
+ }
}
- }
- session.markDirty();
+ session.markDirty();
- namespaces = new ArrayList<String>( namespaces );
- namespaces.addAll( storageNamespaces );
+ namespaces = new ArrayList<String>( namespaces );
+ namespaces.addAll( storageNamespaces );
+ }
+ return namespaces;
+ }
+ catch ( RepositoryStorageRuntimeException e )
+ {
+ throw new MetadataResolutionException( e.getMessage(), e );
}
- return namespaces;
}
public Collection<String> resolveProjects( RepositorySession session, String repoId, String namespace )
throws MetadataResolutionException
{
- MetadataRepository metadataRepository = session.getRepository();
- Collection<String> projects = metadataRepository.getProjects( repoId, namespace );
- Collection<String> exclusions = new ArrayList<String>( projects );
- exclusions.addAll( metadataRepository.getNamespaces( repoId, namespace ) );
- Collection<String> storageProjects =
- repositoryStorage.listProjects( repoId, namespace, new ExcludesFilter<String>( exclusions ) );
- if ( storageProjects != null && !storageProjects.isEmpty() )
+ try
{
- if ( log.isDebugEnabled() )
- {
- log.debug( "Resolved projects from storage: " + storageProjects );
- }
- for ( String projectId : storageProjects )
+ MetadataRepository metadataRepository = session.getRepository();
+ Collection<String> projects = metadataRepository.getProjects( repoId, namespace );
+ Collection<String> exclusions = new ArrayList<String>( projects );
+ exclusions.addAll( metadataRepository.getNamespaces( repoId, namespace ) );
+ Collection<String> storageProjects =
+ repositoryStorage.listProjects( repoId, namespace, new ExcludesFilter<String>( exclusions ) );
+ if ( storageProjects != null && !storageProjects.isEmpty() )
{
- ProjectMetadata projectMetadata = repositoryStorage.readProjectMetadata( repoId, namespace, projectId );
- if ( projectMetadata != null )
+
+ log.debug( "Resolved projects from storage: {}", storageProjects );
+ for ( String projectId : storageProjects )
{
- try
- {
- metadataRepository.updateProject( repoId, projectMetadata );
- }
- catch ( MetadataRepositoryException e )
+ ProjectMetadata projectMetadata =
+ repositoryStorage.readProjectMetadata( repoId, namespace, projectId );
+ if ( projectMetadata != null )
{
- log.warn( "Unable to persist resolved information: " + e.getMessage(), e );
+ try
+ {
+ metadataRepository.updateProject( repoId, projectMetadata );
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ log.warn( "Unable to persist resolved information: " + e.getMessage(), e );
+ }
}
}
- }
- session.markDirty();
+ session.markDirty();
- projects = new ArrayList<String>( projects );
- projects.addAll( storageProjects );
+ projects = new ArrayList<String>( projects );
+ projects.addAll( storageProjects );
+ }
+ return projects;
+ }
+ catch ( RepositoryStorageRuntimeException e )
+ {
+ throw new MetadataResolutionException( e.getMessage(), e );
}
- return projects;
}
public Collection<String> resolveProjectVersions( RepositorySession session, String repoId, String namespace,
String projectId )
throws MetadataResolutionException
{
- MetadataRepository metadataRepository = session.getRepository();
- Collection<String> projectVersions = metadataRepository.getProjectVersions( repoId, namespace, projectId );
- Collection<String> storageProjectVersions = repositoryStorage.listProjectVersions( repoId, namespace, projectId,
- new ExcludesFilter<String>(
- projectVersions ) );
- if ( storageProjectVersions != null && !storageProjectVersions.isEmpty() )
+ try
{
- if ( log.isDebugEnabled() )
- {
- log.debug( "Resolved project versions from storage: " + storageProjectVersions );
- }
- for ( String projectVersion : storageProjectVersions )
+ MetadataRepository metadataRepository = session.getRepository();
+ Collection<String> projectVersions = metadataRepository.getProjectVersions( repoId, namespace, projectId );
+ Collection<String> storageProjectVersions =
+ repositoryStorage.listProjectVersions( repoId, namespace, projectId,
+ new ExcludesFilter<String>( projectVersions ) );
+ if ( storageProjectVersions != null && !storageProjectVersions.isEmpty() )
{
- try
- {
- ProjectVersionMetadata versionMetadata =
- repositoryStorage.readProjectVersionMetadata( repoId, namespace, projectId, projectVersion );
- for ( RepositoryListener listener : listeners )
- {
- listener.addArtifact( session, repoId, namespace, projectId, versionMetadata );
- }
+ log.debug( "Resolved project versions from storage: {}", storageProjectVersions );
- metadataRepository.updateProjectVersion( repoId, namespace, projectId, versionMetadata );
- }
- catch ( MetadataRepositoryException e )
- {
- log.warn( "Unable to persist resolved information: " + e.getMessage(), e );
- }
- catch ( RepositoryStorageMetadataInvalidException e )
+ for ( String projectVersion : storageProjectVersions )
{
- log.warn( "Not update project in metadata repository due to an error resolving it from storage: "
- + e.getMessage() );
+ try
+ {
+ ProjectVersionMetadata versionMetadata =
+ repositoryStorage.readProjectVersionMetadata( repoId, namespace, projectId,
+ projectVersion );
+ for ( RepositoryListener listener : listeners )
+ {
+ listener.addArtifact( session, repoId, namespace, projectId, versionMetadata );
+ }
- for ( RepositoryListener listener : listeners )
+ metadataRepository.updateProjectVersion( repoId, namespace, projectId, versionMetadata );
+ }
+ catch ( MetadataRepositoryException e )
{
- listener.addArtifactProblem( session, repoId, namespace, projectId, projectVersion, e );
+ log.warn( "Unable to persist resolved information: " + e.getMessage(), e );
}
- }
- catch ( RepositoryStorageMetadataNotFoundException e )
- {
- for ( RepositoryListener listener : listeners )
+ catch ( RepositoryStorageMetadataInvalidException e )
{
- listener.addArtifactProblem( session, repoId, namespace, projectId, projectVersion, e );
+ log.warn(
+ "Not update project in metadata repository due to an error resolving it from storage: "
+ + e.getMessage() );
+
+ for ( RepositoryListener listener : listeners )
+ {
+ listener.addArtifactProblem( session, repoId, namespace, projectId, projectVersion, e );
+ }
+ }
+ catch ( RepositoryStorageMetadataNotFoundException e )
+ {
+ for ( RepositoryListener listener : listeners )
+ {
+ listener.addArtifactProblem( session, repoId, namespace, projectId, projectVersion, e );
+ }
}
}
- }
- session.markDirty();
+ session.markDirty();
- projectVersions = new ArrayList<String>( projectVersions );
- projectVersions.addAll( storageProjectVersions );
+ projectVersions = new ArrayList<String>( projectVersions );
+ projectVersions.addAll( storageProjectVersions );
+ }
+ return projectVersions;
+ }
+ catch ( RepositoryStorageRuntimeException e )
+ {
+ throw new MetadataResolutionException( e.getMessage(), e );
}
- return projectVersions;
}
public Collection<ArtifactMetadata> resolveArtifacts( RepositorySession session, String repoId, String namespace,
String projectId, String projectVersion )
throws MetadataResolutionException
{
- MetadataRepository metadataRepository = session.getRepository();
- Collection<ArtifactMetadata> artifacts =
- metadataRepository.getArtifacts( repoId, namespace, projectId, projectVersion );
- ExcludesFilter<String> filter = new ExcludesFilter<String>( createArtifactIdList( artifacts ) );
- Collection<ArtifactMetadata> storageArtifacts =
- repositoryStorage.readArtifactsMetadata( repoId, namespace, projectId, projectVersion, filter );
- if ( storageArtifacts != null && !storageArtifacts.isEmpty() )
+ try
{
- if ( log.isDebugEnabled() )
- {
- log.debug( "Resolved artifacts from storage: " + storageArtifacts );
- }
- for ( ArtifactMetadata artifact : storageArtifacts )
+ MetadataRepository metadataRepository = session.getRepository();
+ Collection<ArtifactMetadata> artifacts =
+ metadataRepository.getArtifacts( repoId, namespace, projectId, projectVersion );
+ ExcludesFilter<String> filter = new ExcludesFilter<String>( createArtifactIdList( artifacts ) );
+ Collection<ArtifactMetadata> storageArtifacts =
+ repositoryStorage.readArtifactsMetadata( repoId, namespace, projectId, projectVersion, filter );
+ if ( storageArtifacts != null && !storageArtifacts.isEmpty() )
{
- try
+ if ( log.isDebugEnabled() )
{
- metadataRepository.updateArtifact( repoId, namespace, projectId, projectVersion, artifact );
+ log.debug( "Resolved artifacts from storage: " + storageArtifacts );
}
- catch ( MetadataRepositoryException e )
+ for ( ArtifactMetadata artifact : storageArtifacts )
{
- log.warn( "Unable to persist resolved information: " + e.getMessage(), e );
+ try
+ {
+ metadataRepository.updateArtifact( repoId, namespace, projectId, projectVersion, artifact );
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ log.warn( "Unable to persist resolved information: " + e.getMessage(), e );
+ }
}
- }
- session.markDirty();
+ session.markDirty();
- artifacts = new ArrayList<ArtifactMetadata>( artifacts );
- artifacts.addAll( storageArtifacts );
+ artifacts = new ArrayList<ArtifactMetadata>( artifacts );
+ artifacts.addAll( storageArtifacts );
+ }
+ return artifacts;
+ }
+ catch ( RepositoryStorageRuntimeException e )
+ {
+ for ( RepositoryListener listener : listeners )
+ {
+ listener.addArtifactProblem( session, repoId, namespace, projectId, projectVersion, e );
+ }
+ throw new MetadataResolutionException( e.getMessage(), e );
}
- return artifacts;
}
private Collection<String> createArtifactIdList( Collection<ArtifactMetadata> artifacts )
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java
index f31f14aaf..e115812da 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java
@@ -19,7 +19,6 @@ package org.apache.archiva.metadata.repository.storage;
* under the License.
*/
-import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
@@ -35,25 +34,25 @@ public interface RepositoryStorage
ProjectVersionMetadata readProjectVersionMetadata( String repoId, String namespace, String projectId,
String projectVersion )
throws RepositoryStorageMetadataInvalidException, RepositoryStorageMetadataNotFoundException,
- RepositoryAdminException;
+ RepositoryStorageRuntimeException;
Collection<String> listRootNamespaces( String repoId, Filter<String> filter )
- throws RepositoryAdminException;
+ throws RepositoryStorageRuntimeException;
Collection<String> listNamespaces( String repoId, String namespace, Filter<String> filter )
- throws RepositoryAdminException;
+ throws RepositoryStorageRuntimeException;
Collection<String> listProjects( String repoId, String namespace, Filter<String> filter )
- throws RepositoryAdminException;
+ throws RepositoryStorageRuntimeException;
Collection<String> listProjectVersions( String repoId, String namespace, String projectId, Filter<String> filter )
- throws RepositoryAdminException;
+ throws RepositoryStorageRuntimeException;
Collection<ArtifactMetadata> readArtifactsMetadata( String repoId, String namespace, String projectId,
String projectVersion, Filter<String> filter )
- throws RepositoryAdminException;
+ throws RepositoryStorageRuntimeException;
// FIXME: reconsider this API, do we want to expose storage format in the form of a path?
ArtifactMetadata readArtifactMetadataFromPath( String repoId, String path )
- throws RepositoryAdminException;
+ throws RepositoryStorageRuntimeException;
}
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorageRuntimeException.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorageRuntimeException.java
new file mode 100644
index 000000000..401449ba1
--- /dev/null
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorageRuntimeException.java
@@ -0,0 +1,38 @@
+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.
+ */
+
+/**
+ * @since 1.4-M3
+ * @author Olivier Lamy
+ */
+public class RepositoryStorageRuntimeException
+ extends RepositoryStorageMetadataException
+{
+ public RepositoryStorageRuntimeException( String id, String msg )
+ {
+ super( id, msg );
+ }
+
+ public RepositoryStorageRuntimeException( String id, String msg, Throwable throwable )
+ {
+ super( id, msg, throwable );
+ }
+}