From c63e2a3f776db2d2bc1aff70834e2ad905e86042 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Wed, 22 Dec 2010 08:31:56 +0000 Subject: [MRM-1327] refactor the repository API to make each concern clearer. Storage, resolver and metadata repository are separate interfaces. Rename methods on the resolver and the storage to be clearer of their intent git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1051788 13f79535-47bb-0310-9956-ffa450edef68 --- .../tree/maven2/DefaultDependencyTreeBuilder.java | 4 +- .../maven2/Maven2RepositoryMetadataResolver.java | 725 --------------------- .../storage/maven2/Maven2RepositoryStorage.java | 676 +++++++++++++++++++ .../repository/TestMetadataRepository.java | 82 ++- .../metadata/repository/TestMetadataResolver.java | 36 +- .../Maven2RepositoryMetadataResolverTest.java | 180 ++--- .../repository/file/FileMetadataRepository.java | 4 +- .../repository/jcr/JcrMetadataRepository.java | 4 +- 8 files changed, 858 insertions(+), 853 deletions(-) delete mode 100644 archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java create mode 100644 archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java (limited to 'archiva-modules/plugins') diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java index 107d616ed..54007ab35 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java @@ -425,8 +425,8 @@ public class DefaultDependencyTreeBuilder Collection projectVersions; try { - projectVersions = metadataResolver.getProjectVersions( repoId, artifact.getGroupId(), - artifact.getArtifactId() ); + projectVersions = metadataResolver.resolveProjectVersions( repoId, artifact.getGroupId(), + artifact.getArtifactId() ); } catch ( MetadataResolutionException e ) { diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java deleted file mode 100644 index 66a41c02a..000000000 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java +++ /dev/null @@ -1,725 +0,0 @@ -package org.apache.archiva.metadata.repository.storage.maven2; - -/* - * 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.checksum.ChecksumAlgorithm; -import org.apache.archiva.checksum.ChecksummedFile; -import org.apache.archiva.metadata.model.ArtifactMetadata; -import org.apache.archiva.metadata.model.ProjectMetadata; -import org.apache.archiva.metadata.model.ProjectVersionMetadata; -import org.apache.archiva.metadata.model.ProjectVersionReference; -import org.apache.archiva.metadata.repository.MetadataRepository; -import org.apache.archiva.metadata.repository.MetadataRepositoryException; -import org.apache.archiva.metadata.repository.MetadataResolutionException; -import org.apache.archiva.metadata.repository.filter.AllFilter; -import org.apache.archiva.metadata.repository.filter.Filter; -import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; -import org.apache.archiva.metadata.repository.storage.StorageMetadataResolver; -import org.apache.archiva.reports.RepositoryProblemFacet; -import org.apache.maven.archiva.common.utils.VersionUtil; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.xml.XMLException; -import org.apache.maven.model.CiManagement; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.IssueManagement; -import org.apache.maven.model.License; -import org.apache.maven.model.MailingList; -import org.apache.maven.model.Model; -import org.apache.maven.model.Organization; -import org.apache.maven.model.Scm; -import org.apache.maven.model.building.DefaultModelBuildingRequest; -import org.apache.maven.model.building.ModelBuilder; -import org.apache.maven.model.building.ModelBuildingException; -import org.apache.maven.model.building.ModelBuildingRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -/** - * @plexus.component role="org.apache.archiva.metadata.repository.storage.StorageMetadataResolver" role-hint="maven2" - */ -public class Maven2RepositoryMetadataResolver - implements StorageMetadataResolver -{ - /** - * @plexus.requirement - */ - private ModelBuilder builder; - - /** - * @plexus.requirement - */ - private ArchivaConfiguration archivaConfiguration; - - /** - * @plexus.requirement role-hint="maven2" - */ - private RepositoryPathTranslator pathTranslator; - - /** - * @plexus.requirement - */ - private MetadataRepository metadataRepository; - - private final static Logger log = LoggerFactory.getLogger( Maven2RepositoryMetadataResolver.class ); - - private static final String METADATA_FILENAME = "maven-metadata.xml"; - - private static final Filter ALL = new AllFilter(); - - private static final String PROBLEM_MISSING_POM = "missing-pom"; - - private static final String PROBLEM_INVALID_POM = "invalid-pom"; - - private static final String PROBLEM_MISLOCATED_POM = "mislocated-pom"; - - private static final List POTENTIAL_PROBLEMS = Arrays.asList( PROBLEM_INVALID_POM, PROBLEM_MISSING_POM, - PROBLEM_MISLOCATED_POM ); - - public ProjectMetadata getProject( String repoId, String namespace, String projectId ) - { - // TODO: could natively implement the "shared model" concept from the browse action to avoid needing it there? - return null; - } - - public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, - String projectVersion ) - throws MetadataResolutionException - { - // Remove problems associated with this version, since we'll be re-adding any that still exist - // TODO: an event mechanism would remove coupling to the problem reporting plugin - // TODO: this removes all problems - do we need something that just removes the problems created by this resolver? - String name = RepositoryProblemFacet.createName( namespace, projectId, projectVersion, null ); - try - { - metadataRepository.removeMetadataFacet( repoId, RepositoryProblemFacet.FACET_ID, name ); - } - catch ( MetadataRepositoryException e ) - { - log.warn( "Unable to remove repository problem facets for the version being removed: " + e.getMessage(), - e ); - } - - ManagedRepositoryConfiguration repositoryConfiguration = - archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId ); - - String artifactVersion = projectVersion; - - File basedir = new File( repositoryConfiguration.getLocation() ); - if ( VersionUtil.isSnapshot( projectVersion ) ) - { - File metadataFile = pathTranslator.toFile( basedir, namespace, projectId, projectVersion, - METADATA_FILENAME ); - try - { - MavenRepositoryMetadata metadata = MavenRepositoryMetadataReader.read( metadataFile ); - - // re-adjust to timestamp if present, otherwise retain the original -SNAPSHOT filename - MavenRepositoryMetadata.Snapshot snapshotVersion = metadata.getSnapshotVersion(); - if ( snapshotVersion != null ) - { - artifactVersion = artifactVersion.substring( 0, artifactVersion.length() - - 8 ); // remove SNAPSHOT from end - artifactVersion = - artifactVersion + snapshotVersion.getTimestamp() + "-" + snapshotVersion.getBuildNumber(); - } - } - catch ( XMLException e ) - { - // unable to parse metadata - log it, and continue with the version as the original SNAPSHOT version - log.warn( "Invalid metadata: " + metadataFile + " - " + e.getMessage() ); - } - } - - // TODO: won't work well with some other layouts, might need to convert artifact parts to ID by path translator - String id = projectId + "-" + artifactVersion + ".pom"; - File file = pathTranslator.toFile( basedir, namespace, projectId, projectVersion, id ); - - if ( !file.exists() ) - { - // TODO: an event mechanism would remove coupling to the problem reporting plugin - addProblemReport( repoId, namespace, projectId, projectVersion, PROBLEM_MISSING_POM, - "The artifact's POM file '" + file + "' was missing" ); - - // metadata could not be resolved - return null; - } - - ModelBuildingRequest req = new DefaultModelBuildingRequest(); - req.setProcessPlugins( false ); - req.setPomFile( file ); - req.setModelResolver( new RepositoryModelResolver( basedir, pathTranslator ) ); - req.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); - - Model model; - try - { - model = builder.build( req ).getEffectiveModel(); - } - catch ( ModelBuildingException e ) - { - addProblemReport( repoId, namespace, projectId, projectVersion, PROBLEM_INVALID_POM, - "The artifact's POM file '" + file + "' was invalid: " + e.getMessage() ); - - throw new MetadataResolutionException( e.getMessage() ); - } - - // Check if the POM is in the correct location - boolean correctGroupId = namespace.equals( model.getGroupId() ); - boolean correctArtifactId = projectId.equals( model.getArtifactId() ); - boolean correctVersion = projectVersion.equals( model.getVersion() ); - if ( !correctGroupId || !correctArtifactId || !correctVersion ) - { - StringBuilder message = new StringBuilder( "Incorrect POM coordinates in '" + file + "':" ); - if ( !correctGroupId ) - { - message.append( "\nIncorrect group ID: " ).append( model.getGroupId() ); - } - if ( !correctArtifactId ) - { - message.append( "\nIncorrect artifact ID: " ).append( model.getArtifactId() ); - } - if ( !correctVersion ) - { - message.append( "\nIncorrect version: " ).append( model.getVersion() ); - } - - String msg = message.toString(); - addProblemReport( repoId, namespace, projectId, projectVersion, PROBLEM_MISLOCATED_POM, msg ); - - throw new MetadataResolutionException( msg ); - } - - ProjectVersionMetadata metadata = new ProjectVersionMetadata(); - metadata.setCiManagement( convertCiManagement( model.getCiManagement() ) ); - metadata.setDescription( model.getDescription() ); - metadata.setId( projectVersion ); - metadata.setIssueManagement( convertIssueManagement( model.getIssueManagement() ) ); - metadata.setLicenses( convertLicenses( model.getLicenses() ) ); - metadata.setMailingLists( convertMailingLists( model.getMailingLists() ) ); - metadata.setDependencies( convertDependencies( model.getDependencies() ) ); - metadata.setName( model.getName() ); - metadata.setOrganization( convertOrganization( model.getOrganization() ) ); - metadata.setScm( convertScm( model.getScm() ) ); - metadata.setUrl( model.getUrl() ); - - MavenProjectFacet facet = new MavenProjectFacet(); - facet.setGroupId( model.getGroupId() != null ? model.getGroupId() : model.getParent().getGroupId() ); - facet.setArtifactId( model.getArtifactId() ); - facet.setPackaging( model.getPackaging() ); - if ( model.getParent() != null ) - { - MavenProjectParent parent = new MavenProjectParent(); - parent.setGroupId( model.getParent().getGroupId() ); - parent.setArtifactId( model.getParent().getArtifactId() ); - parent.setVersion( model.getParent().getVersion() ); - facet.setParent( parent ); - } - metadata.addFacet( facet ); - - return metadata; - } - - private void addProblemReport( String repoId, String namespace, String projectId, String projectVersion, - String problemId, String message ) - { - // TODO: an event mechanism would remove coupling to the problem reporting plugin and allow other plugins to - // generate metadata on the fly if appropriately checked for missing facets in the resolver - RepositoryProblemFacet problem = new RepositoryProblemFacet(); - problem.setProblem( problemId ); - problem.setMessage( message ); - problem.setProject( projectId ); - problem.setNamespace( namespace ); - problem.setRepositoryId( repoId ); - problem.setVersion( projectVersion ); - - try - { - metadataRepository.addMetadataFacet( repoId, problem ); - } - catch ( MetadataRepositoryException e ) - { - log.warn( "Unable to add repository problem facets for the version being removed: " + e.getMessage(), e ); - } - } - - private List convertDependencies( List dependencies ) - { - List l = - new ArrayList(); - for ( Dependency dependency : dependencies ) - { - org.apache.archiva.metadata.model.Dependency newDependency = - new org.apache.archiva.metadata.model.Dependency(); - newDependency.setArtifactId( dependency.getArtifactId() ); - newDependency.setClassifier( dependency.getClassifier() ); - newDependency.setGroupId( dependency.getGroupId() ); - newDependency.setOptional( dependency.isOptional() ); - newDependency.setScope( dependency.getScope() ); - newDependency.setSystemPath( dependency.getSystemPath() ); - newDependency.setType( dependency.getType() ); - newDependency.setVersion( dependency.getVersion() ); - l.add( newDependency ); - } - return l; - } - - private org.apache.archiva.metadata.model.Scm convertScm( Scm scm ) - { - org.apache.archiva.metadata.model.Scm newScm = null; - if ( scm != null ) - { - newScm = new org.apache.archiva.metadata.model.Scm(); - newScm.setConnection( scm.getConnection() ); - newScm.setDeveloperConnection( scm.getDeveloperConnection() ); - newScm.setUrl( scm.getUrl() ); - } - return newScm; - } - - private org.apache.archiva.metadata.model.Organization convertOrganization( Organization organization ) - { - org.apache.archiva.metadata.model.Organization org = null; - if ( organization != null ) - { - org = new org.apache.archiva.metadata.model.Organization(); - org.setName( organization.getName() ); - org.setUrl( organization.getUrl() ); - } - return org; - } - - private List convertLicenses( List licenses ) - { - List l = new ArrayList(); - for ( License license : licenses ) - { - org.apache.archiva.metadata.model.License newLicense = new org.apache.archiva.metadata.model.License(); - newLicense.setName( license.getName() ); - newLicense.setUrl( license.getUrl() ); - l.add( newLicense ); - } - return l; - } - - private List convertMailingLists( List mailingLists ) - { - List l = - new ArrayList(); - for ( MailingList mailingList : mailingLists ) - { - org.apache.archiva.metadata.model.MailingList newMailingList = - new org.apache.archiva.metadata.model.MailingList(); - newMailingList.setName( mailingList.getName() ); - newMailingList.setMainArchiveUrl( mailingList.getArchive() ); - newMailingList.setPostAddress( mailingList.getPost() ); - newMailingList.setSubscribeAddress( mailingList.getSubscribe() ); - newMailingList.setUnsubscribeAddress( mailingList.getUnsubscribe() ); - newMailingList.setOtherArchives( mailingList.getOtherArchives() ); - l.add( newMailingList ); - } - return l; - } - - private org.apache.archiva.metadata.model.IssueManagement convertIssueManagement( IssueManagement issueManagement ) - { - org.apache.archiva.metadata.model.IssueManagement im = null; - if ( issueManagement != null ) - { - im = new org.apache.archiva.metadata.model.IssueManagement(); - im.setSystem( issueManagement.getSystem() ); - im.setUrl( issueManagement.getUrl() ); - } - return im; - } - - private org.apache.archiva.metadata.model.CiManagement convertCiManagement( CiManagement ciManagement ) - { - org.apache.archiva.metadata.model.CiManagement ci = null; - if ( ciManagement != null ) - { - ci = new org.apache.archiva.metadata.model.CiManagement(); - ci.setSystem( ciManagement.getSystem() ); - ci.setUrl( ciManagement.getUrl() ); - } - return ci; - } - - public Collection getArtifactVersions( String repoId, String namespace, String projectId, - String projectVersion ) - { - // TODO: useful, but not implemented yet, not called from DefaultMetadataResolver - throw new UnsupportedOperationException(); - } - - public Collection getProjectReferences( String repoId, String namespace, String projectId, - String projectVersion ) - { - // Can't be determined on a Maven 2 repository - throw new UnsupportedOperationException(); - } - - public Collection getRootNamespaces( String repoId ) - { - return getRootNamespaces( repoId, ALL ); - } - - public Collection getRootNamespaces( String repoId, Filter filter ) - { - File dir = getRepositoryBasedir( repoId ); - - return getSortedFiles( dir, filter ); - } - - private static Collection getSortedFiles( File dir, Filter filter ) - { - List fileNames; - String[] files = dir.list( new DirectoryFilter( filter ) ); - if ( files != null ) - { - fileNames = new ArrayList( Arrays.asList( files ) ); - Collections.sort( fileNames ); - } - else - { - fileNames = Collections.emptyList(); - } - return fileNames; - } - - private File getRepositoryBasedir( String repoId ) - { - ManagedRepositoryConfiguration repositoryConfiguration = - archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId ); - - return new File( repositoryConfiguration.getLocation() ); - } - - public Collection getNamespaces( String repoId, String namespace ) - { - return getNamespaces( repoId, namespace, ALL ); - } - - public Collection getNamespaces( String repoId, String namespace, Filter filter ) - { - File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace ); - - // scan all the directories which are potential namespaces. Any directories known to be projects are excluded - List namespaces = new ArrayList(); - File[] files = dir.listFiles( new DirectoryFilter( filter ) ); - if ( files != null ) - { - for ( File file : files ) - { - if ( !isProject( file, filter ) ) - { - namespaces.add( file.getName() ); - } - } - } - Collections.sort( namespaces ); - return namespaces; - } - - public Collection getProjects( String repoId, String namespace ) - { - return getProjects( repoId, namespace, ALL ); - } - - public Collection getProjects( String repoId, String namespace, Filter filter ) - { - File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace ); - - // scan all directories in the namespace, and only include those that are known to be projects - List projects = new ArrayList(); - File[] files = dir.listFiles( new DirectoryFilter( filter ) ); - if ( files != null ) - { - for ( File file : files ) - { - if ( isProject( file, filter ) ) - { - projects.add( file.getName() ); - } - } - } - Collections.sort( projects ); - return projects; - } - - public Collection getProjectVersions( String repoId, String namespace, String projectId ) - { - return getProjectVersions( repoId, namespace, projectId, ALL ); - } - - public Collection getArtifacts( String repoId, String namespace, String projectId, - String projectVersion ) - { - return getArtifacts( repoId, namespace, projectId, projectVersion, ALL ); - } - - public Collection getProjectVersions( String repoId, String namespace, String projectId, - Filter filter ) - { - File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId ); - - // all directories in a project directory can be considered a version - return getSortedFiles( dir, filter ); - } - - public Collection getArtifacts( String repoId, String namespace, String projectId, - String projectVersion, Filter filter ) - { - File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId, projectVersion ); - - // all files that are not metadata and not a checksum / signature are considered artifacts - File[] files = dir.listFiles( new ArtifactDirectoryFilter( filter ) ); - - List artifacts = new ArrayList(); - if ( files != null ) - { - for ( File file : files ) - { - ArtifactMetadata metadata = getArtifactFromFile( repoId, namespace, projectId, projectVersion, file ); - artifacts.add( metadata ); - } - } - return artifacts; - } - - public ArtifactMetadata getArtifactForPath( String repoId, String path ) - { - ArtifactMetadata metadata = pathTranslator.getArtifactForPath( repoId, path ); - - populateArtifactMetadataFromFile( metadata, new File( getRepositoryBasedir( repoId ), path ) ); - - return metadata; - } - - private ArtifactMetadata getArtifactFromFile( String repoId, String namespace, String projectId, - String projectVersion, File file ) - { - ArtifactMetadata metadata = pathTranslator.getArtifactFromId( repoId, namespace, projectId, projectVersion, - file.getName() ); - - populateArtifactMetadataFromFile( metadata, file ); - - return metadata; - } - - private static void populateArtifactMetadataFromFile( ArtifactMetadata metadata, File file ) - { - metadata.setWhenGathered( new Date() ); - metadata.setFileLastModified( file.lastModified() ); - ChecksummedFile checksummedFile = new ChecksummedFile( file ); - try - { - metadata.setMd5( checksummedFile.calculateChecksum( ChecksumAlgorithm.MD5 ) ); - } - catch ( IOException e ) - { - log.error( "Unable to checksum file " + file + ": " + e.getMessage() ); - } - try - { - metadata.setSha1( checksummedFile.calculateChecksum( ChecksumAlgorithm.SHA1 ) ); - } - catch ( IOException e ) - { - log.error( "Unable to checksum file " + file + ": " + e.getMessage() ); - } - metadata.setSize( file.length() ); - } - - private boolean isProject( File dir, Filter filter ) - { - // scan directories for a valid project version subdirectory, meaning this must be a project directory - File[] files = dir.listFiles( new DirectoryFilter( filter ) ); - if ( files != null ) - { - for ( File file : files ) - { - if ( isProjectVersion( file ) ) - { - return true; - } - } - } - - // if a metadata file is present, check if this is the "artifactId" directory, marking it as a project - MavenRepositoryMetadata metadata = readMetadata( dir ); - if ( metadata != null && dir.getName().equals( metadata.getArtifactId() ) ) - { - return true; - } - - return false; - } - - private boolean isProjectVersion( File dir ) - { - final String artifactId = dir.getParentFile().getName(); - final String projectVersion = dir.getName(); - - // check if there is a POM artifact file to ensure it is a version directory - File[] files; - if ( VersionUtil.isSnapshot( projectVersion ) ) - { - files = dir.listFiles( new FilenameFilter() - { - public boolean accept( File dir, String name ) - { - if ( name.startsWith( artifactId + "-" ) && name.endsWith( ".pom" ) ) - { - String v = name.substring( artifactId.length() + 1, name.length() - 4 ); - v = VersionUtil.getBaseVersion( v ); - if ( v.equals( projectVersion ) ) - { - return true; - } - } - return false; - } - } ); - } - else - { - final String pomFile = artifactId + "-" + projectVersion + ".pom"; - files = dir.listFiles( new FilenameFilter() - { - public boolean accept( File dir, String name ) - { - return pomFile.equals( name ); - } - } ); - } - if ( files != null && files.length > 0 ) - { - return true; - } - - // if a metadata file is present, check if this is the "version" directory, marking it as a project version - MavenRepositoryMetadata metadata = readMetadata( dir ); - if ( metadata != null && projectVersion.equals( metadata.getVersion() ) ) - { - return true; - } - - return false; - } - - private MavenRepositoryMetadata readMetadata( File directory ) - { - MavenRepositoryMetadata metadata = null; - File metadataFile = new File( directory, METADATA_FILENAME ); - if ( metadataFile.exists() ) - { - try - { - metadata = MavenRepositoryMetadataReader.read( metadataFile ); - } - catch ( XMLException e ) - { - // ignore missing or invalid metadata - } - } - return metadata; - } - - public void setConfiguration( ArchivaConfiguration configuration ) - { - this.archivaConfiguration = configuration; - } - - private static class DirectoryFilter - implements FilenameFilter - { - private final Filter filter; - - public DirectoryFilter( Filter filter ) - { - this.filter = filter; - } - - public boolean accept( File dir, String name ) - { - if ( !filter.accept( name ) ) - { - return false; - } - else if ( name.startsWith( "." ) ) - { - return false; - } - else if ( !new File( dir, name ).isDirectory() ) - { - return false; - } - return true; - } - } - - private class ArtifactDirectoryFilter - implements FilenameFilter - { - private final Filter filter; - - public ArtifactDirectoryFilter( Filter filter ) - { - this.filter = filter; - } - - public boolean accept( File dir, String name ) - { - // TODO compare to logic in maven-repository-layer - if ( !filter.accept( name ) ) - { - return false; - } - else if ( name.startsWith( "." ) ) - { - return false; - } - else if ( name.endsWith( ".md5" ) || name.endsWith( ".sha1" ) || name.endsWith( ".asc" ) ) - { - return false; - } - else if ( name.equals( METADATA_FILENAME ) ) - { - return false; - } - else if ( new File( dir, name ).isDirectory() ) - { - return false; - } - return true; - } - } -} diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java new file mode 100644 index 000000000..1abe5a700 --- /dev/null +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java @@ -0,0 +1,676 @@ +package org.apache.archiva.metadata.repository.storage.maven2; + +/* + * 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.checksum.ChecksumAlgorithm; +import org.apache.archiva.checksum.ChecksummedFile; +import org.apache.archiva.metadata.model.ArtifactMetadata; +import org.apache.archiva.metadata.model.ProjectMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; +import org.apache.archiva.metadata.repository.MetadataRepository; +import org.apache.archiva.metadata.repository.MetadataRepositoryException; +import org.apache.archiva.metadata.repository.MetadataResolutionException; +import org.apache.archiva.metadata.repository.filter.Filter; +import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; +import org.apache.archiva.metadata.repository.storage.RepositoryStorage; +import org.apache.archiva.reports.RepositoryProblemFacet; +import org.apache.maven.archiva.common.utils.VersionUtil; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.maven.archiva.xml.XMLException; +import org.apache.maven.model.CiManagement; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.IssueManagement; +import org.apache.maven.model.License; +import org.apache.maven.model.MailingList; +import org.apache.maven.model.Model; +import org.apache.maven.model.Organization; +import org.apache.maven.model.Scm; +import org.apache.maven.model.building.DefaultModelBuildingRequest; +import org.apache.maven.model.building.ModelBuilder; +import org.apache.maven.model.building.ModelBuildingException; +import org.apache.maven.model.building.ModelBuildingRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +/** + * @plexus.component role="org.apache.archiva.metadata.repository.storage.RepositoryStorage" role-hint="maven2" + */ +public class Maven2RepositoryStorage + implements RepositoryStorage +{ + /** + * @plexus.requirement + */ + private ModelBuilder builder; + + /** + * @plexus.requirement + */ + private ArchivaConfiguration archivaConfiguration; + + /** + * @plexus.requirement role-hint="maven2" + */ + private RepositoryPathTranslator pathTranslator; + + /** + * @plexus.requirement + */ + private MetadataRepository metadataRepository; + + private final static Logger log = LoggerFactory.getLogger( Maven2RepositoryStorage.class ); + + private static final String METADATA_FILENAME = "maven-metadata.xml"; + + private static final String PROBLEM_MISSING_POM = "missing-pom"; + + private static final String PROBLEM_INVALID_POM = "invalid-pom"; + + private static final String PROBLEM_MISLOCATED_POM = "mislocated-pom"; + + private static final List POTENTIAL_PROBLEMS = Arrays.asList( PROBLEM_INVALID_POM, PROBLEM_MISSING_POM, + PROBLEM_MISLOCATED_POM ); + + public ProjectMetadata readProjectMetadata( String repoId, String namespace, String projectId ) + { + // TODO: could natively implement the "shared model" concept from the browse action to avoid needing it there? + return null; + } + + public ProjectVersionMetadata readProjectVersionMetadata( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + // Remove problems associated with this version, since we'll be re-adding any that still exist + // TODO: an event mechanism would remove coupling to the problem reporting plugin + // TODO: this removes all problems - do we need something that just removes the problems created by this resolver? + String name = RepositoryProblemFacet.createName( namespace, projectId, projectVersion, null ); + try + { + metadataRepository.removeMetadataFacet( repoId, RepositoryProblemFacet.FACET_ID, name ); + } + catch ( MetadataRepositoryException e ) + { + log.warn( "Unable to remove repository problem facets for the version being removed: " + e.getMessage(), + e ); + } + + ManagedRepositoryConfiguration repositoryConfiguration = + archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId ); + + String artifactVersion = projectVersion; + + File basedir = new File( repositoryConfiguration.getLocation() ); + if ( VersionUtil.isSnapshot( projectVersion ) ) + { + File metadataFile = pathTranslator.toFile( basedir, namespace, projectId, projectVersion, + METADATA_FILENAME ); + try + { + MavenRepositoryMetadata metadata = MavenRepositoryMetadataReader.read( metadataFile ); + + // re-adjust to timestamp if present, otherwise retain the original -SNAPSHOT filename + MavenRepositoryMetadata.Snapshot snapshotVersion = metadata.getSnapshotVersion(); + if ( snapshotVersion != null ) + { + artifactVersion = artifactVersion.substring( 0, artifactVersion.length() - + 8 ); // remove SNAPSHOT from end + artifactVersion = + artifactVersion + snapshotVersion.getTimestamp() + "-" + snapshotVersion.getBuildNumber(); + } + } + catch ( XMLException e ) + { + // unable to parse metadata - log it, and continue with the version as the original SNAPSHOT version + log.warn( "Invalid metadata: " + metadataFile + " - " + e.getMessage() ); + } + } + + // TODO: won't work well with some other layouts, might need to convert artifact parts to ID by path translator + String id = projectId + "-" + artifactVersion + ".pom"; + File file = pathTranslator.toFile( basedir, namespace, projectId, projectVersion, id ); + + if ( !file.exists() ) + { + // TODO: an event mechanism would remove coupling to the problem reporting plugin + addProblemReport( repoId, namespace, projectId, projectVersion, PROBLEM_MISSING_POM, + "The artifact's POM file '" + file + "' was missing" ); + + // metadata could not be resolved + return null; + } + + ModelBuildingRequest req = new DefaultModelBuildingRequest(); + req.setProcessPlugins( false ); + req.setPomFile( file ); + req.setModelResolver( new RepositoryModelResolver( basedir, pathTranslator ) ); + req.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL ); + + Model model; + try + { + model = builder.build( req ).getEffectiveModel(); + } + catch ( ModelBuildingException e ) + { + addProblemReport( repoId, namespace, projectId, projectVersion, PROBLEM_INVALID_POM, + "The artifact's POM file '" + file + "' was invalid: " + e.getMessage() ); + + throw new MetadataResolutionException( e.getMessage() ); + } + + // Check if the POM is in the correct location + boolean correctGroupId = namespace.equals( model.getGroupId() ); + boolean correctArtifactId = projectId.equals( model.getArtifactId() ); + boolean correctVersion = projectVersion.equals( model.getVersion() ); + if ( !correctGroupId || !correctArtifactId || !correctVersion ) + { + StringBuilder message = new StringBuilder( "Incorrect POM coordinates in '" + file + "':" ); + if ( !correctGroupId ) + { + message.append( "\nIncorrect group ID: " ).append( model.getGroupId() ); + } + if ( !correctArtifactId ) + { + message.append( "\nIncorrect artifact ID: " ).append( model.getArtifactId() ); + } + if ( !correctVersion ) + { + message.append( "\nIncorrect version: " ).append( model.getVersion() ); + } + + String msg = message.toString(); + addProblemReport( repoId, namespace, projectId, projectVersion, PROBLEM_MISLOCATED_POM, msg ); + + throw new MetadataResolutionException( msg ); + } + + ProjectVersionMetadata metadata = new ProjectVersionMetadata(); + metadata.setCiManagement( convertCiManagement( model.getCiManagement() ) ); + metadata.setDescription( model.getDescription() ); + metadata.setId( projectVersion ); + metadata.setIssueManagement( convertIssueManagement( model.getIssueManagement() ) ); + metadata.setLicenses( convertLicenses( model.getLicenses() ) ); + metadata.setMailingLists( convertMailingLists( model.getMailingLists() ) ); + metadata.setDependencies( convertDependencies( model.getDependencies() ) ); + metadata.setName( model.getName() ); + metadata.setOrganization( convertOrganization( model.getOrganization() ) ); + metadata.setScm( convertScm( model.getScm() ) ); + metadata.setUrl( model.getUrl() ); + + MavenProjectFacet facet = new MavenProjectFacet(); + facet.setGroupId( model.getGroupId() != null ? model.getGroupId() : model.getParent().getGroupId() ); + facet.setArtifactId( model.getArtifactId() ); + facet.setPackaging( model.getPackaging() ); + if ( model.getParent() != null ) + { + MavenProjectParent parent = new MavenProjectParent(); + parent.setGroupId( model.getParent().getGroupId() ); + parent.setArtifactId( model.getParent().getArtifactId() ); + parent.setVersion( model.getParent().getVersion() ); + facet.setParent( parent ); + } + metadata.addFacet( facet ); + + return metadata; + } + + private void addProblemReport( String repoId, String namespace, String projectId, String projectVersion, + String problemId, String message ) + { + // TODO: an event mechanism would remove coupling to the problem reporting plugin and allow other plugins to + // generate metadata on the fly if appropriately checked for missing facets in the resolver + RepositoryProblemFacet problem = new RepositoryProblemFacet(); + problem.setProblem( problemId ); + problem.setMessage( message ); + problem.setProject( projectId ); + problem.setNamespace( namespace ); + problem.setRepositoryId( repoId ); + problem.setVersion( projectVersion ); + + try + { + metadataRepository.addMetadataFacet( repoId, problem ); + } + catch ( MetadataRepositoryException e ) + { + log.warn( "Unable to add repository problem facets for the version being removed: " + e.getMessage(), e ); + } + } + + private List convertDependencies( List dependencies ) + { + List l = + new ArrayList(); + for ( Dependency dependency : dependencies ) + { + org.apache.archiva.metadata.model.Dependency newDependency = + new org.apache.archiva.metadata.model.Dependency(); + newDependency.setArtifactId( dependency.getArtifactId() ); + newDependency.setClassifier( dependency.getClassifier() ); + newDependency.setGroupId( dependency.getGroupId() ); + newDependency.setOptional( dependency.isOptional() ); + newDependency.setScope( dependency.getScope() ); + newDependency.setSystemPath( dependency.getSystemPath() ); + newDependency.setType( dependency.getType() ); + newDependency.setVersion( dependency.getVersion() ); + l.add( newDependency ); + } + return l; + } + + private org.apache.archiva.metadata.model.Scm convertScm( Scm scm ) + { + org.apache.archiva.metadata.model.Scm newScm = null; + if ( scm != null ) + { + newScm = new org.apache.archiva.metadata.model.Scm(); + newScm.setConnection( scm.getConnection() ); + newScm.setDeveloperConnection( scm.getDeveloperConnection() ); + newScm.setUrl( scm.getUrl() ); + } + return newScm; + } + + private org.apache.archiva.metadata.model.Organization convertOrganization( Organization organization ) + { + org.apache.archiva.metadata.model.Organization org = null; + if ( organization != null ) + { + org = new org.apache.archiva.metadata.model.Organization(); + org.setName( organization.getName() ); + org.setUrl( organization.getUrl() ); + } + return org; + } + + private List convertLicenses( List licenses ) + { + List l = new ArrayList(); + for ( License license : licenses ) + { + org.apache.archiva.metadata.model.License newLicense = new org.apache.archiva.metadata.model.License(); + newLicense.setName( license.getName() ); + newLicense.setUrl( license.getUrl() ); + l.add( newLicense ); + } + return l; + } + + private List convertMailingLists( List mailingLists ) + { + List l = + new ArrayList(); + for ( MailingList mailingList : mailingLists ) + { + org.apache.archiva.metadata.model.MailingList newMailingList = + new org.apache.archiva.metadata.model.MailingList(); + newMailingList.setName( mailingList.getName() ); + newMailingList.setMainArchiveUrl( mailingList.getArchive() ); + newMailingList.setPostAddress( mailingList.getPost() ); + newMailingList.setSubscribeAddress( mailingList.getSubscribe() ); + newMailingList.setUnsubscribeAddress( mailingList.getUnsubscribe() ); + newMailingList.setOtherArchives( mailingList.getOtherArchives() ); + l.add( newMailingList ); + } + return l; + } + + private org.apache.archiva.metadata.model.IssueManagement convertIssueManagement( IssueManagement issueManagement ) + { + org.apache.archiva.metadata.model.IssueManagement im = null; + if ( issueManagement != null ) + { + im = new org.apache.archiva.metadata.model.IssueManagement(); + im.setSystem( issueManagement.getSystem() ); + im.setUrl( issueManagement.getUrl() ); + } + return im; + } + + private org.apache.archiva.metadata.model.CiManagement convertCiManagement( CiManagement ciManagement ) + { + org.apache.archiva.metadata.model.CiManagement ci = null; + if ( ciManagement != null ) + { + ci = new org.apache.archiva.metadata.model.CiManagement(); + ci.setSystem( ciManagement.getSystem() ); + ci.setUrl( ciManagement.getUrl() ); + } + return ci; + } + + public Collection listRootNamespaces( String repoId, Filter filter ) + { + File dir = getRepositoryBasedir( repoId ); + + return getSortedFiles( dir, filter ); + } + + private static Collection getSortedFiles( File dir, Filter filter ) + { + List fileNames; + String[] files = dir.list( new DirectoryFilter( filter ) ); + if ( files != null ) + { + fileNames = new ArrayList( Arrays.asList( files ) ); + Collections.sort( fileNames ); + } + else + { + fileNames = Collections.emptyList(); + } + return fileNames; + } + + private File getRepositoryBasedir( String repoId ) + { + ManagedRepositoryConfiguration repositoryConfiguration = + archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId ); + + return new File( repositoryConfiguration.getLocation() ); + } + + public Collection listNamespaces( String repoId, String namespace, Filter filter ) + { + File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace ); + + // scan all the directories which are potential namespaces. Any directories known to be projects are excluded + List namespaces = new ArrayList(); + File[] files = dir.listFiles( new DirectoryFilter( filter ) ); + if ( files != null ) + { + for ( File file : files ) + { + if ( !isProject( file, filter ) ) + { + namespaces.add( file.getName() ); + } + } + } + Collections.sort( namespaces ); + return namespaces; + } + + public Collection listProjects( String repoId, String namespace, Filter filter ) + { + File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace ); + + // scan all directories in the namespace, and only include those that are known to be projects + List projects = new ArrayList(); + File[] files = dir.listFiles( new DirectoryFilter( filter ) ); + if ( files != null ) + { + for ( File file : files ) + { + if ( isProject( file, filter ) ) + { + projects.add( file.getName() ); + } + } + } + Collections.sort( projects ); + return projects; + } + + public Collection listProjectVersions( String repoId, String namespace, String projectId, + Filter filter ) + { + File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId ); + + // all directories in a project directory can be considered a version + return getSortedFiles( dir, filter ); + } + + public Collection readArtifactsMetadata( String repoId, String namespace, String projectId, + String projectVersion, Filter filter ) + { + File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId, projectVersion ); + + // all files that are not metadata and not a checksum / signature are considered artifacts + File[] files = dir.listFiles( new ArtifactDirectoryFilter( filter ) ); + + List artifacts = new ArrayList(); + if ( files != null ) + { + for ( File file : files ) + { + ArtifactMetadata metadata = getArtifactFromFile( repoId, namespace, projectId, projectVersion, file ); + artifacts.add( metadata ); + } + } + return artifacts; + } + + public ArtifactMetadata readArtifactMetadataFromPath( String repoId, String path ) + { + ArtifactMetadata metadata = pathTranslator.getArtifactForPath( repoId, path ); + + populateArtifactMetadataFromFile( metadata, new File( getRepositoryBasedir( repoId ), path ) ); + + return metadata; + } + + private ArtifactMetadata getArtifactFromFile( String repoId, String namespace, String projectId, + String projectVersion, File file ) + { + ArtifactMetadata metadata = pathTranslator.getArtifactFromId( repoId, namespace, projectId, projectVersion, + file.getName() ); + + populateArtifactMetadataFromFile( metadata, file ); + + return metadata; + } + + private static void populateArtifactMetadataFromFile( ArtifactMetadata metadata, File file ) + { + metadata.setWhenGathered( new Date() ); + metadata.setFileLastModified( file.lastModified() ); + ChecksummedFile checksummedFile = new ChecksummedFile( file ); + try + { + metadata.setMd5( checksummedFile.calculateChecksum( ChecksumAlgorithm.MD5 ) ); + } + catch ( IOException e ) + { + log.error( "Unable to checksum file " + file + ": " + e.getMessage() ); + } + try + { + metadata.setSha1( checksummedFile.calculateChecksum( ChecksumAlgorithm.SHA1 ) ); + } + catch ( IOException e ) + { + log.error( "Unable to checksum file " + file + ": " + e.getMessage() ); + } + metadata.setSize( file.length() ); + } + + private boolean isProject( File dir, Filter filter ) + { + // scan directories for a valid project version subdirectory, meaning this must be a project directory + File[] files = dir.listFiles( new DirectoryFilter( filter ) ); + if ( files != null ) + { + for ( File file : files ) + { + if ( isProjectVersion( file ) ) + { + return true; + } + } + } + + // if a metadata file is present, check if this is the "artifactId" directory, marking it as a project + MavenRepositoryMetadata metadata = readMetadata( dir ); + if ( metadata != null && dir.getName().equals( metadata.getArtifactId() ) ) + { + return true; + } + + return false; + } + + private boolean isProjectVersion( File dir ) + { + final String artifactId = dir.getParentFile().getName(); + final String projectVersion = dir.getName(); + + // check if there is a POM artifact file to ensure it is a version directory + File[] files; + if ( VersionUtil.isSnapshot( projectVersion ) ) + { + files = dir.listFiles( new FilenameFilter() + { + public boolean accept( File dir, String name ) + { + if ( name.startsWith( artifactId + "-" ) && name.endsWith( ".pom" ) ) + { + String v = name.substring( artifactId.length() + 1, name.length() - 4 ); + v = VersionUtil.getBaseVersion( v ); + if ( v.equals( projectVersion ) ) + { + return true; + } + } + return false; + } + } ); + } + else + { + final String pomFile = artifactId + "-" + projectVersion + ".pom"; + files = dir.listFiles( new FilenameFilter() + { + public boolean accept( File dir, String name ) + { + return pomFile.equals( name ); + } + } ); + } + if ( files != null && files.length > 0 ) + { + return true; + } + + // if a metadata file is present, check if this is the "version" directory, marking it as a project version + MavenRepositoryMetadata metadata = readMetadata( dir ); + if ( metadata != null && projectVersion.equals( metadata.getVersion() ) ) + { + return true; + } + + return false; + } + + private MavenRepositoryMetadata readMetadata( File directory ) + { + MavenRepositoryMetadata metadata = null; + File metadataFile = new File( directory, METADATA_FILENAME ); + if ( metadataFile.exists() ) + { + try + { + metadata = MavenRepositoryMetadataReader.read( metadataFile ); + } + catch ( XMLException e ) + { + // ignore missing or invalid metadata + } + } + return metadata; + } + + private static class DirectoryFilter + implements FilenameFilter + { + private final Filter filter; + + public DirectoryFilter( Filter filter ) + { + this.filter = filter; + } + + public boolean accept( File dir, String name ) + { + if ( !filter.accept( name ) ) + { + return false; + } + else if ( name.startsWith( "." ) ) + { + return false; + } + else if ( !new File( dir, name ).isDirectory() ) + { + return false; + } + return true; + } + } + + private class ArtifactDirectoryFilter + implements FilenameFilter + { + private final Filter filter; + + public ArtifactDirectoryFilter( Filter filter ) + { + this.filter = filter; + } + + public boolean accept( File dir, String name ) + { + // TODO compare to logic in maven-repository-layer + if ( !filter.accept( name ) ) + { + return false; + } + else if ( name.startsWith( "." ) ) + { + return false; + } + else if ( name.endsWith( ".md5" ) || name.endsWith( ".sha1" ) || name.endsWith( ".asc" ) ) + { + return false; + } + else if ( name.equals( METADATA_FILENAME ) ) + { + return false; + } + else if ( new File( dir, name ).isDirectory() ) + { + return false; + } + return true; + } + } +} diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java index 932152b68..9d26b53c1 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java @@ -19,6 +19,12 @@ package org.apache.archiva.metadata.repository; * under the License. */ +import org.apache.archiva.metadata.model.ArtifactMetadata; +import org.apache.archiva.metadata.model.MetadataFacet; +import org.apache.archiva.metadata.model.ProjectMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; +import org.apache.archiva.metadata.model.ProjectVersionReference; + import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -26,14 +32,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.archiva.metadata.model.ArtifactMetadata; -import org.apache.archiva.metadata.model.MetadataFacet; -import org.apache.archiva.metadata.model.ProjectMetadata; -import org.apache.archiva.metadata.model.ProjectVersionMetadata; -import org.apache.archiva.metadata.model.ProjectVersionReference; - public class TestMetadataRepository - extends TestMetadataResolver implements MetadataRepository { private Map facets = new HashMap(); @@ -49,7 +48,8 @@ public class TestMetadataRepository //To change body of implemented methods use File | Settings | File Templates. } - public void updateProjectVersion( String repoId, String namespace, String projectId, ProjectVersionMetadata versionMetadata ) + public void updateProjectVersion( String repoId, String namespace, String projectId, + ProjectVersionMetadata versionMetadata ) { //To change body of implemented methods use File | Settings | File Templates. } @@ -105,16 +105,76 @@ public class TestMetadataRepository return null; //To change body of implemented methods use File | Settings | File Templates. } - public void deleteArtifact( String repositoryId, String namespace, String project, String version, String id ) + public void removeArtifact( String repositoryId, String namespace, String project, String version, String id ) { //To change body of implemented methods use File | Settings | File Templates. } - public void deleteRepository( String repoId ) + public void removeRepository( String repoId ) { //To change body of implemented methods use File | Settings | File Templates. } - public List getArtifacts(String repositoryId){ + + public List getArtifacts( String repositoryId ) + { return null; } + + public ProjectMetadata getProject( String repoId, String namespace, String projectId ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getArtifactVersions( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getProjectReferences( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getRootNamespaces( String repoId ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getNamespaces( String repoId, String namespace ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getProjects( String repoId, String namespace ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getProjectVersions( String repoId, String namespace, String projectId ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getArtifacts( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } } \ No newline at end of file diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataResolver.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataResolver.java index bb26ecba6..8ef9d7913 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataResolver.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataResolver.java @@ -19,61 +19,49 @@ 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.ProjectMetadata; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectVersionReference; +import java.util.Collection; + public class TestMetadataResolver implements MetadataResolver { - public ProjectMetadata getProject( String repoId, String namespace, String projectId ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, - String projectVersion ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public Collection getArtifactVersions( String repoId, String namespace, String projectId, - String projectVersion ) + public ProjectVersionMetadata resolveProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection getProjectReferences( String repoId, String namespace, String projectId, - String projectVersion ) + public Collection resolveProjectReferences( String repoId, String namespace, + String projectId, String projectVersion ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection getRootNamespaces( String repoId ) + public Collection resolveRootNamespaces( String repoId ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection getNamespaces( String repoId, String namespace ) + public Collection resolveNamespaces( String repoId, String namespace ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection getProjects( String repoId, String namespace ) + public Collection resolveProjects( String repoId, String namespace ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection getProjectVersions( String repoId, String namespace, String projectId ) + public Collection resolveProjectVersions( String repoId, String namespace, String projectId ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection getArtifacts( String repoId, String namespace, String projectId, - String projectVersion ) + public Collection resolveArtifacts( String repoId, String namespace, String projectId, + String projectVersion ) { return null; //To change body of implemented methods use File | Settings | File Templates. } diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java index 5a0babea0..230cf03ba 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java @@ -27,8 +27,10 @@ import org.apache.archiva.metadata.model.MailingList; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataResolutionException; +import org.apache.archiva.metadata.repository.filter.AllFilter; import org.apache.archiva.metadata.repository.filter.ExcludesFilter; -import org.apache.archiva.metadata.repository.storage.StorageMetadataResolver; +import org.apache.archiva.metadata.repository.filter.Filter; +import org.apache.archiva.metadata.repository.storage.RepositoryStorage; import org.apache.archiva.reports.RepositoryProblemFacet; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; @@ -45,7 +47,9 @@ import java.util.List; public class Maven2RepositoryMetadataResolverTest extends PlexusInSpringTestCase { - private Maven2RepositoryMetadataResolver resolver; + private static final Filter ALL = new AllFilter(); + + private Maven2RepositoryStorage resolver; private static final String TEST_REPO_ID = "test"; @@ -74,7 +78,7 @@ public class Maven2RepositoryMetadataResolverTest c.addManagedRepository( testRepo ); configuration.save( c ); - resolver = (Maven2RepositoryMetadataResolver) lookup( StorageMetadataResolver.class, "maven2" ); + resolver = (Maven2RepositoryStorage) lookup( RepositoryStorage.class, "maven2" ); metadataRepository = (MetadataRepository) lookup( MetadataRepository.class ); metadataRepository.removeMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ); } @@ -82,8 +86,8 @@ public class Maven2RepositoryMetadataResolverTest public void testGetProjectVersionMetadata() throws Exception { - ProjectVersionMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "org.apache.archiva", - "archiva-common", "1.2.1" ); + ProjectVersionMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "org.apache.archiva", + "archiva-common", "1.2.1" ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); assertEquals( "jar", facet.getPackaging() ); assertEquals( "http://archiva.apache.org/ref/1.2.1/archiva-base/archiva-common", metadata.getUrl() ); @@ -136,8 +140,9 @@ public class Maven2RepositoryMetadataResolverTest public void testGetArtifactMetadata() throws Exception { - Collection springArtifacts = resolver.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", - "plexus-spring", "1.2" ); + Collection springArtifacts = resolver.readArtifactsMetadata( TEST_REPO_ID, + "org.codehaus.plexus", + "plexus-spring", "1.2", ALL ); List artifacts = new ArrayList( springArtifacts ); Collections.sort( artifacts, new Comparator() { @@ -177,8 +182,9 @@ public class Maven2RepositoryMetadataResolverTest public void testGetArtifactMetadataSnapshots() throws Exception { - Collection testArtifacts = resolver.getArtifacts( TEST_REPO_ID, "com.example.test", - "test-artifact", "1.0-SNAPSHOT" ); + Collection testArtifacts = resolver.readArtifactsMetadata( TEST_REPO_ID, "com.example.test", + "test-artifact", "1.0-SNAPSHOT", + ALL ); List artifacts = new ArrayList( testArtifacts ); Collections.sort( artifacts, new Comparator() { @@ -259,8 +265,8 @@ public class Maven2RepositoryMetadataResolverTest public void testGetProjectVersionMetadataForTimestampedSnapshot() throws Exception { - ProjectVersionMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "org.apache", "apache", - "5-SNAPSHOT" ); + ProjectVersionMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "org.apache", "apache", + "5-SNAPSHOT" ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); assertEquals( "pom", facet.getPackaging() ); assertEquals( "http://www.apache.org/", metadata.getUrl() ); @@ -296,24 +302,24 @@ public class Maven2RepositoryMetadataResolverTest public void testGetProjectVersionMetadataForTimestampedSnapshotMissingMetadata() throws Exception { - FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "missing-metadata", - "1.0-SNAPSHOT" ); + FacetedMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", + "missing-metadata", "1.0-SNAPSHOT" ); assertNull( metadata ); } public void testGetProjectVersionMetadataForTimestampedSnapshotMalformedMetadata() throws Exception { - FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "malformed-metadata", - "1.0-SNAPSHOT" ); + FacetedMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", + "malformed-metadata", "1.0-SNAPSHOT" ); assertNull( metadata ); } public void testGetProjectVersionMetadataForTimestampedSnapshotIncompleteMetadata() throws Exception { - FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "incomplete-metadata", - "1.0-SNAPSHOT" ); + FacetedMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", + "incomplete-metadata", "1.0-SNAPSHOT" ); assertNull( metadata ); } @@ -324,7 +330,7 @@ public class Maven2RepositoryMetadataResolverTest try { - resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "invalid-pom", "1.0" ); + resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "invalid-pom", "1.0" ); fail( "Should have received an exception due to invalid POM" ); } catch ( MetadataResolutionException e ) @@ -345,7 +351,7 @@ public class Maven2RepositoryMetadataResolverTest try { - resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "mislocated-pom", "1.0" ); + resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "mislocated-pom", "1.0" ); fail( "Should have received an exception due to mislocated POM" ); } catch ( MetadataResolutionException e ) @@ -364,7 +370,8 @@ public class Maven2RepositoryMetadataResolverTest { assertTrue( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() ); - FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "missing-pom", "1.0" ); + FacetedMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "missing-pom", + "1.0" ); assertNull( metadata ); assertFalse( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() ); @@ -377,84 +384,87 @@ public class Maven2RepositoryMetadataResolverTest public void testGetRootNamespaces() { - assertEquals( Arrays.asList( "com", "org" ), resolver.getRootNamespaces( TEST_REPO_ID ) ); + assertEquals( Arrays.asList( "com", "org" ), resolver.listRootNamespaces( TEST_REPO_ID, ALL ) ); } public void testGetNamespaces() { - assertEquals( Arrays.asList( "example" ), resolver.getNamespaces( TEST_REPO_ID, "com" ) ); - assertEquals( Arrays.asList( "test" ), resolver.getNamespaces( TEST_REPO_ID, "com.example" ) ); - assertEquals( Collections.emptyList(), resolver.getNamespaces( TEST_REPO_ID, "com.example.test" ) ); - - assertEquals( Arrays.asList( "apache", "codehaus" ), resolver.getNamespaces( TEST_REPO_ID, "org" ) ); - assertEquals( Arrays.asList( "archiva", "maven" ), resolver.getNamespaces( TEST_REPO_ID, "org.apache" ) ); - assertEquals( Collections.emptyList(), resolver.getNamespaces( TEST_REPO_ID, "org.apache.archiva" ) ); - assertEquals( Arrays.asList( "plugins", "shared" ), resolver.getNamespaces( TEST_REPO_ID, - "org.apache.maven" ) ); - assertEquals( Collections.emptyList(), resolver.getNamespaces( TEST_REPO_ID, - "org.apache.maven.plugins" ) ); - assertEquals( Collections.emptyList(), resolver.getNamespaces( TEST_REPO_ID, - "org.apache.maven.shared" ) ); - - assertEquals( Arrays.asList( "plexus" ), resolver.getNamespaces( TEST_REPO_ID, "org.codehaus" ) ); - assertEquals( Collections.emptyList(), resolver.getNamespaces( TEST_REPO_ID, "org.codehaus.plexus" ) ); + assertEquals( Arrays.asList( "example" ), resolver.listNamespaces( TEST_REPO_ID, "com", ALL ) ); + assertEquals( Arrays.asList( "test" ), resolver.listNamespaces( TEST_REPO_ID, "com.example", ALL ) ); + assertEquals( Collections.emptyList(), resolver.listNamespaces( TEST_REPO_ID, "com.example.test", + ALL ) ); + + assertEquals( Arrays.asList( "apache", "codehaus" ), resolver.listNamespaces( TEST_REPO_ID, "org", ALL ) ); + assertEquals( Arrays.asList( "archiva", "maven" ), resolver.listNamespaces( TEST_REPO_ID, "org.apache", ALL ) ); + assertEquals( Collections.emptyList(), resolver.listNamespaces( TEST_REPO_ID, "org.apache.archiva", + ALL ) ); + assertEquals( Arrays.asList( "plugins", "shared" ), resolver.listNamespaces( TEST_REPO_ID, "org.apache.maven", + ALL ) ); + assertEquals( Collections.emptyList(), resolver.listNamespaces( TEST_REPO_ID, + "org.apache.maven.plugins", ALL ) ); + assertEquals( Collections.emptyList(), resolver.listNamespaces( TEST_REPO_ID, "org.apache.maven.shared", + ALL ) ); + + assertEquals( Arrays.asList( "plexus" ), resolver.listNamespaces( TEST_REPO_ID, "org.codehaus", ALL ) ); + assertEquals( Collections.emptyList(), resolver.listNamespaces( TEST_REPO_ID, "org.codehaus.plexus", + ALL ) ); } public void testGetProjects() { - assertEquals( Collections.emptyList(), resolver.getProjects( TEST_REPO_ID, "com" ) ); - assertEquals( Collections.emptyList(), resolver.getProjects( TEST_REPO_ID, "com.example" ) ); + assertEquals( Collections.emptyList(), resolver.listProjects( TEST_REPO_ID, "com", ALL ) ); + assertEquals( Collections.emptyList(), resolver.listProjects( TEST_REPO_ID, "com.example", ALL ) ); assertEquals( Arrays.asList( "incomplete-metadata", "invalid-pom", "malformed-metadata", "mislocated-pom", - "missing-metadata", "test-artifact" ), resolver.getProjects( TEST_REPO_ID, - "com.example.test" ) ); + "missing-metadata", "test-artifact" ), resolver.listProjects( TEST_REPO_ID, + "com.example.test", + ALL ) ); - assertEquals( Collections.emptyList(), resolver.getProjects( TEST_REPO_ID, "org" ) ); - assertEquals( Arrays.asList( "apache" ), resolver.getProjects( TEST_REPO_ID, "org.apache" ) ); + assertEquals( Collections.emptyList(), resolver.listProjects( TEST_REPO_ID, "org", ALL ) ); + assertEquals( Arrays.asList( "apache" ), resolver.listProjects( TEST_REPO_ID, "org.apache", ALL ) ); assertEquals( Arrays.asList( "archiva", "archiva-base", "archiva-common", "archiva-modules", "archiva-parent" ), - resolver.getProjects( TEST_REPO_ID, "org.apache.archiva" ) ); - assertEquals( Collections.emptyList(), resolver.getProjects( TEST_REPO_ID, "org.apache.maven" ) ); - assertEquals( Collections.emptyList(), resolver.getProjects( TEST_REPO_ID, - "org.apache.maven.plugins" ) ); - assertEquals( Arrays.asList( "maven-downloader" ), resolver.getProjects( TEST_REPO_ID, - "org.apache.maven.shared" ) ); + resolver.listProjects( TEST_REPO_ID, "org.apache.archiva", ALL ) ); + assertEquals( Collections.emptyList(), resolver.listProjects( TEST_REPO_ID, "org.apache.maven", ALL ) ); + assertEquals( Collections.emptyList(), resolver.listProjects( TEST_REPO_ID, "org.apache.maven.plugins", + ALL ) ); + assertEquals( Arrays.asList( "maven-downloader" ), resolver.listProjects( TEST_REPO_ID, + "org.apache.maven.shared", ALL ) ); } public void testGetProjectVersions() { - assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", - "incomplete-metadata" ) ); - assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", - "malformed-metadata" ) ); - assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", - "missing-metadata" ) ); - assertEquals( Arrays.asList( "1.0" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", - "invalid-pom" ) ); - - assertEquals( Arrays.asList( "4", "5-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache", - "apache" ) ); - - assertEquals( Arrays.asList( "1.2.1", "1.2.2" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", - "archiva" ) ); - assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", - "archiva-base" ) ); - assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", - "archiva-common" ) ); - assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", - "archiva-modules" ) ); - assertEquals( Arrays.asList( "3" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", - "archiva-parent" ) ); - - assertEquals( Collections.emptyList(), resolver.getProjectVersions( TEST_REPO_ID, - "org.apache.maven.shared", - "maven-downloader" ) ); + assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.listProjectVersions( TEST_REPO_ID, "com.example.test", + "incomplete-metadata", ALL ) ); + assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.listProjectVersions( TEST_REPO_ID, "com.example.test", + "malformed-metadata", ALL ) ); + assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.listProjectVersions( TEST_REPO_ID, "com.example.test", + "missing-metadata", ALL ) ); + assertEquals( Arrays.asList( "1.0" ), resolver.listProjectVersions( TEST_REPO_ID, "com.example.test", + "invalid-pom", ALL ) ); + + assertEquals( Arrays.asList( "4", "5-SNAPSHOT" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache", + "apache", ALL ) ); + + assertEquals( Arrays.asList( "1.2.1", "1.2.2" ), resolver.listProjectVersions( TEST_REPO_ID, + "org.apache.archiva", "archiva", + ALL ) ); + assertEquals( Arrays.asList( "1.2.1" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache.archiva", + "archiva-base", ALL ) ); + assertEquals( Arrays.asList( "1.2.1" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache.archiva", + "archiva-common", ALL ) ); + assertEquals( Arrays.asList( "1.2.1" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache.archiva", + "archiva-modules", ALL ) ); + assertEquals( Arrays.asList( "3" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache.archiva", + "archiva-parent", ALL ) ); + + assertEquals( Collections.emptyList(), resolver.listProjectVersions( TEST_REPO_ID, + "org.apache.maven.shared", + "maven-downloader", ALL ) ); } public void testGetArtifacts() { - List artifacts = new ArrayList( resolver.getArtifacts( TEST_REPO_ID, - "org.codehaus.plexus", - "plexus-spring", - "1.2" ) ); + List artifacts = new ArrayList( resolver.readArtifactsMetadata( + TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", ALL ) ); assertEquals( 3, artifacts.size() ); Collections.sort( artifacts, new Comparator() { @@ -474,10 +484,8 @@ public class Maven2RepositoryMetadataResolverTest { ExcludesFilter filter = new ExcludesFilter( Collections.singletonList( "plexus-spring-1.2.pom" ) ); - List artifacts = new ArrayList( resolver.getArtifacts( TEST_REPO_ID, - "org.codehaus.plexus", - "plexus-spring", - "1.2", filter ) ); + List artifacts = new ArrayList( resolver.readArtifactsMetadata( + TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", filter ) ); assertEquals( 2, artifacts.size() ); Collections.sort( artifacts, new Comparator() { @@ -493,10 +501,8 @@ public class Maven2RepositoryMetadataResolverTest public void testGetArtifactsTimestampedSnapshots() { - List artifacts = new ArrayList( resolver.getArtifacts( TEST_REPO_ID, - "com.example.test", - "missing-metadata", - "1.0-SNAPSHOT" ) ); + List artifacts = new ArrayList( resolver.readArtifactsMetadata( + TEST_REPO_ID, "com.example.test", "missing-metadata", "1.0-SNAPSHOT", ALL ) ); assertEquals( 1, artifacts.size() ); ArtifactMetadata artifact = artifacts.get( 0 ); diff --git a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java index 58c0aa3c4..76cdd2c7d 100644 --- a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java +++ b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java @@ -565,7 +565,7 @@ public class FileMetadataRepository return artifacts; } - public void deleteArtifact( String repoId, String namespace, String project, String version, String id ) + public void removeArtifact( String repoId, String namespace, String project, String version, String id ) { File directory = new File( getDirectory( repoId ), namespace + "/" + project + "/" + version ); @@ -600,7 +600,7 @@ public class FileMetadataRepository } } - public void deleteRepository( String repoId ) + public void removeRepository( String repoId ) { try { diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java index cd21eeb3e..013bfbab9 100644 --- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java +++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java @@ -589,7 +589,7 @@ public class JcrMetadataRepository return artifacts; } - public void deleteArtifact( String repositoryId, String namespace, String projectId, String projectVersion, + public void removeArtifact( String repositoryId, String namespace, String projectId, String projectVersion, String id ) throws MetadataRepositoryException { @@ -608,7 +608,7 @@ public class JcrMetadataRepository } } - public void deleteRepository( String repositoryId ) + public void removeRepository( String repositoryId ) throws MetadataRepositoryException { try -- cgit v1.2.3