diff options
author | Brett Porter <brett@apache.org> | 2009-12-02 02:33:02 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2009-12-02 02:33:02 +0000 |
commit | 7a63bee6dedc4a58acbbac36ff18a6c18e500275 (patch) | |
tree | e652379eba390bb9f0695f6940747ee280a75770 /archiva-modules | |
parent | cb96e18f97711202e3c33a00aca2095a02b582a1 (diff) | |
download | archiva-7a63bee6dedc4a58acbbac36ff18a6c18e500275.tar.gz archiva-7a63bee6dedc4a58acbbac36ff18a6c18e500275.zip |
[MRM-1025] remove project model as this is all now in the metadata repository
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@886037 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
123 files changed, 40 insertions, 12416 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ProjectModelToDatabaseConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ProjectModelToDatabaseConsumer.java deleted file mode 100644 index 4bfedb39a..000000000 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ProjectModelToDatabaseConsumer.java +++ /dev/null @@ -1,353 +0,0 @@ -package org.apache.maven.archiva.consumers.database; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.common.utils.VersionUtil; -import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer; -import org.apache.maven.archiva.consumers.ConsumerException; -import org.apache.maven.archiva.database.ArchivaDAO; -import org.apache.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.ObjectNotFoundException; -import org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.ArchivaModelCloner; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.Keys; -import org.apache.maven.archiva.model.RepositoryProblem; -import org.apache.maven.archiva.reporting.artifact.CorruptArtifactReport; -import org.apache.maven.archiva.repository.ManagedRepositoryContent; -import org.apache.maven.archiva.repository.RepositoryContentFactory; -import org.apache.maven.archiva.repository.RepositoryException; -import org.apache.maven.archiva.repository.content.ManagedLegacyRepositoryContent; -import org.apache.maven.archiva.repository.project.ProjectModelReader; -import org.apache.maven.archiva.repository.project.filters.EffectiveProjectModelFilter; -import org.apache.maven.archiva.repository.project.readers.ProjectModel300Reader; -import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader; -import org.apache.maven.archiva.xml.XMLException; -import org.codehaus.plexus.cache.Cache; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * ProjectModelToDatabaseConsumer - * - * @version $Id$ - * @plexus.component role="org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer" - * role-hint="update-db-project" - * instantiation-strategy="per-lookup" - */ -public class ProjectModelToDatabaseConsumer - extends AbstractMonitoredConsumer - implements DatabaseUnprocessedArtifactConsumer -{ - private Logger log = LoggerFactory.getLogger( ProjectModelToDatabaseConsumer.class ); - - /** - * @plexus.configuration default-value="update-db-project" - */ - private String id; - - /** - * @plexus.configuration default-value="Update database with project model information." - */ - private String description; - - /** - * @plexus.requirement role-hint="jdo" - */ - private ArchivaDAO dao; - - /** - * @plexus.requirement - */ - private RepositoryContentFactory repositoryFactory; - - /** - * @plexus.requirement role="org.apache.maven.archiva.repository.project.ProjectModelFilter" - * role-hint="effective" - */ - private EffectiveProjectModelFilter effectiveModelFilter; - - private List<String> includes; - - /** - * @plexus.requirement role-hint="effective-project-cache" - */ - private Cache effectiveProjectCache; - - public ProjectModelToDatabaseConsumer() - { - includes = new ArrayList<String>(); - includes.add( "pom" ); - } - - public void beginScan() - { - /* nothing to do here */ - } - - public void completeScan() - { - /* nothing to do here */ - } - - public List<String> getIncludedTypes() - { - return includes; - } - - public void processArchivaArtifact( ArchivaArtifact artifact ) - throws ConsumerException - { - if ( !StringUtils.equals( "pom", artifact.getType() ) ) - { - // Not a pom. Skip it. - return; - } - - ArchivaProjectModel model = null; - - // remove old project model if it already exists in the database - if ( ( model = - getProjectModelFromDatabase( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ) ) != null ) - { - removeOldProjectModel( model ); - model = null; - } - - ManagedRepositoryContent repo = getRepository( artifact ); - File artifactFile = repo.toFile( artifact ); - - ProjectModelReader reader; - if ( repo instanceof ManagedLegacyRepositoryContent ) - { - reader = new ProjectModel300Reader(); - } - else - { - reader = new ProjectModel400Reader(); - } - - try - { - model = reader.read( artifactFile ); - - // The version should be updated to the artifact/filename version if it is a unique snapshot - if ( VersionUtil.isUniqueSnapshot( artifact.getVersion() ) ) - { - model.setVersion( artifact.getVersion() ); - } - - // Resolve the project model (build effective model, resolve expressions) - model = effectiveModelFilter.filter( model ); - - if ( isValidModel( model, repo, artifact ) ) - { - log.debug( "Adding project model to database - " + Keys.toKey( model ) ); - - // Clone model, since DAO while detachingCopy resets its contents - // This changes contents of the cache in EffectiveProjectModelFilter - model = ArchivaModelCloner.clone( model ); - - dao.getProjectModelDAO().saveProjectModel( model ); - } - else - { - log.warn( "Invalid or corrupt pom. Project model not added to database - " + Keys.toKey( model ) ); - } - - } - catch ( XMLException e ) - { - log.warn( "Unable to read project model " + artifactFile + " : " + e.getMessage() ); - - addProblem( artifact, "Unable to read project model " + artifactFile + " : " + e.getMessage() ); - } - catch ( ArchivaDatabaseException e ) - { - log.warn( "Unable to save project model " + artifactFile + " to the database : " + e.getMessage(), e ); - } - catch ( Throwable t ) - { - // Catch the other errors in the process to allow the rest of the process to complete. - log.error( "Unable to process model " + artifactFile + " due to : " + t.getClass().getName() + " : " + - t.getMessage(), t ); - } - } - - private ArchivaProjectModel getProjectModelFromDatabase( String groupId, String artifactId, String version ) - { - try - { - ArchivaProjectModel model = dao.getProjectModelDAO().getProjectModel( groupId, artifactId, version ); - return model; - } - catch ( ObjectNotFoundException e ) - { - return null; - } - catch ( ArchivaDatabaseException e ) - { - return null; - } - } - - private ManagedRepositoryContent getRepository( ArchivaArtifact artifact ) - throws ConsumerException - { - String repoId = artifact.getModel().getRepositoryId(); - try - { - return repositoryFactory.getManagedRepositoryContent( repoId ); - } - catch ( RepositoryException e ) - { - throw new ConsumerException( "Unable to process project model: " + e.getMessage(), e ); - } - } - - public String getDescription() - { - return description; - } - - public String getId() - { - return id; - } - - public boolean isPermanent() - { - // Tells the configuration that this consumer cannot be disabled. - return true; - } - - private boolean isValidModel( ArchivaProjectModel model, ManagedRepositoryContent repo, ArchivaArtifact artifact ) - throws ConsumerException - { - File artifactFile = repo.toFile( artifact ); - - if ( !artifact.getArtifactId().equalsIgnoreCase( model.getArtifactId() ) ) - { - StringBuffer emsg = new StringBuffer(); - emsg.append( "File " ).append( artifactFile.getName() ); - emsg.append( " has an invalid project model [" ); - appendModel( emsg, model ); - emsg.append( "]: The model artifactId [" ).append( model.getArtifactId() ); - emsg.append( "] does not match the artifactId portion of the filename: " ).append( artifact.getArtifactId() ); - - log.warn( emsg.toString() ); - addProblem( artifact, emsg.toString() ); - - return false; - } - - if ( !artifact.getVersion().equalsIgnoreCase( model.getVersion() ) && - !VersionUtil.getBaseVersion( artifact.getVersion() ).equalsIgnoreCase( model.getVersion() ) ) - { - StringBuffer emsg = new StringBuffer(); - emsg.append( "File " ).append( artifactFile.getName() ); - emsg.append( " has an invalid project model [" ); - appendModel( emsg, model ); - emsg.append( "]; The model version [" ).append( model.getVersion() ); - emsg.append( "] does not match the version portion of the filename: " ).append( artifact.getVersion() ); - - log.warn( emsg.toString() ); - addProblem( artifact, emsg.toString() ); - - return false; - } - - return true; - } - - private void appendModel( StringBuffer buf, ArchivaProjectModel model ) - { - buf.append( "groupId:" ).append( model.getGroupId() ); - buf.append( "|artifactId:" ).append( model.getArtifactId() ); - buf.append( "|version:" ).append( model.getVersion() ); - buf.append( "|packaging:" ).append( model.getPackaging() ); - } - - private void addProblem( ArchivaArtifact artifact, String msg ) - throws ConsumerException - { - ManagedRepositoryContent repo = getRepository( artifact ); - - RepositoryProblem problem = new RepositoryProblem(); - problem.setRepositoryId( artifact.getModel().getRepositoryId() ); - problem.setPath( repo.toPath( artifact ) ); - problem.setGroupId( artifact.getGroupId() ); - problem.setArtifactId( artifact.getArtifactId() ); - problem.setVersion( artifact.getVersion() ); - problem.setType( CorruptArtifactReport.PROBLEM_TYPE_CORRUPT_ARTIFACT ); - problem.setOrigin( getId() ); - problem.setMessage( msg ); - - try - { - dao.getRepositoryProblemDAO().saveRepositoryProblem( problem ); - } - catch ( ArchivaDatabaseException e ) - { - String emsg = "Unable to save problem with artifact location to DB: " + e.getMessage(); - log.warn( emsg, e ); - throw new ConsumerException( emsg, e ); - } - } - - private String toProjectKey( ArchivaProjectModel project ) - { - StringBuilder key = new StringBuilder(); - - key.append( project.getGroupId() ).append( ":" ); - key.append( project.getArtifactId() ).append( ":" ); - key.append( project.getVersion() ); - - return key.toString(); - } - - private void removeOldProjectModel( ArchivaProjectModel model ) - { - try - { - dao.getProjectModelDAO().deleteProjectModel( model ); - } - catch ( ArchivaDatabaseException ae ) - { - log.error( "Unable to delete existing project model." ); - } - - // Force removal of project model from effective cache - String projectKey = toProjectKey( model ); - synchronized ( effectiveProjectCache ) - { - if ( effectiveProjectCache.hasKey( projectKey ) ) - { - effectiveProjectCache.remove( projectKey ); - } - } - } -} diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/AbstractDatabaseCleanupTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/AbstractDatabaseCleanupTest.java deleted file mode 100644 index a549e29cc..000000000 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/AbstractDatabaseCleanupTest.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.apache.maven.archiva.consumers.database; - -/* - * 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.commons.io.FileUtils; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.Configuration; -import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.ArchivaArtifactModel; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.repository.RepositoryContentFactory; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; - -import java.io.File; - -/** - */ -public abstract class AbstractDatabaseCleanupTest - extends PlexusInSpringTestCase -{ - ArchivaConfiguration archivaConfig; - - RepositoryContentFactory repositoryFactory; - - public static final String TEST_GROUP_ID = "org.apache.maven.archiva"; - - public static final String TEST_ARTIFACT_ID = "cleanup-artifact-test"; - - public static final String TEST_VERSION = "1.0"; - - public static final String TEST_REPO_ID = "test-repo"; - - public void setUp() - throws Exception - { - super.setUp(); - - // archiva configuration (need to update the repository url) - File userFile = getTestFile( "target/test/repository-manager.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); - - userFile.getParentFile().mkdirs(); - FileUtils.copyFileToDirectory( getTestFile( "src/test/conf/repository-manager.xml" ), - userFile.getParentFile() ); - - archivaConfig = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "database-cleanup" ); - - Configuration configuration = archivaConfig.getConfiguration(); - ManagedRepositoryConfiguration repo = configuration.findManagedRepositoryById( TEST_REPO_ID ); - repo.setLocation( new File( getBasedir(), "src/test/resources/test-repo" ).toString() ); - - archivaConfig.save( configuration ); - - repositoryFactory = (RepositoryContentFactory) lookup( RepositoryContentFactory.class ); - } - - protected ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String type ) - { - ArchivaArtifactModel model = new ArchivaArtifactModel(); - model.setGroupId( groupId ); - model.setArtifactId( artifactId ); - model.setVersion( version ); - model.setType( type ); - model.setRepositoryId( TEST_REPO_ID ); - - return new ArchivaArtifact( model ); - } - - protected ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version ) - { - ArchivaProjectModel projectModel = new ArchivaProjectModel(); - projectModel.setGroupId( groupId ); - projectModel.setArtifactId( artifactId ); - projectModel.setVersion( version ); - - return projectModel; - } -} diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/ProjectModelToDatabaseConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/ProjectModelToDatabaseConsumerTest.java deleted file mode 100644 index 084c9778a..000000000 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/ProjectModelToDatabaseConsumerTest.java +++ /dev/null @@ -1,122 +0,0 @@ -package org.apache.maven.archiva.consumers.database; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; - -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.Configuration; -import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.consumers.ConsumerException; -import org.apache.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.ObjectNotFoundException; -import org.apache.maven.archiva.database.ProjectModelDAO; -import org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.ArchivaArtifactModel; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.Dependency; -import org.apache.maven.archiva.model.Keys; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; - -/** - * Test for ProjectModelToDatabaseConsumerTest - * - */ -public class ProjectModelToDatabaseConsumerTest - extends PlexusInSpringTestCase -{ - private ProjectModelToDatabaseConsumer consumer; - - private ProjectModelDAO modelDao; - - public void setUp() - throws Exception - { - super.setUp(); - - ArchivaConfiguration archivaConfig = (ArchivaConfiguration) lookup( ArchivaConfiguration.class ); - - Configuration configuration = archivaConfig.getConfiguration(); - ManagedRepositoryConfiguration repo = configuration.findManagedRepositoryById( "internal" ); - repo.setLocation( new File( getBasedir(), "src/test/resources/test-repo" ).toString() ); - - consumer = - (ProjectModelToDatabaseConsumer) lookup( DatabaseUnprocessedArtifactConsumer.class, "update-db-project" ); - modelDao = (ProjectModelDAO) lookup( ProjectModelDAO.class, "jdo" ); - } - - public void testProcess() - throws Exception - { - ArchivaProjectModel model = processAndGetModel( "test-project", "test-project-endpoint-pom", "2.4.4" ); - assertNotNull( model.getParentProject() ); - assertEquals( "test-project:test-project:2.4.4", Keys.toKey( model.getParentProject() ) ); - - assertFalse( model.getDependencyManagement().isEmpty() ); - - model = processAndGetModel( "test-project", "test-project-endpoint-ejb", "2.4.4" ); - assertNotNull( model.getParentProject() ); - assertEquals( "test-project:test-project-endpoint-pom:2.4.4", Keys.toKey( model.getParentProject() ) ); - assertTrue( hasDependency( model, "test-project:test-project-api:2.4.4" ) ); - assertTrue( hasDependency( model, "commons-id:commons-id:0.1-dev" ) ); - - model = processAndGetModel( "test-project", "test-project", "2.4.4" ); - assertFalse( model.getDependencyManagement().isEmpty() ); - } - - private boolean hasDependency( ArchivaProjectModel model, String key ) - { - for ( Dependency dependency : model.getDependencies() ) - { - if ( key.equals( Keys.toKey( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() ) ) ) - { - return true; - } - } - return false; - } - - private ArchivaProjectModel processAndGetModel( String group, String artifactId, String version ) - throws ConsumerException, ObjectNotFoundException, ArchivaDatabaseException - { - ArchivaArtifact artifact = createArtifact( group, artifactId, version, "pom" ); - consumer.processArchivaArtifact( artifact ); - - ArchivaProjectModel model = modelDao.getProjectModel( group, artifactId, version ); - assertEquals( group, model.getGroupId() ); - assertEquals( artifactId, model.getArtifactId() ); - assertEquals( version, model.getVersion() ); - return model; - } - - protected ArchivaArtifact createArtifact( String group, String artifactId, String version, String type ) - { - ArchivaArtifactModel model = new ArchivaArtifactModel(); - model.setGroupId( group ); - model.setArtifactId( artifactId ); - model.setVersion( version ); - model.setType( type ); - model.setRepositoryId( "internal" ); - - return new ArchivaArtifact( model ); - } - -} diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/ProjectModelToDatabaseConsumerTest.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/ProjectModelToDatabaseConsumerTest.xml deleted file mode 100644 index 376664603..000000000 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/test/resources/org/apache/maven/archiva/consumers/database/ProjectModelToDatabaseConsumerTest.xml +++ /dev/null @@ -1,86 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - ~ 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. ---> - -<component-set> - <components> - <!-- JdoAccess --> - <component> - <role>org.apache.maven.archiva.database.jdo.JdoAccess</role> - <role-hint>archiva</role-hint> - <implementation>org.apache.maven.archiva.database.jdo.JdoAccess</implementation> - <requirements> - <requirement> - <role>org.codehaus.plexus.jdo.JdoFactory</role> - <role-hint>archiva</role-hint> - </requirement> - </requirements> - </component> - - <!-- JDO Factory --> - <component> - <role>org.codehaus.plexus.jdo.JdoFactory</role> - <role-hint>archiva</role-hint> - <implementation>org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory</implementation> - - <configuration> - <!-- Database Configuration --> - <driverName>org.hsqldb.jdbcDriver</driverName> - <url>jdbc:hsqldb:mem:TESTDB</url> - <userName>sa</userName> - <password></password> - - <!-- JPOX and JDO configuration --> - <persistenceManagerFactoryClass>org.jpox.PersistenceManagerFactoryImpl</persistenceManagerFactoryClass> - <otherProperties> - <property> - <name>javax.jdo.PersistenceManagerFactoryClass</name> - <value>org.jpox.PersistenceManagerFactoryImpl</value> - </property> - <property> - <name>org.jpox.autoCreateSchema</name> - <value>true</value> - </property> - </otherProperties> - </configuration> - </component> - - <component> - <role>org.codehaus.plexus.cache.Cache</role> - <role-hint>effective-project-cache</role-hint> - <implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation> - <description>Effective Project Cache</description> - <configuration> - <disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds> - <disk-persistent>true</disk-persistent> - <disk-store-path>${java.io.tmpdir}/archiva/effectiveproject</disk-store-path> - <eternal>true</eternal> - <max-elements-in-memory>1000</max-elements-in-memory> - <memory-eviction-policy>LRU</memory-eviction-policy> - <name>effective-project-cache</name> - <overflow-to-disk>false</overflow-to-disk> - <!-- TODO: Adjust the time to live to be more sane (ie: huge 4+ hours) --> - <!-- 45 minutes = 2700 seconds --> - <time-to-idle-seconds>2700</time-to-idle-seconds> - <!-- 30 minutes = 1800 seconds --> - <time-to-live-seconds>1800</time-to-live-seconds> - </configuration> - </component> - </components> -</component-set> diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractArtifactKey.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractArtifactKey.java index bf9d95ac4..cf6017b1a 100644 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractArtifactKey.java +++ b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractArtifactKey.java @@ -19,10 +19,10 @@ package org.apache.maven.archiva.model; * under the License. */ -import org.apache.commons.lang.StringUtils; - import java.io.Serializable; +import org.apache.commons.lang.StringUtils; + /** * <p> * AbstractArtifactKey - a artifact reference to a versioned project. @@ -44,14 +44,6 @@ import java.io.Serializable; * <th>Type</th> * </tr> * <tr> - * <td>{@link AbstractProjectKey}</td> - * <td align="center">Yes</td> - * <td align="center">Yes</td> - * <td> </td> - * <td> </td> - * <td> </td> - * </tr> - * <tr> * <td>{@link AbstractVersionedKey}</td> * <td align="center">Yes</td> * <td align="center">Yes</td> diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractProjectKey.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractProjectKey.java deleted file mode 100644 index 445c21e99..000000000 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractProjectKey.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.apache.maven.archiva.model; - -/* - * 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.commons.lang.StringUtils; - -import java.io.Serializable; - -/** - * <p> - * AbstractProjectKey - A versionless reference to a Project. - * This refers to all versions, and all artifacts of a project. - * This type of reference is typically used by {@link ArchivaRepositoryMetadata} objects. - * </p> - * - * <p> - * If you require things like "Version" or "Type", consider the other keys below. - * </p> - * - * <table border="1" cellpadding="3"> - * <tr> - * <th>Key Type</th> - * <th>Group ID</th> - * <th>Artifact ID</th> - * <th>Version</th> - * <th>Classifier</th> - * <th>Type</th> - * </tr> - * <tr> - * <td>{@link AbstractProjectKey}</td> - * <td align="center">Yes</td> - * <td align="center">Yes</td> - * <td> </td> - * <td> </td> - * <td> </td> - * </tr> - * <tr> - * <td>{@link AbstractVersionedKey}</td> - * <td align="center">Yes</td> - * <td align="center">Yes</td> - * <td align="center">Yes</td> - * <td> </td> - * <td> </td> - * </tr> - * <tr> - * <td>{@link AbstractArtifactKey}</td> - * <td align="center">Yes</td> - * <td align="center">Yes</td> - * <td align="center">Yes</td> - * <td align="center">Yes</td> - * <td align="center">Yes</td> - * </tr> - * </table> - * - * <p> - * NOTE: This is a jpox required compound key handler class. - * </p> - * - * @version $Id$ - */ -public class AbstractProjectKey - implements CompoundKey, Serializable -{ - private static final long serialVersionUID = 4949927971768396064L; - - /** - * The Group ID. (JPOX Requires this remain public) - */ - public String groupId = ""; - - /** - * The Artifact ID. (JPOX Requires this remain public) - */ - public String artifactId = ""; - - /** - * Default Constructor. Required by JPOX. - */ - public AbstractProjectKey() - { - /* do nothing */ - } - - /** - * Key Based Constructor. Required by JPOX. - * - * @param key the String representing this object's values. - */ - public AbstractProjectKey( String key ) - { - String parts[] = StringUtils.splitPreserveAllTokens( key, ":" ); - groupId = parts[0]; - artifactId = parts[1]; - } - - /** - * Get the String representation of this object. - Required by JPOX. - */ - @Override - public String toString() - { - return StringUtils.join( new String[] { groupId, artifactId } ); - } - - /** - * Get the hashcode for this object's values - Required by JPOX. - */ - @Override - public int hashCode() - { - final int PRIME = 31; - int result = super.hashCode(); - result = PRIME * result + ( ( groupId == null ) ? 0 : groupId.hashCode() ); - result = PRIME * result + ( ( artifactId == null ) ? 0 : artifactId.hashCode() ); - return result; - } - - /** - * Get the equals for this object's values - Required by JPOX. - */ - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - { - return true; - } - - if ( !super.equals( obj ) ) - { - return false; - } - - if ( getClass() != obj.getClass() ) - { - return false; - } - - final AbstractProjectKey other = (AbstractProjectKey) obj; - - if ( groupId == null ) - { - if ( other.groupId != null ) - { - return false; - } - } - else if ( !groupId.equals( other.groupId ) ) - { - return false; - } - - if ( artifactId == null ) - { - if ( other.artifactId != null ) - { - return false; - } - } - else if ( !artifactId.equals( other.artifactId ) ) - { - return false; - } - - return true; - } -} diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractVersionedKey.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractVersionedKey.java index 14f1db386..115385394 100644 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractVersionedKey.java +++ b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/AbstractVersionedKey.java @@ -19,10 +19,10 @@ package org.apache.maven.archiva.model; * under the License. */ -import org.apache.commons.lang.StringUtils; - import java.io.Serializable; +import org.apache.commons.lang.StringUtils; + /** * <p> * AbstractVersionedKey - a versioned reference to a Project. @@ -44,14 +44,6 @@ import java.io.Serializable; * <th>Type</th> * </tr> * <tr> - * <td>{@link AbstractProjectKey}</td> - * <td align="center">Yes</td> - * <td align="center">Yes</td> - * <td> </td> - * <td> </td> - * <td> </td> - * </tr> - * <tr> * <td>{@link AbstractVersionedKey}</td> * <td align="center">Yes</td> * <td align="center">Yes</td> diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/ArchivaModelCloner.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/ArchivaModelCloner.java index 66af52d93..cffabc277 100644 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/ArchivaModelCloner.java +++ b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/ArchivaModelCloner.java @@ -21,7 +21,6 @@ package org.apache.maven.archiva.model; import java.util.ArrayList; import java.util.Enumeration; -import java.util.Iterator; import java.util.List; import java.util.Properties; @@ -32,43 +31,6 @@ import java.util.Properties; */ public class ArchivaModelCloner { - public static ArchivaProjectModel clone( ArchivaProjectModel model ) - { - if ( model == null ) - { - return null; - } - - ArchivaProjectModel cloned = new ArchivaProjectModel(); - - cloned.setGroupId( model.getGroupId() ); - cloned.setArtifactId( model.getArtifactId() ); - cloned.setVersion( model.getVersion() ); - - cloned.setParentProject( clone( model.getParentProject() ) ); - - cloned.setName( model.getName() ); - cloned.setDescription( model.getDescription() ); - cloned.setUrl( model.getUrl() ); - cloned.setPackaging( model.getPackaging() ); - cloned.setOrigin( model.getOrigin() ); - - cloned.setMailingLists( cloneMailingLists( model.getMailingLists() ) ); - cloned.setCiManagement( clone( model.getCiManagement() ) ); - cloned.setIndividuals( cloneIndividuals( model.getIndividuals() ) ); - cloned.setIssueManagement( clone( model.getIssueManagement() ) ); - cloned.setLicenses( cloneLicenses( model.getLicenses() ) ); - cloned.setOrganization( clone( model.getOrganization() ) ); - cloned.setScm( clone( model.getScm() ) ); - cloned.setRepositories( cloneRepositories( model.getRepositories() ) ); - cloned.setDependencies( cloneDependencies( model.getDependencies() ) ); - cloned.setPlugins( clonePlugins( model.getPlugins() ) ); - cloned.setReports( cloneReports( model.getReports() ) ); - cloned.setDependencyManagement( cloneDependencies( model.getDependencyManagement() ) ); - cloned.setProperties( clone(model.getProperties() ) ); - - return cloned; - } public static ArtifactReference clone( ArtifactReference artifactReference ) { @@ -88,101 +50,6 @@ public class ArchivaModelCloner return cloned; } - public static CiManagement clone( CiManagement ciManagement ) - { - if ( ciManagement == null ) - { - return null; - } - - CiManagement cloned = new CiManagement(); - - cloned.setSystem( ciManagement.getSystem() ); - cloned.setUrl( ciManagement.getUrl() ); - cloned.setCiUrl( ciManagement.getCiUrl() ); - - return cloned; - } - - public static Dependency clone( Dependency dependency ) - { - if ( dependency == null ) - { - return null; - } - - Dependency cloned = new Dependency(); - - // Identification - cloned.setGroupId( dependency.getGroupId() ); - cloned.setArtifactId( dependency.getArtifactId() ); - cloned.setVersion( dependency.getVersion() ); - cloned.setClassifier( dependency.getClassifier() ); - cloned.setType( dependency.getType() ); - - // The rest. - cloned.setTransitive( dependency.isTransitive() ); - cloned.setScope( dependency.getScope() ); - cloned.setOptional( dependency.isOptional() ); - cloned.setSystemPath( dependency.getSystemPath() ); - cloned.setUrl( dependency.getUrl() ); - cloned.setExclusions( cloneExclusions( dependency.getExclusions() ) ); - - return cloned; - } - - public static IssueManagement clone( IssueManagement issueManagement ) - { - if ( issueManagement == null ) - { - return null; - } - - IssueManagement cloned = new IssueManagement(); - - cloned.setIssueManagementUrl( issueManagement.getIssueManagementUrl() ); - cloned.setSystem( issueManagement.getSystem() ); - cloned.setUrl( issueManagement.getUrl() ); - - return cloned; - } - - public static MailingList clone( MailingList mailingList ) - { - if ( mailingList == null ) - { - return null; - } - - MailingList cloned = new MailingList(); - - cloned.setName( mailingList.getName() ); - cloned.setSubscribeAddress( mailingList.getSubscribeAddress() ); - cloned.setUnsubscribeAddress( mailingList.getUnsubscribeAddress() ); - cloned.setPostAddress( mailingList.getPostAddress() ); - cloned.setMainArchiveUrl( mailingList.getMainArchiveUrl() ); - cloned.setOtherArchives( cloneSimpleStringList( mailingList.getOtherArchives() ) ); - - return cloned; - } - - public static Organization clone( Organization organization ) - { - if ( organization == null ) - { - return null; - } - - Organization cloned = new Organization(); - - cloned.setFavicon( organization.getFavicon() ); - cloned.setName( organization.getName() ); - cloned.setUrl( organization.getUrl() ); - cloned.setOrganizationName( organization.getOrganizationName() ); - - return cloned; - } - @SuppressWarnings("unchecked") public static Properties clone( Properties properties ) { @@ -204,22 +71,6 @@ public class ArchivaModelCloner return cloned; } - public static Scm clone( Scm scm ) - { - if ( scm == null ) - { - return null; - } - - Scm cloned = new Scm(); - - cloned.setConnection( scm.getConnection() ); - cloned.setDeveloperConnection( scm.getDeveloperConnection() ); - cloned.setUrl( scm.getUrl() ); - - return cloned; - } - public static SnapshotVersion clone( SnapshotVersion snapshotVersion ) { if ( snapshotVersion == null ) @@ -268,174 +119,6 @@ public class ArchivaModelCloner return ret; } - public static List<Dependency> cloneDependencies( List<Dependency> dependencies ) - { - if ( dependencies == null ) - { - return null; - } - - List<Dependency> ret = new ArrayList<Dependency>(); - - for ( Dependency dep : dependencies ) - { - if ( dep == null ) - { - // Skip null dependency. - continue; - } - - ret.add( clone( dep ) ); - } - - return ret; - } - - public static List<Exclusion> cloneExclusions( List<Exclusion> exclusions ) - { - if ( exclusions == null ) - { - return null; - } - - List<Exclusion> ret = new ArrayList<Exclusion>(); - - for ( Exclusion exclusion : exclusions ) - { - Exclusion cloned = new Exclusion(); - - cloned.setGroupId( exclusion.getGroupId() ); - cloned.setArtifactId( exclusion.getArtifactId() ); - - ret.add( cloned ); - } - - return ret; - } - - public static List<Individual> cloneIndividuals( List<Individual> individuals ) - { - if ( individuals == null ) - { - return individuals; - } - - List<Individual> ret = new ArrayList<Individual>(); - - Iterator<Individual> it = individuals.iterator(); - while ( it.hasNext() ) - { - Individual individual = it.next(); - Individual cloned = new Individual(); - - cloned.setPrincipal( individual.getPrincipal() ); - - cloned.setEmail( individual.getEmail() ); - cloned.setName( individual.getName() ); - cloned.setOrganization( individual.getOrganization() ); - cloned.setOrganizationUrl( individual.getOrganizationUrl() ); - cloned.setUrl( individual.getUrl() ); - cloned.setTimezone( individual.getTimezone() ); - cloned.setIndividualEmail( individual.getIndividualEmail() ); - - cloned.setRoles( cloneRoles( individual.getRoles() ) ); - cloned.setProperties( clone( individual.getProperties() ) ); - - ret.add( cloned ); - } - - return ret; - } - - public static List<License> cloneLicenses( List<License> licenses ) - { - if ( licenses == null ) - { - return null; - } - - List<License> ret = new ArrayList<License>(); - - for ( License license : licenses ) - { - License cloned = new License(); - - cloned.setId( license.getId() ); - cloned.setName( license.getName() ); - cloned.setUrl( license.getUrl() ); - cloned.setComments( license.getComments() ); - - ret.add( cloned ); - } - - return ret; - } - - public static List<MailingList> cloneMailingLists( List<MailingList> mailingLists ) - { - if ( mailingLists == null ) - { - return null; - } - - List<MailingList> ret = new ArrayList<MailingList>(); - - for ( MailingList mailingList : mailingLists ) - { - if ( mailingList == null ) - { - // Skip null mailing list. - continue; - } - - ret.add( clone( mailingList ) ); - } - - return ret; - } - - public static List<ArtifactReference> clonePlugins( List<ArtifactReference> plugins ) - { - return cloneArtifactReferences( plugins ); - } - - public static List<ArtifactReference> cloneReports( List<ArtifactReference> reports ) - { - return cloneArtifactReferences( reports ); - } - - public static List<ProjectRepository> cloneRepositories( List<ProjectRepository> repositories ) - { - if ( repositories == null ) - { - return null; - } - - List<ProjectRepository> ret = new ArrayList<ProjectRepository>(); - - for ( ProjectRepository repository : repositories ) - { - ProjectRepository cloned = new ProjectRepository(); - - cloned.setId( repository.getId() ); - cloned.setName( repository.getName() ); - cloned.setUrl( repository.getUrl() ); - cloned.setLayout( repository.getLayout() ); - cloned.setPlugins( repository.isPlugins() ); - cloned.setReleases( repository.isReleases() ); - cloned.setSnapshots( repository.isSnapshots() ); - - ret.add( cloned ); - } - - return ret; - } - - public static List<String> cloneRoles( List<String> roles ) - { - return cloneSimpleStringList( roles ); - } - private static List<String> cloneSimpleStringList( List<String> simple ) { if ( simple == null ) diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/DependencyScope.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/DependencyScope.java deleted file mode 100644 index 4881499e6..000000000 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/DependencyScope.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.apache.maven.archiva.model; - -/* - * 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.commons.collections.map.MultiValueMap; -import org.apache.commons.lang.StringUtils; - -/** - * DependencyScope - utility methods and constants for working with scopes. - * - * @version $Id$ - */ -public class DependencyScope -{ - public static final String SYSTEM = "system"; - - public static final String COMPILE = "compile"; - - public static final String PROVIDED = "provided"; - - public static final String RUNTIME = "runtime"; - - public static final String TEST = "test"; - - private static final MultiValueMap scopeMap; - - static - { - // Store the map of scopes to what other scopes are 'within' that scope. - scopeMap = new MultiValueMap(); - - scopeMap.put( COMPILE, COMPILE ); - scopeMap.put( COMPILE, RUNTIME ); - scopeMap.put( COMPILE, PROVIDED ); - scopeMap.put( COMPILE, SYSTEM ); - - scopeMap.put( TEST, COMPILE ); - scopeMap.put( TEST, RUNTIME ); - scopeMap.put( TEST, PROVIDED ); - scopeMap.put( TEST, SYSTEM ); - scopeMap.put( TEST, TEST ); - - scopeMap.put( RUNTIME, RUNTIME ); - scopeMap.put( RUNTIME, PROVIDED ); - scopeMap.put( RUNTIME, SYSTEM ); - - scopeMap.put( PROVIDED, RUNTIME ); - scopeMap.put( PROVIDED, PROVIDED ); - scopeMap.put( PROVIDED, SYSTEM ); - - scopeMap.put( SYSTEM, SYSTEM ); - } - - public static boolean isSystemScoped( Dependency dep ) - { - return StringUtils.equals( SYSTEM, dep.getScope() ); - } - - /** - * Test the provided scope against the desired scope to see if it is - * within that scope's pervue. - * - * Examples: - * actual:compile, desired:test = true - * actual:compile, desired:compile = true - * actual:test, desired:compile = false - * actual:provided, desired:compile = false - * - * @param actualScope - * @param desiredScope - * @return - */ - public static boolean isWithinScope( String actualScope, String desiredScope ) - { - if ( StringUtils.isBlank( desiredScope ) ) - { - // nothing desired? everything should fail. - return false; - } - - String scope = StringUtils.defaultIfEmpty( actualScope, COMPILE ); - - return scopeMap.containsValue( desiredScope, scope ); - } -} diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/Keys.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/Keys.java index 365d6d718..0cfcebfd9 100644 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/Keys.java +++ b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/Keys.java @@ -28,11 +28,6 @@ import org.apache.commons.lang.StringUtils; */ public class Keys { - public static String toKey( ArchivaProjectModel model ) - { - return toKey( model.getGroupId(), model.getArtifactId(), model.getVersion() ); - } - public static String toKey( String groupId, String artifactId, String version, String classifier, String type ) { StringBuffer key = new StringBuffer(); diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/functors/UnprocessedArtifactPredicate.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/functors/UnprocessedArtifactPredicate.java deleted file mode 100644 index 2a9e33f9a..000000000 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/functors/UnprocessedArtifactPredicate.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.apache.maven.archiva.model.functors; - -/* - * 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.commons.collections.Predicate; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.ArchivaArtifactModel; - -/** - * Allows for selection of unprocessed artifacts. - * - * @version $Id$ - */ -public class UnprocessedArtifactPredicate - implements Predicate -{ - private static UnprocessedArtifactPredicate INSTANCE = new UnprocessedArtifactPredicate(); - - public static UnprocessedArtifactPredicate getInstance() - { - return INSTANCE; - } - - public boolean evaluate( Object object ) - { - boolean satisfies = false; - - if ( object instanceof ArchivaArtifact ) - { - ArchivaArtifact artifact = (ArchivaArtifact) object; - satisfies = !artifact.getModel().isProcessed(); - } - else if ( object instanceof ArchivaArtifactModel ) - { - ArchivaArtifactModel model = (ArchivaArtifactModel) object; - satisfies = !model.isProcessed(); - } - - return satisfies; - } -} diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/jpox/ArchivaProjectModelKey.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/jpox/ArchivaProjectModelKey.java deleted file mode 100644 index 9f3535ead..000000000 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/jpox/ArchivaProjectModelKey.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.maven.archiva.model.jpox; - -/* - * 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.maven.archiva.model.AbstractVersionedKey; - -import java.io.Serializable; - -/** - * ArchivaProjectModelKey - unique classid-key for JPOX. - * - * @version $Id$ - */ -public class ArchivaProjectModelKey - extends AbstractVersionedKey - implements Serializable -{ - private static final long serialVersionUID = 7789859208617327581L; - - public ArchivaProjectModelKey() - { - } - - public ArchivaProjectModelKey( String key ) - { - super( key ); - } - -} diff --git a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/jpox/ProjectReferenceKey.java b/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/jpox/ProjectReferenceKey.java deleted file mode 100644 index 1036c781b..000000000 --- a/archiva-modules/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/jpox/ProjectReferenceKey.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.maven.archiva.model.jpox; - -/* - * 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.maven.archiva.model.AbstractProjectKey; - -import java.io.Serializable; - -/** - * ProjectReferenceKey - unique classid-key for JPOX. - * - * @version $Id$ - */ -public class ProjectReferenceKey - extends AbstractProjectKey - implements Serializable -{ - private static final long serialVersionUID = 7803774484166902823L; - - public ProjectReferenceKey() - { - super(); - } - - public ProjectReferenceKey( String key ) - { - super( key ); - } -} diff --git a/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml b/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml index de08a8d7b..0c9a400f0 100644 --- a/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml +++ b/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml @@ -25,16 +25,6 @@ This object is not serialized to the Database. </description> <fields> - <!-- Note: these are only managed repositories. This should be reviewed as to whether they are still needed - <field> - <name>repositories</name> - <version>1.0.0+</version> - <association> - <type>ArchivaRepositoryModel</type> - <multiplicity>*</multiplicity> - </association> - </field> - --> <field> <name>artifacts</name> <version>1.0.0+</version> @@ -52,14 +42,6 @@ </association> </field> <field> - <name>projects</name> - <version>1.0.0+</version> - <association> - <type>ArchivaProjectModel</type> - <multiplicity>*</multiplicity> - </association> - </field> - <field> <name>repositoryProblems</name> <version>1.0.0+</version> <association> @@ -87,127 +69,6 @@ </class> <!-- _______________________________________________________________ - ____ _ _ - | _ \ ___ _ __ ___ ___(_) |_ ___ _ __ _ _ - | |_) / _ \ '_ \ / _ \/ __| | __/ _ \| '__| | | | - | _ < __/ |_) | (_) \__ \ | || (_) | | | |_| | - |_| \_\___| .__/ \___/|___/_|\__\___/|_| \__, | - |_| |___/ - --> - <!-- - <class stash.storable="true" - jpox.table="REPOSITORIES"> - <name>ArchivaRepositoryModel</name> - <version>1.0.0+</version> - <fields> - <field stash.maxSize="50" - jpox.primary-key="true" - jpox.value-strategy="off"> - <name>id</name> - <identifier>true</identifier> - <version>1.0.0+</version> - <type>String</type> - <required>true</required> - <description> - The unique ID for the repository. - </description> - </field> - <field stash.maxSize="250"> - <name>name</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <type>String</type> - <required>true</required> - <description> - The Name of the repository. - </description> - </field> - <field stash.maxSize="250"> - <name>url</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <type>String</type> - <required>true</required> - <description> - The URL of the repository. - </description> - </field> - <field stash.maxSize="250"> - <name>repositoryUsername</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <type>String</type> - <description> - The Username of the repository. - </description> - </field> - <field stash.maxSize="250"> - <name>repositoryPassword</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <type>String</type> - <description> - The Password of the repository. - </description> - </field> - <field stash.maxSize="20"> - <name>creationSource</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <type>String</type> - <required>true</required> - <description> - The Source of this repository. - (Example: Configuration, POM) - </description> - </field> - <field stash.maxSize="16"> - <name>layoutName</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <type>String</type> - <required>true</required> - <description> - The layout of the repository. - (Either 'default', or 'legacy') - </description> - <defaultValue>default</defaultValue> - </field> - <field> - <name>releasePolicy</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <type>boolean</type> - <required>true</required> - <description> - The releases policy of the repository. - </description> - <defaultValue>true</defaultValue> - </field> - <field> - <name>snapshotPolicy</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <type>boolean</type> - <required>true</required> - <description> - The snapshot policy of the repository. - </description> - <defaultValue>false</defaultValue> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - private static final long serialVersionUID = 6823195399928260795L; - ]]></code> - </codeSegment> - </codeSegments> - </class> - --> - - <!-- _______________________________________________________________ _ _ _ __ _ / \ _ __| |_(_)/ _| __ _ ___| |_ / _ \ | '__| __| | |_ / _` |/ __| __| @@ -1059,1015 +920,6 @@ </class> <!-- _______________________________________________________________ - __ __ ____ _ _ - | \/ | __ ___ _____ _ __ | _ \ _ __ ___ (_) ___ ___| |_ - | |\/| |/ _` \ \ / / _ \ '_ \ | |_) | '__/ _ \| |/ _ \/ __| __| - | | | | (_| |\ V / __/ | | | | __/| | | (_) | | __/ (__| |_ - |_| |_|\__,_| \_/ \___|_| |_| |_| |_| \___// |\___|\___|\__| - |__/ - --> - - <class stash.storable="true" - jpox.table="PROJECT" - jpox.use-identifiers-as-primary-key="false" - jpox.identity-type="application" - jpox.identity-class="org.apache.maven.archiva.model.jpox.ArchivaProjectModelKey"> - <name>ArchivaProjectModel</name> - <version>1.0.0+</version> - <fields> - <field stash.maxSize="250" - jpox.primary-key="true" - jpox.value-strategy="off" - jpox.persistence-modifier="persistent"> - <name>groupId</name> - <identifier>true</identifier> - <version>1.0.0+</version> - <type>String</type> - <required>true</required> - <description> - The Group ID of the repository content. - </description> - </field> - <field stash.maxSize="80" - jpox.primary-key="true" - jpox.value-strategy="off" - jpox.persistence-modifier="persistent"> - <name>artifactId</name> - <identifier>true</identifier> - <version>1.0.0+</version> - <type>String</type> - <required>true</required> - <description> - The Artifact ID of the repository content. - </description> - </field> - <field stash.maxSize="50" - jpox.primary-key="true" - jpox.value-strategy="off" - jpox.persistence-modifier="persistent"> - <name>version</name> - <identifier>true</identifier> - <version>1.0.0+</version> - <type>String</type> - <required>true</required> - <description> - The version of the repository content. - </description> - </field> - <field> - <name>parentProject</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <required>false</required> - <association stash.part="true" - jpox.join="false"> - <type>VersionedReference</type> - <multiplicity>1</multiplicity> - </association> - <description> - The content key for a parent reference. - </description> - </field> - <field> - <name>packaging</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <required>true</required> - <type>String</type> - <description> - The declared packaging for this project model. - </description> - </field> - <field> - <name>name</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <required>false</required> - <type>String</type> - <description> - The name of this project. - </description> - </field> - <field stash.maxSize="8192"> - <name>description</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <required>false</required> - <type>String</type> - <description> - The description of this project. - </description> - </field> - <field> - <name>origin</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <required>true</required> - <type>String</type> - <description> - The Origin of this Model. (Filesystem, Proxy, or Deploy) - </description> - </field> - <field> - <name>whenIndexed</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <required>false</required> - <type>Date</type> - <description> - The timestamp when this model was indexed. - </description> - </field> - <field stash.maxSize="1020"> - <name>url</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <required>false</required> - <type>String</type> - <description> - The URL for the project's homepage. - </description> - </field> - <field> - <name>organization</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <required>false</required> - <association stash.part="true" - jpox.join="false"> - <type>Organization</type> - </association> - </field> - <field> - <name>licenses</name> - <identifier>false</identifier> - <version>1.0.0+</version> - <required>false</required> - <association stash.part="true" - jpox.join="false"> - <type>License</type> - <multiplicity>*</multiplicity> - </association> - </field> - <field> - <name>mailingLists</name> - <version>1.0.0+</version> - <description>The mailing lists.</description> - <required>false</required> - <association stash.part="true" - jpox.join="false"> - <type>MailingList</type> - <multiplicity>*</multiplicity> - </association> - </field> - <field> - <name>issueManagement</name> - <version>1.0.0+</version> - <description><![CDATA[The project's issue management system information.]]></description> - <association stash.part="true" - jpox.join="false"> - <type>IssueManagement</type> - </association> - </field> - <field> - <name>ciManagement</name> - <version>1.0.0+</version> - <description><![CDATA[The project's continuous integration information.]]></description> - <association stash.part="true" - jpox.join="false"> - <type>CiManagement</type> - </association> - </field> - <field> - <name>scm</name> - <version>1.0.0+</version> - <description> - <![CDATA[Specification for the SCM used by the project, such as CVS, Subversion, etc.]]></description> - <association stash.part="true" - jpox.join="false"> - <type>Scm</type> - </association> - </field> - <field> - <name>individuals</name> - <version>1.0.0+</version> - <description> - The list of individuals around this project. - </description> - <association stash.part="true" - jpox.join="false"> - <type>Individual</type> - <multiplicity>*</multiplicity> - </association> - </field> - <field> - <name>dependencies</name> - <version>1.0.0+</version> - <description><![CDATA[ - This element describes all of the dependencies associated with a - project. - ]]></description> - <association stash.part="true" - jpox.join="false"> - <type>Dependency</type> - <multiplicity>*</multiplicity> - </association> - </field> - <field> - <name>dependencyManagement</name> - <version>1.0.0+</version> - <description> - The list of dependency management settings. - </description> - <association stash.part="true" - jpox.join="false"> - <type>Dependency</type> - <multiplicity>*</multiplicity> - </association> - </field> - <field> - <name>repositories</name> - <version>1.0.0+</version> - <description> - The list project repositories in use by this project. - </description> - <association stash.part="true" - jpox.join="false"> - <type>ProjectRepository</type> - <multiplicity>*</multiplicity> - </association> - </field> - <field> - <name>plugins</name> - <version>1.0.0+</version> - <description> - The list of plugins that this project uses. - </description> - <association stash.part="true" - jpox.join="false"> - <type>ArtifactReference</type> - <multiplicity>*</multiplicity> - </association> - </field> - <field> - <name>reports</name> - <version>1.0.0+</version> - <description> - The list of reports that this project uses. - </description> - <association stash.part="true" - jpox.join="false"> - <type>ArtifactReference</type> - <multiplicity>*</multiplicity> - </association> - </field> - <field> - <name>buildExtensions</name> - <version>1.0.0+</version> - <description> - The list of build extensions that this project uses. - </description> - <association stash.part="true" - jpox.join="false"> - <type>ArtifactReference</type> - <multiplicity>*</multiplicity> - </association> - </field> - <field> - <name>properties</name> - <version>1.0.0+</version> - <description><![CDATA[ - Properties on the project. Only really used to resolve - variables inside of the project during an effective project - model resolution. - ]]></description> - <type>Properties</type> - <association xml.mapStyle="inline"> - <type>String</type> - <multiplicity>*</multiplicity> - </association> - </field> - <field> - <name>relocation</name> - <version>1.0.0+</version> - <description>If relocated, this is the new location reference</description> - <association stash.part="true" - jpox.join="false"> - <type>VersionedReference</type> - <multiplicity>1</multiplicity> - </association> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - private static final long serialVersionUID = -4216128775884469616L; - ]]></code> - </codeSegment> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - public Dependency asDependency() - { - Dependency dep = new Dependency(); - - dep.setGroupId( groupId ); - dep.setArtifactId( artifactId ); - dep.setVersion( version ); - dep.setType( packaging ); - - return dep; - } - ]]></code> - </codeSegment> - </codeSegments> - </class> - - <class stash.storable="true" - jpox.table="MAILING_LISTS"> - <name>MailingList</name> - <description>A Mailing List</description> - <version>1.0.0+</version> - <fields> - <field> - <name>name</name> - <version>1.0.0+</version> - <description>The name of the mailing list.</description> - <type>String</type> - </field> - <field> - <name>subscribeAddress</name> - <version>1.0.0+</version> - <description>The email address to subscribe to this mailing list.</description> - <type>String</type> - </field> - <field> - <name>unsubscribeAddress</name> - <version>1.0.0+</version> - <description>The email address to unsubscribe to this mailing list.</description> - <type>String</type> - </field> - <field> - <name>postAddress</name> - <version>1.0.0+</version> - <description>The email address to post to this mailing list.</description> - <type>String</type> - </field> - <field stash.maxSize="1020"> - <name>mainArchiveUrl</name> - <version>1.0.0+</version> - <description>The url to the archive for this mailing list.</description> - <type>String</type> - </field> - <field> - <name>otherArchives</name> - <version>1.0.0+</version> - <description>The email address to subscribe to this mailing list.</description> - <association stash.part="true" - jpox.join="false"> - <type>String</type> - <multiplicity>*</multiplicity> - </association> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - private static final long serialVersionUID = 843006855864469245L; - ]]></code> - </codeSegment> - </codeSegments> - </class> - - <class stash.storable="true" - jpox.table="ORGANIZATION"> - <name>Organization</name> - <description>Specifies the organization that produces this project.</description> - <version>1.0.0+</version> - <fields> - <field stash.maxSize="250"> - <name>name</name> - <identifier>true</identifier> - <version>1.0.0+</version> - <description><![CDATA[The generated id of the organization object. Due to problems in upgrading, - we cannot unset this as the identifier and we cannot rename this as well.]]></description> - <type>String</type> - </field> - <field stash.maxSize="250" null-value="default"> - <name>organizationName</name> - <version>1.2.1+</version> - <description><![CDATA[The full name of the organization.]]></description> - <type>String</type> - </field> - <field stash.maxSize="1020"> - <name>url</name> - <version>1.0.0+</version> - <description><![CDATA[The URL to the organization's home page.]]></description> - <type>String</type> - </field> - <field stash.maxSize="1020" - jpox.column="FAVICON_URL"> - <name>favicon</name> - <version>1.0.0+</version> - <description><![CDATA[ - The URL to the organization's logo image. This can be an URL relative - to the base directory of the generated web site, - (e.g., <code>/images/org-logo.png</code>) or an absolute URL - (e.g., <code>http://my.corp/logo.png</code>). This value is used - when generating the project documentation. - ]]></description> - <type>String</type> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - private static final long serialVersionUID = -7782212828768434535L; - ]]></code> - </codeSegment> - </codeSegments> - </class> - - <class stash.storable="true" - jpox.table="LICENSES"> - <name>License</name> - <description><![CDATA[ - Describes the licenses for this project. This is used to generate - the license page of the project's web site, as well as being taken into consideration in other reporting and - validation. The licenses listed for the project are that of the project itself, and not of dependencies. - ]]></description> - <version>1.0.0+</version> - <fields> - <field jpox.column="LICENSE_ID"> - <name>id</name> - <identifier>true</identifier> - <version>1.0.0+</version> - <type>int</type> - <description> - The type of license. - </description> - </field> - <field stash.maxSize="250"> - <name>name</name> - <version>1.0.0+</version> - <description><![CDATA[The full legal name of the license.]]></description> - <type>String</type> - </field> - <field stash.maxSize="1020"> - <name>url</name> - <version>1.0.0+</version> - <description><![CDATA[The official url for the license text.]]></description> - <type>String</type> - </field> - <field stash.maxSize="8192"> - <name>comments</name> - <description> - Addendum information pertaining to this license. - </description> - <version>1.0.0+</version> - <type>String</type> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - private static final long serialVersionUID = 6078130909089038238L; - ]]></code> - </codeSegment> - </codeSegments> - </class> - - <class stash.storable="true" - jpox.table="ISSUE_MANAGEMENT"> - <name>IssueManagement</name> - <description> - Information about the issue tracking (or bug tracking) system used to manage this project. - </description> - <version>1.0.0+</version> - <fields> - <field stash.maxSize="250"> - <name>url</name> - <identifier>true</identifier> - <version>1.0.0+</version> - <description><![CDATA[The generated id for the issue management object. Due to problems in upgrading, - we cannot unset this as the identifier and we cannot rename this as well.]]></description> - <type>String</type> - </field> - <field stash.maxSize="1020" null-value="default"> - <name>issueManagementUrl</name> - <version>1.2.1+</version> - <description><![CDATA[URL for the issue management system used by the project.]]></description> - <type>String</type> - </field> - <field jpox.column="SYSTEM_NAME"> - <name>system</name> - <version>1.0.0+</version> - <description><![CDATA[The name of the issue management system, e.g. Bugzilla]]></description> - <type>String</type> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - private static final long serialVersionUID = -8881904886381224821L; - ]]></code> - </codeSegment> - </codeSegments> - </class> - - <class> - <name>CiManagement</name> - <version>1.0.0+</version> - <fields> - <field stash.maxSize="250"> - <name>url</name> - <version>1.0.0+</version> - <identifier>true</identifier> - <description> - <![CDATA[The generated id for the CI management object. Due to problems in upgrading, - we cannot unset this as the identifier and we cannot rename this as well.]]></description> - <type>String</type> - </field> - <field stash.maxSize="1020" null-value="default"> - <name>ciUrl</name> - <version>1.2.1+</version> - <description> - <![CDATA[URL for the continuous integration system used by the project if it has a web interface.]]></description> - <type>String</type> - </field> - <field stash.maxSize="50" - jpox.column="SYSTEM_NAME"> - <name>system</name> - <version>1.0.0+</version> - <description> - <![CDATA[The name of the continuous integration system, e.g. <code>continuum</code>.]]></description> - <type>String</type> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - private static final long serialVersionUID = 7592740408468517476L; - ]]></code> - </codeSegment> - </codeSegments> - </class> - - <class stash.storable="true"> - <name>Individual</name> - <description> - Description of a person who has contributed to the project. - This includes contributors and commitors. - </description> - <version>1.0.0+</version> - <fields> - <field stash.maxSize="250"> - <name>email</name> - <identifier>true</identifier> - <version>1.0.0+</version> - <description><![CDATA[The generated id for the object. Due to problems in upgrading, - we cannot unset this as the identifier and we cannot rename this as well.]]></description> - <type>String</type> - </field> - <field stash.maxSize="250" null-value="default"> - <name>individualEmail</name> - <version>1.2.1+</version> - <description><![CDATA[The email address of the individual.]]></description> - <type>String</type> - </field> - <field> - <name>name</name> - <version>1.0.0+</version> - <description><![CDATA[The full name of the individual.]]></description> - <type>String</type> - </field> - <field> - <name>principal</name> - <version>1.0.0+</version> - <description> - The RedBack (plexus security) principal associated with this Invididual. - </description> - <type>String</type> - </field> - <field> - <name>commitor</name> - <version>1.0.0+</version> - <description> - The flag if this user is a developer and/or commitor. - </description> - <type>boolean</type> - </field> - <field stash.maxSize="1020"> - <name>url</name> - <version>1.0.0+</version> - <description><![CDATA[The URL for the homepage of the individual.]]></description> - <type>String</type> - </field> - <!-- TODO: should this just be a single Organization element --> - <field> - <name>organization</name> - <alias>organisation</alias> - <version>1.0.0+</version> - <description><![CDATA[The organization to which the individual belongs.]]></description> - <type>String</type> - </field> - <field stash.maxSize="1020"> - <name>organizationUrl</name> - <alias>organisationUrl</alias> - <version>1.0.0+</version> - <description><![CDATA[The URL of the organization.]]></description> - <type>String</type> - </field> - <field jpox.column="CONTRIBUTOR_ROLES"> - <name>roles</name> - <version>1.0.0+</version> - <description><![CDATA[ - The roles the individual plays in the project. Each role is - described by a <code>role</code> element, the body of which is a - role name. This can also be used to describe the contribution. - ]]></description> - <association stash.part="true" - jpox.join="false"> - <type>String</type> - <multiplicity>*</multiplicity> - </association> - </field> - <field> - <name>timezone</name> - <version>1.0.0+</version> - <description><![CDATA[ - The timezone the individual is in. This is a number in the range -11 to 12. - ]]></description> - <type>String</type> - </field> - <field> - <name>properties</name> - <version>1.0.0+</version> - <description><![CDATA[ - Properties about the individual, such as an instant messenger handle. - ]]></description> - <type>Properties</type> - <association xml.mapStyle="inline"> - <type>String</type> - <multiplicity>*</multiplicity> - </association> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - private static final long serialVersionUID = -3847642264665088605L; - ]]></code> - </codeSegment> - </codeSegments> - </class> - - <class stash.storable="true" - jpox.table="DEPENDENCY"> - <name>Dependency</name> - <version>1.0.0+</version> - <fields> - <field stash.maxSize="250"> - <name>groupId</name> - <version>1.0.0+</version> - <type>String</type> - <required>true</required> - <description> - The Group ID of the repository content. - </description> - </field> - <field stash.maxSize="80"> - <name>artifactId</name> - <version>1.0.0+</version> - <type>String</type> - <required>true</required> - <description> - The Artifact ID of the repository content. - </description> - </field> - <field stash.maxSize="50"> - <name>version</name> - <version>1.0.0+</version> - <type>String</type> - <required>false</required> - <description> - The version of the repository content. - </description> - </field> - <field stash.maxSize="50"> - <name>classifier</name> - <version>1.0.0+</version> - <type>String</type> - <required>false</required> - <defaultValue></defaultValue> - <description><![CDATA[ - The classifier of the dependency. This allows distinguishing two artifacts that belong to the same POM but - were built differently, and is appended to the filename after the version. For example, - <code>jdk14</code> and <code>jdk15</code>. - ]]></description> - </field> - <field stash.maxSize="50" - jpox.column="DEPENDENCY_TYPE"> - <name>type</name> - <version>1.0.0+</version> - <type>String</type> - <required>true</required> - <description><![CDATA[ - The type of dependency. This defaults to <code>jar</code>. While it usually represents the extension on - the filename of the dependency, that is not always the case. A type can be mapped to a different - extension and a classifier. - The type often correspongs to the packaging used, though this is also not always the case. - Some examples are <code>jar</code>, <code>war</code>, <code>ejb-client</code> and <code>test-jar</code>. - New types can be defined by plugins that set - <code>extensions</code> to <code>true</code>, so this is not a complete list. - ]]></description> - <defaultValue>jar</defaultValue> - </field> - <field> - <name>transitive</name> - <version>1.0.0+</version> - <required>false</required> - <description>True if the dependency is only here due a transitive resolution</description> - <type>boolean</type> - <!-- <defaultValue>false</defaultValue> --> - </field> - <field> - <name>fromParent</name> - <version>1.0.0+</version> - <required>false</required> - <description>True if the dependency is only here due a parent pom</description> - <type>boolean</type> - <!-- <defaultValue>false</defaultValue> --> - </field> - <field stash.maxSize="1020"> - <name>url</name> - <version>1.0.0+</version> - <description><![CDATA[ - This url will be provided to the user if the jar file cannot be downloaded - from the central repository. - ]]></description> - <type>String</type> - </field> - <field jpox.column="DEPENDENCY_SCOPE"> - <name>scope</name> - <version>1.0.0+</version> - <description><![CDATA[ - The scope of the dependency - <code>compile</code>, <code>runtime</code>, <code>test</code>, - <code>system</code>, and <code>provided</code>. Used to - calculate the various classpaths used for compilation, testing, and so on. It also assists in determining - which artifacts to include in a distribution of this project. For more information, see - <a href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html">the - dependency mechanism</a>. - ]]> - </description> - <type>String</type> - </field> - <field stash.maxSize="250"> - <name>systemPath</name> - <version>1.0.0+</version> - <description><![CDATA[ - FOR SYSTEM SCOPE ONLY. Note that use of this property is <b>discouraged</b> and may be replaced in later - versions. This specifies the path on the filesystem for this dependency. - Requires an absolute path for the value, not relative. - Use a property that gives the machine specific absolute path, - e.g. <code>${java.home}</code>. - ]]></description> - <type>String</type> - </field> - <field> - <name>exclusions</name> - <version>1.0.0+</version> - <description> - Lists a set of artifacts that should be excluded from this dependency's artifact list when it comes to - calculating transitive dependencies. - </description> - <association stash.part="true" - jpox.join="false"> - <type>Exclusion</type> - <multiplicity>*</multiplicity> - </association> - </field> - <field> - <name>optional</name> - <version>1.0.0+</version> - <description> - Indicates the dependency is optional for use of this library. While the version of the dependency will be - taken into account for dependency calculation if the library is used elsewhere, it will not be passed on - transitively. - </description> - <type>boolean</type> - <defaultValue>false</defaultValue> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - private static final long serialVersionUID = -5401218809636164002L; - ]]></code> - </codeSegment> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - public String toString() - { - return Dependency.toKey( this ); - } - - public static String toKey( Dependency dep ) - { - StringBuffer key = new StringBuffer(); - - key.append( dep.getGroupId() ).append( ":" ); - key.append( dep.getArtifactId() ).append( ":" ); - key.append( dep.getVersion() ).append( ":" ); - if ( dep.getClassifier() != null ) - { - key.append( dep.getClassifier() ); - } - key.append( ":" ); - key.append( dep.getType() ); - - return key.toString(); - } - - public static String toVersionlessKey( Dependency dep ) - { - StringBuffer key = new StringBuffer(); - - key.append( dep.getGroupId() ).append( ":" ); - key.append( dep.getArtifactId() ).append( ":" ); - if ( dep.getClassifier() != null ) - { - key.append( dep.getClassifier() ); - } - key.append( ":" ); - key.append( dep.getType() ); - - return key.toString(); - } - ]]></code> - </codeSegment> - </codeSegments> - </class> - - <class stash.storable="true" - jpox.table="EXCLUSIONS"> - <name>Exclusion</name> - <version>1.0.0+</version> - <fields> - <field stash.maxSize="250"> - <name>groupId</name> - <version>1.0.0+</version> - <description><![CDATA[The group ID of the project to exclude.]]></description> - <type>String</type> - <required>true</required> - </field> - <field stash.maxSize="80"> - <name>artifactId</name> - <version>1.0.0+</version> - <description><![CDATA[The artifact ID of the project to exclude.]]></description> - <type>String</type> - <required>true</required> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - private static final long serialVersionUID = 5655957444245343314L; - ]]></code> - </codeSegment> - </codeSegments> - </class> - - <class stash.storable="true" - jpox.table="SCM"> - <name>Scm</name> - <version>1.0.0+</version> - <fields> - <field stash.maxSize="1020" jpox.column="SCM_URL"> - <name>connection</name> - <version>1.0.0+</version> - <description><![CDATA[ - The source control management system URL - that describes the repository and how to connect to the - repository. For more information, see the - <a href="http://maven.apache.org/scm/scm-url-format.html">URL format</a> - and <a href="http://maven.apache.org/scm/scms-overview.html">list of supported SCMs</a>. - This connection is read-only. - ]]></description> - <type>String</type> - </field> - <field stash.maxSize="1020"> - <name>developerConnection</name> - <version>1.0.0+</version> - <description><![CDATA[ - Just like <code>connection</code>, but for developers, i.e. this scm connection - will not be read only. - ]]></description> - <type>String</type> - </field> - <field stash.maxSize="1020"> - <name>url</name> - <version>1.0.0+</version> - <description> - <![CDATA[The URL to the project's browsable SCM repository, such as ViewVC or Fisheye.]]></description> - <type>String</type> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - private static final long serialVersionUID = 4075086167850885575L; - ]]></code> - </codeSegment> - </codeSegments> - </class> - - <class stash.storable="true" jpox.table="PROJECT_REPOSITORIES"> - <name>ProjectRepository</name> - <version>1.0.0+</version> - <fields> - <field stash.maxSize="50"> - <name>id</name> - <version>1.0.0+</version> - <description><![CDATA[ - A unique identifier for a repository. This is used to match the repository to configuration in - the <code>settings.xml</code> file, for example. - ]]></description> - <type>String</type> - </field> - <field stash.maxSize="250"> - <name>name</name> - <version>1.0.0+</version> - <description><![CDATA[ - Human readable name of the repository. - ]]></description> - <type>String</type> - </field> - <field stash.maxSize="1020"> - <name>url</name> - <version>1.0.0+</version> - <description><![CDATA[ - The url of the repository, in the form <code>protocol://hostname/path</code>. - ]]></description> - <type>String</type> - </field> - <field stash.maxSize="16"> - <name>layout</name> - <version>1.0.0+</version> - <description><![CDATA[ - The type of layout this repository uses for locating and storing artifacts - can be <code>legacy</code> or - <code>default</code>. - ]]></description> - <type>String</type> - <defaultValue>default</defaultValue> - </field> - <field> - <name>plugins</name> - <version>1.0.0+</version> - <description> - Flag indicating if this repository is for plugin resolution. - </description> - <type>boolean</type> - </field> - <field> - <name>releases</name> - <version>1.0.0+</version> - <description> - Flag indicating if this repository has release versioned artifacts. - </description> - <type>boolean</type> - </field> - <field> - <name>snapshots</name> - <version>1.0.0+</version> - <description> - Flag indicating if this repository has snapshot versioned artifacts. - </description> - <type>boolean</type> - </field> - </fields> - <codeSegments> - <codeSegment> - <version>1.0.0+</version> - <code><![CDATA[ - private static final long serialVersionUID = 8906309721278091848L; - ]]></code> - </codeSegment> - </codeSegments> - </class> - - <!-- _______________________________________________________________ _ _ _ _ _ | | | | ___ __ _| | |_| |__ | |_| |/ _ \/ _` | | __| '_ \ diff --git a/archiva-modules/archiva-base/archiva-model/src/test/java/org/apache/maven/archiva/model/ArchivaModelClonerTest.java b/archiva-modules/archiva-base/archiva-model/src/test/java/org/apache/maven/archiva/model/ArchivaModelClonerTest.java deleted file mode 100644 index 7b4017ff5..000000000 --- a/archiva-modules/archiva-base/archiva-model/src/test/java/org/apache/maven/archiva/model/ArchivaModelClonerTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.apache.maven.archiva.model; - -/* - * 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.codehaus.plexus.spring.PlexusInSpringTestCase; - -/** - * ArchivaModelClonerTest - * - * @version $Id$ - */ -public class ArchivaModelClonerTest - extends PlexusInSpringTestCase -{ - public void testCloneProjectModelWithParent() - { - ArchivaProjectModel actualModel = new ArchivaProjectModel(); - actualModel.setGroupId( null ); - actualModel.setArtifactId( "archiva-common" ); - actualModel.setVersion( null ); - actualModel.setParentProject( new VersionedReference() ); - actualModel.getParentProject().setGroupId( "org.apache.maven.archiva" ); - actualModel.getParentProject().setArtifactId( "archiva-parent" ); - actualModel.getParentProject().setVersion( "1.0" ); - - ArchivaProjectModel clonedModel = ArchivaModelCloner.clone( actualModel ); - - // Should not be the same object (in memory) - assertNotSame( clonedModel, actualModel ); - - // Should be equal in value. - assertEquals( clonedModel, actualModel ); - - // Test specific fields. - assertNull( "Group Id", clonedModel.getGroupId() ); - assertNull( "Version", clonedModel.getVersion() ); - assertNotNull( "Parent Reference", clonedModel.getParentProject() ); - assertEquals( "Parent Group Id", "org.apache.maven.archiva", clonedModel.getParentProject().getGroupId() ); - assertEquals( "Parent Artifact Id", "archiva-parent", clonedModel.getParentProject().getArtifactId() ); - assertEquals( "Parent Version", "1.0", clonedModel.getParentProject().getVersion() ); - } -} diff --git a/archiva-modules/archiva-base/archiva-model/src/test/java/org/apache/maven/archiva/model/DependencyScopeTest.java b/archiva-modules/archiva-base/archiva-model/src/test/java/org/apache/maven/archiva/model/DependencyScopeTest.java deleted file mode 100644 index cc2f06740..000000000 --- a/archiva-modules/archiva-base/archiva-model/src/test/java/org/apache/maven/archiva/model/DependencyScopeTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.apache.maven.archiva.model; - -/* - * 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 junit.framework.TestCase; - -/** - * DependencyScopeTest - * - * @version $Id$ - */ -public class DependencyScopeTest - extends TestCase -{ - public void testIsWithinScope() - { - // Test on blank / empty desired scopes. - assertFalse( DependencyScope.isWithinScope( "compile", null ) ); - assertFalse( DependencyScope.isWithinScope( "test", null ) ); - assertFalse( DependencyScope.isWithinScope( "runtime", null ) ); - assertFalse( DependencyScope.isWithinScope( "provided", null ) ); - assertFalse( DependencyScope.isWithinScope( "compile", "" ) ); - assertFalse( DependencyScope.isWithinScope( "test", "" ) ); - assertFalse( DependencyScope.isWithinScope( "runtime", "" ) ); - assertFalse( DependencyScope.isWithinScope( "provided", "" ) ); - - // Tests on blank / empty actual scopes. - assertTrue( DependencyScope.isWithinScope( "", DependencyScope.COMPILE ) ); - assertTrue( DependencyScope.isWithinScope( null, DependencyScope.COMPILE ) ); - assertTrue( DependencyScope.isWithinScope( "", DependencyScope.TEST ) ); - assertTrue( DependencyScope.isWithinScope( null, DependencyScope.TEST ) ); - assertFalse( DependencyScope.isWithinScope( "", DependencyScope.PROVIDED ) ); - assertFalse( DependencyScope.isWithinScope( null, DependencyScope.PROVIDED ) ); - assertFalse( DependencyScope.isWithinScope( "", DependencyScope.RUNTIME ) ); - assertFalse( DependencyScope.isWithinScope( null, DependencyScope.RUNTIME ) ); - - // Tests on compile desired scopes. - assertTrue( DependencyScope.isWithinScope( "compile", DependencyScope.COMPILE ) ); - assertFalse( DependencyScope.isWithinScope( "test", DependencyScope.COMPILE ) ); - - // Tests on test desired scopes. - assertTrue( DependencyScope.isWithinScope( "compile", DependencyScope.TEST ) ); - assertTrue( DependencyScope.isWithinScope( "test", DependencyScope.TEST ) ); - - // Tests on oddball scopes. - assertFalse( DependencyScope.isWithinScope( "compile", DependencyScope.PROVIDED ) ); - assertFalse( DependencyScope.isWithinScope( "test", DependencyScope.PROVIDED ) ); - assertTrue( DependencyScope.isWithinScope( "provided", DependencyScope.PROVIDED ) ); - - assertFalse( DependencyScope.isWithinScope( "compile", DependencyScope.RUNTIME ) ); - assertFalse( DependencyScope.isWithinScope( "test", DependencyScope.RUNTIME ) ); - assertTrue( DependencyScope.isWithinScope( "provided", DependencyScope.RUNTIME ) ); - assertTrue( DependencyScope.isWithinScope( "runtime", DependencyScope.RUNTIME ) ); - } -} diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/stubs/ArchivaDAOStub.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/stubs/ArchivaDAOStub.java index e6a67a8ff..cd220ae55 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/stubs/ArchivaDAOStub.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/stubs/ArchivaDAOStub.java @@ -24,7 +24,6 @@ import java.util.List; import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.ArtifactDAO; -import org.apache.maven.archiva.database.ProjectModelDAO; import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO; import org.apache.maven.archiva.database.RepositoryProblemDAO; import org.apache.maven.archiva.database.SimpleConstraint; @@ -42,12 +41,6 @@ public class ArchivaDAOStub return null; } - public ProjectModelDAO getProjectModelDAO() - { - // TODO Auto-generated method stub - return null; - } - public RepositoryContentStatisticsDAO getRepositoryContentStatisticsDAO() { // TODO Auto-generated method stub diff --git a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml index a939999f2..f246248a6 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml @@ -80,18 +80,6 @@ <goal>generate-metadata</goal> </goals> </execution> - <execution> - <id>merge</id> - <goals> - <goal>merge-metadata</goal> - </goals> - <configuration> - <descriptors> - <descriptor>${basedir}/src/main/resources/META-INF/plexus/components-fragment.xml</descriptor> - <descriptor>${project.build.outputDirectory}/META-INF/plexus/components.xml</descriptor> - </descriptors> - </configuration> - </execution> </executions> </plugin> </plugins> diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelException.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelException.java deleted file mode 100644 index 3d23c6c26..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelException.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.archiva.repository.project; - -/* - * 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.maven.archiva.common.ArchivaException; - -/** - * ProjectModelException - * - * @version $Id$ - */ -public class ProjectModelException extends ArchivaException -{ - public ProjectModelException( String message, Throwable cause ) - { - super( message, cause ); - } - - public ProjectModelException( String message ) - { - super( message ); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelFilter.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelFilter.java deleted file mode 100644 index 054b3dcdb..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelFilter.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.apache.maven.archiva.repository.project; - -/* - * 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.maven.archiva.model.ArchivaProjectModel; - -/** - * Generic Filtering interface for {@link ArchivaProjectModel} objects. - * - * @version $Id$ - */ -public interface ProjectModelFilter -{ - /** - * Filter a model and return the results of the filtering. - * - * @param model the model to filter. - * @return a new model representing the filtered state of the model. - * @throws ProjectModelException if there was a problem executing the filter. - */ - public ArchivaProjectModel filter( final ArchivaProjectModel model ) throws ProjectModelException; -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelMerge.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelMerge.java deleted file mode 100644 index a5b959872..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelMerge.java +++ /dev/null @@ -1,688 +0,0 @@ -package org.apache.maven.archiva.repository.project; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.model.ArchivaModelCloner; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.ArtifactReference; -import org.apache.maven.archiva.model.CiManagement; -import org.apache.maven.archiva.model.Dependency; -import org.apache.maven.archiva.model.Exclusion; -import org.apache.maven.archiva.model.Individual; -import org.apache.maven.archiva.model.IssueManagement; -import org.apache.maven.archiva.model.License; -import org.apache.maven.archiva.model.Organization; -import org.apache.maven.archiva.model.ProjectRepository; -import org.apache.maven.archiva.model.Scm; - -/** - * ProjectModelMerge - * - * TODO: Should call this ProjectModelAncestry as it deals with the current project and its parent. - * - * @version $Id$ - */ -public class ProjectModelMerge -{ - /** - * Merge the contents of a project with it's parent project. - * - * @param mainProject the main project. - * @param parentProject the parent project to merge. - * @throws ProjectModelException if there was a problem merging the model. - */ - public static ArchivaProjectModel merge( ArchivaProjectModel mainProject, ArchivaProjectModel parentProject ) - throws ProjectModelException - { - if ( mainProject == null ) - { - throw new ProjectModelException( "Cannot merge with a null main project." ); - } - - if ( parentProject == null ) - { - throw new ProjectModelException( "Cannot merge with a null parent project." ); - } - - ArchivaProjectModel merged = new ArchivaProjectModel(); - - // Unmerged. - merged.setParentProject(mainProject.getParentProject()); - merged.setArtifactId( mainProject.getArtifactId() ); - merged.setPackaging( StringUtils.defaultIfEmpty( mainProject.getPackaging(), "jar" ) ); - merged.setRelocation( mainProject.getRelocation() ); - - // Merged - merged.setGroupId( merge( mainProject.getGroupId(), parentProject.getGroupId() ) ); - merged.setVersion( merge( mainProject.getVersion(), parentProject.getVersion() ) ); - merged.setName( merge( mainProject.getName(), parentProject.getName() ) ); - merged.setUrl( merge( mainProject.getUrl(), parentProject.getUrl() ) ); - merged.setDescription( merge( mainProject.getDescription(), parentProject.getDescription() ) ); - - merged.setOrigin( "merged" ); - - merged.setCiManagement( merge( mainProject.getCiManagement(), parentProject.getCiManagement() ) ); - merged.setIndividuals( mergeIndividuals( mainProject.getIndividuals(), parentProject.getIndividuals() ) ); - merged.setIssueManagement( merge( mainProject.getIssueManagement(), parentProject.getIssueManagement() ) ); - merged.setLicenses( mergeLicenses( mainProject.getLicenses(), parentProject.getLicenses() ) ); - merged.setOrganization( merge( mainProject.getOrganization(), parentProject.getOrganization() ) ); - merged.setScm( merge( mainProject.getScm(), parentProject.getScm() ) ); - merged.setRepositories( mergeRepositories( mainProject.getRepositories(), parentProject.getRepositories() ) ); - merged.setDependencies( mergeDependencies( mainProject.getDependencies(), parentProject.getDependencies() ) ); - merged.setDependencyManagement( mergeDependencyManagement( mainProject.getDependencyManagement(), parentProject - .getDependencyManagement() ) ); - merged.setPlugins( mergePlugins( mainProject.getPlugins(), parentProject.getPlugins() ) ); - merged.setReports( mergeReports( mainProject.getReports(), parentProject.getReports() ) ); - merged.setProperties( merge( mainProject.getProperties(), parentProject.getProperties() ) ); - - return merged; - } - - private static Map<String, ArtifactReference> createArtifactReferenceMap( List<ArtifactReference> artifactReferences ) - { - Map<String, ArtifactReference> ret = new HashMap<String, ArtifactReference>(); - - for ( ArtifactReference artifactReference : artifactReferences ) - { - String key = toVersionlessArtifactKey( artifactReference ); - ret.put( key, artifactReference ); - } - - return ret; - } - - private static Map<String, Dependency> createDependencyMap( List<Dependency> dependencies ) - { - Map<String, Dependency> ret = new HashMap<String, Dependency>(); - - Iterator<Dependency> it = dependencies.iterator(); - while ( it.hasNext() ) - { - Dependency dep = it.next(); - String key = toVersionlessDependencyKey( dep ); - ret.put( key, dep ); - } - - return ret; - } - - private static Map<String, Exclusion> createExclusionMap( List<Exclusion> exclusions ) - { - Map<String, Exclusion> ret = new HashMap<String, Exclusion>(); - - Iterator<Exclusion> it = exclusions.iterator(); - while ( it.hasNext() ) - { - Exclusion exclusion = it.next(); - String key = exclusion.getGroupId() + ":" + exclusion.getArtifactId(); - ret.put( key, exclusion ); - } - - return ret; - } - - private static Map<String, License> createLicensesMap( List<License> licenses ) - { - Map<String, License> ret = new HashMap<String, License>(); - - for ( License license : licenses ) - { - // TODO: Change to 'id' when LicenseTypeMapper is created. - String key = license.getName(); - ret.put( key, license ); - } - - return ret; - } - - private static Map<String, ProjectRepository> createRepositoriesMap( List<ProjectRepository> repositories ) - { - Map<String, ProjectRepository> ret = new HashMap<String, ProjectRepository>(); - - for ( ProjectRepository repo : repositories ) - { - // Should this really be using repo.id ? - String key = repo.getUrl(); - ret.put( key, repo ); - } - - return ret; - } - - private static boolean empty( String val ) - { - if ( val == null ) - { - return true; - } - - return ( val.trim().length() <= 0 ); - } - - private static ArtifactReference merge( ArtifactReference mainArtifactReference, - ArtifactReference parentArtifactReference ) - { - if ( parentArtifactReference == null ) - { - return mainArtifactReference; - } - - if ( mainArtifactReference == null ) - { - return ArchivaModelCloner.clone( parentArtifactReference ); - } - - ArtifactReference merged = new ArtifactReference(); - - // Unmerged. - merged.setGroupId( mainArtifactReference.getGroupId() ); - merged.setArtifactId( mainArtifactReference.getArtifactId() ); - - // Merged. - merged.setVersion( merge( mainArtifactReference.getVersion(), parentArtifactReference.getVersion() ) ); - merged.setClassifier( merge( mainArtifactReference.getClassifier(), parentArtifactReference.getClassifier() ) ); - merged.setType( merge( mainArtifactReference.getType(), parentArtifactReference.getType() ) ); - - return merged; - } - - private static CiManagement merge( CiManagement mainCim, CiManagement parentCim ) - { - if ( parentCim == null ) - { - return mainCim; - } - - if ( mainCim == null ) - { - return ArchivaModelCloner.clone( parentCim ); - } - - CiManagement merged = new CiManagement(); - - merged.setSystem( merge( mainCim.getSystem(), parentCim.getSystem() ) ); - merged.setUrl( merge( mainCim.getUrl(), parentCim.getUrl() ) ); - merged.setCiUrl( merge( mainCim.getCiUrl(), parentCim.getCiUrl() ) ); - - return merged; - } - - private static Dependency merge( Dependency mainDep, Dependency parentDep ) - { - if ( parentDep == null ) - { - return mainDep; - } - - if ( mainDep == null ) - { - Dependency dep = ArchivaModelCloner.clone( parentDep ); - dep.setFromParent( true ); - return dep; - } - - Dependency merged = new Dependency(); - - merged.setFromParent( true ); - - // Unmerged. - merged.setGroupId( mainDep.getGroupId() ); - merged.setArtifactId( mainDep.getArtifactId() ); - - // Merged. - merged.setVersion( merge( mainDep.getVersion(), parentDep.getVersion() ) ); - merged.setClassifier( merge( mainDep.getClassifier(), parentDep.getClassifier() ) ); - merged.setType( merge( mainDep.getType(), parentDep.getType() ) ); - merged.setScope( merge( mainDep.getScope(), parentDep.getScope() ) ); - if ( parentDep.isOptional() ) - { - merged.setOptional( true ); - } - - merged.setSystemPath( merge( mainDep.getSystemPath(), parentDep.getSystemPath() ) ); - merged.setUrl( merge( mainDep.getUrl(), parentDep.getUrl() ) ); - merged.setExclusions( mergeExclusions( mainDep.getExclusions(), parentDep.getExclusions() ) ); - - return merged; - } - - private static IssueManagement merge( IssueManagement mainIssueManagement, IssueManagement parentIssueManagement ) - { - if ( parentIssueManagement == null ) - { - return mainIssueManagement; - } - - if ( mainIssueManagement == null ) - { - return ArchivaModelCloner.clone( parentIssueManagement ); - } - - IssueManagement merged = new IssueManagement(); - - merged.setSystem( merge( mainIssueManagement.getSystem(), parentIssueManagement.getSystem() ) ); - merged.setUrl( merge( mainIssueManagement.getUrl(), parentIssueManagement.getUrl() ) ); - merged.setIssueManagementUrl( merge( mainIssueManagement.getIssueManagementUrl(), parentIssueManagement.getIssueManagementUrl() ) ); - - return merged; - } - - private static Organization merge( Organization mainOrganization, Organization parentOrganization ) - { - if ( parentOrganization == null ) - { - return mainOrganization; - } - - if ( mainOrganization == null ) - { - return ArchivaModelCloner.clone( parentOrganization ); - } - - Organization merged = new Organization(); - - merged.setFavicon( merge( mainOrganization.getFavicon(), parentOrganization.getFavicon() ) ); - merged.setOrganizationName( merge( mainOrganization.getOrganizationName(), parentOrganization.getOrganizationName() ) ); - merged.setName( merge( mainOrganization.getName(), parentOrganization.getName() ) ); - merged.setUrl( merge( mainOrganization.getUrl(), parentOrganization.getUrl() ) ); - - return merged; - } - - @SuppressWarnings("unchecked") - private static Properties merge( Properties mainProperties, Properties parentProperties ) - { - if ( parentProperties == null ) - { - return mainProperties; - } - - if ( mainProperties == null ) - { - return ArchivaModelCloner.clone( parentProperties ); - } - - Properties merged = new Properties(); - merged.putAll(mainProperties); - - Enumeration<String> keys = (Enumeration<String>) parentProperties.propertyNames(); - while ( keys.hasMoreElements() ) - { - String key = (String) keys.nextElement(); - String value = merge( mainProperties.getProperty( key ), parentProperties.getProperty( key ) ); - - if ( value != null ) - { - merged.put( key, value ); - } - } - - return merged; - } - - private static Scm merge( Scm mainScm, Scm parentScm ) - { - if ( parentScm == null ) - { - return mainScm; - } - - if ( mainScm == null ) - { - return ArchivaModelCloner.clone( parentScm ); - } - - Scm merged = new Scm(); - - merged.setConnection( merge( mainScm.getConnection(), parentScm.getConnection() ) ); - merged.setDeveloperConnection( merge( mainScm.getDeveloperConnection(), parentScm.getDeveloperConnection() ) ); - merged.setUrl( merge( mainScm.getUrl(), parentScm.getUrl() ) ); - - return merged; - } - - private static String merge( String main, String parent ) - { - if ( empty( main ) && !empty( parent ) ) - { - return parent; - } - - return main; - } - - private static List<ArtifactReference> mergeArtifactReferences( List<ArtifactReference> mainArtifactReferences, List<ArtifactReference> parentArtifactReferences ) - { - if ( parentArtifactReferences == null ) - { - return mainArtifactReferences; - } - - if ( mainArtifactReferences == null ) - { - return ArchivaModelCloner.cloneArtifactReferences( parentArtifactReferences ); - } - - List<ArtifactReference> merged = new ArrayList<ArtifactReference>(); - - Map<String, ArtifactReference> mainArtifactReferenceMap = createArtifactReferenceMap( mainArtifactReferences ); - Map<String, ArtifactReference> parentArtifactReferenceMap = createArtifactReferenceMap( parentArtifactReferences ); - - for ( Map.Entry<String,ArtifactReference> entry : mainArtifactReferenceMap.entrySet() ) - { - String key = entry.getKey(); - ArtifactReference mainArtifactReference = (ArtifactReference) entry.getValue(); - ArtifactReference parentArtifactReference = parentArtifactReferenceMap.get( key ); - - if ( parentArtifactReference == null ) - { - merged.add( mainArtifactReference ); - } - else - { - // Not merging. Local wins. - merged.add( merge( mainArtifactReference, parentArtifactReference ) ); - } - } - - return merged; - } - - private static List<Dependency> mergeDependencies( List<Dependency> mainDependencies, List<Dependency> parentDependencies ) - { - if ( parentDependencies == null ) - { - return mainDependencies; - } - - if ( mainDependencies == null ) - { - List<Dependency> merged = ArchivaModelCloner.cloneDependencies( parentDependencies ); - Iterator<Dependency> it = merged.iterator(); - while ( it.hasNext() ) - { - Dependency dep = it.next(); - dep.setFromParent( true ); - } - return merged; - } - - List<Dependency> merged = new ArrayList<Dependency>(); - - Map<String, Dependency> mainDepMap = createDependencyMap( mainDependencies ); - Map<String, Dependency> parentDepMap = createDependencyMap( parentDependencies ); - Set<String> uniqueKeys = new HashSet<String>(); - uniqueKeys.addAll( mainDepMap.keySet() ); - uniqueKeys.addAll( parentDepMap.keySet() ); - - Iterator<String> it = uniqueKeys.iterator(); - while ( it.hasNext() ) - { - String key = it.next(); - Dependency parentDep = parentDepMap.get( key ); - Dependency mainDep = mainDepMap.get( key ); - - if ( parentDep == null ) - { - // Means there is no parent dep to override main dep. - merged.add( mainDep ); - } - else - { - // Parent dep exists (main doesn't have to). - // Merge the parent over the main dep. - merged.add( merge( mainDep, parentDep ) ); - } - } - - return merged; - } - - private static List<Dependency> mergeDependencyManagement( List<Dependency> mainDepMgmt, List<Dependency> parentDepMgmt ) - { - if ( parentDepMgmt == null ) - { - return mainDepMgmt; - } - - if ( mainDepMgmt == null ) - { - List<Dependency> merged = ArchivaModelCloner.cloneDependencies( parentDepMgmt ); - Iterator<Dependency> it = merged.iterator(); - while ( it.hasNext() ) - { - Dependency dep = it.next(); - dep.setFromParent( true ); - } - return merged; - } - - List<Dependency> merged = new ArrayList<Dependency>(); - - Map<String, Dependency> mainDepMap = createDependencyMap( mainDepMgmt ); - Map<String, Dependency> parentDepMap = createDependencyMap( parentDepMgmt ); - Set<String> uniqueKeys = new HashSet<String>(); - uniqueKeys.addAll( mainDepMap.keySet() ); - uniqueKeys.addAll( parentDepMap.keySet() ); - - Iterator<String> it = uniqueKeys.iterator(); - while ( it.hasNext() ) - { - String key = it.next(); - Dependency parentDep = parentDepMap.get( key ); - Dependency mainDep = mainDepMap.get( key ); - - if ( parentDep == null ) - { - // Means there is no parent depMan entry to override main depMan. - merged.add( mainDep ); - } - else - { - // Parent depMan entry exists (main doesn't have to). - // Merge the parent over the main depMan entry. - merged.add( merge( mainDep, parentDep ) ); - } - } - - return merged; - } - - public static List<Exclusion> mergeExclusions( List<Exclusion> mainExclusions, List<Exclusion> parentExclusions ) - { - if ( parentExclusions == null ) - { - return mainExclusions; - } - - if ( mainExclusions == null ) - { - return ArchivaModelCloner.cloneExclusions( parentExclusions ); - } - - List<Exclusion> merged = new ArrayList<Exclusion>(); - - Map<String, Exclusion> mainExclusionMap = createExclusionMap( mainExclusions ); - Map<String, Exclusion> parentExclusionMap = createExclusionMap( parentExclusions ); - - for ( Map.Entry<String, Exclusion> entry : mainExclusionMap.entrySet() ) - { - String key = entry.getKey(); - Exclusion mainExclusion = entry.getValue(); - Exclusion parentExclusion = parentExclusionMap.get( key ); - - if ( parentExclusion == null ) - { - merged.add( mainExclusion ); - } - else - { - merged.add( parentExclusion ); - } - } - - return merged; - } - - private static List<Individual> mergeIndividuals( List<Individual> mainIndividuals, List<Individual> parentIndividuals ) - { - if ( parentIndividuals == null ) - { - return mainIndividuals; - } - - if ( mainIndividuals == null ) - { - return ArchivaModelCloner.cloneIndividuals( parentIndividuals ); - } - - List<Individual> merged = ArchivaModelCloner.cloneIndividuals( mainIndividuals ); - - Iterator<Individual> it = parentIndividuals.iterator(); - while ( it.hasNext() ) - { - Individual parentIndividual = it.next(); - - if ( !mainIndividuals.contains( parentIndividual ) ) - { - merged.add( parentIndividual ); - } - } - - return merged; - } - - private static List<License> mergeLicenses( List<License> mainLicenses, List<License> parentLicenses ) - { - if ( parentLicenses == null ) - { - return mainLicenses; - } - - if ( mainLicenses == null ) - { - return ArchivaModelCloner.cloneLicenses( parentLicenses ); - } - - List<License> merged = new ArrayList<License>(); - - Map<String, License> mainLicensesMap = createLicensesMap( mainLicenses ); - Map<String, License> parentLicensesMap = createLicensesMap( parentLicenses ); - - for ( Map.Entry<String, License> entry : mainLicensesMap.entrySet() ) - { - String key = entry.getKey(); - License mainLicense = entry.getValue(); - License parentLicense = parentLicensesMap.get( key ); - - if ( parentLicense == null ) - { - merged.add( mainLicense ); - } - else - { - // Not merging. Local wins. - merged.add( parentLicense ); - } - } - - return merged; - } - - private static List<ArtifactReference> mergePlugins( List<ArtifactReference> mainPlugins, List<ArtifactReference> parentPlugins ) - { - return mergeArtifactReferences( mainPlugins, parentPlugins ); - } - - private static List<ArtifactReference> mergeReports( List<ArtifactReference> mainReports, List<ArtifactReference> parentReports ) - { - return mergeArtifactReferences( mainReports, parentReports ); - } - - private static List<ProjectRepository> mergeRepositories( List<ProjectRepository> mainRepositories, List<ProjectRepository> parentRepositories ) - { - if ( parentRepositories == null ) - { - return mainRepositories; - } - - if ( mainRepositories == null ) - { - return ArchivaModelCloner.cloneRepositories( parentRepositories ); - } - - List<ProjectRepository> merged = new ArrayList<ProjectRepository>(); - - Map<String, ProjectRepository> mainRepositoriesMap = createRepositoriesMap( mainRepositories ); - Map<String, ProjectRepository> parentRepositoriesMap = createRepositoriesMap( parentRepositories ); - - for ( Map.Entry<String, ProjectRepository> entry : mainRepositoriesMap.entrySet() ) - { - String key = entry.getKey(); - ProjectRepository mainProjectRepository = entry.getValue(); - ProjectRepository parentProjectRepository = parentRepositoriesMap.get( key ); - - if ( parentProjectRepository == null ) - { - merged.add( mainProjectRepository ); - } - else - { - // Not merging. Local wins. - merged.add( parentProjectRepository ); - } - } - - return merged; - } - - private static String toVersionlessArtifactKey( ArtifactReference artifactReference ) - { - StringBuffer key = new StringBuffer(); - - key.append( artifactReference.getGroupId() ).append( ":" ).append( artifactReference.getArtifactId() ); - key.append( StringUtils.defaultString( artifactReference.getClassifier() ) ).append( ":" ); - key.append( artifactReference.getType() ); - - return key.toString(); - } - - private static String toVersionlessDependencyKey( Dependency dep ) - { - StringBuffer key = new StringBuffer(); - - key.append( dep.getGroupId() ).append( ":" ).append( dep.getArtifactId() ); - key.append( StringUtils.defaultString( dep.getClassifier() ) ).append( ":" ); - key.append( dep.getType() ); - - return key.toString(); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelMonitor.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelMonitor.java deleted file mode 100644 index 8e1666e4e..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelMonitor.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.apache.maven.archiva.repository.project; - -/* - * 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.maven.archiva.model.ArchivaProjectModel; - -/** - * ProjectModelMonitor - * - * @version $Id$ - */ -public interface ProjectModelMonitor -{ - /** - * Report a problem encountered with a model. - * - * @param model the model that caused the problem. - * @param type the type of problem. - * @param problem the problem description. - */ - public void modelProblem( ArchivaProjectModel model, String type, String problem ); -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelReader.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelReader.java deleted file mode 100644 index a795a445d..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelReader.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.apache.maven.archiva.repository.project; - -/* - * 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.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.xml.XMLException; - -import java.io.File; - -/** - * ProjectModelReader - * - * @version $Id$ - */ -public interface ProjectModelReader -{ - public ArchivaProjectModel read( File pomFile ) - throws XMLException; -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelResolver.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelResolver.java deleted file mode 100644 index 1c56bc3a4..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelResolver.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.maven.archiva.repository.project; - -/* - * 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.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.VersionedReference; - -/** - * Interface for ProjectModel resolution. - * - * @version $Id$ - */ -public interface ProjectModelResolver -{ - /** - * Get the ProjectModel given a specific {@link RepositoryContent} key. - * - * @param reference the reference to the other project. - * @return the ArchivaProjectModel representing the provided {@link RepositoryContent} key. - * @throws ProjectModelException if the project model cannot be resolved. - */ - public ArchivaProjectModel resolveProjectModel( VersionedReference reference ) - throws ProjectModelException; -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelResolverFactory.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelResolverFactory.java deleted file mode 100644 index a1bf8fa87..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelResolverFactory.java +++ /dev/null @@ -1,136 +0,0 @@ -package org.apache.maven.archiva.repository.project; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.List; - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.ConfigurationNames; -import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.repository.ManagedRepositoryContent; -import org.apache.maven.archiva.repository.RepositoryContentFactory; -import org.apache.maven.archiva.repository.RepositoryException; -import org.apache.maven.archiva.repository.project.readers.ProjectModel300Reader; -import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader; -import org.apache.maven.archiva.repository.project.resolvers.ManagedRepositoryProjectResolver; -import org.apache.maven.archiva.repository.project.resolvers.NopProjectResolver; -import org.apache.maven.archiva.repository.project.resolvers.ProjectModelResolverStack; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; -import org.codehaus.plexus.registry.Registry; -import org.codehaus.plexus.registry.RegistryListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Factory for ProjectModelResolver objects - * - * @version $Id$ - * @plexus.component role="org.apache.maven.archiva.repository.project.ProjectModelResolverFactory" - */ -public class ProjectModelResolverFactory - implements RegistryListener, Initializable -{ - private Logger log = LoggerFactory.getLogger( ProjectModelResolverFactory.class ); - - /** - * @plexus.requirement - */ - private ArchivaConfiguration archivaConfiguration; - - /** - * @plexus.requirement - */ - private RepositoryContentFactory repositoryFactory; - - private ProjectModelResolverStack currentResolverStack = new ProjectModelResolverStack(); - - public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue ) - { - if ( ConfigurationNames.isManagedRepositories( propertyName ) ) - { - update(); - } - } - - public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue ) - { - /* do nothing */ - } - - public ProjectModelResolverStack getCurrentResolverStack() - { - return currentResolverStack; - } - - public void initialize() - throws InitializationException - { - update(); - archivaConfiguration.addChangeListener( this ); - } - - private ManagedRepositoryProjectResolver toResolver( ManagedRepositoryConfiguration repo ) - throws RepositoryException - { - ManagedRepositoryContent repoContent = repositoryFactory.getManagedRepositoryContent( repo.getId() ); - - ProjectModelReader reader; - if ( StringUtils.equals( "legacy", repo.getLayout() ) ) - { - reader = new ProjectModel300Reader(); - } - else - { - reader = new ProjectModel400Reader(); - } - - return new ManagedRepositoryProjectResolver( repoContent, reader ); - } - - private void update() - { - synchronized ( currentResolverStack ) - { - this.currentResolverStack.clearResolvers(); - - List<ManagedRepositoryConfiguration> list = - archivaConfiguration.getConfiguration().getManagedRepositories(); - for ( ManagedRepositoryConfiguration repo : list ) - { - try - { - ManagedRepositoryProjectResolver resolver = toResolver( repo ); - - // Add filesystem based resolver. - this.currentResolverStack.addProjectModelResolver( resolver ); - } - catch ( RepositoryException e ) - { - log.warn( e.getMessage(), e ); - } - } - - // Add no-op resolver. - this.currentResolverStack.addProjectModelResolver( NopProjectResolver.getInstance() ); - } - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelWriter.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelWriter.java deleted file mode 100644 index d2054cec8..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/ProjectModelWriter.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.apache.maven.archiva.repository.project; - -/* - * 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.maven.archiva.model.ArchivaProjectModel; - -import java.io.File; -import java.io.IOException; -import java.io.Writer; - -/** - * ProjectModelWriter - * - * @version $Id$ - */ -public interface ProjectModelWriter -{ - /** - * Write a project model out to disk. - * - * @param model the model to write. - * @param pomFile the (pom) file on disk to write to. - * @throws ProjectModelException if there was a problem with the model itself. - * @throws IOException if there was a problem writing the pom file. - */ - public void write( ArchivaProjectModel model, File pomFile ) - throws ProjectModelException, IOException; - - /** - * Write a project model out to a {@link Writer}. - * - * @param model the model to write. - * @param writer the writer (stream) to write to. - * @throws ProjectModelException if there was a problem with the model itself. - * @throws IOException if there was a problem writing the pom file. - */ - public void write( ArchivaProjectModel model, Writer writer ) - throws ProjectModelException, IOException; -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilter.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilter.java deleted file mode 100644 index 04bec93af..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilter.java +++ /dev/null @@ -1,312 +0,0 @@ -package org.apache.maven.archiva.repository.project.filters; - -/* - * 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.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.model.ArchivaModelCloner; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.Dependency; -import org.apache.maven.archiva.model.IssueManagement; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelFilter; -import org.apache.maven.archiva.repository.project.ProjectModelMerge; -import org.apache.maven.archiva.repository.project.ProjectModelResolverFactory; -import org.codehaus.plexus.cache.Cache; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * Builder for the Effective Project Model. - * - * @version $Id$ - * @plexus.component role="org.apache.maven.archiva.repository.project.ProjectModelFilter" - * role-hint="effective" - */ -public class EffectiveProjectModelFilter - implements ProjectModelFilter -{ - private ProjectModelFilter expressionFilter = new ProjectModelExpressionFilter(); - - /** - * @plexus.requirement - */ - private ProjectModelResolverFactory resolverFactory; - - /** - * @plexus.requirement role-hint="effective-project-cache" - */ - private Cache effectiveProjectCache; - - /** - * Take the provided {@link ArchivaProjectModel} and build the effective {@link ArchivaProjectModel}. - * - * Steps: - * 1) Expand any expressions / properties. - * 2) Walk the parent project references and merge. - * 3) Apply dependency management settings. - * - * @param project the project to create the effective {@link ArchivaProjectModel} from. - * @return a the effective {@link ArchivaProjectModel}. - * @throws ProjectModelException if there was a problem building the effective pom. - */ - public ArchivaProjectModel filter( final ArchivaProjectModel project ) - throws ProjectModelException - { - if ( project == null ) - { - return null; - } - - if ( resolverFactory.getCurrentResolverStack().isEmpty() ) - { - throw new IllegalStateException( "Unable to build effective pom with no project model resolvers defined." ); - } - - ArchivaProjectModel effectiveProject; - String projectKey = toProjectKey( project ); - - synchronized ( effectiveProjectCache ) - { - if ( effectiveProjectCache.hasKey( projectKey ) ) - { - DEBUG( "Fetching (from cache/projectKey): " + projectKey ); - effectiveProject = (ArchivaProjectModel) effectiveProjectCache.get( projectKey ); - return effectiveProject; - } - } - - // Clone submitted project (so that we don't mess with it) - effectiveProject = ArchivaModelCloner.clone( project ); - - DEBUG( "Starting build of effective with: " + effectiveProject ); - - // Merge in all the parent poms. - effectiveProject = mergeParent( effectiveProject ); - - // Setup Expression Evaluation pieces. - effectiveProject = expressionFilter.filter( effectiveProject ); - - // Resolve dependency versions from dependency management. - applyDependencyManagement( effectiveProject ); - - // groupId or version could be updated by parent or expressions - projectKey = toProjectKey( effectiveProject ); - - // Do not add project into cache if it contains no groupId and - // version information - if ( effectiveProject.getGroupId() != null && effectiveProject.getVersion() != null ) - { - synchronized ( effectiveProjectCache ) - { - DEBUG( "Putting (to cache/projectKey): " + projectKey ); - effectiveProjectCache.put( projectKey, effectiveProject ); - } - } - - // Return what we got. - return effectiveProject; - } - - private void applyDependencyManagement( ArchivaProjectModel pom ) - { - if ( CollectionUtils.isEmpty( pom.getDependencyManagement() ) - || CollectionUtils.isEmpty( pom.getDependencies() ) ) - { - // Nothing to do. All done! - return; - } - - Map<String, Dependency> managedDependencies = createDependencyMap( pom.getDependencyManagement() ); - Iterator<Dependency> it = pom.getDependencies().iterator(); - while ( it.hasNext() ) - { - Dependency dep = it.next(); - String key = toVersionlessDependencyKey( dep ); - - // Do we need to do anything? - if ( managedDependencies.containsKey( key ) ) - { - Dependency mgmtDep = (Dependency) managedDependencies.get( key ); - - dep.setVersion( mgmtDep.getVersion() ); - dep.setScope( mgmtDep.getScope() ); - dep.setExclusions( ProjectModelMerge.mergeExclusions( dep.getExclusions(), mgmtDep.getExclusions() ) ); - } - } - } - - private ArchivaProjectModel mergeParent( ArchivaProjectModel pom ) - throws ProjectModelException - { - ArchivaProjectModel mixedProject; - - DEBUG( "Project: " + toProjectKey( pom ) ); - - if ( pom.getParentProject() != null ) - { - // Use parent reference. - VersionedReference parentRef = pom.getParentProject(); - - String parentKey = VersionedReference.toKey( parentRef ); - - DEBUG( "Has parent: " + parentKey ); - - ArchivaProjectModel parentProject; - - synchronized ( effectiveProjectCache ) - { - // is the pre-merged parent in the cache? - if ( effectiveProjectCache.hasKey( parentKey ) ) - { - DEBUG( "Fetching (from cache/parentKey): " + parentKey ); - // Use the one from the cache. - parentProject = (ArchivaProjectModel) effectiveProjectCache.get( parentKey ); - } - else - { - // Look it up, using resolvers. - parentProject = this.resolverFactory.getCurrentResolverStack().findProject( parentRef ); - } - } - - if ( parentProject != null ) - { - // Merge the pom with the parent pom. - parentProject = mergeParent( parentProject ); - parentProject = expressionFilter.filter( parentProject ); - - // Cache the pre-merged parent. - synchronized ( effectiveProjectCache ) - { - DEBUG( "Putting (to cache/parentKey/merged): " + parentKey ); - // Add the merged parent pom to the cache. - effectiveProjectCache.put( parentKey, parentProject ); - } - - // Now merge the parent with the current - mixedProject = ProjectModelMerge.merge( pom, parentProject ); - } - else - { - // Shortcircuit due to missing parent pom. - // TODO: Document this via a monitor. - mixedProject = mixinSuperPom( pom ); - - // Cache the non-existant parent. - synchronized ( effectiveProjectCache ) - { - DEBUG( "Putting (to cache/parentKey/basicPom): " + parentKey ); - // Add the basic pom to cache. - effectiveProjectCache.put( parentKey, createBasicPom( parentRef ) ); - } - } - } - else - { - DEBUG( "No parent found" ); - - /* Mix in the super-pom. - * - * Super POM from maven/components contains many things. - * However, for purposes of archiva, only the <repositories> - * and <pluginRepositories> sections are of any value. - */ - - mixedProject = mixinSuperPom( pom ); - } - - return mixedProject; - } - - private ArchivaProjectModel createBasicPom( VersionedReference ref ) - { - ArchivaProjectModel model = new ArchivaProjectModel(); - model.setGroupId( ref.getGroupId() ); - model.setArtifactId( ref.getArtifactId() ); - model.setVersion( ref.getVersion() ); - model.setPackaging( "jar" ); - - return model; - } - - /** - * Super POM from maven/components contains many things. - * However, for purposes of archiva, only the <repositories> - * and <pluginRepositories> sections are of any value. - * - * @param pom - * @return - */ - private ArchivaProjectModel mixinSuperPom( ArchivaProjectModel pom ) - { - // TODO: add super pom repositories. - DEBUG( "Mix in Super POM: " + pom ); - - return pom; - } - - private static Map<String, Dependency> createDependencyMap( List<Dependency> dependencies ) - { - Map<String, Dependency> ret = new HashMap<String, Dependency>(); - - Iterator<Dependency> it = dependencies.iterator(); - while ( it.hasNext() ) - { - Dependency dep = it.next(); - String key = toVersionlessDependencyKey( dep ); - ret.put( key, dep ); - } - - return ret; - } - - private static String toVersionlessDependencyKey( Dependency dep ) - { - StringBuffer key = new StringBuffer(); - - key.append( dep.getGroupId() ).append( ":" ).append( dep.getArtifactId() ); - key.append( StringUtils.defaultString( dep.getClassifier() ) ).append( ":" ); - key.append( dep.getType() ); - - return key.toString(); - } - - private String toProjectKey( ArchivaProjectModel project ) - { - StringBuffer key = new StringBuffer(); - - key.append( project.getGroupId() ).append( ":" ); - key.append( project.getArtifactId() ).append( ":" ); - key.append( project.getVersion() ); - - return key.toString(); - } - - private void DEBUG( String msg ) - { - // Used in debugging of this object. - // System.out.println( "[EffectiveProjectModelFilter] " + msg ); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionFilter.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionFilter.java deleted file mode 100644 index 26277dec6..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionFilter.java +++ /dev/null @@ -1,458 +0,0 @@ -package org.apache.maven.archiva.repository.project.filters; - -/* - * 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.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.model.ArchivaModelCloner; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.ArtifactReference; -import org.apache.maven.archiva.model.CiManagement; -import org.apache.maven.archiva.model.Dependency; -import org.apache.maven.archiva.model.Exclusion; -import org.apache.maven.archiva.model.Individual; -import org.apache.maven.archiva.model.IssueManagement; -import org.apache.maven.archiva.model.License; -import org.apache.maven.archiva.model.MailingList; -import org.apache.maven.archiva.model.Organization; -import org.apache.maven.archiva.model.ProjectRepository; -import org.apache.maven.archiva.model.Scm; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelFilter; -import org.codehaus.plexus.evaluator.DefaultExpressionEvaluator; -import org.codehaus.plexus.evaluator.EvaluatorException; -import org.codehaus.plexus.evaluator.ExpressionEvaluator; -import org.codehaus.plexus.evaluator.ExpressionSource; -import org.codehaus.plexus.evaluator.sources.PropertiesExpressionSource; -import org.codehaus.plexus.evaluator.sources.SystemPropertyExpressionSource; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Properties; -import java.util.Set; - -/** - * ProjectModelExpressionFilter - * - * @version $Id$ - * @plexus.component role="org.apache.maven.archiva.repository.project.ProjectModelFilter" - * role-hint="expression" - * instantiation-strategy="per-lookup" - */ -public class ProjectModelExpressionFilter - implements ProjectModelFilter -{ - private ExpressionEvaluator evaluator = new DefaultExpressionEvaluator(); - - /** - * Find and Evaluate the Expressions present in the model. - * - * @param model the model to correct. - */ - @SuppressWarnings("unchecked") - public ArchivaProjectModel filter( final ArchivaProjectModel model ) - throws ProjectModelException - { - Properties props = new Properties(); - - if ( model.getProperties() != null ) - { - props.putAll( model.getProperties() ); - } - - ArchivaProjectModel ret = ArchivaModelCloner.clone( model ); - - // TODO: should probably clone evaluator to prevent threading issues. - synchronized ( evaluator ) - { - // TODO: create .resetSources() method in ExpressionEvaluator project on plexus side. - // Remove previous expression sources. - List<ExpressionSource> oldSources = new ArrayList<ExpressionSource>(); - oldSources.addAll( evaluator.getExpressionSourceList() ); - for ( ExpressionSource exprSrc : oldSources ) - { - evaluator.removeExpressionSource( exprSrc ); - } - - // Setup new sources (based on current model) - PropertiesExpressionSource propsSource = new PropertiesExpressionSource(); - propsSource.setProperties( props ); - evaluator.addExpressionSource( propsSource ); - - // Add system properties to the mix. - evaluator.addExpressionSource( new SystemPropertyExpressionSource() ); - - try - { - // Setup some common properties. - VersionedReference parent = model.getParentProject(); - if ( parent != null ) - { - String parentGroupId = StringUtils.defaultString( evaluator.expand( parent.getGroupId() ) ); - String parentArtifactId = StringUtils.defaultString( evaluator.expand( parent.getArtifactId() ) ); - String parentVersion = StringUtils.defaultString( evaluator.expand( parent.getVersion() ) ); - - props.setProperty( "parent.groupId", parentGroupId ); - props.setProperty( "parent.artifactId", parentArtifactId ); - props.setProperty( "parent.version", parentVersion ); - } - - String groupId = StringUtils.defaultString( evaluator.expand( model.getGroupId() ) ); - String artifactId = StringUtils.defaultString( evaluator.expand( model.getArtifactId() ) ); - String version = StringUtils.defaultString( evaluator.expand( model.getVersion() ) ); - String name = StringUtils.defaultString( evaluator.expand( model.getName() ) ); - - - /* Archiva doesn't need to handle a full expression language with object tree walking - * as the requirements within Archiva are much smaller, a quick replacement of the - * important fields (groupId, artifactId, version, name) are handled specifically. - */ - props.setProperty( "pom.groupId", groupId ); - props.setProperty( "pom.artifactId", artifactId ); - props.setProperty( "pom.version", version ); - props.setProperty( "pom.name", name ); - props.setProperty( "project.groupId", groupId ); - props.setProperty( "project.artifactId", artifactId ); - props.setProperty( "project.version", version ); - props.setProperty( "project.name", name ); - - // Evaluate everything. - ret.setVersion( evaluator.expand( ret.getVersion() ) ); - ret.setGroupId( evaluator.expand( ret.getGroupId() ) ); - ret.setName( evaluator.expand( ret.getName() ) ); - ret.setDescription( evaluator.expand( ret.getDescription() ) ); - ret.setPackaging( evaluator.expand( ret.getPackaging() ) ); - ret.setUrl( evaluator.expand( ret.getUrl() ) ); - - evaluateParentProject( evaluator, ret.getParentProject() ); - - evaluateBuildExtensions( evaluator, ret.getBuildExtensions() ); - evaluateCiManagement( evaluator, ret.getCiManagement() ); - evaluateDependencyList( evaluator, ret.getDependencies() ); - evaluateDependencyList( evaluator, ret.getDependencyManagement() ); - evaluateIndividuals( evaluator, ret.getIndividuals() ); - evaluateIssueManagement( evaluator, ret.getIssueManagement() ); - evaluateLicenses( evaluator, ret.getLicenses() ); - evaluateMailingLists( evaluator, ret.getMailingLists() ); - evaluateOrganization( evaluator, ret.getOrganization() ); - evaluatePlugins( evaluator, ret.getPlugins() ); - evaluateRelocation( evaluator, ret.getRelocation() ); - evaluateReports( evaluator, ret.getReports() ); - evaluateRepositories( evaluator, ret.getRepositories() ); - evaluateScm( evaluator, ret.getScm() ); - } - catch ( EvaluatorException e ) - { - throw new ProjectModelException( "Unable to evaluate expression in model: " + e.getMessage(), e ); - } - } - - return ret; - } - - private void evaluateArtifactReferenceList( ExpressionEvaluator eval, List<ArtifactReference> refs ) - throws EvaluatorException - { - if ( CollectionUtils.isEmpty( refs ) ) - { - return; - } - - for ( ArtifactReference ref : refs ) - { - ref.setGroupId( eval.expand( ref.getGroupId() ) ); - ref.setArtifactId( eval.expand( ref.getArtifactId() ) ); - ref.setVersion( eval.expand( ref.getVersion() ) ); - ref.setClassifier( eval.expand( ref.getClassifier() ) ); - ref.setType( eval.expand( ref.getType() ) ); - } - } - - private void evaluateBuildExtensions( ExpressionEvaluator eval, List<ArtifactReference> buildExtensions ) - throws EvaluatorException - { - if ( CollectionUtils.isEmpty( buildExtensions ) ) - { - return; - } - - for ( ArtifactReference ref : buildExtensions ) - { - ref.setGroupId( eval.expand( ref.getGroupId() ) ); - ref.setArtifactId( eval.expand( ref.getArtifactId() ) ); - ref.setVersion( eval.expand( ref.getVersion() ) ); - ref.setClassifier( eval.expand( ref.getClassifier() ) ); - ref.setType( eval.expand( ref.getType() ) ); - } - } - - private void evaluateCiManagement( ExpressionEvaluator eval, CiManagement ciManagement ) - throws EvaluatorException - { - if ( ciManagement == null ) - { - return; - } - - ciManagement.setSystem( eval.expand( ciManagement.getSystem() ) ); - ciManagement.setUrl( eval.expand( ciManagement.getUrl() ) ); - ciManagement.setCiUrl( eval.expand( ciManagement.getCiUrl() ) ); - } - - private void evaluateDependencyList( ExpressionEvaluator eval, List<Dependency> dependencies ) - throws EvaluatorException - { - if ( CollectionUtils.isEmpty( dependencies ) ) - { - return; - } - - for ( Dependency dependency : dependencies ) - { - dependency.setGroupId( eval.expand( dependency.getGroupId() ) ); - dependency.setArtifactId( eval.expand( dependency.getArtifactId() ) ); - dependency.setVersion( eval.expand( dependency.getVersion() ) ); - dependency.setScope( eval.expand( dependency.getScope() ) ); - dependency.setType( eval.expand( dependency.getType() ) ); - dependency.setUrl( eval.expand( dependency.getUrl() ) ); - - evaluateExclusions( eval, dependency.getExclusions() ); - } - } - - private void evaluateExclusions( ExpressionEvaluator eval, List<Exclusion> exclusions ) - throws EvaluatorException - { - if ( CollectionUtils.isEmpty( exclusions ) ) - { - return; - } - - for ( Exclusion exclusion : exclusions ) - { - exclusion.setGroupId( eval.expand( exclusion.getGroupId() ) ); - exclusion.setArtifactId( eval.expand( exclusion.getArtifactId() ) ); - } - } - - private void evaluateIndividuals( ExpressionEvaluator eval, List<Individual> individuals ) - throws EvaluatorException - { - if ( CollectionUtils.isEmpty( individuals ) ) - { - return; - } - - for ( Individual individual : individuals ) - { - individual.setPrincipal( eval.expand( individual.getPrincipal() ) ); - individual.setName( eval.expand( individual.getName() ) ); - individual.setEmail( eval.expand( individual.getEmail() ) ); - individual.setTimezone( eval.expand( individual.getTimezone() ) ); - individual.setOrganization( eval.expand( individual.getOrganization() ) ); - individual.setOrganizationUrl( eval.expand( individual.getOrganizationUrl() ) ); - individual.setUrl( eval.expand( individual.getUrl() ) ); - individual.setIndividualEmail( eval.expand( individual.getIndividualEmail() ) ); - - evaluateProperties( eval, individual.getProperties() ); - evaluateStringList( eval, individual.getRoles() ); - } - } - - private void evaluateIssueManagement( ExpressionEvaluator eval, IssueManagement issueManagement ) - throws EvaluatorException - { - if ( issueManagement == null ) - { - return; - } - - issueManagement.setSystem( eval.expand( issueManagement.getSystem() ) ); - issueManagement.setUrl( eval.expand( issueManagement.getUrl() ) ); - issueManagement.setIssueManagementUrl( eval.expand( issueManagement.getIssueManagementUrl() ) ); - } - - private void evaluateLicenses( ExpressionEvaluator eval, List<License> licenses ) - throws EvaluatorException - { - if ( CollectionUtils.isEmpty( licenses ) ) - { - return; - } - - for ( License license : licenses ) - { - license.setName( eval.expand( license.getName() ) ); - license.setUrl( eval.expand( license.getUrl() ) ); - license.setComments( eval.expand( license.getComments() ) ); - } - } - - private void evaluateMailingLists( ExpressionEvaluator eval, List<MailingList> mailingLists ) - throws EvaluatorException - { - if ( CollectionUtils.isEmpty( mailingLists ) ) - { - return; - } - - for ( MailingList mlist : mailingLists ) - { - mlist.setName( eval.expand( mlist.getName() ) ); - mlist.setSubscribeAddress( eval.expand( mlist.getSubscribeAddress() ) ); - mlist.setUnsubscribeAddress( eval.expand( mlist.getUnsubscribeAddress() ) ); - mlist.setPostAddress( eval.expand( mlist.getPostAddress() ) ); - mlist.setMainArchiveUrl( eval.expand( mlist.getMainArchiveUrl() ) ); - - evaluateStringList( eval, mlist.getOtherArchives() ); - } - } - - private void evaluateOrganization( ExpressionEvaluator eval, Organization organization ) - throws EvaluatorException - { - if ( organization == null ) - { - return; - } - - organization.setOrganizationName( eval.expand( organization.getOrganizationName() ) ); - organization.setName( eval.expand( organization.getName() ) ); - organization.setUrl( eval.expand( organization.getUrl() ) ); - organization.setFavicon( eval.expand( organization.getFavicon() ) ); - } - - private void evaluateParentProject( ExpressionEvaluator eval, VersionedReference parentProject ) - throws EvaluatorException - { - if ( parentProject == null ) - { - return; - } - - parentProject.setGroupId( eval.expand( parentProject.getGroupId() ) ); - parentProject.setArtifactId( eval.expand( parentProject.getArtifactId() ) ); - parentProject.setVersion( eval.expand( parentProject.getVersion() ) ); - } - - private void evaluatePlugins( ExpressionEvaluator eval, List<ArtifactReference> plugins ) - throws EvaluatorException - { - evaluateArtifactReferenceList( eval, plugins ); - } - - private void evaluateProperties( ExpressionEvaluator eval, Properties props ) - throws EvaluatorException - { - if ( props == null ) - { - return; - } - - // Only evaluate the values, not the keys. - - // Collect the key names. (Done ahead of time to prevent iteration / concurrent modification exceptions) - Set<String> keys = new HashSet<String>(); - for ( Object obj : props.keySet() ) - { - keys.add( (String) obj ); - } - - // Evaluate all of the values. - for ( String key : keys ) - { - String value = props.getProperty( key ); - props.setProperty( key, eval.expand( value ) ); - } - } - - private void evaluateRelocation( ExpressionEvaluator eval, VersionedReference relocation ) - throws EvaluatorException - { - if ( relocation == null ) - { - return; - } - - relocation.setGroupId( eval.expand( relocation.getGroupId() ) ); - relocation.setArtifactId( eval.expand( relocation.getArtifactId() ) ); - relocation.setVersion( eval.expand( relocation.getVersion() ) ); - } - - private void evaluateReports( ExpressionEvaluator eval, List<ArtifactReference> reports ) - throws EvaluatorException - { - evaluateArtifactReferenceList( eval, reports ); - } - - private void evaluateRepositories( ExpressionEvaluator eval, List<ProjectRepository> repositories ) - throws EvaluatorException - { - if ( CollectionUtils.isEmpty( repositories ) ) - { - return; - } - - for ( ProjectRepository repository : repositories ) - { - repository.setId( eval.expand( repository.getId() ) ); - repository.setLayout( eval.expand( repository.getLayout() ) ); - repository.setName( eval.expand( repository.getName() ) ); - repository.setUrl( eval.expand( repository.getUrl() ) ); - } - } - - private void evaluateScm( ExpressionEvaluator eval, Scm scm ) - throws EvaluatorException - { - if ( scm == null ) - { - return; - } - - scm.setConnection( eval.expand( scm.getConnection() ) ); - scm.setDeveloperConnection( eval.expand( scm.getDeveloperConnection() ) ); - scm.setUrl( eval.expand( scm.getUrl() ) ); - } - - private void evaluateStringList( ExpressionEvaluator eval, List<String> strings ) - throws EvaluatorException - { - if ( CollectionUtils.isEmpty( strings ) ) - { - return; - } - - // Create new list to hold post-evaluated strings. - List<String> evaluated = new ArrayList<String>(); - - // Evaluate them all - for ( String str : strings ) - { - evaluated.add( eval.expand( str ) ); - } - - // Populate the original list with the post-evaluated list. - strings.clear(); - strings.addAll( evaluated ); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel300Reader.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel300Reader.java deleted file mode 100644 index 863a55d42..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel300Reader.java +++ /dev/null @@ -1,415 +0,0 @@ -package org.apache.maven.archiva.repository.project.readers; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.ArtifactReference; -import org.apache.maven.archiva.model.Dependency; -import org.apache.maven.archiva.model.Individual; -import org.apache.maven.archiva.model.IssueManagement; -import org.apache.maven.archiva.model.License; -import org.apache.maven.archiva.model.MailingList; -import org.apache.maven.archiva.model.Organization; -import org.apache.maven.archiva.model.ProjectRepository; -import org.apache.maven.archiva.model.Scm; -import org.apache.maven.archiva.repository.project.ProjectModelReader; -import org.apache.maven.archiva.xml.XMLException; -import org.apache.maven.archiva.xml.XMLReader; -import org.dom4j.Element; - -/** - * ProjectModel300Reader - * - * @version $Id$ - */ -public class ProjectModel300Reader - implements ProjectModelReader -{ - - public ArchivaProjectModel read( File pomFile ) - throws XMLException - { - XMLReader xml = new XMLReader( "project", pomFile ); - - ArchivaProjectModel model = new ArchivaProjectModel(); - - xml.removeNamespaces(); - - Element project = xml.getElement( "//project" ); - - // TODO: Handle <extend /> ?? (is this even possible?) - - model.setGroupId( project.elementTextTrim( "groupId" ) ); - model.setArtifactId( project.elementTextTrim( "artifactId" ) ); - // TODO: Handle <id /> - model.setVersion( project.elementTextTrim( "currentVersion" ) ); - model.setName( project.elementTextTrim( "name" ) ); - model.setDescription( project.elementTextTrim( "description" ) ); - // TODO: what to do with <shortDescription /> ? - model.setUrl( project.elementTextTrim( "url" ) ); - // TODO: Handle <logo /> - // TODO: Handle <inceptionYear /> - - model.setIssueManagement( getIssueManagement( xml ) ); - // TODO: What to do with <gumpRepositoryId /> ? - // TODO: Handle <siteAddress /> - // TODO: Handle <siteDirectory /> ? - // TODO: Handle <distributionSite /> - // TODO: Handle <distributionDirectory /> - model.setMailingLists( getMailingLists( xml ) ); - model.setIndividuals( getIndividuals( xml ) ); - model.setLicenses( getLicenses( xml ) ); - model.setReports( getReports( xml ) ); - model.setRepositories( getRepositories( xml ) ); - model.setScm( getSCM( xml ) ); - model.setOrganization( getOrganization( xml ) ); - model.setProperties( getProperties( xml.getElement( "//project/properties" ) ) ); - model.setDependencies( getDependencies( xml ) ); - - model.setOrigin( "filesystem" ); - - /* - * Following are not valid for <pomVersion>3</pomVersion> / Maven 1 pom files. model.setDependencyManagement() - * model.setPlugins() model.setParentProject() model.setPackaging() model.setCiManagement() - * model.setBuildExtensions() model.setRelocation() - */ - - return model; - } - - private ArtifactReference getArtifactReference( Element elemPlugin, String defaultType ) - { - ArtifactReference reference = new ArtifactReference(); - - reference.setGroupId( StringUtils.defaultString( elemPlugin.elementTextTrim( "groupId" ) ) ); - reference.setArtifactId( elemPlugin.elementTextTrim( "artifactId" ) ); - reference.setVersion( StringUtils.defaultString( elemPlugin.elementTextTrim( "version" ) ) ); - reference.setClassifier( StringUtils.defaultString( elemPlugin.elementTextTrim( "classifier" ) ) ); - reference.setType( StringUtils.defaultIfEmpty( elemPlugin.elementTextTrim( "type" ), defaultType ) ); - - return reference; - } - - /** - * Get List of {@link ArtifactReference} objects from xpath expr. - */ - private List<ArtifactReference> getArtifactReferenceList( XMLReader xml, String xpathExpr, String defaultType ) - throws XMLException - { - List<ArtifactReference> refs = new ArrayList<ArtifactReference>(); - - Iterator<Element> it = xml.getElementList( xpathExpr ).iterator(); - while ( it.hasNext() ) - { - Element elemPlugin = it.next(); - - refs.add( getArtifactReference( elemPlugin, defaultType ) ); - } - - return refs; - } - - private List<Dependency> getDependencies( XMLReader xml ) - throws XMLException - { - return getDependencyList( xml, new String[] { "dependencies" } ); - } - - @SuppressWarnings("unchecked") - private List<Dependency> getDependencyList( XMLReader xml, String parts[] ) - throws XMLException - { - List<Dependency> dependencyList = new ArrayList<Dependency>(); - - Element project = xml.getElement( "//project" ); - - Element depsParent = project; - - for ( String part : parts ) - { - depsParent = depsParent.element( part ); - if ( depsParent == null ) - { - return dependencyList; - } - } - - Iterator<Element> it = depsParent.elementIterator( "dependency" ); - while ( it.hasNext() ) - { - Element elemDependency = it.next(); - Dependency dependency = new Dependency(); - - dependency.setGroupId( elemDependency.elementTextTrim( "groupId" ) ); - dependency.setArtifactId( elemDependency.elementTextTrim( "artifactId" ) ); - dependency.setVersion( elemDependency.elementTextTrim( "version" ) ); - - dependency.setType( StringUtils.defaultIfEmpty( elemDependency.elementTextTrim( "type" ), "jar" ) ); - dependency.setUrl( elemDependency.elementTextTrim( "url" ) ); - /* Following are not valid for <pomVersion>3</pomVersion> / Maven 1 pom files. - * - * dependency.setClassifier( StringUtils.defaultString( elemDependency.elementTextTrim( "classifier" ) ) ); - * dependency.setScope( StringUtils.defaultIfEmpty( elemDependency.elementTextTrim( "scope" ), "compile" ) ); - * dependency.setOptional( toBoolean( elemDependency.elementTextTrim( "optional" ), false ) ); - */ - - dependency.setSystemPath( elemDependency.elementTextTrim( "jar" ) ); - - if ( dependencyList.contains( dependency ) ) - { - // TODO: throw into monitor as "duplicate dependency" issue. - } - - dependencyList.add( dependency ); - } - - return dependencyList; - } - - private List<Individual> getIndividuals( XMLReader xml ) - throws XMLException - { - List<Individual> individuals = new ArrayList<Individual>(); - - individuals.addAll( getIndividuals( xml, true, "//project/developers/developer" ) ); - individuals.addAll( getIndividuals( xml, false, "//project/contributors/contributor" ) ); - - return individuals; - } - - @SuppressWarnings("unchecked") - private List<Individual> getIndividuals( XMLReader xml, boolean isCommitor, String xpathExpr ) - throws XMLException - { - List<Individual> ret = new ArrayList<Individual>(); - - List<Element> modelPersonList = xml.getElementList( xpathExpr ); - - Iterator<Element> iter = modelPersonList.iterator(); - while ( iter.hasNext() ) - { - Element elemPerson = iter.next(); - Individual individual = new Individual(); - - if ( isCommitor ) - { - individual.setPrincipal( elemPerson.elementTextTrim( "id" ) ); - } - - individual.setCommitor( isCommitor ); - individual.setEmail( elemPerson.elementTextTrim( "email" ) ); - individual.setName( elemPerson.elementTextTrim( "name" ) ); - individual.setOrganization( elemPerson.elementTextTrim( "organization" ) ); - individual.setOrganizationUrl( elemPerson.elementTextTrim( "organizationUrl" ) ); - individual.setUrl( elemPerson.elementTextTrim( "url" ) ); - individual.setTimezone( elemPerson.elementTextTrim( "timezone" ) ); - individual.setIndividualEmail( elemPerson.elementTextTrim( "email" ) ); - - // Roles - Element elemRoles = elemPerson.element( "roles" ); - if ( elemRoles != null ) - { - List<Element> roleNames = elemRoles.elements( "role" ); - Iterator<Element> itRole = roleNames.iterator(); - while ( itRole.hasNext() ) - { - Element role = itRole.next(); - individual.addRole( role.getTextTrim() ); - } - } - - // Properties - individual.setProperties( getProperties( elemPerson.element( "properties" ) ) ); - - ret.add( individual ); - } - - return ret; - } - - private IssueManagement getIssueManagement( XMLReader xml ) - throws XMLException - { - Element issueTrackingUrlElem = xml.getElement( "//project/issueTrackingUrl" ); - - if ( issueTrackingUrlElem == null ) - { - return null; - } - - String issueTrackingUrl = issueTrackingUrlElem.getTextTrim(); - if ( StringUtils.isBlank( issueTrackingUrl ) ) - { - return null; - } - - IssueManagement issueMgmt = new IssueManagement(); - issueMgmt.setUrl( issueTrackingUrl ); - issueMgmt.setIssueManagementUrl( issueTrackingUrl ); - - return issueMgmt; - } - - @SuppressWarnings("unchecked") - private List<License> getLicenses( XMLReader xml ) - throws XMLException - { - List<License> licenses = new ArrayList<License>(); - - Element elemLicenses = xml.getElement( "//project/licenses" ); - - if ( elemLicenses != null ) - { - List<Element> licenseList = elemLicenses.elements( "license" ); - for ( Element elemLicense : licenseList ) - { - License license = new License(); - - // TODO: Create LicenseIdentity class to managed license ids. - // license.setId( elemLicense.elementTextTrim("id") ); - license.setName( elemLicense.elementTextTrim( "name" ) ); - license.setUrl( elemLicense.elementTextTrim( "url" ) ); - license.setComments( elemLicense.elementTextTrim( "comments" ) ); - - licenses.add( license ); - } - } - - return licenses; - } - - @SuppressWarnings("unchecked") - private List<MailingList> getMailingLists( XMLReader xml ) - throws XMLException - { - List<MailingList> mailingLists = new ArrayList<MailingList>(); - - List<Element> mailingListElems = xml.getElementList( "//project/mailingLists/mailingList" ); - for ( Element elemMailingList : mailingListElems ) - { - MailingList mlist = new MailingList(); - - mlist.setName( elemMailingList.elementTextTrim( "name" ) ); - mlist.setSubscribeAddress( elemMailingList.elementTextTrim( "subscribe" ) ); - mlist.setUnsubscribeAddress( elemMailingList.elementTextTrim( "unsubscribe" ) ); - mlist.setPostAddress( elemMailingList.elementTextTrim( "post" ) ); - mlist.setMainArchiveUrl( elemMailingList.elementTextTrim( "archive" ) ); - - Element elemOtherArchives = elemMailingList.element( "otherArchives" ); - if ( elemOtherArchives != null ) - { - List<String> otherArchives = new ArrayList<String>(); - List<Element> others = elemOtherArchives.elements( "otherArchive" ); - for ( Element other : others ) - { - String otherArchive = other.getTextTrim(); - otherArchives.add( otherArchive ); - } - - mlist.setOtherArchives( otherArchives ); - } - - mailingLists.add( mlist ); - } - - return mailingLists; - } - - private Organization getOrganization( XMLReader xml ) - throws XMLException - { - Element elemOrg = xml.getElement( "//project/organization" ); - if ( elemOrg != null ) - { - Organization org = new Organization(); - - org.setOrganizationName( elemOrg.elementTextTrim( "name" ) ); - org.setName( elemOrg.elementTextTrim( "name" ) ); - org.setUrl( elemOrg.elementTextTrim( "url" ) ); - // TODO: Handle <logo /> - - return org; - } - - return null; - } - - @SuppressWarnings("unchecked") - private Properties getProperties( Element elemProperties ) - { - if ( elemProperties == null ) - { - return null; - } - - Properties ret = new Properties(); - - Iterator<Element> itProps = elemProperties.elements().iterator(); - while ( itProps.hasNext() ) - { - Element elemProp = (Element) itProps.next(); - ret.setProperty( elemProp.getName(), elemProp.getText() ); - } - - return ret; - } - - private List<ArtifactReference> getReports( XMLReader xml ) - throws XMLException - { - return getArtifactReferenceList( xml, "//project/reports/plugins/plugin", "maven-plugin" ); - } - - private List<ProjectRepository> getRepositories( XMLReader xml ) - throws XMLException - { - List<ProjectRepository> repos = new ArrayList<ProjectRepository>(); - - // Repositories are not stored within the maven 1 pom. - - return repos; - } - - private Scm getSCM( XMLReader xml ) - throws XMLException - { - Element elemScm = xml.getElement( "//project/repository" ); - - if ( elemScm != null ) - { - Scm scm = new Scm(); - - scm.setConnection( elemScm.elementTextTrim( "connection" ) ); - scm.setDeveloperConnection( elemScm.elementTextTrim( "developerConnection" ) ); - scm.setUrl( elemScm.elementTextTrim( "url" ) ); - - return scm; - } - - return null; - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel400Reader.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel400Reader.java deleted file mode 100644 index 399fcbfa1..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/readers/ProjectModel400Reader.java +++ /dev/null @@ -1,549 +0,0 @@ -package org.apache.maven.archiva.repository.project.readers; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.ArtifactReference; -import org.apache.maven.archiva.model.CiManagement; -import org.apache.maven.archiva.model.Dependency; -import org.apache.maven.archiva.model.DependencyScope; -import org.apache.maven.archiva.model.Exclusion; -import org.apache.maven.archiva.model.Individual; -import org.apache.maven.archiva.model.IssueManagement; -import org.apache.maven.archiva.model.License; -import org.apache.maven.archiva.model.MailingList; -import org.apache.maven.archiva.model.Organization; -import org.apache.maven.archiva.model.ProjectRepository; -import org.apache.maven.archiva.model.Scm; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelReader; -import org.apache.maven.archiva.xml.XMLException; -import org.apache.maven.archiva.xml.XMLReader; -import org.dom4j.Element; - -/** - * ProjectModel400Reader - read in modelVersion 4.0.0 pom files into archiva-model structures. - * - * @version $Id$ - */ -@SuppressWarnings("unchecked") -public class ProjectModel400Reader - implements ProjectModelReader -{ - public ArchivaProjectModel read( File pomFile ) - throws XMLException - { - XMLReader xml = new XMLReader( "project", pomFile ); - - ArchivaProjectModel model = new ArchivaProjectModel(); - - if ( !"http://maven.apache.org/POM/4.0.0".equals( xml.getDefaultNamespaceURI() ) ) - { - // No namespace defined - // TODO: Output to monitor the problem with the Namespace. - } - - xml.removeNamespaces(); - - Element project = xml.getElement( "//project" ); - - model.setGroupId( project.elementTextTrim( "groupId" ) ); - model.setArtifactId( project.elementTextTrim( "artifactId" ) ); - model.setVersion( project.elementTextTrim( "version" ) ); - model.setName( project.elementTextTrim( "name" ) ); - model.setDescription( project.elementTextTrim( "description" ) ); - model.setUrl( project.elementTextTrim( "url" ) ); - - model.setPackaging( StringUtils.defaultIfEmpty( project.elementTextTrim( "packaging" ), "jar" ) ); - - model.setParentProject( getParentProject( xml ) ); - - model.setMailingLists( getMailingLists( xml ) ); - model.setCiManagement( getCiManagement( xml ) ); - model.setIndividuals( getIndividuals( xml ) ); - model.setIssueManagement( getIssueManagement( xml ) ); - model.setLicenses( getLicenses( xml ) ); - model.setOrganization( getOrganization( xml ) ); - model.setScm( getSCM( xml ) ); - model.setRepositories( getRepositories( xml ) ); - - model.setDependencies( getDependencies( xml ) ); - model.setDependencyManagement( getDependencyManagement( xml ) ); - model.setPlugins( getPlugins( xml ) ); - model.setReports( getReports( xml ) ); - model.setProperties( getProperties( xml.getElement( "//project/properties" ) ) ); - - model.setBuildExtensions( getBuildExtensions( xml ) ); - - model.setRelocation( getRelocation( xml ) ); - - model.setOrigin( "filesystem" ); - - return model; - } - - private ArtifactReference getArtifactReference( Element elemPlugin, String defaultType ) - { - ArtifactReference reference = new ArtifactReference(); - - reference.setGroupId( StringUtils.defaultString( elemPlugin.elementTextTrim( "groupId" ) ) ); - reference.setArtifactId( elemPlugin.elementTextTrim( "artifactId" ) ); - reference.setVersion( StringUtils.defaultString( elemPlugin.elementTextTrim( "version" ) ) ); - reference.setClassifier( StringUtils.defaultString( elemPlugin.elementTextTrim( "classifier" ) ) ); - reference.setType( StringUtils.defaultIfEmpty( elemPlugin.elementTextTrim( "type" ), defaultType ) ); - - return reference; - } - - /** - * Get List of {@link ArtifactReference} objects from xpath expr. - */ - private List<ArtifactReference> getArtifactReferenceList( XMLReader xml, String xpathExpr, String defaultType ) - throws XMLException - { - List<ArtifactReference> refs = new ArrayList<ArtifactReference>(); - - Iterator<Element> it = xml.getElementList( xpathExpr ).iterator(); - while ( it.hasNext() ) - { - Element elemPlugin = it.next(); - - refs.add( getArtifactReference( elemPlugin, defaultType ) ); - } - - return refs; - } - - private List<ArtifactReference> getBuildExtensions( XMLReader xml ) - throws XMLException - { - return getArtifactReferenceList( xml, "//project/build/extensions/extension", "jar" ); - } - - private CiManagement getCiManagement( XMLReader xml ) - throws XMLException - { - Element elemCiMgmt = xml.getElement( "//project/ciManagement" ); - if ( elemCiMgmt != null ) - { - CiManagement ciManagement = new CiManagement(); - ciManagement.setSystem( elemCiMgmt.elementTextTrim( "system" ) ); - ciManagement.setUrl( elemCiMgmt.elementTextTrim( "url" ) ); - ciManagement.setCiUrl( elemCiMgmt.elementTextTrim( "url" ) ); - return ciManagement; - } - - return null; - } - - private List<Dependency> getDependencies( XMLReader xml ) - throws XMLException - { - return getDependencyList( xml, new String[] { "dependencies" } ); - } - - private List<Dependency> getDependencyList( XMLReader xml, String parts[] ) - throws XMLException - { - List<Dependency> dependencyList = new ArrayList<Dependency>(); - - Element project = xml.getElement( "//project" ); - - Element depsParent = project; - - for ( String part : parts ) - { - depsParent = depsParent.element( part ); - if ( depsParent == null ) - { - return dependencyList; - } - } - - Iterator<Element> it = depsParent.elementIterator( "dependency" ); - while ( it.hasNext() ) - { - Element elemDependency = it.next(); - Dependency dependency = new Dependency(); - - dependency.setGroupId( elemDependency.elementTextTrim( "groupId" ) ); - dependency.setArtifactId( elemDependency.elementTextTrim( "artifactId" ) ); - dependency.setVersion( elemDependency.elementTextTrim( "version" ) ); - - dependency.setClassifier( StringUtils.defaultString( elemDependency.elementTextTrim( "classifier" ) ) ); - dependency.setType( StringUtils.defaultIfEmpty( elemDependency.elementTextTrim( "type" ), "jar" ) ); - dependency.setScope( StringUtils.defaultIfEmpty( elemDependency.elementTextTrim( "scope" ), "compile" ) ); - // Not for v4.0.0 -> dependency.setUrl( elemDependency.elementTextTrim("url") ); - dependency.setOptional( toBoolean( elemDependency.elementTextTrim( "optional" ), false ) ); - if ( DependencyScope.isSystemScoped( dependency ) ) - { - dependency.setSystemPath( elemDependency.elementTextTrim( "systemPath" ) ); - } - - dependency.setExclusions( getExclusions( elemDependency ) ); - - if ( dependencyList.contains( dependency ) ) - { - // TODO: throw into monitor as "duplicate dependency" issue. - } - - dependencyList.add( dependency ); - } - - return dependencyList; - } - - private List<Dependency> getDependencyManagement( XMLReader xml ) - throws XMLException - { - return getDependencyList( xml, new String[] { "dependencyManagement", "dependencies" } ); - } - - private List<Exclusion> getExclusions( Element elemDependency ) - { - List<Exclusion> exclusions = new ArrayList<Exclusion>(); - - Element elemExclusions = elemDependency.element( "exclusions" ); - - if ( elemExclusions != null ) - { - Iterator<Element> it = elemExclusions.elementIterator( "exclusion" ); - while ( it.hasNext() ) - { - Element elemExclusion = it.next(); - Exclusion exclusion = new Exclusion(); - - exclusion.setGroupId( elemExclusion.elementTextTrim( "groupId" ) ); - exclusion.setArtifactId( elemExclusion.elementTextTrim( "artifactId" ) ); - - exclusions.add( exclusion ); - } - } - - return exclusions; - } - - private List<Individual> getIndividuals( XMLReader xml ) - throws XMLException - { - List<Individual> individuals = new ArrayList<Individual>(); - - individuals.addAll( getIndividuals( xml, true, "//project/developers/developer" ) ); - individuals.addAll( getIndividuals( xml, false, "//project/contributors/contributor" ) ); - - return individuals; - } - - private List<Individual> getIndividuals( XMLReader xml, boolean isCommitor, String xpathExpr ) - throws XMLException - { - List<Individual> ret = new ArrayList<Individual>(); - - List<Element> modelPersonList = xml.getElementList( xpathExpr ); - - Iterator<Element> iter = modelPersonList.iterator(); - while ( iter.hasNext() ) - { - Element elemPerson = iter.next(); - Individual individual = new Individual(); - - if ( isCommitor ) - { - individual.setPrincipal( elemPerson.elementTextTrim( "id" ) ); - } - - individual.setCommitor( isCommitor ); - individual.setEmail( elemPerson.elementTextTrim( "email" ) ); - individual.setName( elemPerson.elementTextTrim( "name" ) ); - individual.setOrganization( elemPerson.elementTextTrim( "organization" ) ); - individual.setOrganizationUrl( elemPerson.elementTextTrim( "organizationUrl" ) ); - individual.setUrl( elemPerson.elementTextTrim( "url" ) ); - individual.setTimezone( elemPerson.elementTextTrim( "timezone" ) ); - individual.setIndividualEmail( elemPerson.elementTextTrim( "email" ) ); - - // Roles - Element elemRoles = elemPerson.element( "roles" ); - if ( elemRoles != null ) - { - List<Element> roleNames = elemRoles.elements( "role" ); - Iterator<Element> itRole = roleNames.iterator(); - while ( itRole.hasNext() ) - { - Element role = itRole.next(); - individual.addRole( role.getTextTrim() ); - } - } - - // Properties - individual.setProperties( getProperties( elemPerson.element( "properties" ) ) ); - - ret.add( individual ); - } - - return ret; - } - - private IssueManagement getIssueManagement( XMLReader xml ) - throws XMLException - { - Element elemIssueMgmt = xml.getElement( "//project/issueManagement" ); - if ( elemIssueMgmt != null ) - { - IssueManagement issueMgmt = new IssueManagement(); - - issueMgmt.setSystem( elemIssueMgmt.elementTextTrim( "system" ) ); - issueMgmt.setUrl( elemIssueMgmt.elementTextTrim( "url" ) ); - issueMgmt.setIssueManagementUrl( elemIssueMgmt.elementTextTrim( "url" ) ); - - return issueMgmt; - } - - return null; - } - - private List<License> getLicenses( XMLReader xml ) - throws XMLException - { - List<License> licenses = new ArrayList<License>(); - - Element elemLicenses = xml.getElement( "//project/licenses" ); - - if ( elemLicenses != null ) - { - List<Element> licenseList = elemLicenses.elements( "license" ); - for ( Element elemLicense : licenseList ) - { - License license = new License(); - - // TODO: Create LicenseIdentity class to managed license ids. - // license.setId( elemLicense.elementTextTrim("id") ); - license.setName( elemLicense.elementTextTrim( "name" ) ); - license.setUrl( elemLicense.elementTextTrim( "url" ) ); - license.setComments( elemLicense.elementTextTrim( "comments" ) ); - - licenses.add( license ); - } - } - - return licenses; - } - - private List<MailingList> getMailingLists( XMLReader xml ) - throws XMLException - { - List<MailingList> mailingLists = new ArrayList<MailingList>(); - - List<Element> mailingListElems = xml.getElementList( "//project/mailingLists/mailingList" ); - for ( Element elemMailingList : mailingListElems ) - { - MailingList mlist = new MailingList(); - - mlist.setName( elemMailingList.elementTextTrim( "name" ) ); - mlist.setSubscribeAddress( elemMailingList.elementTextTrim( "subscribe" ) ); - mlist.setUnsubscribeAddress( elemMailingList.elementTextTrim( "unsubscribe" ) ); - mlist.setPostAddress( elemMailingList.elementTextTrim( "post" ) ); - mlist.setMainArchiveUrl( elemMailingList.elementTextTrim( "archive" ) ); - - Element elemOtherArchives = elemMailingList.element( "otherArchives" ); - if ( elemOtherArchives != null ) - { - List<String> otherArchives = new ArrayList<String>(); - List<Element> others = elemOtherArchives.elements( "otherArchive" ); - for ( Element other : others ) - { - String otherArchive = other.getTextTrim(); - otherArchives.add( otherArchive ); - } - - mlist.setOtherArchives( otherArchives ); - } - - mailingLists.add( mlist ); - } - - return mailingLists; - } - - private Organization getOrganization( XMLReader xml ) - throws XMLException - { - Element elemOrg = xml.getElement( "//project/organization" ); - if ( elemOrg != null ) - { - Organization org = new Organization(); - - org.setOrganizationName( elemOrg.elementTextTrim( "name" ) ); - org.setName( elemOrg.elementTextTrim( "name" ) ); - org.setUrl( elemOrg.elementTextTrim( "url" ) ); - - return org; - } - - return null; - } - - private VersionedReference getParentProject( XMLReader xml ) - throws XMLException - { - Element elemParent = xml.getElement( "//project/parent" ); - - if ( elemParent != null ) - { - return getVersionedReference( elemParent ); - } - - return null; - } - - private List<ArtifactReference> getPlugins( XMLReader xml ) - throws XMLException - { - return getArtifactReferenceList( xml, "//project/build/plugins/plugin", "maven-plugin" ); - } - - private Properties getProperties( Element elemProperties ) - { - if ( elemProperties == null ) - { - return null; - } - - Properties ret = new Properties(); - - Iterator<Element> itProps = elemProperties.elements().iterator(); - while ( itProps.hasNext() ) - { - Element elemProp = (Element) itProps.next(); - ret.setProperty( elemProp.getName(), elemProp.getText() ); - } - - return ret; - } - - private VersionedReference getRelocation( XMLReader xml ) - throws XMLException - { - Element elemRelocation = xml.getElement( "//project/distributionManagement/relocation" ); - - if ( elemRelocation != null ) - { - return getVersionedReference( elemRelocation ); - } - - return null; - } - - private List<ArtifactReference> getReports( XMLReader xml ) - throws XMLException - { - return getArtifactReferenceList( xml, "//project/reporting/plugins/plugin", "maven-plugin" ); - } - - private List<ProjectRepository> getRepositories( XMLReader xml ) - throws XMLException - { - List<ProjectRepository> repos = new ArrayList<ProjectRepository>(); - - repos.addAll( getRepositories( xml, false, "//project/repositories/repository" ) ); - repos.addAll( getRepositories( xml, true, "//project/pluginRepositories/pluginRepository" ) ); - - return repos; - } - - private List<ProjectRepository> getRepositories( XMLReader xml, boolean isPluginRepo, String xpathExpr ) - throws XMLException - { - List<ProjectRepository> ret = new ArrayList<ProjectRepository>(); - - List<Element> repositoriesList = xml.getElementList( xpathExpr ); - - for ( Element elemRepo : repositoriesList ) - { - ProjectRepository repo = new ProjectRepository(); - - repo.setId( elemRepo.elementTextTrim( "id" ) ); - repo.setName( elemRepo.elementTextTrim( "name" ) ); - repo.setUrl( elemRepo.elementTextTrim( "url" ) ); - repo.setLayout( StringUtils.defaultIfEmpty( elemRepo.elementTextTrim( "layout" ), "default" ) ); - repo.setPlugins( isPluginRepo ); - - repo.setReleases( toBoolean( xml.getElementText( elemRepo, "releases/enabled" ), true ) ); - repo.setSnapshots( toBoolean( xml.getElementText( elemRepo, "snapshots/enabled" ), false ) ); - - ret.add( repo ); - } - - return ret; - } - - private Scm getSCM( XMLReader xml ) - throws XMLException - { - Element elemScm = xml.getElement( "//project/scm" ); - - if ( elemScm != null ) - { - Scm scm = new Scm(); - - scm.setConnection( elemScm.elementTextTrim( "connection" ) ); - scm.setDeveloperConnection( elemScm.elementTextTrim( "developerConnection" ) ); - scm.setUrl( elemScm.elementTextTrim( "url" ) ); - - return scm; - } - - return null; - } - - private VersionedReference getVersionedReference( Element elem ) - { - VersionedReference reference = new VersionedReference(); - - reference.setGroupId( elem.elementTextTrim( "groupId" ) ); - reference.setArtifactId( elem.elementTextTrim( "artifactId" ) ); - reference.setVersion( elem.elementTextTrim( "version" ) ); - - return reference; - } - - private boolean toBoolean( String value, boolean defaultValue ) - { - if ( StringUtils.equalsIgnoreCase( value, "true" ) ) - { - return true; - } - else if ( StringUtils.equalsIgnoreCase( value, "false" ) ) - { - return false; - } - else - { - // If unset, or not "true" or "false". - return defaultValue; - } - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/FalseProjectResolver.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/FalseProjectResolver.java deleted file mode 100644 index 856e4c025..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/FalseProjectResolver.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.archiva.repository.project.resolvers; - -/* - * 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.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelResolver; - -/** - * FalseProjectResolver will never resolver a model. - * - * @version $Id$ - */ -public class FalseProjectResolver - implements ProjectModelResolver -{ - public ArchivaProjectModel resolveProjectModel( VersionedReference reference ) - throws ProjectModelException - { - throw new ProjectModelException( "Cannot resolve model in FalseProjectResolver." ); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/FilesystemBasedResolver.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/FilesystemBasedResolver.java deleted file mode 100644 index 627c43061..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/FilesystemBasedResolver.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.apache.maven.archiva.repository.project.resolvers; - -/* - * 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. - */ - -/** - * Tag for RepositoryProjectResolver's to indicate that it is basing - * it's resolution from the Filesystem. - * - * @version $Id$ - */ -public interface FilesystemBasedResolver -{ - -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ManagedRepositoryProjectResolver.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ManagedRepositoryProjectResolver.java deleted file mode 100644 index 12d177fba..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ManagedRepositoryProjectResolver.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.apache.maven.archiva.repository.project.resolvers; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.apache.maven.archiva.common.utils.VersionComparator; -import org.apache.maven.archiva.common.utils.VersionUtil; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.ContentNotFoundException; -import org.apache.maven.archiva.repository.ManagedRepositoryContent; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelReader; -import org.apache.maven.archiva.repository.project.ProjectModelResolver; -import org.apache.maven.archiva.xml.XMLException; - - -/** - * Resolve Project from managed repository. - * - * @version $Id$ - */ -public class ManagedRepositoryProjectResolver - implements ProjectModelResolver, FilesystemBasedResolver -{ - private ManagedRepositoryContent repository; - - private ProjectModelReader reader; - - public ManagedRepositoryProjectResolver( ManagedRepositoryContent repository, ProjectModelReader reader ) - { - this.repository = repository; - this.reader = reader; - } - - public ArchivaProjectModel resolveProjectModel( VersionedReference reference ) - throws ProjectModelException - { - ArchivaArtifact artifact = new ArchivaArtifact( reference.getGroupId(), reference.getArtifactId(), reference - .getVersion(), "", "pom", repository.getId() ); - - File repoFile = repository.toFile( artifact ); - - // MRM-1194 - if( !repoFile.exists() && VersionUtil.isGenericSnapshot( reference.getVersion() ) ) - { - // check if a timestamped version exists, get the latest if true - try - { - List<String> versions = new ArrayList<String>( repository.getVersions( reference ) ); - Collections.sort( versions, VersionComparator.getInstance() ); - String latestSnapshot = versions.get( versions.size() - 1 ); - artifact = - new ArchivaArtifact( reference.getGroupId(), reference.getArtifactId(), latestSnapshot, "", "pom", - repository.getId() ); - - repoFile = repository.toFile( artifact ); - } - catch( ContentNotFoundException e ) - { - throw new ProjectModelException( e.getMessage(), e ); - } - } - - try - { - return reader.read( repoFile ); - } - catch ( XMLException e ) - { - throw new ProjectModelException( e.getMessage(), e ); - } - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/NopProjectResolver.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/NopProjectResolver.java deleted file mode 100644 index 7092bf356..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/NopProjectResolver.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.apache.maven.archiva.repository.project.resolvers; - -/* - * 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.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelResolver; - -/** - * A No-op Project Resolver, perform no lookup, just returns the requested - * information in the form of a simple ArchviaProjectModel. - * - * @version $Id$ - */ -public class NopProjectResolver - implements ProjectModelResolver -{ - private static NopProjectResolver INSTANCE = new NopProjectResolver(); - - public static NopProjectResolver getInstance() - { - return INSTANCE; - } - - public ArchivaProjectModel resolveProjectModel( VersionedReference reference ) - throws ProjectModelException - { - ArchivaProjectModel model = new ArchivaProjectModel(); - - model.setGroupId( reference.getGroupId() ); - model.setArtifactId( reference.getArtifactId() ); - model.setVersion( reference.getVersion() ); - model.setPackaging( "pom" ); - - model.setOrigin( "nop" ); - - return model; - } - -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolutionListener.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolutionListener.java deleted file mode 100644 index 2587429df..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolutionListener.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.apache.maven.archiva.repository.project.resolvers; - -/* - * 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.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelResolver; - -import java.util.List; - -/** - * ProjectModelResolutionListener - * - * @version $Id$ - */ -public interface ProjectModelResolutionListener -{ - /** - * Indicates that the resolution process has started for a specific project. - * - * @param projectRef the project reference. - * @param resolverList the {@link List} of {@link ProjectModelResolver}'s that will be searched. - * @see #resolutionSuccess(VersionedReference, ProjectModelResolver, ArchivaProjectModel) - * @see #resolutionNotFound(VersionedReference, List) - */ - public void resolutionStart( VersionedReference projectRef, List<ProjectModelResolver> resolverList ); - - /** - * Indicates that a resolution against a specific resolver is about - * to occur. - * - * @param projectRef the project reference. - * @param resolver the resolver to attempt resolution on. - */ - public void resolutionAttempting( VersionedReference projectRef, ProjectModelResolver resolver ); - - /** - * Indicates that a resolution against a specific resolver resulted - * in in a missed resolution. - * - * "Miss" in this case refers to an attempt against a resolver, and that - * resolver essentially responds with a "not found here" response. - * - * @param projectRef the project reference. - * @param resolver the resolver the attempt was made on. - */ - public void resolutionMiss( VersionedReference projectRef, ProjectModelResolver resolver ); - - /** - * Indicates that a resolution against the specific resolver has - * caused an error. - * - * @param projectRef the project reference. - * @param resolver the (optional) resolver on which the error occured. - * @param cause the cause of the error. - */ - public void resolutionError( VersionedReference projectRef, ProjectModelResolver resolver, Exception cause ); - - /** - * Indicates that a resolution process has finished, and the requested - * projectRef has been found. - * - * @param projectRef the project reference. - * @param resolver the resolver on which success occured. - * @param model the resolved model. - * @see #resolutionStart(VersionedReference, List) - */ - public void resolutionSuccess( VersionedReference projectRef, ProjectModelResolver resolver, ArchivaProjectModel model ); - - /** - * Indicates that the resolution process has finished, and the requested - * projectRef could not be found. - * - * @param projectRef the project reference. - * @param resolverList the {@link List} of {@link ProjectModelResolver}'s that was be searched. - * @see #resolutionStart(VersionedReference, List) - */ - public void resolutionNotFound( VersionedReference projectRef, List<ProjectModelResolver> resolverList ); -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolverStack.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolverStack.java deleted file mode 100644 index 534342392..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/resolvers/ProjectModelResolverStack.java +++ /dev/null @@ -1,258 +0,0 @@ -package org.apache.maven.archiva.repository.project.resolvers; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelResolver; - -/** - * Represents a stack of {@link ProjectModelResolver} resolvers for - * finding/resolving an ArchivaProjectModel from multiple sources. - * - * @version $Id$ - */ -public class ProjectModelResolverStack -{ - private List<ProjectModelResolver> resolvers; - - private List<ProjectModelResolutionListener> listeners; - - public ProjectModelResolverStack() - { - this.resolvers = new ArrayList<ProjectModelResolver>(); - this.listeners = new ArrayList<ProjectModelResolutionListener>(); - } - - public void addListener( ProjectModelResolutionListener listener ) - { - if ( listener == null ) - { - return; - } - - this.listeners.add( listener ); - } - - public void addProjectModelResolver( ProjectModelResolver resolver ) - { - if ( resolver == null ) - { - return; - } - - this.resolvers.add( resolver ); - } - - public void clearResolvers() - { - this.resolvers.clear(); - } - - public ArchivaProjectModel findProject( VersionedReference projectRef ) - { - if ( CollectionUtils.isEmpty( this.resolvers ) ) - { - throw new IllegalStateException( "No resolvers have been defined." ); - } - - triggerResolutionStart( projectRef, this.resolvers ); - - Iterator<ProjectModelResolver> it = this.resolvers.iterator(); - - while ( it.hasNext() ) - { - ProjectModelResolver resolver = it.next(); - - try - { - triggerResolutionAttempting( projectRef, resolver ); - ArchivaProjectModel model = resolver.resolveProjectModel( projectRef ); - - if ( model != null ) - { - // Project was found. - triggerResolutionSuccess( projectRef, resolver, model ); - return model; - } - triggerResolutionMiss( projectRef, resolver ); - } - catch ( ProjectModelException e ) - { - triggerResolutionError( projectRef, resolver, e ); - } - } - - // Project was not found in entire resolver list. - triggerResolutionNotFound( projectRef, this.resolvers ); - - return null; - } - - public boolean hasResolver( ProjectModelResolver resolver ) - { - return this.resolvers.contains( resolver ); - } - - public boolean isEmpty() - { - return this.resolvers.isEmpty(); - } - - public void prependProjectModelResolver( ProjectModelResolver resolver ) - { - if ( resolver == null ) - { - return; - } - - this.resolvers.add( 0, resolver ); - } - - public void removeListener( ProjectModelResolutionListener listener ) - { - if ( listener == null ) - { - return; - } - - this.listeners.add( listener ); - } - - public void removeResolver( ProjectModelResolver resolver ) - { - this.resolvers.remove( resolver ); - } - - private void triggerResolutionAttempting( VersionedReference projectRef, ProjectModelResolver resolver ) - { - Iterator<ProjectModelResolutionListener> it = this.listeners.iterator(); - while ( it.hasNext() ) - { - ProjectModelResolutionListener listener = it.next(); - - try - { - listener.resolutionAttempting( projectRef, resolver ); - } - catch ( Exception e ) - { - // do nothing with exception. - } - } - } - - private void triggerResolutionError( VersionedReference projectRef, ProjectModelResolver resolver, Exception cause ) - { - Iterator<ProjectModelResolutionListener> it = this.listeners.iterator(); - while ( it.hasNext() ) - { - ProjectModelResolutionListener listener = it.next(); - - try - { - listener.resolutionError( projectRef, resolver, cause ); - } - catch ( Exception e ) - { - // do nothing with exception. - } - } - } - - private void triggerResolutionMiss( VersionedReference projectRef, ProjectModelResolver resolver ) - { - Iterator<ProjectModelResolutionListener> it = this.listeners.iterator(); - while ( it.hasNext() ) - { - ProjectModelResolutionListener listener = it.next(); - - try - { - listener.resolutionMiss( projectRef, resolver ); - } - catch ( Exception e ) - { - // do nothing with exception. - } - } - } - - private void triggerResolutionNotFound( VersionedReference projectRef, List<ProjectModelResolver> resolvers ) - { - Iterator<ProjectModelResolutionListener> it = this.listeners.iterator(); - while ( it.hasNext() ) - { - ProjectModelResolutionListener listener = it.next(); - - try - { - listener.resolutionNotFound( projectRef, resolvers ); - } - catch ( Exception e ) - { - // do nothing with exception. - } - } - } - - private void triggerResolutionStart( VersionedReference projectRef, List<ProjectModelResolver> resolvers ) - { - Iterator<ProjectModelResolutionListener> it = this.listeners.iterator(); - while ( it.hasNext() ) - { - ProjectModelResolutionListener listener = it.next(); - - try - { - listener.resolutionStart( projectRef, resolvers ); - } - catch ( Exception e ) - { - // do nothing with exception. - } - } - } - - private void triggerResolutionSuccess( VersionedReference projectRef, ProjectModelResolver resolver, - ArchivaProjectModel model ) - { - Iterator<ProjectModelResolutionListener> it = this.listeners.iterator(); - while ( it.hasNext() ) - { - ProjectModelResolutionListener listener = it.next(); - - try - { - listener.resolutionSuccess( projectRef, resolver, model ); - } - catch ( Exception e ) - { - // do nothing with exception. - } - } - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/writers/ProjectModel400Writer.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/writers/ProjectModel400Writer.java deleted file mode 100644 index cb85febe2..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/writers/ProjectModel400Writer.java +++ /dev/null @@ -1,540 +0,0 @@ -package org.apache.maven.archiva.repository.project.writers; - -/* - * 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.commons.collections.CollectionUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.ArtifactReference; -import org.apache.maven.archiva.model.CiManagement; -import org.apache.maven.archiva.model.Dependency; -import org.apache.maven.archiva.model.Exclusion; -import org.apache.maven.archiva.model.Individual; -import org.apache.maven.archiva.model.IssueManagement; -import org.apache.maven.archiva.model.License; -import org.apache.maven.archiva.model.MailingList; -import org.apache.maven.archiva.model.Organization; -import org.apache.maven.archiva.model.ProjectRepository; -import org.apache.maven.archiva.model.Scm; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelWriter; -import org.apache.maven.archiva.xml.XMLException; -import org.apache.maven.archiva.xml.XMLWriter; -import org.dom4j.Document; -import org.dom4j.DocumentHelper; -import org.dom4j.Element; -import org.dom4j.Namespace; -import org.dom4j.Node; -import org.dom4j.QName; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; -import java.util.Iterator; -import java.util.List; - -/** - * ProjectModel400Writer for Maven 2 project model v4.0.0 pom files. - * - * @version $Id$ - */ -public class ProjectModel400Writer - implements ProjectModelWriter -{ - private static final Namespace DEFAULT_NAMESPACE = Namespace.get( "", "http://maven.apache.org/POM/4.0.0" ); - - public void write( ArchivaProjectModel model, File pomFile ) - throws ProjectModelException, IOException - { - FileWriter writer = null; - try - { - writer = new FileWriter( pomFile ); - write( model, writer ); - writer.flush(); - } - finally - { - IOUtils.closeQuietly( writer ); - } - } - - public void write( ArchivaProjectModel model, Writer writer ) - throws ProjectModelException, IOException - { - Document doc = DocumentHelper.createDocument(); - - Element root = DocumentHelper.createElement( "project" ); - - root.add( DEFAULT_NAMESPACE ); - root.addNamespace( "xsi", "http://www.w3.org/2001/XMLSchema-instance" ); - root.addAttribute( "xsi:schemaLocation", - "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" ); - - doc.setRootElement( root ); - - root.addElement( "modelVersion" ).setText( "4.0.0" ); - - addParent( root, model.getParentProject() ); - - addChildElement( root, "groupId", model.getGroupId() ); - root.addElement( "artifactId" ).setText( model.getArtifactId() ); - - addChildElement( root, "version", model.getVersion() ); - - addChildElement( root, "packaging", model.getPackaging() ); - addChildElement( root, "name", model.getName() ); - addChildElement( root, "description", model.getDescription() ); - addChildElement( root, "url", model.getUrl() ); - // TODO: add inceptionYear to ArchivaProjectModel - - addOrganization( root, model.getOrganization() ); - - addIssueManagement( root, model.getIssueManagement() ); - addCiManagement( root, model.getCiManagement() ); - addMailingLists( root, model.getMailingLists() ); - addDevelopersAndContributors( root, model.getIndividuals() ); - // TODO: add distribution management to ArchivaProjectModel - - addLicenses( root, model.getLicenses() ); - addRepositories( root, model.getRepositories() ); - addDependencyManagement( root, model.getDependencyManagement() ); - addDependencies( root, model.getDependencies() ); - - addReporting( root, model.getReports() ); - addScm( root, model.getScm() ); - - // <build> element - addPlugins( root, model.getPlugins() ); - addBuildExtensions( root, model.getBuildExtensions() ); - - // <distributionManagement> - addRelocation( root, model.getRelocation() ); - - fixDefaultNamespace( root ); - - try - { - XMLWriter.write( doc, writer ); - } - catch ( XMLException e ) - { - throw new ProjectModelException( "Unable to write xml contents to writer: " + e.getMessage(), e ); - } - } - - private void addArtifactReference( Element elem, ArtifactReference ref, String defaultType ) - { - addChildElement( elem, "groupId", ref.getGroupId() ); - addChildElement( elem, "artifactId", ref.getArtifactId() ); - addChildElement( elem, "version", ref.getVersion() ); - addChildElement( elem, "classifier", ref.getClassifier() ); - - if ( !StringUtils.equals( defaultType, ref.getType() ) ) - { - addChildElement( elem, "type", ref.getType() ); - } - } - - private void addBuildExtensions( Element root, List<ArtifactReference> buildExtensions ) - { - if ( CollectionUtils.isEmpty( buildExtensions ) ) - { - return; - } - - Element build = root.element( "build" ); - if ( build == null ) - { - build = root.addElement( "build" ); - } - - Element elemExtensions = build.addElement( "extensions" ); - - for ( ArtifactReference extension : buildExtensions ) - { - Element elem = elemExtensions.addElement( "extension" ); - - addArtifactReference( elem, extension, "jar" ); - } - } - - private void addCiManagement( Element root, CiManagement ciManagement ) - { - if ( ciManagement == null ) - { - return; - } - - Element elem = root.addElement( "ciManagement" ); - addChildElement( elem, "system", ciManagement.getSystem() ); - addChildElement( elem, "url", ciManagement.getUrl() ); - // TODO: Add notifiers into ArchivaProjectModel - } - - private void addDependencies( Element root, List<Dependency> dependencies ) - { - if ( CollectionUtils.isEmpty( dependencies ) ) - { - return; - } - - addDependencyList( root, dependencies ); - } - - private void addDependencyList( Element elemParent, List<Dependency> dependencies ) - { - if ( CollectionUtils.isEmpty( dependencies ) ) - { - return; - } - - Element elemDeps = elemParent.addElement( "dependencies" ); - - for ( Dependency dep : dependencies ) - { - Element elem = elemDeps.addElement( "dependency" ); - - addChildElement( elem, "groupId", dep.getGroupId() ); - addChildElement( elem, "artifactId", dep.getArtifactId() ); - addChildElement( elem, "version", dep.getVersion() ); - addChildElement( elem, "classifier", dep.getClassifier() ); - addChildElement( elem, "type", dep.getType() ); - addChildElement( elem, "scope", dep.getScope() ); - addChildElement( elem, "systemPath", dep.getSystemPath() ); - - addExclusions( elem, dep.getExclusions() ); - } - } - - private void addDependencyManagement( Element root, List<Dependency> dependencyManagement ) - { - if ( CollectionUtils.isEmpty( dependencyManagement ) ) - { - return; - } - - Element elemDepMgmt = root.addElement( "dependencyManagement" ); - addDependencyList( elemDepMgmt, dependencyManagement ); - } - - private void addDevelopersAndContributors( Element root, List<Individual> individuals ) - { - if ( CollectionUtils.isEmpty( individuals ) ) - { - return; - } - - Element developers = null; - Element contributors = null; - - for ( Individual individual : individuals ) - { - if ( individual.isCommitor() ) - { - if ( developers == null ) - { - developers = root.addElement( "developers" ); - } - - Element developer = developers.addElement( "developer" ); - addChildElement( developer, "id", individual.getPrincipal() ); - addIndividual( developer, individual ); - } - else - { - if ( contributors == null ) - { - contributors = root.addElement( "contributors" ); - } - - Element contributor = contributors.addElement( "contributor" ); - addIndividual( contributor, individual ); - } - } - } - - private void addExclusions( Element elemParent, List<Exclusion> exclusions ) - { - if ( CollectionUtils.isEmpty( exclusions ) ) - { - return; - } - - Element elemExclusions = elemParent.addElement( "exclusions" ); - - for ( Exclusion exclusion : exclusions ) - { - Element elem = elemExclusions.addElement( "exclusion" ); - - addChildElement( elem, "groupId", exclusion.getGroupId() ); - addChildElement( elem, "artifactId", exclusion.getArtifactId() ); - } - } - - private void addIndividual( Element elem, Individual individual ) - { - addChildElement( elem, "name", individual.getName() ); - addChildElement( elem, "email", individual.getEmail() ); - addChildElement( elem, "organization", individual.getOrganization() ); - addChildElement( elem, "organizationUrl", individual.getOrganizationUrl() ); - addChildElement( elem, "timezone", individual.getTimezone() ); - - if ( CollectionUtils.isNotEmpty( individual.getRoles() ) ) - { - Element roles = elem.addElement( "roles" ); - List<String> roleList = individual.getRoles(); - for ( String roleName : roleList ) - { - addChildElement( roles, "role", roleName ); - } - } - } - - private void addIssueManagement( Element root, IssueManagement issueManagement ) - { - if ( issueManagement == null ) - { - return; - } - - Element elem = root.addElement( "issueManagement" ); - addChildElement( elem, "system", issueManagement.getSystem() ); - addChildElement( elem, "url", issueManagement.getUrl() ); - } - - private void addLicenses( Element root, List<License> licenses ) - { - if ( CollectionUtils.isEmpty( licenses ) ) - { - return; - } - - Element elemLicenses = root.addElement( "licenses" ); - - for ( License license : licenses ) - { - Element elem = elemLicenses.addElement( "license" ); - addChildElement( elem, "name", license.getName() ); - addChildElement( elem, "url", license.getUrl() ); - // TODO: research if we need <distribution> subelement. - } - } - - private void addMailingLists( Element root, List<MailingList> mailingLists ) - { - if ( CollectionUtils.isEmpty( mailingLists ) ) - { - return; - } - - Element mlists = root.addElement( "mailingLists" ); - - for ( MailingList mailingList : mailingLists ) - { - Element mlist = mlists.addElement( "mailingList" ); - addChildElement( mlist, "name", mailingList.getName() ); - addChildElement( mlist, "post", mailingList.getPostAddress() ); - addChildElement( mlist, "subscribe", mailingList.getSubscribeAddress() ); - addChildElement( mlist, "unsubscribe", mailingList.getUnsubscribeAddress() ); - addChildElement( mlist, "archive", mailingList.getMainArchiveUrl() ); - - addOtherArchives( mlist, mailingList.getOtherArchives() ); - } - } - - private void addOtherArchives( Element mlist, List<String> otherArchives ) - { - if ( CollectionUtils.isEmpty( otherArchives ) ) - { - return; - } - - Element elemOtherArchives = mlist.addElement( "otherArchives" ); - - for ( String archive : otherArchives ) - { - addChildElement( elemOtherArchives, "otherArchive", archive ); - } - } - - private void addOrganization( Element root, Organization organization ) - { - if ( organization == null ) - { - return; - } - - Element elem = root.addElement( "organization" ); - - //addChildElement( elem, "name", organization.getOrganizationName() ); - addChildElement( elem, "name", organization.getName() ); - addChildElement( elem, "url", organization.getUrl() ); - } - - private void addParent( Element root, VersionedReference parentProject ) - { - if ( parentProject == null ) - { - return; - } - - Element parent = root.addElement( "parent" ); - parent.addElement( "groupId" ).setText( parentProject.getGroupId() ); - parent.addElement( "artifactId" ).setText( parentProject.getArtifactId() ); - parent.addElement( "version" ).setText( parentProject.getVersion() ); - } - - private void addPlugins( Element root, List<ArtifactReference> plugins ) - { - if ( CollectionUtils.isEmpty( plugins ) ) - { - return; - } - - Element build = root.element( "build" ); - if ( build == null ) - { - build = root.addElement( "build" ); - } - - Element elemPlugins = build.addElement( "plugins" ); - - for ( ArtifactReference plugin : plugins ) - { - Element elem = elemPlugins.addElement( "plugin" ); - - addArtifactReference( elem, plugin, "maven-plugin" ); - } - } - - private void addRelocation( Element root, VersionedReference relocation ) - { - if ( relocation == null ) - { - return; - } - - Element distribManagement = root.element( "distributionManagement" ); - - if ( distribManagement == null ) - { - distribManagement = root.addElement( "distributionManagement" ); - } - - Element elem = distribManagement.addElement( "relocation" ); - addChildElement( elem, "groupId", relocation.getGroupId() ); - addChildElement( elem, "artifactId", relocation.getArtifactId() ); - addChildElement( elem, "version", relocation.getVersion() ); - } - - private void addReporting( Element root, List<ArtifactReference> reports ) - { - if ( CollectionUtils.isEmpty( reports ) ) - { - return; - } - - Element reporting = root.addElement( "reporting" ); - Element plugins = reporting.addElement( "plugins" ); - - for ( ArtifactReference reference : reports ) - { - Element plugin = plugins.addElement( "plugin" ); - addChildElement( plugin, "groupId", reference.getGroupId() ); - addChildElement( plugin, "artifactId", reference.getArtifactId() ); - addChildElement( plugin, "version", reference.getVersion() ); - } - } - - private void addRepositories( Element root, List<ProjectRepository> repositories ) - { - if ( CollectionUtils.isEmpty( repositories ) ) - { - return; - } - - Element elemRepos = root.addElement( "repositories" ); - for ( ProjectRepository repository : repositories ) - { - Element elem = elemRepos.addElement( "repository" ); - addChildElement( elem, "id", repository.getId() ); - addChildElement( elem, "name", repository.getName() ); - addChildElement( elem, "url", repository.getUrl() ); - - if ( !StringUtils.equals( "default", repository.getLayout() ) ) - { - addChildElement( elem, "layout", repository.getLayout() ); - } - } - } - - private void addScm( Element root, Scm scm ) - { - if ( scm == null ) - { - return; - } - - Element elem = root.addElement( "scm" ); - - addChildElement( elem, "connection", scm.getConnection() ); - addChildElement( elem, "developerConnection", scm.getDeveloperConnection() ); - addChildElement( elem, "url", scm.getUrl() ); - } - - /** - * Fix the default namespace on all elements recursively. - */ - @SuppressWarnings("unchecked") - private void fixDefaultNamespace( Element elem ) - { - elem.remove( elem.getNamespace() ); - elem.setQName( QName.get( elem.getName(), DEFAULT_NAMESPACE, elem.getQualifiedName() ) ); - - Node n; - - Iterator<Node> it = elem.elementIterator(); - while ( it.hasNext() ) - { - n = it.next(); - - switch ( n.getNodeType() ) - { - case Node.ELEMENT_NODE: - fixDefaultNamespace( (Element) n ); - break; - } - } - } - - private static void addChildElement( Element elem, String elemName, String text ) - { - if ( StringUtils.isBlank( text ) ) - { - return; - } - - elem.addElement( elemName ).setText( text ); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/resources/META-INF/plexus/components-fragment.xml b/archiva-modules/archiva-base/archiva-repository-layer/src/main/resources/META-INF/plexus/components-fragment.xml deleted file mode 100644 index ed63a3b82..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/resources/META-INF/plexus/components-fragment.xml +++ /dev/null @@ -1,25 +0,0 @@ -<component-set> - <components> - <component> - <role>org.codehaus.plexus.cache.Cache</role> - <role-hint>effective-project-cache</role-hint> - <implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation> - <description>Effective Project Cache</description> - <configuration> - <disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds> - <disk-persistent>true</disk-persistent> - <disk-store-path>${java.io.tmpdir}/archiva/effectiveproject</disk-store-path> - <eternal>true</eternal> - <max-elements-in-memory>1000</max-elements-in-memory> - <memory-eviction-policy>LRU</memory-eviction-policy> - <name>effective-project-cache</name> - <overflow-to-disk>false</overflow-to-disk> - <!-- TODO: Adjust the time to live to be more sane (ie: huge 4+ hours) --> - <!-- 45 minutes = 2700 seconds --> - <time-to-idle-seconds>2700</time-to-idle-seconds> - <!-- 30 minutes = 1800 seconds --> - <time-to-live-seconds>1800</time-to-live-seconds> - </configuration> - </component> - </components> -</component-set> diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/ProjectModelMergeTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/ProjectModelMergeTest.java deleted file mode 100644 index 93716cea4..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/ProjectModelMergeTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.apache.maven.archiva.repository.project; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Enumeration; -import java.util.Properties; - -import org.apache.maven.archiva.repository.project.ProjectModelMerge; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.VersionedReference; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; - -/** - * ProjectModelMergeTest - * - * @author jzurbano - */ -public class ProjectModelMergeTest - extends PlexusInSpringTestCase -{ - private ProjectModelMerge modelMerge; - - private Enumeration<String> keys; - - @Override - protected void setUp() - throws Exception - { - super.setUp(); - - modelMerge = new ProjectModelMerge(); - } - - @SuppressWarnings("unchecked") - public void testPropertiesMerge() - throws Exception - { - ArchivaProjectModel mainProject = createMainProject(); - ArchivaProjectModel parentProject = createParentProject(); - - assertNotNull( mainProject.getProperties() ); - - Properties prop = parentProject.getProperties(); - assertNotNull( prop ); - - keys = (Enumeration<String>) prop.propertyNames(); - assertTrue( keys.hasMoreElements() ); - - modelMerge.merge( mainProject, parentProject ); - } - - private ArchivaProjectModel createMainProject() - { - ArchivaProjectModel mainProject = new ArchivaProjectModel(); - - VersionedReference parent = new VersionedReference(); - parent.setGroupId( "org.apache" ); - parent.setArtifactId( "apache" ); - parent.setVersion( "4" ); - - mainProject.setParentProject( parent ); - mainProject.setGroupId( "org.apache.servicemix" ); - mainProject.setArtifactId( "servicemix-pom" ); - mainProject.setVersion( "2" ); - mainProject.setPackaging( "pom" ); - mainProject.setName( "ServiceMix POM" ); - mainProject.setUrl( "http://servicemix.apache.org/" ); - mainProject.setDescription( "This pom provides project information that is common to all ServiceMix branches." ); - mainProject.setProperties( new Properties() ); - - return mainProject; - } - - private ArchivaProjectModel createParentProject() - { - ArchivaProjectModel parentProject = new ArchivaProjectModel(); - - parentProject.setGroupId( "org.apache" ); - parentProject.setArtifactId( "apache" ); - parentProject.setVersion( "4" ); - parentProject.setPackaging( "pom" ); - - Properties prop = new Properties(); - prop.setProperty( "test.key", "" ); - parentProject.setProperties( prop ); - - return parentProject; - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilterTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilterTest.java deleted file mode 100644 index e5990f774..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilterTest.java +++ /dev/null @@ -1,395 +0,0 @@ -package org.apache.maven.archiva.repository.project.filters; - -/* - * 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.maven.archiva.common.utils.VersionUtil; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.ArtifactReference; -import org.apache.maven.archiva.model.Dependency; -import org.apache.maven.archiva.model.Individual; -import org.apache.maven.archiva.repository.AbstractRepositoryLayerTestCase; -import org.apache.maven.archiva.repository.ManagedRepositoryContent; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelFilter; -import org.apache.maven.archiva.repository.project.ProjectModelReader; -import org.apache.maven.archiva.repository.project.ProjectModelResolver; -import org.apache.maven.archiva.repository.project.ProjectModelResolverFactory; -import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader; -import org.apache.maven.archiva.repository.project.resolvers.ManagedRepositoryProjectResolver; -import org.apache.maven.archiva.xml.XMLException; - -import java.io.File; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * EffectiveProjectModelFilterTest - * - * @version $Id$ - */ -public class EffectiveProjectModelFilterTest - extends AbstractRepositoryLayerTestCase -{ - private static final String DEFAULT_REPOSITORY = "src/test/repositories/default-repository"; - - private EffectiveProjectModelFilter lookupEffective() - throws Exception - { - return (EffectiveProjectModelFilter) lookup( ProjectModelFilter.class, "effective" ); - } - - private ArchivaProjectModel createArchivaProjectModel( String path ) - throws XMLException - { - ProjectModelReader reader = new ProjectModel400Reader(); - - File pomFile = new File( getBasedir(), path ); - - return reader.read( pomFile ); - } - - private ProjectModelResolver createDefaultRepositoryResolver() throws Exception - { - File defaultRepoDir = new File( getBasedir(), DEFAULT_REPOSITORY ); - - ManagedRepositoryContent repo = createManagedRepositoryContent( "defaultTestRepo", "Default Test Repo", defaultRepoDir, "default" ); - - ProjectModelReader reader = new ProjectModel400Reader(); - ManagedRepositoryProjectResolver resolver = new ManagedRepositoryProjectResolver( repo, reader ); - - return resolver; - } - - public void testBuildEffectiveProject() - throws Exception - { - assertEffectiveProject( - "/org/apache/maven/archiva/archiva-model/1.0-SNAPSHOT/archiva-model-1.0-SNAPSHOT.pom", - "/archiva-model-effective.pom"); - - assertEffectiveProject( - "/test-project/test-project-endpoint-ejb/2.4.4/test-project-endpoint-ejb-2.4.4.pom", - "/test-project-model-effective.pom"); - } - - private void assertEffectiveProject(String pomFile, String effectivePomFile) throws Exception, - ProjectModelException { - initTestResolverFactory(); - EffectiveProjectModelFilter filter = lookupEffective(); - - ArchivaProjectModel startModel = createArchivaProjectModel( DEFAULT_REPOSITORY + pomFile ); - - ArchivaProjectModel effectiveModel = filter.filter( startModel ); - - ArchivaProjectModel expectedModel = createArchivaProjectModel( "src/test/expected-poms/" + effectivePomFile); - - assertModel( expectedModel, effectiveModel ); - } - - - /** - * [MRM-510] In Repository Browse, the first unique snapshot version clicked is getting persisted in the - * request resulting to 'version does not match' error - * - * The purpose of this test is ensure that timestamped SNAPSHOTS do not cache improperly, and each timestamped - * pom can be loaded through the effective project filter correctly. - */ - public void testBuildEffectiveSnapshotProject() - throws Exception - { - initTestResolverFactory(); - EffectiveProjectModelFilter filter = lookupEffective(); - - String axisVersions[] = new String[] { - "1.3-20070725.210059-1", - "1.3-20070725.232304-2", - "1.3-20070726.053327-3", - "1.3-20070726.173653-5", - "1.3-20070727.113106-7", - "1.3-20070728.053229-10", - "1.3-20070728.112043-11", - "1.3-20070729.171937-16", - "1.3-20070730.232112-20", - "1.3-20070731.113304-21", - "1.3-20070731.172936-22", - "1.3-20070802.113139-29" }; - - for ( int i = 0; i < axisVersions.length; i++ ) - { - assertTrue( "Version should be a unique snapshot.", VersionUtil.isUniqueSnapshot( axisVersions[i] ) ); - - ArchivaProjectModel initialModel = createArchivaProjectModel( DEFAULT_REPOSITORY - + "/org/apache/axis2/axis2/1.3-SNAPSHOT/axis2-" + axisVersions[i] + ".pom" ); - - // This is the process that ProjectModelToDatabaseConsumer uses, so we mimic it here. - // This logic is related to the MRM-510 jira. - String baseVersion = VersionUtil.getBaseVersion( axisVersions[i] ); - - assertEquals( "Base Version <" + baseVersion + "> of filename <" + axisVersions[i] - + "> should be equal to what is in model.", initialModel.getVersion(), baseVersion ); - - initialModel.setVersion( axisVersions[i] ); - - assertEquals( "Unique snapshot versions of initial model should be equal.", axisVersions[i], initialModel - .getVersion() ); - - ArchivaProjectModel effectiveModel = filter.filter( initialModel ); - - assertEquals( "Unique snapshot versions of initial model should be equal.", axisVersions[i], initialModel - .getVersion() ); - assertEquals( "Unique snapshot versions of filtered/effective model should be equal.", axisVersions[i], - effectiveModel.getVersion() ); - } - } - - /* - * Test before and after the properties are evaluated. pom snippet: <maven.version>2.0.5</maven.version> - * <wagon.version>1.0-beta-2</wagon.version> <plexus-security.version>1.0-alpha-10-SNAPSHOT</plexus-security.version> - */ - public void testEffectiveProjectProperty() - throws Exception - { - initTestResolverFactory(); - EffectiveProjectModelFilter filter = lookupEffective(); - - String pomFile = "/org/apache/maven/archiva/archiva/1.0-SNAPSHOT/archiva-1.0-SNAPSHOT.pom"; - ArchivaProjectModel startModel = createArchivaProjectModel( DEFAULT_REPOSITORY + pomFile ); - - String plexusSecurityVersion = "1.0-alpha-10-SNAPSHOT"; - String wagonVersion = "1.0-beta-2"; - - boolean passedPlexusVersionChecking = false; - boolean passedWagonVersionChecking = false; - - List<Dependency> startDeps = startModel.getDependencyManagement(); - for ( Dependency startDep : startDeps ) - { - if ( "org.codehaus.plexus.security".equals( startDep.getGroupId() ) ) - { - assertEquals( startDep.getVersion(), "${plexus-security.version}" ); - } - else if ( "org.apache.maven.wagon".equals( startDep.getGroupId() ) ) - { - assertEquals( startDep.getVersion(), "${wagon.version}" ); - } - } - - ArchivaProjectModel effectiveModel = filter.filter( startModel ); - - List<Dependency> effectiveDeps = effectiveModel.getDependencyManagement(); - for ( Dependency dependency : effectiveDeps ) - { - if ( "org.codehaus.plexus.security".equals( dependency.getGroupId() ) ) - { - assertEquals( dependency.getVersion(), plexusSecurityVersion ); - - if ( !passedPlexusVersionChecking ) - { - passedPlexusVersionChecking = true; - } - } - else if ( "org.apache.maven.wagon".equals( dependency.getGroupId() ) ) - { - assertEquals( dependency.getVersion(), wagonVersion ); - - if ( !passedWagonVersionChecking ) - { - passedWagonVersionChecking = true; - } - } - - } - assertTrue( passedPlexusVersionChecking ); - assertTrue( passedWagonVersionChecking ); - } - - // MRM-1194 - public void testEffectiveProjectPropertyExistingParentHasUniqueSnapshotVersion() - throws Exception - { - initTestResolverFactory(); - EffectiveProjectModelFilter filter = lookupEffective(); - - String pomFile = "/org/apache/archiva/sample-project/2.1-SNAPSHOT/sample-project-2.1-SNAPSHOT.pom"; - ArchivaProjectModel startModel = createArchivaProjectModel( DEFAULT_REPOSITORY + pomFile ); - - String buildHelperPluginVersion = "1.0"; - - boolean passedBuildHelperVersionChecking = false; - - List<ArtifactReference> startPlugins = startModel.getPlugins(); - for( ArtifactReference plugin : startPlugins ) - { - if( "build-helper-maven-plugin".equals( plugin.getArtifactId() ) ) - { - assertEquals( "${build-helper-maven-plugin.version}", plugin.getVersion() ); - } - } - - ArchivaProjectModel effectiveModel = filter.filter( startModel ); - - List<ArtifactReference> effectivePlugins = effectiveModel.getPlugins(); - for( ArtifactReference plugin : effectivePlugins ) - { - if( "build-helper-maven-plugin".equals( plugin.getArtifactId() ) ) - { - assertEquals( buildHelperPluginVersion, plugin.getVersion() ); - - if ( !passedBuildHelperVersionChecking ) - { - passedBuildHelperVersionChecking = true; - } - } - } - - assertTrue( passedBuildHelperVersionChecking ); - } - - - private ProjectModelResolverFactory initTestResolverFactory() - throws Exception - { - ProjectModelResolverFactory resolverFactory = (ProjectModelResolverFactory) lookup( ProjectModelResolverFactory.class ); - - resolverFactory.getCurrentResolverStack().clearResolvers(); - resolverFactory.getCurrentResolverStack().addProjectModelResolver( createDefaultRepositoryResolver() ); - - return resolverFactory; - } - - private void assertModel( ArchivaProjectModel expectedModel, ArchivaProjectModel effectiveModel ) - { - assertEquals( "Equivalent Models", expectedModel, effectiveModel ); - - assertContainsSameIndividuals( "Individuals", expectedModel.getIndividuals(), effectiveModel.getIndividuals() ); - dumpDependencyList( "Expected", expectedModel.getDependencies() ); - dumpDependencyList( "Effective", effectiveModel.getDependencies() ); - assertContainsSameDependencies( "Dependencies", expectedModel.getDependencies(), effectiveModel - .getDependencies() ); - assertContainsSameDependencies( "DependencyManagement", expectedModel.getDependencyManagement(), effectiveModel - .getDependencyManagement() ); - } - - private void dumpDependencyList( String type, List<Dependency> deps ) - { - if ( deps == null ) - { - System.out.println( " Dependencies [" + type + "] is null." ); - return; - } - - if ( deps.isEmpty() ) - { - System.out.println( " Dependencies [" + type + "] dependency list is empty." ); - return; - } - - System.out.println( ".\\ [" + type + "] Dependency List (size:" + deps.size() + ") \\.________________" ); - Iterator<Dependency> it = deps.iterator(); - while ( it.hasNext() ) - { - Dependency dep = it.next(); - System.out.println( " " + Dependency.toKey( dep ) ); - } - System.out.println( "" ); - } - - private void assertEquivalentLists( String listId, List<?> expectedList, List<?> effectiveList ) - { - if ( ( expectedList == null ) && ( effectiveList == null ) ) - { - return; - } - - if ( ( expectedList == null ) && ( effectiveList != null ) ) - { - fail( "Effective [" + listId + "] List is instantiated, while expected List is null." ); - } - - if ( ( expectedList != null ) && ( effectiveList == null ) ) - { - fail( "Effective [" + listId + "] List is null, while expected List is instantiated." ); - } - - assertEquals( "[" + listId + "] List Size", expectedList.size(), expectedList.size() ); - } - - private void assertContainsSameIndividuals( String listId, List<Individual> expectedList, - List<Individual> effectiveList ) - { - assertEquivalentLists( listId, expectedList, effectiveList ); - - Map<String, Individual> expectedMap = getIndividualsMap( expectedList ); - Map<String, Individual> effectiveMap = getIndividualsMap( effectiveList ); - - Iterator<String> it = expectedMap.keySet().iterator(); - while ( it.hasNext() ) - { - String key = (String) it.next(); - - assertTrue( "Should exist in Effective [" + listId + "] list: " + key, effectiveMap.containsKey( key ) ); - } - } - - private void assertContainsSameDependencies( String listId, List<Dependency> expectedList, - List<Dependency> effectiveList ) - { - assertEquivalentLists( listId, expectedList, effectiveList ); - - Map<String, Dependency> expectedMap = getDependencyMap( expectedList ); - Map<String, Dependency> effectiveMap = getDependencyMap( effectiveList ); - - Iterator<String> it = expectedMap.keySet().iterator(); - while ( it.hasNext() ) - { - String key = it.next(); - - assertTrue( "Should exist in Effective [" + listId + "] list: " + key, effectiveMap.containsKey( key ) ); - } - } - - private Map<String, Individual> getIndividualsMap( List<Individual> individuals ) - { - Map<String, Individual> map = new HashMap<String, Individual>(); - Iterator<Individual> it = individuals.iterator(); - while ( it.hasNext() ) - { - Individual individual = it.next(); - String key = individual.getEmail(); - map.put( key, individual ); - } - return map; - } - - private Map<String, Dependency> getDependencyMap( List<Dependency> deps ) - { - Map<String, Dependency> map = new HashMap<String, Dependency>(); - Iterator<Dependency> it = deps.iterator(); - while ( it.hasNext() ) - { - Dependency dep = it.next(); - String key = Dependency.toKey( dep ); - map.put( key, dep ); - } - return map; - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionExpanderTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionExpanderTest.java deleted file mode 100644 index 1bb246d02..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/filters/ProjectModelExpressionExpanderTest.java +++ /dev/null @@ -1,161 +0,0 @@ -package org.apache.maven.archiva.repository.project.filters; - -/* - * 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.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.Dependency; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelFilter; -import org.apache.maven.archiva.repository.project.ProjectModelReader; -import org.apache.maven.archiva.repository.project.ProjectModelWriter; -import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader; -import org.apache.maven.archiva.repository.project.writers.ProjectModel400Writer; -import org.apache.maven.archiva.xml.XMLException; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; - -import java.io.File; -import java.io.IOException; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * ProjectModelExpressionExpanderTest - * - * @version $Id$ - */ -public class ProjectModelExpressionExpanderTest - extends PlexusInSpringTestCase -{ - private static final String DEFAULT_REPOSITORY = "src/test/repositories/default-repository"; - - private ProjectModelExpressionFilter lookupExpression() - throws Exception - { - return (ProjectModelExpressionFilter) lookup( ProjectModelFilter.class, "expression" ); - } - - public void testExpressionEvaluation() - throws Exception - { - ArchivaProjectModel model = new ArchivaProjectModel(); - model.setGroupId( "org.apache.maven.archiva" ); - model.setArtifactId( "archiva-test-project" ); - model.setVersion( "1.0-SNAPSHOT" ); - - List<Dependency> deps = new ArrayList<Dependency>(); - - deps.add( createDependency( "org.apache.maven.archiva", "archiva-model", "${archiva.version}" ) ); - deps.add( createDependency( "org.apache.maven.archiva", "archiva-common", "${archiva.version}" ) ); - deps.add( createDependency( "org.apache.maven.archiva", "archiva-indexer", "${archiva.version}" ) ); - - model.setDependencies( deps ); - - model.addProperty( "archiva.version", "1.0-SNAPSHOT" ); - - ProjectModelExpressionFilter filter = lookupExpression(); - - model = filter.filter( model ); - - assertNotNull( model ); - assertEquals( "Group ID", "org.apache.maven.archiva", model.getGroupId() ); - assertEquals( "Artifact ID", "archiva-test-project", model.getArtifactId() ); - assertEquals( "Version", "1.0-SNAPSHOT", model.getVersion() ); - assertNotNull( "Dependencies", model.getDependencies() ); - assertEquals( "Dependencies Size", 3, model.getDependencies().size() ); - - Iterator<Dependency> it = model.getDependencies().iterator(); - while ( it.hasNext() ) - { - Dependency dep = it.next(); - assertEquals( "Dependency [" + dep.getArtifactId() + "] Group ID", "org.apache.maven.archiva", dep - .getGroupId() ); - assertEquals( "Dependency [" + dep.getArtifactId() + "] Version", "1.0-SNAPSHOT", dep.getVersion() ); - } - } - - /** - * [MRM-487] pom version is not resolved - * [MRM-488] properties in pom are not resolved (at least while browsing) - * - * This is to ensure that any expression within the pom is evaluated properly. - */ - public void testExpressionHell() - throws Exception - { - ProjectModelExpressionFilter filter = lookupExpression(); - - ArchivaProjectModel initialModel = createArchivaProjectModel( DEFAULT_REPOSITORY - + "/org/apache/maven/test/2.0.4-SNAPSHOT/test-2.0.4-SNAPSHOT.pom" ); - - ArchivaProjectModel filteredModel = filter.filter( initialModel ); - - // Dump the evaluated model to xml - String evaluatedModelText = toModelText( filteredModel ); - - // Test xml buffer for the existance of an unevaluated expression. - boolean foundUnevaluated = false; - if ( evaluatedModelText.indexOf( "${" ) != ( -1 ) ) - { - System.err.println( "Found Expression:\n" + evaluatedModelText ); - foundUnevaluated = true; - } - - if ( foundUnevaluated ) - { - fail( "Found Unevaluated Expression. (see System.err for details)" ); - } - } - - private String toModelText( ArchivaProjectModel model ) - throws ProjectModelException, IOException - { - StringWriter strWriter = new StringWriter(); - - ProjectModelWriter modelWriter = new ProjectModel400Writer(); - modelWriter.write( model, strWriter ); - - return strWriter.toString(); - } - - private ArchivaProjectModel createArchivaProjectModel( String path ) - throws XMLException - { - ProjectModelReader reader = new ProjectModel400Reader(); - - File pomFile = new File( getBasedir(), path ); - - return reader.read( pomFile ); - } - - private Dependency createDependency( String groupId, String artifactId, String version ) - { - Dependency dep = new Dependency(); - - dep.setGroupId( groupId ); - dep.setArtifactId( artifactId ); - dep.setVersion( version ); - dep.setTransitive( false ); - - return dep; - } - -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/readers/ProjectModel300ReaderTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/readers/ProjectModel300ReaderTest.java deleted file mode 100644 index 87910d036..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/readers/ProjectModel300ReaderTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.apache.maven.archiva.repository.project.readers; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; - -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.Dependency; -import org.apache.maven.archiva.repository.project.ProjectModelReader; -import org.apache.maven.archiva.xml.XMLException; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; - -/** - * ProjectModel300ReaderTest - * - * @version $Id$ - */ -public class ProjectModel300ReaderTest - extends PlexusInSpringTestCase -{ - public void testLoadSimple() - throws XMLException - { - File defaultRepoDir = new File( getBasedir(), "src/test/repositories/legacy-repository" ); - File pomFile = new File( defaultRepoDir, "org.apache.maven/poms/maven-model-v3-2.0.pom" ); - - ProjectModelReader reader = new ProjectModel300Reader(); - - ArchivaProjectModel project = reader.read( pomFile ); - - assertNotNull( project ); - assertEquals( "Group Id", "org.apache.maven", project.getGroupId() ); - assertEquals( "Artifact Id", "maven-model-v3", project.getArtifactId() ); - assertEquals( "Version", "2.0", project.getVersion() ); - assertEquals( "Name", "Maven Model v3", project.getName() ); - assertEquals( "Description", "Maven Model v3", project.getDescription() ); - - assertNull( "Has no parent project.", project.getParentProject() ); - - assertNotNull( "Dependencies", project.getDependencies() ); - assertEquals( "Dependencies.size", 1, project.getDependencies().size() ); - - Dependency dep = (Dependency) project.getDependencies().get( 0 ); - assertNotNull( dep ); - assertEquals( "dep.groupId", "org.codehaus.plexus", dep.getGroupId() ); - assertEquals( "dep.artifactId", "plexus-utils", dep.getArtifactId() ); - assertEquals( "dep.version", "1.0.4", dep.getVersion() ); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/readers/ProjectModel400ReaderTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/readers/ProjectModel400ReaderTest.java deleted file mode 100644 index 42c64331d..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/readers/ProjectModel400ReaderTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.apache.maven.archiva.repository.project.readers; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; - -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelReader; -import org.apache.maven.archiva.xml.XMLException; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; - -/** - * ProjectModel400ReaderTest - * - * @version $Id$ - */ -public class ProjectModel400ReaderTest - extends PlexusInSpringTestCase -{ - public void testLoadSimple() - throws XMLException - { - File defaultRepoDir = new File( getBasedir(), "src/test/repositories/default-repository" ); - File pomFile = new File( defaultRepoDir, - "org/apache/maven/shared/maven-downloader/1.0/maven-downloader-1.0.pom" ); - - ProjectModelReader reader = new ProjectModel400Reader(); - - ArchivaProjectModel project = reader.read( pomFile ); - - assertNotNull( project ); - assertEquals( "Group Id", "org.apache.maven.shared", project.getGroupId() ); - assertEquals( "Artifact Id", "maven-downloader", project.getArtifactId() ); - assertEquals( "Version", "1.0", project.getVersion() ); - assertEquals( "Name", "Maven Downloader", project.getName() ); - assertEquals( "Description", "Provide a super simple interface for downloading a single artifact.", project - .getDescription() ); - - // Test for parent - VersionedReference parentRef = project.getParentProject(); - assertNotNull( "Parent Reference", parentRef ); - assertEquals( "Parent Group ID", "org.apache.maven.shared", parentRef.getGroupId() ); - assertEquals( "Parent Artifact ID", "maven-shared-components", parentRef.getArtifactId() ); - assertEquals( "Parent Version", "4", parentRef.getVersion() ); - - assertNotNull( "Dependencies", project.getDependencies() ); - assertEquals( "Dependencies.size", 3, project.getDependencies().size() ); - } - - public void testLoadWithNamespace() - throws XMLException - { - File defaultRepoDir = new File( getBasedir(), "src/test/repositories/default-repository" ); - File pomFile = new File( defaultRepoDir, - "org/apache/maven/archiva/archiva-model/1.0-SNAPSHOT/archiva-model-1.0-SNAPSHOT.pom" ); - - ProjectModelReader reader = new ProjectModel400Reader(); - - ArchivaProjectModel project = reader.read( pomFile ); - - assertNotNull( project ); - assertEquals( "Group Id", null, project.getGroupId() ); - assertEquals( "Artifact Id", "archiva-model", project.getArtifactId() ); - assertEquals( "Version", null, project.getVersion() ); - assertEquals( "Name", "Archiva Base :: Model", project.getName() ); - assertEquals( "Description", null, project.getDescription() ); - - // Test for parent - VersionedReference parentRef = project.getParentProject(); - assertNotNull( "Parent Reference", parentRef ); - assertEquals( "Parent Group ID", "org.apache.maven.archiva", parentRef.getGroupId() ); - assertEquals( "Parent Artifact ID", "archiva-base", parentRef.getArtifactId() ); - assertEquals( "Parent Version", "1.0-SNAPSHOT", parentRef.getVersion() ); - - assertNotNull( "Dependencies", project.getDependencies() ); - assertEquals( "Dependencies.size", 8, project.getDependencies().size() ); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/resolvers/ManagedRepositoryProjectResolverTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/resolvers/ManagedRepositoryProjectResolverTest.java deleted file mode 100644 index d9a315600..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/resolvers/ManagedRepositoryProjectResolverTest.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.apache.maven.archiva.repository.project.resolvers; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; - -import org.apache.maven.archiva.configuration.FileTypes; -import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; - -public class ManagedRepositoryProjectResolverTest - extends PlexusInSpringTestCase -{ - private ManagedRepositoryProjectResolver resolver; - - public void setUp() throws Exception - { - super.setUp(); - - FileTypes fileTypes = new MockFileTypes(); - - ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration(); - repoConfig.setId( "test-repo" ); - repoConfig.setLocation( new File( getBasedir(), "target/test-classes/test-repo" ).getPath() ); - repoConfig.setName( "Test Repository" ); - - ManagedDefaultRepositoryContent repository = new ManagedDefaultRepositoryContent(); - repository.setRepository( repoConfig ); - repository.setFiletypes( fileTypes ); - - resolver = new ManagedRepositoryProjectResolver( repository, new ProjectModel400Reader() ); - } - - public void testResolveSnapshotUniqueVersionPresent() - throws Exception - { - VersionedReference ref = new VersionedReference(); - ref.setGroupId( "org.apache.archiva" ); - ref.setArtifactId( "unique-version" ); - ref.setVersion( "1.0-SNAPSHOT" ); - - try - { - ArchivaProjectModel model = resolver.resolveProjectModel( ref ); - - assertNotNull( model ); - assertEquals( "org.apache.archiva", model.getGroupId() ); - assertEquals( "unique-version", model.getArtifactId() ); - assertEquals( "1.0-SNAPSHOT", model.getVersion() ); - assertEquals( "Unique Version Snapshot - Build 3", model.getName() ); - } - catch ( ProjectModelException e ) - { - fail( "A ProjectModelException should not have occurred. Instead, the latest timestamp should have been found!" ); - } - } - - public void testResolveSnapshotGenericVersionPresent() - throws Exception - { - VersionedReference ref = new VersionedReference(); - ref.setGroupId( "org.apache.archiva" ); - ref.setArtifactId( "generic-version" ); - ref.setVersion( "1.0-SNAPSHOT" ); - - ArchivaProjectModel model = resolver.resolveProjectModel( ref ); - - assertNotNull( model ); - assertEquals( "org.apache.archiva", model.getGroupId() ); - assertEquals( "generic-version", model.getArtifactId() ); - assertEquals( "1.0-SNAPSHOT", model.getVersion() ); - } - - public void testResolveSuccessful() - throws Exception - { - VersionedReference ref = new VersionedReference(); - ref.setGroupId( "org.apache.archiva" ); - ref.setArtifactId( "released-version" ); - ref.setVersion( "1.0" ); - - ArchivaProjectModel model = resolver.resolveProjectModel( ref ); - - assertNotNull( model ); - assertEquals( "org.apache.archiva", model.getGroupId() ); - assertEquals( "released-version", model.getArtifactId() ); - assertEquals( "1.0", model.getVersion() ); - } - - public void testResolveNotFound() - throws Exception - { - VersionedReference ref = new VersionedReference(); - ref.setGroupId( "org.apache.archiva" ); - ref.setArtifactId( "non-existant" ); - ref.setVersion( "2.0" ); - - try - { - resolver.resolveProjectModel( ref ); - fail( "A ProjectModelException should have been thrown." ); - } - catch( ProjectModelException e ) - { - assertTrue( true ); - } - } - - class MockFileTypes - extends FileTypes - { - public boolean matchesArtifactPattern( String relativePath ) - { - return true; - } - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/writers/ProjectModel400WriterTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/writers/ProjectModel400WriterTest.java deleted file mode 100644 index e18b46aa4..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/project/writers/ProjectModel400WriterTest.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.apache.maven.archiva.repository.project.writers; - -/* - * 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.commons.io.FileUtils; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelReader; -import org.apache.maven.archiva.repository.project.ProjectModelWriter; -import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader; -import org.apache.maven.archiva.xml.XMLException; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; -import org.custommonkey.xmlunit.DetailedDiff; -import org.custommonkey.xmlunit.Diff; - -import java.io.File; -import java.io.IOException; -import java.io.StringWriter; - -/** - * ProjectModel400WriterTest - * - * @version $Id$ - */ -public class ProjectModel400WriterTest - extends PlexusInSpringTestCase -{ - private static final String DEFAULT_REPOSITORY = "src/test/repositories/default-repository"; - - private ProjectModelWriter modelWriter; - - @Override - protected void setUp() - throws Exception - { - super.setUp(); - - modelWriter = new ProjectModel400Writer(); - } - - public void testSimpleWrite() - throws Exception - { - ArchivaProjectModel model = new ArchivaProjectModel(); - model.setGroupId( "org.apache.archiva.test" ); - model.setArtifactId( "simple-model-write" ); - model.setVersion( "1.0" ); - - String actualModel = writeToString( model ); - String expectedModel = getExpectedModelString( "model-write-400-simple.pom" ); - - assertModelSimilar( expectedModel, actualModel ); - } - - public void testReadWriteSimple() - throws Exception - { - String pathToModel = DEFAULT_REPOSITORY + "/org/apache/maven/A/1.0/A-1.0.pom"; - ArchivaProjectModel model = createArchivaProjectModel( pathToModel ); - - String actualModel = writeToString( model ); - String expectedModel = FileUtils.readFileToString( new File( pathToModel ), null ); - - assertModelSimilar( expectedModel, actualModel ); - } - - public void testReadWriteMavenParent() - throws Exception - { - ArchivaProjectModel model = createArchivaProjectModel( DEFAULT_REPOSITORY - + "/org/apache/maven/maven-parent/4/maven-parent-4.pom" ); - - String actualModel = writeToString( model ); - String expectedModel = getExpectedModelString( "maven-parent-4.pom" ); - - assertModelSimilar( expectedModel, actualModel ); - } - - public void testReadWriteCocoon() - throws Exception - { - ArchivaProjectModel model = createArchivaProjectModel( DEFAULT_REPOSITORY - + "/org/apache/cocoon/cocoon/1/cocoon-1.pom" ); - - String actualModel = writeToString( model ); - String expectedModel = getExpectedModelString( "cocoon-1.pom" ); - - assertModelSimilar( expectedModel, actualModel ); - } - - private void assertModelSimilar( String expectedModel, String actualModel ) - throws Exception - { - Diff diff = new Diff( expectedModel, actualModel ); - DetailedDiff detailedDiff = new DetailedDiff( diff ); - if ( !detailedDiff.similar() ) - { - // If it isn't similar, dump the difference. - System.out.println( detailedDiff.toString() ); - System.out.println( "-- Actual Model --\n" + actualModel + "\n---------------\n\n" ); - System.out.println( "-- Expected Model --\n" + expectedModel + "\n---------------\n\n" ); - - assertEquals( expectedModel, actualModel ); - } - } - - private String getExpectedModelString( String pomfilename ) - throws IOException - { - File pomFile = getTestFile( "src/test/expected-poms/" + pomfilename ); - return FileUtils.readFileToString( pomFile, null ); - } - - private ArchivaProjectModel createArchivaProjectModel( String path ) - throws XMLException - { - ProjectModelReader reader = new ProjectModel400Reader(); - - File pomFile = new File( getBasedir(), path ); - - return reader.read( pomFile ); - } - - private String writeToString( ArchivaProjectModel model ) - throws ProjectModelException, IOException - { - StringWriter writer = new StringWriter(); - - modelWriter.write( model, writer ); - - return writer.toString(); - } -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilterTest.xml b/archiva-modules/archiva-base/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilterTest.xml deleted file mode 100644 index 72b797c20..000000000 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/resources/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilterTest.xml +++ /dev/null @@ -1,50 +0,0 @@ -<!-- - ~ 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. - --> - -<component-set> - <components> - <component> - <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> - <role-hint>mock</role-hint> - <implementation>org.apache.maven.archiva.repository.MockConfiguration</implementation> - </component> - - <component> - <role>org.codehaus.plexus.cache.Cache</role> - <role-hint>effective-project-cache</role-hint> - <implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation> - <description>Effective Project Cache</description> - <configuration> - <disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds> - <disk-persistent>true</disk-persistent> - <disk-store-path>${java.io.tmpdir}/archiva/effectiveproject</disk-store-path> - <eternal>true</eternal> - <max-elements-in-memory>1000</max-elements-in-memory> - <memory-eviction-policy>LRU</memory-eviction-policy> - <name>effective-project-cache</name> - <overflow-to-disk>false</overflow-to-disk> - <!-- TODO: Adjust the time to live to be more sane (ie: huge 4+ hours) --> - <!-- 45 minutes = 2700 seconds --> - <time-to-idle-seconds>2700</time-to-idle-seconds> - <!-- 30 minutes = 1800 seconds --> - <time-to-live-seconds>1800</time-to-live-seconds> - </configuration> - </component> - </components> -</component-set> diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java index 76566b4d7..581c3db81 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java @@ -49,8 +49,6 @@ public interface ArchivaDAO ArtifactDAO getArtifactDAO(); - ProjectModelDAO getProjectModelDAO(); - RepositoryProblemDAO getRepositoryProblemDAO(); RepositoryContentStatisticsDAO getRepositoryContentStatisticsDAO(); diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ProjectModelDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ProjectModelDAO.java deleted file mode 100644 index 743c3735c..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ProjectModelDAO.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.apache.maven.archiva.database; - -/* - * 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.maven.archiva.model.ArchivaProjectModel; - -import java.util.List; - -/** - * ProjectModelDAO - * - * @version $Id$ - */ -public interface ProjectModelDAO -{ - /* NOTE TO ARCHIVA DEVELOPERS. - * - * Please keep this interface clean and lean. - * We don't want a repeat of the Continuum Store. - * You should have the following methods per object type ... - * - * (Required Methods) - * - * DatabaseObject .createDatabaseObject( Required Params ) ; - * List .queryDatabaseObject( Constraint ) throws ObjectNotFoundException, DatabaseException; - * DatabaseObject .saveDatabaseObject( DatabaseObject ) throws DatabaseException; - * - * (Optional Methods) - * - * DatabaseObject .getDatabaseObject( Id ) throws ObjectNotFoundException, DatabaseException; - * List .getDatabaseObjects() throws ObjectNotFoundException, DatabaseException; - * void .deleteDatabaseObject( DatabaseObject ) throws DatabaseException; - * - * This is the only list of options created in this DAO. - */ - - public ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version ); - - public ArchivaProjectModel getProjectModel( String groupId, String artifactId, String version ) - throws ObjectNotFoundException, ArchivaDatabaseException; - - public List<ArchivaProjectModel> queryProjectModels( Constraint constraint ) - throws ObjectNotFoundException, ArchivaDatabaseException; - - public ArchivaProjectModel saveProjectModel( ArchivaProjectModel model ) - throws ArchivaDatabaseException; - - public void deleteProjectModel( ArchivaProjectModel model ) - throws ArchivaDatabaseException; -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryDatabaseEventListener.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryDatabaseEventListener.java index c18f587b2..ba916d5fe 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryDatabaseEventListener.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryDatabaseEventListener.java @@ -23,15 +23,13 @@ import java.util.List; import org.apache.maven.archiva.database.constraints.RepositoryProblemByArtifactConstraint; import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.ArchivaProjectModel; import org.apache.maven.archiva.model.RepositoryProblem; import org.apache.maven.archiva.repository.ManagedRepositoryContent; import org.apache.maven.archiva.repository.events.RepositoryListener; -import org.codehaus.plexus.cache.Cache; /** * Process repository management events and respond appropriately. - * + * * @plexus.component role="org.apache.maven.archiva.repository.events.RepositoryListener" role-hint="database" */ public class RepositoryDatabaseEventListener @@ -47,23 +45,13 @@ public class RepositoryDatabaseEventListener */ private RepositoryProblemDAO repositoryProblemDAO; - /** - * @plexus.requirement role-hint="jdo" - */ - private ProjectModelDAO projectModelDAO; - - /** - * @plexus.requirement role-hint="effective-project-cache" - */ - private Cache effectiveProjectCache; - public void deleteArtifact( ManagedRepositoryContent repository, ArchivaArtifact artifact ) { try { ArchivaArtifact queriedArtifact = artifactDAO.getArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), - artifact.getClassifier(), artifact.getType() , repository.getId()); + artifact.getClassifier(), artifact.getType(), repository.getId() ); artifactDAO.deleteArtifact( queriedArtifact ); } catch ( ArchivaDatabaseException e ) @@ -90,42 +78,5 @@ public class RepositoryDatabaseEventListener { // ignored } - - if ( "pom".equals( artifact.getType() ) ) - { - try - { - ArchivaProjectModel projectModel = - projectModelDAO.getProjectModel( artifact.getGroupId(), artifact.getArtifactId(), - artifact.getVersion() ); - - projectModelDAO.deleteProjectModel( projectModel ); - - // Force removal of project model from effective cache - String projectKey = toProjectKey( projectModel ); - synchronized ( effectiveProjectCache ) - { - if ( effectiveProjectCache.hasKey( projectKey ) ) - { - effectiveProjectCache.remove( projectKey ); - } - } - } - catch ( ArchivaDatabaseException e ) - { - // ignored - } - } - } - - private String toProjectKey( ArchivaProjectModel project ) - { - StringBuilder key = new StringBuilder(); - - key.append( project.getGroupId() ).append( ":" ); - key.append( project.getArtifactId() ).append( ":" ); - key.append( project.getVersion() ); - - return key.toString(); } } diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/BrowsingResults.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/BrowsingResults.java deleted file mode 100644 index efa808a01..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/BrowsingResults.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.apache.maven.archiva.database.browsing; - -/* - * 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.commons.collections.CollectionUtils; - -import java.util.List; - -/** - * BrowsingResults - * - * @version $Id$ - */ -public class BrowsingResults -{ - private String selectedGroupId; - - private String selectedArtifactId; - - private List<String> selectedRepositoryIds = null; - - private List<String> groupIds = null; - - private List<String> artifacts = null; - - private List<String> versions = null; - - public BrowsingResults() - { - /* do nothing, this is the results of the root */ - } - - public BrowsingResults( String groupId ) - { - this.selectedGroupId = groupId; - } - - public BrowsingResults( String groupId, String artifactId ) - { - this.selectedGroupId = groupId; - this.selectedArtifactId = artifactId; - } - - public List<String> getArtifacts() - { - return artifacts; - } - - public List<String> getGroupIds() - { - return groupIds; - } - - public String getSelectedArtifactId() - { - return selectedArtifactId; - } - - public String getSelectedGroupId() - { - return selectedGroupId; - } - - public List<String> getVersions() - { - return versions; - } - - public boolean hasArtifacts() - { - return CollectionUtils.isNotEmpty( artifacts ); - } - - public boolean hasGroupIds() - { - return CollectionUtils.isNotEmpty( groupIds ); - } - - public boolean hasVersions() - { - return CollectionUtils.isNotEmpty( versions ); - } - - public void setArtifacts( List<String> artifacts ) - { - this.artifacts = artifacts; - } - - public void setGroupIds( List<String> groupIds ) - { - this.groupIds = groupIds; - } - - public void setVersions( List<String> versions ) - { - this.versions = versions; - } - - public List<String> getSelectedRepositoryIds() - { - return selectedRepositoryIds; - } - - public void setSelectedRepositoryIds( List<String> selectedRepositoryIds ) - { - this.selectedRepositoryIds = selectedRepositoryIds; - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/GroupIdFilter.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/GroupIdFilter.java deleted file mode 100644 index cd2e9b9da..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/GroupIdFilter.java +++ /dev/null @@ -1,170 +0,0 @@ -package org.apache.maven.archiva.database.browsing; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.TreeMap; - -/** - * GroupIdFilter - utility methods for filtering groupIds. - * - * @version $Id$ - */ -public class GroupIdFilter -{ - private static final String GROUP_SEPARATOR = "."; - - /** - * <p> - * Filter out excessive groupId naming. (to provide a tree-ish view of the list of groupIds). - * </p> - * - * <pre> - * // Input List - * commons-lang - * com.jsch - * org.apache.apache - * org.apache.maven - * org.codehaus.modello - * // Filtered List - * commons-lang - * com.jsch - * org - * </pre> - * - * <pre> - * // Input List - * commons-lang - * commons-io - * commons-pool - * com.jsch - * com.jsch.lib - * com.jsch.providers - * org.apache.apache - * org.apache.maven - * org.apache.maven.archiva - * org.apache.maven.shared - * // Filtered List - * commons-lang - * commons-io - * commons-pool - * com.jsch - * org.apache - * </pre> - * - * @param groups the list of groupIds. - * @return - */ - public static List<String> filterGroups( List<String> groups ) - { - GroupTreeNode tree = buildGroupTree( groups ); - return collateGroups( tree ); - } - - public static GroupTreeNode buildGroupTree( List<String> groups ) - { - GroupTreeNode rootNode = new GroupTreeNode(); - - // build a tree structure - for ( String groupId : groups ) - { - StringTokenizer tok = new StringTokenizer( groupId, GROUP_SEPARATOR ); - - GroupTreeNode node = rootNode; - - while ( tok.hasMoreTokens() ) - { - String part = tok.nextToken(); - - if ( !node.getChildren().containsKey( part ) ) - { - GroupTreeNode newNode = new GroupTreeNode( part, node ); - node.addChild( newNode ); - node = newNode; - } - else - { - node = node.getChildren().get( part ); - } - } - } - - return rootNode; - } - - private static List<String> collateGroups( GroupTreeNode rootNode ) - { - List<String> groups = new ArrayList<String>(); - for ( GroupTreeNode node : rootNode.getChildren().values() ) - { - while ( node.getChildren().size() == 1 ) - { - node = node.getChildren().values().iterator().next(); - } - - groups.add( node.getFullName() ); - } - return groups; - } - - private static class GroupTreeNode - { - private final String name; - - private final String fullName; - - private final Map<String, GroupTreeNode> children = new TreeMap<String, GroupTreeNode>(); - - GroupTreeNode() - { - name = null; - fullName = null; - } - - GroupTreeNode( String name, GroupTreeNode parent ) - { - this.name = name; - this.fullName = parent.fullName != null ? parent.fullName + GROUP_SEPARATOR + name : name; - } - - public String getName() - { - return name; - } - - public String getFullName() - { - return fullName; - } - - public Map<String, GroupTreeNode> getChildren() - { - return children; - } - - public void addChild( GroupTreeNode newNode ) - { - children.put( newNode.name, newNode ); - } - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraint.java deleted file mode 100644 index 7dc57c5fe..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraint.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.apache.maven.archiva.database.constraints; - -/* - * 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.maven.archiva.database.DeclarativeConstraint; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.Dependency; - -/** - * ProjectsByArtifactUsageConstraint - * - * @version $Id$ - */ -public class ProjectsByArtifactUsageConstraint - extends AbstractDeclarativeConstraint - implements DeclarativeConstraint -{ - private String filter; - - public ProjectsByArtifactUsageConstraint( ArchivaArtifact artifact ) - { - this( artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion() ); - } - - public ProjectsByArtifactUsageConstraint( String groupId, String artifactId, String version ) - { - super.declImports = new String[] { - "import " + Dependency.class.getName() - }; - - super.variables = new String[] { - "Dependency dep" - }; - - super.declParams = new String[] { - "String selectedGroupId", - "String selectedArtifactId", - "String selectedVersion" - }; - - filter = "dependencies.contains( dep ) && " + - "dep.groupId == selectedGroupId && " + - "dep.artifactId == selectedArtifactId && " + - "dep.version == selectedVersion"; - - super.params = new Object[] { groupId, artifactId, version }; - } - - public String getSortColumn() - { - return "groupId"; - } - - public String getWhereCondition() - { - return null; - } - - public String getFilter() - { - return filter; - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java index 54d30af86..f5b579475 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java @@ -19,16 +19,15 @@ package org.apache.maven.archiva.database.jdo; * under the License. */ +import java.io.Serializable; +import java.util.List; + import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.ArtifactDAO; -import org.apache.maven.archiva.database.ProjectModelDAO; import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO; import org.apache.maven.archiva.database.RepositoryProblemDAO; import org.apache.maven.archiva.database.SimpleConstraint; -import java.io.Serializable; -import java.util.List; - /** * JdoArchivaDAO * @@ -52,11 +51,6 @@ public class JdoArchivaDAO /** * @plexus.requirement role-hint="jdo" */ - private ProjectModelDAO projectModelDAO; - - /** - * @plexus.requirement role-hint="jdo" - */ private RepositoryProblemDAO repositoryProblemDAO; /** @@ -64,6 +58,10 @@ public class JdoArchivaDAO */ private RepositoryContentStatisticsDAO repositoryContentStatisticsDAO; + public JdoArchivaDAO() + { + super(); //To change body of overridden methods use File | Settings | File Templates. + } public List<?> query( SimpleConstraint constraint ) { @@ -80,11 +78,6 @@ public class JdoArchivaDAO return artifactDAO; } - public ProjectModelDAO getProjectModelDAO() - { - return projectModelDAO; - } - public RepositoryProblemDAO getRepositoryProblemDAO() { return repositoryProblemDAO; diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAO.java deleted file mode 100644 index 12c223018..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAO.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.apache.maven.archiva.database.jdo; - -/* - * 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.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.Constraint; -import org.apache.maven.archiva.database.ObjectNotFoundException; -import org.apache.maven.archiva.database.ProjectModelDAO; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.jpox.ArchivaProjectModelKey; - -import java.util.List; - -/** - * JdoProjectModelDAO - * - * @version $Id$ - * - * @plexus.component role-hint="jdo" - */ -public class JdoProjectModelDAO - implements ProjectModelDAO -{ - /** - * @plexus.requirement role-hint="archiva" - */ - private JdoAccess jdo; - - public ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version ) - { - ArchivaProjectModel model; - - try - { - model = getProjectModel( groupId, artifactId, version ); - } - catch ( ArchivaDatabaseException e ) - { - model = new ArchivaProjectModel(); - model.setGroupId( groupId ); - model.setArtifactId( artifactId ); - model.setVersion( version ); - } - - return model; - } - - public ArchivaProjectModel getProjectModel( String groupId, String artifactId, String version ) - throws ObjectNotFoundException, ArchivaDatabaseException - { - ArchivaProjectModelKey key = new ArchivaProjectModelKey(); - key.groupId = groupId; - key.artifactId = artifactId; - key.version = version; - - return (ArchivaProjectModel) jdo.getObjectById( ArchivaProjectModel.class, key, null ); - } - - @SuppressWarnings("unchecked") - public List<ArchivaProjectModel> queryProjectModels( Constraint constraint ) - throws ObjectNotFoundException, ArchivaDatabaseException - { - return (List<ArchivaProjectModel>) jdo.queryObjects( ArchivaProjectModel.class, constraint ); - } - - public ArchivaProjectModel saveProjectModel( ArchivaProjectModel model ) - throws ArchivaDatabaseException - { - return (ArchivaProjectModel) jdo.saveObject( model ); - } - - public void deleteProjectModel( ArchivaProjectModel model ) - throws ArchivaDatabaseException - { - jdo.removeObject( model ); - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/DatabaseProjectModelResolver.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/DatabaseProjectModelResolver.java deleted file mode 100644 index c05b624ec..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/DatabaseProjectModelResolver.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.apache.maven.archiva.database.project; - -/* - * 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.maven.archiva.database.ArchivaDAO; -import org.apache.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.ObjectNotFoundException; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelResolver; - -/** - * Resolves a project model from the database. - * - * @version $Id$ - * - * @plexus.component role="org.apache.maven.archiva.repository.project.ProjectModelResolver" - * role-hint="database" - */ -public class DatabaseProjectModelResolver - implements ProjectModelResolver -{ - /** - * @plexus.requirement role-hint="jdo" - */ - private ArchivaDAO dao; - - public ArchivaProjectModel resolveProjectModel( VersionedReference reference ) - throws ProjectModelException - { - try - { - ArchivaProjectModel model = dao.getProjectModelDAO().getProjectModel( reference.getGroupId(), - reference.getArtifactId(), - reference.getVersion() ); - return model; - } - catch ( ObjectNotFoundException e ) - { - return null; - } - catch ( ArchivaDatabaseException e ) - { - return null; - } - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/ProjectModelToDatabaseListener.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/ProjectModelToDatabaseListener.java deleted file mode 100644 index edba43335..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/ProjectModelToDatabaseListener.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.apache.maven.archiva.database.project; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.List; - -import org.apache.maven.archiva.database.ArchivaDAO; -import org.apache.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.ObjectNotFoundException; -import org.apache.maven.archiva.model.ArchivaModelCloner; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelResolver; -import org.apache.maven.archiva.repository.project.resolvers.FilesystemBasedResolver; -import org.apache.maven.archiva.repository.project.resolvers.ProjectModelResolutionListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Just in Time save of project models to the database, implemented as a listener - * on {@link ProjectModelResolver} objects that implement {@link FilesystemBasedResolver}. - * - * @version $Id$ - * - * @plexus.component - * role="org.apache.maven.archiva.repository.project.resolvers.ProjectModelResolutionListener" - * role-hint="model-to-db" - */ -public class ProjectModelToDatabaseListener - implements ProjectModelResolutionListener -{ - private Logger log = LoggerFactory.getLogger( ProjectModelToDatabaseListener.class ); - - /** - * @plexus.requirement role-hint="jdo" - */ - private ArchivaDAO dao; - - private void saveInDatabase( ArchivaProjectModel model ) - throws ProjectModelException - { - try - { - dao.getProjectModelDAO().saveProjectModel( model ); - } - catch ( ArchivaDatabaseException e ) - { - throw new ProjectModelException( "Unable to save model to database: " + e.getMessage(), e ); - } - } - - private void removeFromDatabase( ArchivaProjectModel model ) - throws ProjectModelException - { - try - { - dao.getProjectModelDAO().deleteProjectModel( model ); - } - catch ( ArchivaDatabaseException e ) - { - throw new ProjectModelException( "Unable to remove existing model from database: " + e.getMessage(), e ); - } - } - - private boolean existsInDatabase( ArchivaProjectModel model ) - throws ProjectModelException - { - try - { - ArchivaProjectModel dbmodel = dao.getProjectModelDAO().getProjectModel( model.getGroupId(), - model.getArtifactId(), - model.getVersion() ); - - return ( dbmodel != null ); - } - catch ( ObjectNotFoundException e ) - { - return false; - } - catch ( ArchivaDatabaseException e ) - { - throw new ProjectModelException( "Unable to check for existing model from database: " + e.getMessage(), e ); - } - } - - public void resolutionAttempting( VersionedReference projectRef, ProjectModelResolver resolver ) - { - /* do nothing */ - } - - public void resolutionError( VersionedReference projectRef, ProjectModelResolver resolver, Exception cause ) - { - /* do nothing */ - } - - public void resolutionMiss( VersionedReference projectRef, ProjectModelResolver resolver ) - { - /* do nothing */ - } - - public void resolutionNotFound( VersionedReference projectRef, List<ProjectModelResolver> resolverList ) - { - /* do nothing */ - } - - public void resolutionStart( VersionedReference projectRef, List<ProjectModelResolver> resolverList ) - { - /* do nothing */ - } - - public void resolutionSuccess( VersionedReference projectRef, ProjectModelResolver resolver, - ArchivaProjectModel model ) - { - if ( !( resolver instanceof FilesystemBasedResolver ) ) - { - // Nothing to do. skip it. - return; - } - - // Clone model, since DAO while detachingCopy resets contents of the model - // this changes behaviour of EffectiveProjectModelFilter - model = ArchivaModelCloner.clone( model ); - - try - { - // Test if it exists. - if ( existsInDatabase( model ) ) - { - removeFromDatabase( model ); - } - - saveInDatabase( model ); - } - catch ( ProjectModelException e ) - { - log.warn( e.getMessage(), e ); - } - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java deleted file mode 100644 index ed0fad974..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.Predicate; -import org.apache.commons.collections.functors.OrPredicate; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; -import org.apache.maven.archiva.consumers.functors.PermanentConsumerPredicate; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; - -/** - * DatabaseConsumers - * - * @version $Id$ - */ -public class DatabaseConsumers - implements ApplicationContextAware -{ - private ArchivaConfiguration archivaConfiguration; - - private Predicate selectedUnprocessedConsumers; - - private ApplicationContext applicationContext; - - public DatabaseConsumers( ArchivaConfiguration archivaConfiguration ) - { - this.archivaConfiguration = archivaConfiguration; - - Predicate permanentConsumers = new PermanentConsumerPredicate(); - - selectedUnprocessedConsumers = new OrPredicate( permanentConsumers, new SelectedUnprocessedConsumersPredicate() ); - } - - class SelectedUnprocessedConsumersPredicate - implements Predicate - { - public boolean evaluate( Object object ) - { - boolean satisfies = false; - - if ( object instanceof DatabaseUnprocessedArtifactConsumer ) - { - DatabaseUnprocessedArtifactConsumer consumer = (DatabaseUnprocessedArtifactConsumer) object; - DatabaseScanningConfiguration config = archivaConfiguration.getConfiguration().getDatabaseScanning(); - - return config.getUnprocessedConsumers().contains( consumer.getId() ); - } - - return satisfies; - } - } - - public void initialize() - throws InitializationException - { - Predicate permanentConsumers = new PermanentConsumerPredicate(); - - selectedUnprocessedConsumers = new OrPredicate( permanentConsumers, new SelectedUnprocessedConsumersPredicate() ); - } - - public void setApplicationContext( ApplicationContext applicationContext ) - throws BeansException - { - this.applicationContext = applicationContext; - } - - /** - * Get the {@link List} of {@link DatabaseUnprocessedArtifactConsumer} objects - * for those consumers selected due to the configuration. - * - * @return the list of selected {@link DatabaseUnprocessedArtifactConsumer} objects. - */ - @SuppressWarnings("unchecked") - public List<ArchivaArtifactConsumer> getSelectedUnprocessedConsumers() - { - List<ArchivaArtifactConsumer> ret = new ArrayList<ArchivaArtifactConsumer>(); - ret.addAll( CollectionUtils.select( getAvailableUnprocessedConsumers(), selectedUnprocessedConsumers ) ); - return ret; - } - - /** - * Get the complete {@link List} of {@link DatabaseUnprocessedArtifactConsumer} objects - * that are available in the system, regardless of configuration. - * - * @return the list of all available {@link DatabaseUnprocessedArtifactConsumer} objects. - */ - @SuppressWarnings("unchecked") - public List<DatabaseUnprocessedArtifactConsumer> getAvailableUnprocessedConsumers() - { - return new ArrayList<DatabaseUnprocessedArtifactConsumer>( applicationContext.getBeansOfType( DatabaseUnprocessedArtifactConsumer.class ).values() ); - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseUnprocessedArtifactConsumer.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseUnprocessedArtifactConsumer.java deleted file mode 100644 index a3cde7eaa..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseUnprocessedArtifactConsumer.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * 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. - */ - -/** - * DatabaseUnprocessedArtifactConsumer - * - * @version $Id$ - */ -public interface DatabaseUnprocessedArtifactConsumer - extends ArchivaArtifactConsumer -{ - -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseUpdater.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseUpdater.java deleted file mode 100644 index b6e5b0fba..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseUpdater.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * 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.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.model.ArchivaArtifact; - -/** - * The database update component. - * - * @version $Id$ - */ -public interface DatabaseUpdater -{ - /** - * Update all unprocessed content. - * - * @throws ArchivaDatabaseException if there was a fatal error with the database. - */ - public void updateAllUnprocessed() - throws ArchivaDatabaseException; - - /** - * Update specific unprocessed content. - * - * @throws ArchivaDatabaseException if there was a fatal error with the database. - */ - public void updateUnprocessed( ArchivaArtifact artifact ) - throws ArchivaDatabaseException; -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java deleted file mode 100644 index cde8fc8af..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Date; -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.IteratorUtils; -import org.apache.commons.collections.Predicate; -import org.apache.maven.archiva.database.ArchivaDAO; -import org.apache.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.constraints.ArtifactsProcessedConstraint; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.functors.UnprocessedArtifactPredicate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * JdoDatabaseUpdater - * - * @version $Id$ - * - * @plexus.component role="org.apache.maven.archiva.database.updater.DatabaseUpdater" - * role-hint="jdo" - */ -public class JdoDatabaseUpdater - implements DatabaseUpdater -{ - private Logger log = LoggerFactory.getLogger( JdoDatabaseUpdater.class ); - - /** - * @plexus.requirement role-hint="jdo" - */ - private ArchivaDAO dao; - - /** - * @plexus.requirement - */ - private DatabaseConsumers dbConsumers; - - private ProcessArchivaArtifactClosure processArtifactClosure = new ProcessArchivaArtifactClosure(); - - public void updateAllUnprocessed() - throws ArchivaDatabaseException - { - List<ArchivaArtifact> unprocessedArtifacts = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( false ) ); - - beginConsumerLifecycle( dbConsumers.getSelectedUnprocessedConsumers() ); - - try - { - // Process each consumer. - Predicate predicate = UnprocessedArtifactPredicate.getInstance(); - - Iterator<ArchivaArtifact> it = IteratorUtils.filteredIterator( unprocessedArtifacts.iterator(), predicate ); - while ( it.hasNext() ) - { - ArchivaArtifact artifact = it.next(); - updateUnprocessed( artifact ); - } - } - finally - { - endConsumerLifecycle( dbConsumers.getSelectedUnprocessedConsumers() ); - } - } - - private void endConsumerLifecycle( List<ArchivaArtifactConsumer> consumers ) - { - for ( ArchivaArtifactConsumer consumer : consumers ) - { - consumer.completeScan(); - } - } - - private void beginConsumerLifecycle( List<ArchivaArtifactConsumer> consumers ) - { - for ( ArchivaArtifactConsumer consumer : consumers ) - { - consumer.beginScan(); - } - } - - public void updateUnprocessed( ArchivaArtifact artifact ) - throws ArchivaDatabaseException - { - List<ArchivaArtifactConsumer> consumers = dbConsumers.getSelectedUnprocessedConsumers(); - - if ( CollectionUtils.isEmpty( consumers ) ) - { - log.warn( "There are no selected consumers for unprocessed artifacts." ); - return; - } - - this.processArtifactClosure.setArtifact( artifact ); - CollectionUtils.forAllDo( consumers, this.processArtifactClosure ); - - artifact.getModel().setWhenProcessed( new Date() ); - dao.getArtifactDAO().saveArtifact( artifact ); - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/ProcessArchivaArtifactClosure.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/ProcessArchivaArtifactClosure.java deleted file mode 100644 index eee178b8f..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/ProcessArchivaArtifactClosure.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * 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.commons.collections.Closure; -import org.apache.maven.archiva.consumers.ConsumerException; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * ProcessArchivaArtifactClosure - * - * @version $Id$ - */ -class ProcessArchivaArtifactClosure - implements Closure -{ - private Logger log = LoggerFactory.getLogger( ProcessArchivaArtifactClosure.class ); - - private ArchivaArtifact artifact; - - public void execute( Object input ) - { - if ( input instanceof ArchivaArtifactConsumer ) - { - ArchivaArtifactConsumer consumer = (ArchivaArtifactConsumer) input; - - try - { - consumer.processArchivaArtifact( artifact ); - } - catch ( ConsumerException e ) - { - log.warn( "Unable to process artifact [" + artifact + "] with consumer [" + consumer.getId() + "]", e ); - } - } - - } - - public ArchivaArtifact getArtifact() - { - return artifact; - } - - public void setArtifact( ArchivaArtifact artifact ) - { - this.artifact = artifact; - } -} diff --git a/archiva-modules/archiva-database/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-database/src/main/resources/META-INF/spring-context.xml deleted file mode 100644 index 53b798ec8..000000000 --- a/archiva-modules/archiva-database/src/main/resources/META-INF/spring-context.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - - <bean id="databaseConsumers" class="org.apache.maven.archiva.database.updater.DatabaseConsumers" scope="prototype"> - <constructor-arg> - <ref bean="archivaConfiguration"/> - </constructor-arg> - </bean> -</beans>
\ No newline at end of file diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java index 3a8865b73..7c5321553 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java @@ -29,8 +29,6 @@ import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer; -import org.apache.maven.archiva.database.updater.TestDatabaseUnprocessedConsumer; import org.apache.maven.archiva.model.ArtifactReference; import org.apache.maven.archiva.model.VersionedReference; import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory; @@ -128,16 +126,6 @@ public abstract class AbstractArchivaDatabaseTestCase this.dao = (ArchivaDAO) lookup( ArchivaDAO.class.getName(), "jdo" ); } - protected TestDatabaseUnprocessedConsumer lookupTestUnprocessedConsumer() - throws Exception - { - TestDatabaseUnprocessedConsumer consumer = (TestDatabaseUnprocessedConsumer) lookup( - DatabaseUnprocessedArtifactConsumer.class, - "test-db-unprocessed" ); - assertNotNull( "Test Database Unprocessed Consumer should not be null.", consumer ); - return consumer; - } - protected Date toDate( String txt ) throws Exception { diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraintTest.java deleted file mode 100644 index 7795b3a9a..000000000 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraintTest.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.apache.maven.archiva.database.constraints; - -/* - * 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.maven.archiva.database.AbstractArchivaDatabaseTestCase; -import org.apache.maven.archiva.database.DeclarativeConstraint; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.ArtifactReference; -import org.apache.maven.archiva.model.Dependency; -import org.apache.maven.archiva.model.VersionedReference; - -import java.util.Date; -import java.util.List; - -/** - * ProjectsByArtifactUsageConstraintTest - * - * @version $Id$ - */ -public class ProjectsByArtifactUsageConstraintTest - extends AbstractArchivaDatabaseTestCase -{ - @Override - protected void setUp() - throws Exception - { - super.setUp(); - } - - private void saveModel( String modelId, String deps[] ) - throws Exception - { - ArchivaProjectModel model = new ArchivaProjectModel(); - // Piece together a simple model. - VersionedReference ref = toVersionedReference( modelId ); - model.setGroupId( ref.getGroupId() ); - model.setArtifactId( ref.getArtifactId() ); - model.setVersion( ref.getVersion() ); - model.setPackaging( "jar" ); - model.setOrigin( "testcase" ); - - if ( deps != null ) - { - for ( int i = 0; i < deps.length; i++ ) - { - ArtifactReference artiref = toArtifactReference( deps[i] ); - Dependency dep = new Dependency(); - dep.setGroupId( artiref.getGroupId() ); - dep.setArtifactId( artiref.getArtifactId() ); - dep.setVersion( artiref.getVersion() ); - dep.setClassifier( artiref.getClassifier() ); - dep.setClassifier( artiref.getType() ); - - model.addDependency( dep ); - } - } - - dao.getProjectModelDAO().saveProjectModel( model ); - } - - public ArchivaArtifact toArtifact( String id ) - { - ArtifactReference ref = toArtifactReference( id ); - - ArchivaArtifact artifact = new ArchivaArtifact( ref.getGroupId(), ref.getArtifactId(), ref.getVersion(), ref - .getClassifier(), ref.getType(), "testable_repo" ); - artifact.getModel().setLastModified( new Date() ); - artifact.getModel().setRepositoryId( "testable_repo" ); - return artifact; - } - - public void testContraint() - throws Exception - { - saveModel( "org.apache.maven.archiva:archiva-configuration:1.0", - new String[] { "org.codehaus.plexus:plexus-digest:1.0::jar:" } ); - - saveModel( "org.apache.maven.archiva:archiva-common:1.0", new String[] { - "org.codehaus.plexus:plexus-digest:1.0::jar:", - "junit:junit:3.8.1::jar:" } ); - - ArchivaArtifact artifact; - - artifact = toArtifact( "org.foo:bar:4.0::jar:" ); - assertConstraint( 0, new ProjectsByArtifactUsageConstraint( artifact ) ); - artifact = toArtifact( "org.codehaus.plexus:plexus-digest:1.0::jar:testable_repo" ); - assertConstraint( 2, new ProjectsByArtifactUsageConstraint( artifact ) ); - } - - private void assertConstraint( int expectedHits, DeclarativeConstraint constraint ) - throws Exception - { - List<ArchivaProjectModel> results = dao.getProjectModelDAO().queryProjectModels( constraint ); - assertNotNull( "Projects By Artifact Usage: Not Null", results ); - assertEquals( "Projects By Artifact Usage: Results.size", expectedHits, results.size() ); - } -} diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java index 2ec9cde2b..c0c06bb1d 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java @@ -32,7 +32,6 @@ public class JdoArchivaDAOTest public void testSubDAOs() { assertNotNull( "Artifact DAO", dao.getArtifactDAO() ); - assertNotNull( "Project Model DAO", dao.getProjectModelDAO() ); assertNotNull( "Repository Problem DAO", dao.getRepositoryProblemDAO() ); } } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java deleted file mode 100644 index c51168468..000000000 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java +++ /dev/null @@ -1,168 +0,0 @@ -package org.apache.maven.archiva.database.jdo; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.jdo.JDOHelper; - -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase; -import org.apache.maven.archiva.database.ProjectModelDAO; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.repository.project.ProjectModelReader; -import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader; - -/** - * JdoProjectModelDAOTest - * - * @version $Id$ - */ -public class JdoProjectModelDAOTest - extends AbstractArchivaDatabaseTestCase -{ - public void testProjectModelCRUD() - throws Exception - { - ProjectModelDAO projectDao = dao.getProjectModelDAO(); - - // Create it - ArchivaProjectModel model = projectDao.createProjectModel( "org.apache.maven.archiva", "archiva-test-module", - "1.0" ); - assertNotNull( model ); - - // Set some mandatory values - model.setPackaging( "pom" ); - model.setWhenIndexed( new Date() ); - model.setOrigin( "test" ); - - // Save it. - ArchivaProjectModel savedModel = projectDao.saveProjectModel( model ); - assertNotNull( savedModel ); - String savedKeyId = JDOHelper.getObjectId( savedModel ).toString(); - assertEquals( "org.apache.maven.archiva:archiva-test-module:1.0", savedKeyId ); - - // Test that something has been saved. - List<ArchivaProjectModel> projects = projectDao.queryProjectModels( null ); - assertNotNull( projects ); - assertEquals( 1, projects.size() ); - - // Test that retrieved object is what we expect. - ArchivaProjectModel firstModel = (ArchivaProjectModel) projects.get( 0 ); - assertNotNull( firstModel ); - assertEquals( "org.apache.maven.archiva", firstModel.getGroupId() ); - assertEquals( "archiva-test-module", firstModel.getArtifactId() ); - assertEquals( "1.0", firstModel.getVersion() ); - - // Change value and save. - savedModel.setOrigin( "changed" ); - projectDao.saveProjectModel( savedModel ); - - // Test that only 1 object is saved. - assertEquals( 1, projectDao.queryProjectModels( null ).size() ); - - // Get the specific artifact. - ArchivaProjectModel actualModel = projectDao.getProjectModel( "org.apache.maven.archiva", - "archiva-test-module", "1.0" ); - assertNotNull( actualModel ); - - // Test expected values. - assertEquals( "archiva-test-module", actualModel.getArtifactId() ); - assertEquals( "changed", actualModel.getOrigin() ); - - // Test that only 1 object is saved. - assertEquals( 1, projectDao.queryProjectModels( null ).size() ); - - // Delete object. - projectDao.deleteProjectModel( actualModel ); - assertEquals( 0, projectDao.queryProjectModels( null ).size() ); - } - - public void testSaveGetRealProjectModel() - throws Exception - { - String groupId = "org.apache.maven.shared"; - String artifactId = "maven-shared-jar"; - String version = "1.0-SNAPSHOT"; - - ProjectModelDAO projectDao = dao.getProjectModelDAO(); - - ProjectModelReader modelReader = new ProjectModel400Reader(); - - File pomFile = getTestFile( "src/test/resources/projects/maven-shared-jar-1.0-SNAPSHOT.pom" ); - - assertTrue( "pom file should exist: " + pomFile.getAbsolutePath(), pomFile.exists() && pomFile.isFile() ); - - ArchivaProjectModel model = modelReader.read( pomFile ); - assertNotNull( "Model should not be null.", model ); - - /* NOTE: We are intentionally using a basic project model in this unit test. - * The expansion of expressions, resolving of dependencies, and merging - * of parent poms is *NOT* performed to keep this unit test simple. - */ - - // Fill in mandatory/missing fields - model.setGroupId( groupId ); - model.setOrigin( "testcase" ); - - projectDao.saveProjectModel( model ); - - ArchivaProjectModel savedModel = projectDao.getProjectModel( groupId, artifactId, version ); - assertNotNull( "Project model should not be null.", savedModel ); - - // Test proper detachment of sub-objects. - List<String> exprs = new ArrayList<String>(); - exprs.add( "parentProject.groupId" ); - exprs.add( "organization.name" ); - exprs.add( "issueManagement.system" ); - exprs.add( "ciManagement.system" ); - exprs.add( "scm.url" ); - exprs.add( "individuals[0].name" ); - exprs.add( "dependencies[0].groupId" ); - exprs.add( "dependencyManagement[0].artifactId" ); - exprs.add( "repositories[0].id" ); - exprs.add( "plugins[0].artifactId" ); - exprs.add( "reports[0].artifactId" ); - exprs.add( "buildExtensions[0].artifactId" ); - exprs.add( "licenses[0].url" ); - exprs.add( "mailingLists[0].name" ); - - for ( String expr : exprs ) - { - try - { - Object obj = PropertyUtils.getProperty( model, expr ); - assertNotNull( "Expr \"" + expr + "\" != null", obj ); - assertTrue( "Expr \"" + expr + "\" should be a String.", ( obj instanceof String ) ); - String value = (String) obj; - assertTrue( "Expr \"" + expr + "\" value should not be blank.", StringUtils.isNotBlank( value ) ); - } - catch ( IndexOutOfBoundsException e ) - { - fail( "Expr \"" + expr + "\" unable to get indexed property: " + e.getClass().getName() + ": " - + e.getMessage() ); - } - } - } -} diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.java deleted file mode 100644 index c62f112f4..000000000 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.List; - -import org.apache.commons.collections.CollectionUtils; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; - -/** - * DatabaseConsumersTest - * - * @version $Id$ - */ -public class DatabaseConsumersTest - extends PlexusInSpringTestCase -{ - private DatabaseConsumers lookupDbConsumers() - throws Exception - { - DatabaseConsumers dbconsumers = (DatabaseConsumers) lookup( DatabaseConsumers.class ); - assertNotNull( "DatabaseConsumers should not be null.", dbconsumers ); - return dbconsumers; - } - - public void testGetAvailableUnprocessedConsumers() - throws Exception - { - DatabaseConsumers dbconsumers = lookupDbConsumers(); - List<DatabaseUnprocessedArtifactConsumer> available = dbconsumers.getAvailableUnprocessedConsumers(); - assertNotNull( "Available Unprocessed Consumers should never be null.", available ); - - assertTrue( "Available Unprocessed Consumers should have entries.", CollectionUtils.isNotEmpty( available ) ); - } - - public void testGetSelectedUnprocessedConsumers() - throws Exception - { - DatabaseConsumers dbconsumers = lookupDbConsumers(); - List<ArchivaArtifactConsumer> available = dbconsumers.getSelectedUnprocessedConsumers(); - assertNotNull( "Selected Unprocessed Consumers should never be null.", available ); - - assertTrue( "Selected Unprocessed Consumers should have entries.", CollectionUtils.isNotEmpty( available ) ); - } - -} diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.java deleted file mode 100644 index 2056123b3..000000000 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * 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.maven.archiva.database.AbstractArchivaDatabaseTestCase; -import org.apache.maven.archiva.database.ArtifactDAO; -import org.apache.maven.archiva.model.ArchivaArtifact; - -import java.util.Date; - -/** - * DatabaseUpdaterTest - * - * @version $Id$ - */ -public class DatabaseUpdaterTest - extends AbstractArchivaDatabaseTestCase -{ - private DatabaseUpdater dbupdater; - - public ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String whenProcessed ) - throws Exception - { - ArchivaArtifact artifact = dao.getArtifactDAO().createArtifact( groupId, artifactId, version, "", "jar", "testrepo" ); - assertNotNull( "Artifact should not be null.", artifact ); - Date dateWhenProcessed = null; - - if ( whenProcessed != null ) - { - dateWhenProcessed = toDate( whenProcessed ); - } - - artifact.getModel().setWhenProcessed( dateWhenProcessed ); - - // Satisfy table / column requirements. - artifact.getModel().setLastModified( new Date() ); - - return artifact; - } - - @Override - protected void setUp() - throws Exception - { - super.setUp(); - - ArtifactDAO adao = dao.getArtifactDAO(); - assertNotNull( "Artifact DAO should not be null.", adao ); - - adao.saveArtifact( createArtifact( "org.apache.maven.archiva", "archiva-common", "1.0-SNAPSHOT", null ) ); - adao.saveArtifact( createArtifact( "org.apache.maven.archiva", "archiva-utils", "1.0-SNAPSHOT", null ) ); - adao.saveArtifact( createArtifact( "org.apache.maven.archiva", "archiva-old", "0.1", "2004/02/15 9:01:00" ) ); - adao.saveArtifact( createArtifact( "org.apache.maven.archiva", "archiva-database", "1.0-SNAPSHOT", null ) ); - - dbupdater = (DatabaseUpdater) lookup( DatabaseUpdater.class, "jdo" ); - assertNotNull( "DatabaseUpdater should not be null.", dbupdater ); - } - - public void testUpdateUnprocessed() - throws Exception - { - String groupId = "org.apache.maven.archiva"; - String artifactId = "archiva-utils"; - String version = "1.0-SNAPSHOT"; - String classifier = ""; - String type = "jar"; - - TestDatabaseUnprocessedConsumer consumer = lookupTestUnprocessedConsumer(); - consumer.resetCount(); - - // Check the state of the artifact in the DB. - ArchivaArtifact savedArtifact = dao.getArtifactDAO().getArtifact( groupId, artifactId, version, classifier, - type, "testrepo" ); - assertFalse( "Artifact should not be considered processed (yet).", savedArtifact.getModel().isProcessed() ); - - // Update the artifact - dbupdater.updateUnprocessed( savedArtifact ); - - // Check the update. - ArchivaArtifact processed = dao.getArtifactDAO().getArtifact( groupId, artifactId, version, classifier, type, "testrepo" ); - assertTrue( "Artifact should be flagged as processed.", processed.getModel().isProcessed() ); - - // Did the unprocessed consumer do it's thing? - assertEquals( "Processed Count.", 1, consumer.getCountProcessed() ); - } -} diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseUnprocessedConsumer.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseUnprocessedConsumer.java deleted file mode 100644 index f35dd67d6..000000000 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseUnprocessedConsumer.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer; -import org.apache.maven.archiva.consumers.ConsumerException; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * TestDatabaseUnprocessedConsumer - * - * @version $Id$ - */ -public class TestDatabaseUnprocessedConsumer - extends AbstractMonitoredConsumer - implements DatabaseUnprocessedArtifactConsumer -{ - private Logger log = LoggerFactory.getLogger( TestDatabaseUnprocessedConsumer.class ); - - private int countBegin = 0; - - private int countComplete = 0; - - private int countProcessed = 0; - - public void resetCount() - { - countBegin = 0; - countProcessed = 0; - countComplete = 0; - } - - public void beginScan() - { - countBegin++; - } - - public void completeScan() - { - countComplete++; - } - - public List<String> getIncludedTypes() - { - List<String> types = new ArrayList<String>(); - types.add( "pom" ); - types.add( "jar" ); - return types; - } - - public void processArchivaArtifact( ArchivaArtifact artifact ) - throws ConsumerException - { - log.info( "Processing Artifact: " + artifact ); - countProcessed++; - } - - public String getDescription() - { - return "Test Consumer for Database Unprocessed"; - } - - public String getId() - { - return "test-db-unprocessed"; - } - - public boolean isPermanent() - { - return false; - } - - public int getCountBegin() - { - return countBegin; - } - - public int getCountComplete() - { - return countComplete; - } - - public int getCountProcessed() - { - return countProcessed; - } -} diff --git a/archiva-modules/archiva-database/src/test/resources/META-INF/plexus/components.xml b/archiva-modules/archiva-database/src/test/resources/META-INF/plexus/components.xml index 4783e9e1f..0e6441f55 100644 --- a/archiva-modules/archiva-database/src/test/resources/META-INF/plexus/components.xml +++ b/archiva-modules/archiva-database/src/test/resources/META-INF/plexus/components.xml @@ -14,12 +14,6 @@ </otherProperties> </configuration> </component> - - <component> - <role>org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer</role> - <role-hint>test-db-unprocessed</role-hint> - <implementation>org.apache.maven.archiva.database.updater.TestDatabaseUnprocessedConsumer</implementation> - </component> </components> </component-set> diff --git a/archiva-modules/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.xml b/archiva-modules/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.xml deleted file mode 100644 index c9e47bd41..000000000 --- a/archiva-modules/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" ?> - -<component-set> - <components> - <component> - <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> - <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation> - <requirements> - <requirement> - <role>org.codehaus.plexus.registry.Registry</role> - <role-hint>configured</role-hint> - </requirement> - <requirement> - <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role> - <field-name>prePolicies</field-name> - </requirement> - <requirement> - <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role> - <field-name>postPolicies</field-name> - </requirement> - </requirements> - </component> - <component> - <role>org.codehaus.plexus.registry.Registry</role> - <role-hint>configured</role-hint> - <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation> - <configuration> - <properties> - <system/> - <xml fileName="${basedir}/src/test/resources/archiva-test.xml" - config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/> - </properties> - </configuration> - </component> - </components> -</component-set> - diff --git a/archiva-modules/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.xml b/archiva-modules/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.xml deleted file mode 100644 index c9e47bd41..000000000 --- a/archiva-modules/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" ?> - -<component-set> - <components> - <component> - <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> - <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation> - <requirements> - <requirement> - <role>org.codehaus.plexus.registry.Registry</role> - <role-hint>configured</role-hint> - </requirement> - <requirement> - <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role> - <field-name>prePolicies</field-name> - </requirement> - <requirement> - <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role> - <field-name>postPolicies</field-name> - </requirement> - </requirements> - </component> - <component> - <role>org.codehaus.plexus.registry.Registry</role> - <role-hint>configured</role-hint> - <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation> - <configuration> - <properties> - <system/> - <xml fileName="${basedir}/src/test/resources/archiva-test.xml" - config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/> - </properties> - </configuration> - </component> - </components> -</component-set> - diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/pom.xml deleted file mode 100644 index 73c70f4a8..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - <parent> - <artifactId>archiva-scheduler</artifactId> - <groupId>org.apache.archiva</groupId> - <version>1.3-SNAPSHOT</version> - </parent> - <artifactId>archiva-scheduler-database</artifactId> - <name>Archiva Base :: Scheduled Tasks :: Database</name> - <dependencies> - <dependency> - <groupId>org.apache.archiva</groupId> - <artifactId>archiva-scheduler-api</artifactId> - </dependency> - <dependency> - <groupId>org.apache.archiva</groupId> - <artifactId>archiva-configuration</artifactId> - </dependency> - <dependency> - <groupId>org.apache.archiva</groupId> - <artifactId>archiva-database</artifactId> - </dependency> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-quartz</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-simple</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>hsqldb</groupId> - <artifactId>hsqldb</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-spring</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-component-metadata</artifactId> - <executions> - <execution> - <id>merge</id> - <goals> - <goal>merge-metadata</goal> - </goals> - <configuration> - <descriptors> - <descriptor>${basedir}/src/main/resources/META-INF/plexus/components.xml</descriptor> - <descriptor>${project.build.outputDirectory}/META-INF/plexus/components.xml</descriptor> - </descriptors> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutor.java deleted file mode 100644 index a675d8e51..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutor.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.apache.archiva.scheduler.database; - -/* - * 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.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.updater.DatabaseUpdater; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; -import org.codehaus.plexus.taskqueue.Task; -import org.codehaus.plexus.taskqueue.execution.TaskExecutionException; -import org.codehaus.plexus.taskqueue.execution.TaskExecutor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * ArchivaDatabaseTaskExecutor - * - * @version $Id$ - * - * @plexus.component - * role="org.codehaus.plexus.taskqueue.execution.TaskExecutor" - * role-hint="database-update" - */ -public class ArchivaDatabaseUpdateTaskExecutor - implements TaskExecutor, Initializable -{ - private Logger log = LoggerFactory.getLogger( ArchivaDatabaseUpdateTaskExecutor.class ); - - /** - * @plexus.requirement role-hint="jdo" - */ - private DatabaseUpdater databaseUpdater; - - public void initialize() - throws InitializationException - { - log.info( "Initialized " + this.getClass().getName() ); - } - - public void executeTask( Task task ) - throws TaskExecutionException - { - DatabaseTask dbtask = (DatabaseTask) task; - - log.info( "Executing task from queue with job name: " + dbtask ); - long time = System.currentTimeMillis(); - - try - { - log.info( "Task: Updating unprocessed artifacts" ); - databaseUpdater.updateAllUnprocessed(); - } - catch ( ArchivaDatabaseException e ) - { - throw new TaskExecutionException( "Error running unprocessed updater", e ); - } - - time = System.currentTimeMillis() - time; - - log.info( "Finished database task in " + time + "ms." ); - } -} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseArchivaTaskScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseArchivaTaskScheduler.java deleted file mode 100644 index c98f692af..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseArchivaTaskScheduler.java +++ /dev/null @@ -1,209 +0,0 @@ -package org.apache.archiva.scheduler.database; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.text.ParseException; -import java.util.List; - -import org.apache.archiva.scheduler.ArchivaTaskScheduler; -import org.apache.maven.archiva.common.ArchivaException; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.ConfigurationEvent; -import org.apache.maven.archiva.configuration.ConfigurationListener; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException; -import org.codehaus.plexus.scheduler.CronExpressionValidator; -import org.codehaus.plexus.scheduler.Scheduler; -import org.codehaus.plexus.taskqueue.Task; -import org.codehaus.plexus.taskqueue.TaskQueue; -import org.codehaus.plexus.taskqueue.TaskQueueException; -import org.codehaus.plexus.taskqueue.execution.TaskExecutionException; -import org.quartz.CronTrigger; -import org.quartz.JobDataMap; -import org.quartz.JobDetail; -import org.quartz.SchedulerException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Default implementation of a scheduling component for archiva. - * - * @plexus.component role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="database" - */ -public class DatabaseArchivaTaskScheduler - implements ArchivaTaskScheduler<DatabaseTask>, Startable, ConfigurationListener -{ - private Logger log = LoggerFactory.getLogger( DatabaseArchivaTaskScheduler.class ); - - /** - * @plexus.requirement - */ - private Scheduler scheduler; - - /** - * @plexus.requirement role-hint="database-update" - */ - private TaskQueue databaseUpdateQueue; - - /** - * @plexus.requirement - */ - private ArchivaConfiguration archivaConfiguration; - - private static final String DATABASE_SCAN_GROUP = "dbg"; - - private static final String DATABASE_JOB = "dbj"; - - private static final String DATABASE_JOB_TRIGGER = "dbt"; - - static final String TASK_QUEUE = "TASK_QUEUE"; - - public static final String CRON_HOURLY = "0 0 * * * ?"; - - public void startup() - throws ArchivaException - { - archivaConfiguration.addListener( this ); - - try - { - start(); - } - catch ( StartingException e ) - { - throw new ArchivaException( e.getMessage(), e ); - } - } - - public void start() - throws StartingException - { - try - { - scheduleDatabaseJobs(); - } - catch ( SchedulerException e ) - { - throw new StartingException( "Unable to start scheduler: " + e.getMessage(), e ); - } - } - - public void stop() - throws StoppingException - { - try - { - scheduler.unscheduleJob( DATABASE_JOB, DATABASE_SCAN_GROUP ); - } - catch ( SchedulerException e ) - { - throw new StoppingException( "Unable to unschedule tasks", e ); - } - } - - public void scheduleDatabaseTasks() - throws TaskExecutionException - { - try - { - scheduleDatabaseJobs(); - } - catch ( SchedulerException e ) - { - throw new TaskExecutionException( "Unable to schedule repository jobs: " + e.getMessage(), e ); - - } - } - - @SuppressWarnings("unchecked") - public boolean isProcessingDatabaseTask() - { - List<? extends Task> queue = null; - - try - { - queue = databaseUpdateQueue.getQueueSnapshot(); - } - catch ( TaskQueueException e ) - { - // not possible with plexus-taskqueue implementation, ignore - } - - return !queue.isEmpty(); - } - - public void queueTask( DatabaseTask task ) - throws TaskQueueException - { - databaseUpdateQueue.put( task ); - } - - public void configurationEvent( ConfigurationEvent event ) - { - if ( event.getType() == ConfigurationEvent.SAVED ) - { - try - { - scheduler.unscheduleJob( DATABASE_JOB, DATABASE_SCAN_GROUP ); - - scheduleDatabaseJobs(); - } - catch ( SchedulerException e ) - { - log.error( "Error restarting the database scanning job after property change." ); - } - } - } - - private synchronized void scheduleDatabaseJobs() - throws SchedulerException - { - String cronString = archivaConfiguration.getConfiguration().getDatabaseScanning().getCronExpression(); - - // setup the unprocessed artifact job - JobDetail databaseJob = new JobDetail( DATABASE_JOB, DATABASE_SCAN_GROUP, DatabaseTaskJob.class ); - - JobDataMap dataMap = new JobDataMap(); - dataMap.put( TASK_QUEUE, databaseUpdateQueue ); - databaseJob.setJobDataMap( dataMap ); - - CronExpressionValidator cronValidator = new CronExpressionValidator(); - if ( !cronValidator.validate( cronString ) ) - { - log.warn( - "Cron expression [" + cronString + "] for database update is invalid. Defaulting to hourly." ); - cronString = CRON_HOURLY; - } - - try - { - CronTrigger trigger = new CronTrigger( DATABASE_JOB_TRIGGER, DATABASE_SCAN_GROUP, cronString ); - - scheduler.scheduleJob( databaseJob, trigger ); - } - catch ( ParseException e ) - { - log.error( - "ParseException in database scanning cron expression, disabling database scanning: " + e.getMessage() ); - } - - } -}
\ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseTask.java deleted file mode 100644 index 6757fa43f..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseTask.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.archiva.scheduler.database; - -/* - * 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.codehaus.plexus.taskqueue.Task; - -/** - * DataRefreshTask - task for discovering changes in the repository - * and updating all associated data. - * - * @version $Id: DataRefreshTask.java 525176 2007-04-03 15:21:33Z joakime $ - */ -public class DatabaseTask - implements Task -{ - @Override - public String toString() - { - return "DatabaseTask"; - } - - public long getMaxExecutionTime() - { - return 0; - } -} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseTaskJob.java b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseTaskJob.java deleted file mode 100644 index 1721505a3..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/java/org/apache/archiva/scheduler/database/DatabaseTaskJob.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.apache.archiva.scheduler.database; - -/* - * 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.codehaus.plexus.scheduler.AbstractJob; -import org.codehaus.plexus.taskqueue.Task; -import org.codehaus.plexus.taskqueue.TaskQueue; -import org.codehaus.plexus.taskqueue.TaskQueueException; -import org.quartz.JobDataMap; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; - -/** - * This class is the database job that is executed by the scheduler. - */ -public class DatabaseTaskJob - extends AbstractJob -{ - /** - * Execute the discoverer and the indexer. - * - * @param context - * @throws org.quartz.JobExecutionException - * - */ - public void execute( JobExecutionContext context ) - throws JobExecutionException - { - JobDataMap dataMap = context.getJobDetail().getJobDataMap(); - setJobDataMap( dataMap ); - - TaskQueue taskQueue = (TaskQueue) dataMap.get( DatabaseArchivaTaskScheduler.TASK_QUEUE ); - - Task task = new DatabaseTask(); - - try - { - // The database job only needs to run one at a time - if ( taskQueue.getQueueSnapshot().isEmpty() ) - { - taskQueue.put( task ); - } - } - catch ( TaskQueueException e ) - { - throw new JobExecutionException( e ); - } - } -} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/resources/META-INF/plexus/components.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/resources/META-INF/plexus/components.xml deleted file mode 100644 index 3d77c29ce..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/main/resources/META-INF/plexus/components.xml +++ /dev/null @@ -1,63 +0,0 @@ -<?xml version="1.0" ?> -<!-- - ~ 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. - --> - -<component-set> - <components> - <!-- - | - | Database Update Task Queue / Executor - | - --> - <component> - <role>org.codehaus.plexus.taskqueue.TaskQueue</role> - <role-hint>database-update</role-hint> - <implementation>org.codehaus.plexus.taskqueue.DefaultTaskQueue</implementation> - <lifecycle-handler>plexus-configurable</lifecycle-handler> - <configuration> - <task-entry-evaluators> - </task-entry-evaluators> - <task-exit-evaluators> - </task-exit-evaluators> - <task-viability-evaluators> - </task-viability-evaluators> - </configuration> - </component> - - <component> - <role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role> - <role-hint>database-update</role-hint> - <implementation>org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor</implementation> - <instantiation-strategy>singleton</instantiation-strategy> - <requirements> - <requirement> - <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role> - <role-hint>database-update</role-hint> - </requirement> - <requirement> - <role>org.codehaus.plexus.taskqueue.TaskQueue</role> - <role-hint>database-update</role-hint> - </requirement> - </requirements> - <configuration> - <name>database-update</name> - </configuration> - </component> - </components> -</component-set> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutorTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutorTest.java deleted file mode 100644 index 6d83c4c7f..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutorTest.java +++ /dev/null @@ -1,190 +0,0 @@ -package org.apache.archiva.scheduler.database; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.net.URL; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import javax.jdo.PersistenceManager; -import javax.jdo.PersistenceManagerFactory; - -import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.database.ArchivaDAO; -import org.apache.maven.archiva.database.ArtifactDAO; -import org.apache.maven.archiva.database.constraints.ArtifactsProcessedConstraint; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory; -import org.codehaus.plexus.jdo.JdoFactory; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; -import org.codehaus.plexus.taskqueue.execution.TaskExecutor; -import org.jpox.SchemaTool; - -/** - * ArchivaDatabaseUpdateTaskExecutorTest - * - * @version $Id:$ - */ -public class ArchivaDatabaseUpdateTaskExecutorTest - extends PlexusInSpringTestCase -{ - private TaskExecutor taskExecutor; - - protected ArchivaDAO dao; - - protected void setUp() - throws Exception - { - super.setUp(); - - DefaultConfigurableJdoFactory jdoFactory = (DefaultConfigurableJdoFactory) lookup( JdoFactory.ROLE, "archiva" ); - assertEquals( DefaultConfigurableJdoFactory.class.getName(), jdoFactory.getClass().getName() ); - - jdoFactory.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" ); - - /* derby version - File derbyDbDir = new File( "target/plexus-home/testdb" ); - if ( derbyDbDir.exists() ) - { - FileUtils.deleteDirectory( derbyDbDir ); - } - - jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.apache.derby.jdbc.EmbeddedDriver" ) ); - jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:derby:" + derbyDbDir.getAbsolutePath() + ";create=true" ) ); - */ - - jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.hsqldb.jdbcDriver" ) ); - jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:hsqldb:mem:" + getName() ) ); - - jdoFactory.setUserName( System.getProperty( "jdo.test.user", "sa" ) ); - - jdoFactory.setPassword( System.getProperty( "jdo.test.pass", "" ) ); - - jdoFactory.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" ); - - jdoFactory.setProperty( "org.jpox.poid.transactionIsolation", "READ_COMMITTED" ); - - jdoFactory.setProperty( "org.jpox.autoCreateSchema", "true" ); - - jdoFactory.setProperty( "javax.jdo.option.RetainValues", "true" ); - - jdoFactory.setProperty( "javax.jdo.option.RestoreValues", "true" ); - - // jdoFactory.setProperty( "org.jpox.autoCreateColumns", "true" ); - - jdoFactory.setProperty( "org.jpox.validateTables", "true" ); - - jdoFactory.setProperty( "org.jpox.validateColumns", "true" ); - - jdoFactory.setProperty( "org.jpox.validateConstraints", "true" ); - - Properties properties = jdoFactory.getProperties(); - - for ( Map.Entry<Object, Object> entry : properties.entrySet() ) - { - System.setProperty( (String) entry.getKey(), (String) entry.getValue() ); - } - - URL jdoFileUrls[] = new URL[] { getClass().getResource( "/org/apache/maven/archiva/model/package.jdo" ) }; - - if ( ( jdoFileUrls == null ) || ( jdoFileUrls[0] == null ) ) - { - fail( "Unable to process test " + getName() + " - missing package.jdo." ); - } - - File propsFile = null; // intentional - boolean verbose = true; - - SchemaTool.deleteSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose ); - SchemaTool.createSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose, null ); - - PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory(); - - assertNotNull( pmf ); - - PersistenceManager pm = pmf.getPersistenceManager(); - - pm.close(); - - this.dao = (ArchivaDAO) lookup( ArchivaDAO.class.getName(), "jdo" ); - - taskExecutor = (TaskExecutor) lookup( TaskExecutor.class, "test-database-update" ); - } - - public void testExecutor() - throws Exception - { - File repoDir = new File( getBasedir(), "src/test/repositories/default-repository" ); - - assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() ); - - ManagedRepositoryConfiguration repo = createRepository( "testRepo", "Test Repository", repoDir ); - assertNotNull( repo ); - - ArtifactDAO adao = dao.getArtifactDAO(); - - ArchivaArtifact sqlArtifact = adao.createArtifact( "javax.sql", "jdbc", "2.0", "", "jar", repo.getId() ); - sqlArtifact.getModel().setLastModified( new Date() ); - sqlArtifact.getModel().setSize( 1234 ); - sqlArtifact.getModel().setOrigin( "testcase" ); - sqlArtifact.getModel().setWhenProcessed( null ); - - adao.saveArtifact( sqlArtifact ); - - ArchivaArtifact artifact = adao.getArtifact( "javax.sql", "jdbc", "2.0", null, "jar", repo.getId() ); - - assertNotNull( artifact ); - - // Test for artifact existance. - List<ArchivaArtifact> artifactList = adao.queryArtifacts( null ); - assertNotNull( "Artifact list should not be null.", artifactList ); - assertEquals( "Artifact list size", 1, artifactList.size() ); - - // Test for unprocessed artifacts. - List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) ); - assertNotNull( "Unprocessed Results should not be null.", unprocessedResultList ); - assertEquals( "Incorrect number of unprocessed artifacts detected.", 1, unprocessedResultList.size() ); - - // Execute the database task. - DatabaseTask dataTask = new DatabaseTask(); - taskExecutor.executeTask( dataTask ); - - // Test for artifact existance. - artifactList = adao.queryArtifacts( null ); - assertNotNull( "Artifact list should not be null.", artifactList ); - assertEquals( "Artifact list size", 1, artifactList.size() ); - - // Test for processed artifacts. - List<ArchivaArtifact> processedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( true ) ); - assertNotNull( "Processed Results should not be null.", processedResultList ); - assertEquals( "Incorrect number of processed artifacts detected.", 1, processedResultList.size() ); - } - - protected ManagedRepositoryConfiguration createRepository( String id, String name, File location ) - { - ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration(); - repo.setId( id ); - repo.setName( name ); - repo.setLocation( location.getAbsolutePath() ); - return repo; - } -} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database/TestDatabaseUnprocessedConsumer.java b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database/TestDatabaseUnprocessedConsumer.java deleted file mode 100644 index 185071b9a..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/java/org/apache/archiva/scheduler/database/TestDatabaseUnprocessedConsumer.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.apache.archiva.scheduler.database; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer; -import org.apache.maven.archiva.consumers.ConsumerException; -import org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * TestDatabaseUnprocessedConsumer - * - * @version $Id$ - */ -public class TestDatabaseUnprocessedConsumer - extends AbstractMonitoredConsumer - implements DatabaseUnprocessedArtifactConsumer -{ - private Logger log = LoggerFactory.getLogger( TestDatabaseUnprocessedConsumer.class ); - - private int countBegin = 0; - - private int countComplete = 0; - - private int countProcessed = 0; - - public void resetCount() - { - countBegin = 0; - countProcessed = 0; - countComplete = 0; - } - - public void beginScan() - { - countBegin++; - } - - public void completeScan() - { - countComplete++; - } - - public List<String> getIncludedTypes() - { - List<String> types = new ArrayList<String>(); - types.add( "pom" ); - types.add( "jar" ); - return types; - } - - public void processArchivaArtifact( ArchivaArtifact artifact ) - throws ConsumerException - { - log.info( "Processing Artifact: " + artifact ); - countProcessed++; - } - - public String getDescription() - { - return "Test Consumer for Database Unprocessed"; - } - - public String getId() - { - return "test-db-unprocessed"; - } - - public boolean isPermanent() - { - return false; - } - - public int getCountBegin() - { - return countBegin; - } - - public int getCountComplete() - { - return countComplete; - } - - public int getCountProcessed() - { - return countProcessed; - } -} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/maven-metadata.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/maven-metadata.xml deleted file mode 100644 index b3baf545d..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/maven-metadata.xml +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - ~ 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. - --> - -<!-- This metdata is intentionally wrong. --> -<metadata> - <groupId>javax.sql</groupId> - <artifactId>jdbc</artifactId> - <version>2.0</version> -</metadata> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml deleted file mode 100644 index caf5b6697..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - ~ 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. - --> - -<metadata> - <groupId>javax.sql</groupId> - <artifactId>jdbc</artifactId> - <version>2.0</version> -</metadata> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml deleted file mode 100644 index bb7570891..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - ~ 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. - --> - -<metadata> - <groupId>javax.sql</groupId> - <artifactId>jdbc</artifactId> - <version>2.0</version> - <versioning> - <versions> - <version>2.0</version> - </versions> - </versioning> -</metadata> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml deleted file mode 100644 index caf5b6697..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - ~ 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. - --> - -<metadata> - <groupId>javax.sql</groupId> - <artifactId>jdbc</artifactId> - <version>2.0</version> -</metadata> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom deleted file mode 100644 index 202a0a448..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ -<!-- - ~ 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. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.maven</groupId> - <artifactId>A</artifactId> - <version>1.0</version> - <name>Maven Test Repository Artifact Discovery</name> - <packaging>war</packaging> -</project> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom deleted file mode 100644 index fa5f8f6c8..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ -<!-- - ~ 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. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.maven</groupId> - <artifactId>B</artifactId> - <version>1.0</version> - <name>Maven Test Repository Artifact Discovery</name> - <packaging>pom</packaging> -</project> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom deleted file mode 100644 index c3034e820..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom +++ /dev/null @@ -1,28 +0,0 @@ -<!-- - ~ 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. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.maven</groupId> - <artifactId>B</artifactId> - <version>2.0</version> - <name>Maven Test Repository Artifact Discovery</name> - <packaging>pom</packaging> -</project> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom deleted file mode 100644 index ae14cd7eb..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ -<!-- - ~ 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. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.maven</groupId> - <artifactId>C</artifactId> - <version>1.0</version> - <name>Maven Test Repository Artifact Discovery</name> - <packaging>war</packaging> -</project> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml deleted file mode 100644 index 8ce7fc7bb..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - ~ 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. - --> - -<metadata> - <groupId>org.apache.maven</groupId> -</metadata>
\ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom deleted file mode 100644 index 12538e81a..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ -<!-- - ~ 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. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.testgroup</groupId> - <artifactId>discovery</artifactId> - <version>1.0</version> - <name>Maven Test Repository Artifact Discovery</name> - <packaging>pom</packaging> -</project> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml deleted file mode 100644 index 8ee18048c..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - ~ 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. - --> - -<metadata> - <groupId>org.apache.testgroup</groupId> - <artifactId>discovery</artifactId> - <version>1.0</version> -</metadata>
\ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml deleted file mode 100644 index b024ef7ef..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - ~ 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. - --> - -<metadata> - <groupId>org.apache.testgroup</groupId> - <artifactId>discovery</artifactId> -</metadata>
\ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/resources/archiva-test.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/resources/archiva-test.xml deleted file mode 100644 index 7721bb63e..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/resources/archiva-test.xml +++ /dev/null @@ -1,119 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - ~ 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. - --> - -<configuration> - <managedRepositories> - <managedRepository> - <id>testRepo</id> - <name>Archiva Test Repository</name> - <location>${basedir}/src/test/repositories/default-repository</location> - <layout>default</layout> - <releases>true</releases> - <snapshots>false</snapshots> - <indexed>true</indexed> - <refreshCronExpression>0 0 * * * ?</refreshCronExpression> - </managedRepository> - </managedRepositories> - - <proxyConnectors /> - - <networkProxies /> - - <repositoryScanning> - <fileTypes> - <fileType> - <id>artifacts</id> - <patterns> - <pattern>**/*.pom</pattern> - <pattern>**/*.jar</pattern> - <pattern>**/*.ear</pattern> - <pattern>**/*.war</pattern> - <pattern>**/*.car</pattern> - <pattern>**/*.sar</pattern> - <pattern>**/*.mar</pattern> - <pattern>**/*.rar</pattern> - <pattern>**/*.dtd</pattern> - <pattern>**/*.tld</pattern> - <pattern>**/*.tar.gz</pattern> - <pattern>**/*.tar.bz2</pattern> - <pattern>**/*.zip</pattern> - </patterns> - </fileType> - <fileType> - <id>indexable-content</id> - <patterns> - <pattern>**/*.txt</pattern> - <pattern>**/*.TXT</pattern> - <pattern>**/*.block</pattern> - <pattern>**/*.config</pattern> - <pattern>**/*.pom</pattern> - <pattern>**/*.xml</pattern> - <pattern>**/*.xsd</pattern> - <pattern>**/*.dtd</pattern> - <pattern>**/*.tld</pattern> - </patterns> - </fileType> - <fileType> - <id>auto-remove</id> - <patterns> - <pattern>**/*.bak</pattern> - <pattern>**/*~</pattern> - <pattern>**/*-</pattern> - </patterns> - </fileType> - <fileType> - <id>ignored</id> - <patterns> - <pattern>**/.htaccess</pattern> - <pattern>**/KEYS</pattern> - <pattern>**/*.rb</pattern> - <pattern>**/*.sh</pattern> - <pattern>**/.svn/**</pattern> - <pattern>**/.DAV/**</pattern> - </patterns> - </fileType> - </fileTypes> - <knownContentConsumers> - <knownContentConsumer>update-db-artifact</knownContentConsumer> - <knownContentConsumer>create-missing-checksums</knownContentConsumer> - <knownContentConsumer>update-db-repository-metadata</knownContentConsumer> - <knownContentConsumer>validate-checksum</knownContentConsumer> - <knownContentConsumer>validate-signature</knownContentConsumer> - <knownContentConsumer>index-content</knownContentConsumer> - <knownContentConsumer>auto-remove</knownContentConsumer> - <knownContentConsumer>auto-rename</knownContentConsumer> - </knownContentConsumers> - <invalidContentConsumers> - <invalidContentConsumer>update-db-bad-content</invalidContentConsumer> - </invalidContentConsumers> - </repositoryScanning> - - <databaseScanning> - <cronExpression>0 0 * * * ?</cronExpression> - <unprocessedConsumers> - <unprocessedConsumer>test-db-unprocessed</unprocessedConsumer> - <unprocessedConsumer>update-db-artifact</unprocessedConsumer> - </unprocessedConsumers> - <cleanupConsumers> - <cleanupConsumer>test-db-cleanup</cleanupConsumer> - </cleanupConsumers> - </databaseScanning> - -</configuration> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/resources/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutorTest.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/resources/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutorTest.xml deleted file mode 100644 index 2d2746d21..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-database/src/test/resources/org/apache/archiva/scheduler/database/ArchivaDatabaseUpdateTaskExecutorTest.xml +++ /dev/null @@ -1,92 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - ~ 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. - --> - -<component-set> - <components> - <component> - <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role> - <role-hint>test-database-update</role-hint> - <implementation>org.apache.archiva.scheduler.database.ArchivaDatabaseUpdateTaskExecutor</implementation> - <description></description> - <requirements> - <requirement> - <role>org.apache.maven.archiva.database.updater.DatabaseUpdater</role> - <role-hint>jdo</role-hint> - <field-name>databaseUpdater</field-name> - </requirement> - </requirements> - </component> - - <component> - <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> - <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation> - <requirements> - <requirement> - <role>org.codehaus.plexus.registry.Registry</role> - <role-hint>configured</role-hint> - </requirement> - <requirement> - <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role> - <field-name>prePolicies</field-name> - </requirement> - <requirement> - <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role> - <field-name>postPolicies</field-name> - </requirement> - </requirements> - </component> - - <component> - <role>org.codehaus.plexus.registry.Registry</role> - <role-hint>configured</role-hint> - <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation> - <configuration> - <properties> - <system/> - <xml fileName="${basedir}/src/test/resources/archiva-test.xml" - config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/> - </properties> - </configuration> - </component> - - <component> - <role>org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer</role> - <role-hint>test-db-unprocessed</role-hint> - <implementation>org.apache.archiva.scheduler.database.TestDatabaseUnprocessedConsumer</implementation> - </component> - - - <component> - <role>org.codehaus.plexus.jdo.JdoFactory</role> - <role-hint>archiva</role-hint> - <implementation>org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory</implementation> - <configuration> - <persistenceManagerFactoryClass>org.jpox.PersistenceManagerFactoryImpl</persistenceManagerFactoryClass> - <otherProperties> - <property> - <name>javax.jdo.PersistenceManagerFactoryClass</name> - <value>org.jpox.PersistenceManagerFactoryImpl</value> - </property> - </otherProperties> - </configuration> - </component> - - </components> -</component-set> diff --git a/archiva-modules/archiva-scheduler/pom.xml b/archiva-modules/archiva-scheduler/pom.xml index a08c13faf..9da400013 100644 --- a/archiva-modules/archiva-scheduler/pom.xml +++ b/archiva-modules/archiva-scheduler/pom.xml @@ -31,7 +31,6 @@ <modules> <module>archiva-scheduler-api</module> <module>archiva-scheduler-indexing</module> - <module>archiva-scheduler-database</module> <module>archiva-scheduler-repository</module> </modules> -</project>
\ No newline at end of file +</project> diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml index 21efbfa0f..c839ce3cc 100644 --- a/archiva-modules/archiva-web/archiva-webapp/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml @@ -39,10 +39,6 @@ </dependency> <dependency> <groupId>org.apache.archiva</groupId> - <artifactId>archiva-scheduler-database</artifactId> - </dependency> - <dependency> - <groupId>org.apache.archiva</groupId> <artifactId>archiva-indexer</artifactId> </dependency> <dependency> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java index de5dc2d4d..79ca76474 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java @@ -40,7 +40,6 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.database.ArchivaDatabaseException; import org.apache.maven.archiva.database.ArtifactDAO; import org.apache.maven.archiva.database.constraints.ArtifactVersionsConstraint; -import org.apache.maven.archiva.database.updater.DatabaseConsumers; import org.apache.maven.archiva.model.ArchivaArtifact; import org.apache.maven.archiva.model.ArchivaRepositoryMetadata; import org.apache.maven.archiva.model.VersionedReference; @@ -115,11 +114,6 @@ public class DeleteArtifactAction */ private ArtifactDAO artifactDAO; - /** - * @plexus.requirement - */ - private DatabaseConsumers databaseConsumers; - /** @plexus.requirement role="org.apache.maven.archiva.repository.events.RepositoryListener" */ private List<RepositoryListener> listeners; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java index f4cab02be..350609979 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/SchedulerAction.java @@ -19,8 +19,6 @@ package org.apache.maven.archiva.web.action.admin; * under the License. */ -import org.apache.archiva.scheduler.database.DatabaseArchivaTaskScheduler; -import org.apache.archiva.scheduler.database.DatabaseTask; import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; import org.apache.archiva.scheduler.repository.RepositoryTask; import org.apache.commons.lang.StringUtils; @@ -46,11 +44,6 @@ public class SchedulerAction */ private RepositoryArchivaTaskScheduler repositoryTaskScheduler; - /** - * @plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="database" - */ - private DatabaseArchivaTaskScheduler databaseTaskScheduler; - private String repoid; private boolean scanAll; @@ -89,32 +82,6 @@ public class SchedulerAction return SUCCESS; } - public String updateDatabase() - { - log.info( "Queueing database task on request from user interface" ); - DatabaseTask task = new DatabaseTask(); - - if ( databaseTaskScheduler.isProcessingDatabaseTask() ) - { - addActionError( "Database task was already queued." ); - } - else - { - try - { - databaseTaskScheduler.queueTask( task ); - addActionMessage( "Your request to update the database has been queued." ); - } - catch ( TaskQueueException e ) - { - addActionError( "Unable to queue your request to update the database: " + e.getMessage() ); - } - } - - // Return to the database screen. - return SUCCESS; - } - @Override public void addActionMessage( String aMessage ) { diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/AddAdminDatabaseConsumerClosure.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/AddAdminDatabaseConsumerClosure.java deleted file mode 100644 index c625ec1f1..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/AddAdminDatabaseConsumerClosure.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.apache.maven.archiva.web.action.admin.database; - -/* - * 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.commons.collections.Closure; -import org.apache.maven.archiva.database.updater.ArchivaArtifactConsumer; - -import java.util.ArrayList; -import java.util.List; - -/** - * AddAdminDatabaseConsumerClosure - * - * @version $Id$ - */ -public class AddAdminDatabaseConsumerClosure - implements Closure -{ - private List<AdminDatabaseConsumer> list = new ArrayList<AdminDatabaseConsumer>(); - - private List<String> selectedIds; - - public AddAdminDatabaseConsumerClosure( List<String> selectedIds ) - { - this.selectedIds = selectedIds; - } - - public void execute( Object input ) - { - if ( input instanceof ArchivaArtifactConsumer ) - { - ArchivaArtifactConsumer consumer = (ArchivaArtifactConsumer) input; - - boolean enabled = this.selectedIds.contains( consumer.getId() ); - - AdminDatabaseConsumer adminconsumer = new AdminDatabaseConsumer(); - adminconsumer.setEnabled( enabled ); - adminconsumer.setId( consumer.getId() ); - adminconsumer.setDescription( consumer.getDescription() ); - - list.add( adminconsumer ); - } - } - - public List<AdminDatabaseConsumer> getList() - { - return list; - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/AdminDatabaseConsumer.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/AdminDatabaseConsumer.java deleted file mode 100644 index 0ee243ee7..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/AdminDatabaseConsumer.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.apache.maven.archiva.web.action.admin.database; - -/* - * 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. - */ - -/** - * AdminDatabaseConsumer - * - * @version $Id$ - */ -public class AdminDatabaseConsumer -{ - private boolean enabled = false; - - private String id; - - private String description; - - public String getDescription() - { - return description; - } - - public String getId() - { - return id; - } - - public boolean isEnabled() - { - return enabled; - } - - public void setDescription( String description ) - { - this.description = description; - } - - public void setEnabled( boolean enabled ) - { - this.enabled = enabled; - } - - public void setId( String id ) - { - this.id = id; - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/AdminDatabaseConsumerComparator.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/AdminDatabaseConsumerComparator.java deleted file mode 100644 index 50746c55c..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/AdminDatabaseConsumerComparator.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.apache.maven.archiva.web.action.admin.database; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Comparator; - -/** - * AdminDatabaseConsumerComparator - * - * @version $Id$ - */ -public class AdminDatabaseConsumerComparator - implements Comparator<AdminDatabaseConsumer> -{ - private static AdminDatabaseConsumerComparator INSTANCE = new AdminDatabaseConsumerComparator(); - - public static AdminDatabaseConsumerComparator getInstance() - { - return INSTANCE; - } - - public int compare( AdminDatabaseConsumer o1, AdminDatabaseConsumer o2 ) - { - if ( o1 == null && o2 == null ) - { - return 0; - } - - if ( o1 == null && o2 != null ) - { - return 1; - } - - if ( o1 != null && o2 == null ) - { - return -1; - } - - String id1 = o1.getId(); - String id2 = o2.getId(); - return id1.compareToIgnoreCase( id2 ); - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/DatabaseAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/DatabaseAction.java deleted file mode 100644 index 58df2bbb3..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/database/DatabaseAction.java +++ /dev/null @@ -1,221 +0,0 @@ -package org.apache.maven.archiva.web.action.admin.database; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Collections; -import java.util.List; - -import com.opensymphony.xwork2.Preparable; -import org.apache.commons.collections.CollectionUtils; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.Configuration; -import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; -import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; -import org.apache.maven.archiva.database.updater.DatabaseConsumers; -import org.apache.maven.archiva.repository.audit.AuditEvent; -import org.apache.maven.archiva.repository.audit.Auditable; -import org.apache.maven.archiva.security.ArchivaRoleConstants; -import org.apache.maven.archiva.web.action.PlexusActionSupport; -import org.codehaus.plexus.redback.rbac.Resource; -import org.codehaus.plexus.registry.RegistryException; -import org.codehaus.redback.integration.interceptor.SecureAction; -import org.codehaus.redback.integration.interceptor.SecureActionBundle; -import org.codehaus.redback.integration.interceptor.SecureActionException; - -/** - * DatabaseAction - * - * @version $Id$ - * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="databaseAction" instantiation-strategy="per-lookup" - */ -public class DatabaseAction - extends PlexusActionSupport - implements Preparable, SecureAction, Auditable -{ - /** - * @plexus.requirement - */ - private ArchivaConfiguration archivaConfiguration; - - /** - * @plexus.requirement - */ - private DatabaseConsumers databaseConsumers; - - private String cron; - - /** - * List of available {@link AdminDatabaseConsumer} objects for unprocessed artifacts. - */ - private List<AdminDatabaseConsumer> unprocessedConsumers; - - /** - * List of enabled {@link AdminDatabaseConsumer} objects for unprocessed artifacts. - */ - private List<String> enabledUnprocessedConsumers; - - public void prepare() - throws Exception - { - Configuration config = archivaConfiguration.getConfiguration(); - DatabaseScanningConfiguration dbscanning = config.getDatabaseScanning(); - - this.cron = dbscanning.getCronExpression(); - - AddAdminDatabaseConsumerClosure addAdminDbConsumer; - - addAdminDbConsumer = new AddAdminDatabaseConsumerClosure( dbscanning.getUnprocessedConsumers() ); - CollectionUtils.forAllDo( databaseConsumers.getAvailableUnprocessedConsumers(), addAdminDbConsumer ); - this.unprocessedConsumers = addAdminDbConsumer.getList(); - Collections.sort( this.unprocessedConsumers, AdminDatabaseConsumerComparator.getInstance() ); - } - - public String updateUnprocessedConsumers() - { - List<String> oldConsumers = archivaConfiguration.getConfiguration().getDatabaseScanning().getUnprocessedConsumers(); - - archivaConfiguration.getConfiguration().getDatabaseScanning().setUnprocessedConsumers( - enabledUnprocessedConsumers ); - - if ( enabledUnprocessedConsumers != null ) - { - filterAddedConsumers( oldConsumers, enabledUnprocessedConsumers ); - filterRemovedConsumers( oldConsumers, enabledUnprocessedConsumers ); - } - else - { - disableAllEnabledConsumers( oldConsumers ); - } - - return saveConfiguration(); - } - - public String updateSchedule() - { - String oldCron = archivaConfiguration.getConfiguration().getDatabaseScanning().getCronExpression(); - - archivaConfiguration.getConfiguration().getDatabaseScanning().setCronExpression( cron ); - - if ( !oldCron.equals( cron ) ) - { - triggerAuditEvent( AuditEvent.DB_SCHEDULE + " " + cron ); - } - - return saveConfiguration(); - } - - private String saveConfiguration() - { - try - { - archivaConfiguration.save( archivaConfiguration.getConfiguration() ); - addActionMessage( "Successfully saved configuration" ); - } - catch ( RegistryException e ) - { - log.error( e.getMessage(), e ); - addActionError( "Error in saving configuration" ); - return INPUT; - } - catch ( IndeterminateConfigurationException e ) - { - addActionError( e.getMessage() ); - return INPUT; - } - - return SUCCESS; - } - - public SecureActionBundle getSecureActionBundle() - throws SecureActionException - { - SecureActionBundle bundle = new SecureActionBundle(); - - bundle.setRequiresAuthentication( true ); - bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL ); - - return bundle; - } - - public String getCron() - { - return cron; - } - - public void setCron( String cron ) - { - this.cron = cron; - } - - public List getUnprocessedConsumers() - { - return unprocessedConsumers; - } - - public List<String> getEnabledUnprocessedConsumers() - { - return enabledUnprocessedConsumers; - } - - public void setEnabledUnprocessedConsumers( List<String> enabledUnprocessedConsumers ) - { - this.enabledUnprocessedConsumers = enabledUnprocessedConsumers; - } - - public ArchivaConfiguration getArchivaConfiguration() - { - return archivaConfiguration; - } - - public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration ) - { - this.archivaConfiguration = archivaConfiguration; - } - - private void filterAddedConsumers( List<String> oldList, List<String> newList ) - { - for ( String consumer : newList ) - { - if ( !oldList.contains( consumer ) ) - { - triggerAuditEvent( consumer, AuditEvent.ENABLE_DB_CONSUMER ); - } - } - } - - private void filterRemovedConsumers( List<String> oldList, List<String> newList ) - { - for ( String consumer : oldList ) - { - if ( !newList.contains( consumer ) ) - { - triggerAuditEvent( consumer, AuditEvent.DISABLE_DB_CONSUMER ); - } - } - } - - private void disableAllEnabledConsumers( List<String> enabledConsumers ) - { - for( String consumer : enabledConsumers ) - { - triggerAuditEvent( consumer, AuditEvent.DISABLE_DB_CONSUMER ); - } - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java index a2793ce09..fed1d50e7 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java @@ -19,12 +19,15 @@ package org.apache.maven.archiva.web.action.admin.repositories; * under the License. */ -import com.opensymphony.xwork2.Preparable; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import com.opensymphony.xwork2.Preparable; import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; - +import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.ArchivaDatabaseException; import org.apache.maven.archiva.database.Constraint; @@ -32,18 +35,10 @@ import org.apache.maven.archiva.database.ObjectNotFoundException; import org.apache.maven.archiva.database.constraints.ArtifactsByRepositoryConstraint; import org.apache.maven.archiva.database.constraints.RepositoryContentStatisticsByRepositoryConstraint; import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.ArchivaProjectModel; import org.apache.maven.archiva.model.RepositoryContentStatistics; import org.apache.maven.archiva.repository.audit.AuditEvent; - -import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; - import org.codehaus.plexus.redback.role.RoleManagerException; -import java.io.IOException; -import java.util.List; -import java.util.Map; - /** * DeleteManagedRepositoryAction * @@ -182,11 +177,6 @@ public class DeleteManagedRepositoryAction { archivaDAO.getArtifactDAO().deleteArtifact( artifact ); - ArchivaProjectModel projectModel = - archivaDAO.getProjectModelDAO().getProjectModel( artifact.getGroupId(), artifact.getArtifactId(), - artifact.getVersion() ); - - archivaDAO.getProjectModelDAO().deleteProjectModel( projectModel ); } catch ( ObjectNotFoundException oe ) { diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaStartup.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaStartup.java index fb3984362..1f86c4e91 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaStartup.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaStartup.java @@ -23,7 +23,6 @@ import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import org.apache.archiva.scheduler.ArchivaTaskScheduler; -import org.apache.archiva.scheduler.database.DatabaseArchivaTaskScheduler; import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; import org.apache.maven.archiva.common.ArchivaException; import org.codehaus.plexus.spring.PlexusToSpringUtils; @@ -48,21 +47,14 @@ public class ArchivaStartup SecuritySynchronization securitySync = (SecuritySynchronization) wac.getBean( PlexusToSpringUtils.buildSpringId( SecuritySynchronization.class ) ); - ResolverFactoryInit resolverFactory = - (ResolverFactoryInit) wac.getBean( PlexusToSpringUtils.buildSpringId( ResolverFactoryInit.class ) ); - DatabaseArchivaTaskScheduler databaseTaskScheduler = (DatabaseArchivaTaskScheduler) wac.getBean( - PlexusToSpringUtils.buildSpringId( ArchivaTaskScheduler.class, "database" ) ); RepositoryArchivaTaskScheduler repositoryTaskScheduler = (RepositoryArchivaTaskScheduler) wac.getBean( PlexusToSpringUtils.buildSpringId( ArchivaTaskScheduler.class, "repository" ) ); - wac.getBean( PlexusToSpringUtils.buildSpringId( TaskQueueExecutor.class, "database-update" ) ); wac.getBean( PlexusToSpringUtils.buildSpringId( TaskQueueExecutor.class, "repository-scanning" ) ); wac.getBean( PlexusToSpringUtils.buildSpringId( TaskQueueExecutor.class, "indexing" ) ); try { securitySync.startup(); - resolverFactory.startup(); - databaseTaskScheduler.startup(); repositoryTaskScheduler.startup(); Banner.display(); } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ResolverFactoryInit.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ResolverFactoryInit.java deleted file mode 100644 index 8b27b9630..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ResolverFactoryInit.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.apache.maven.archiva.web.startup; - -/* - * 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.maven.archiva.common.ArchivaException; -import org.apache.maven.archiva.database.project.ProjectModelToDatabaseListener; -import org.apache.maven.archiva.repository.project.ProjectModelResolver; -import org.apache.maven.archiva.repository.project.ProjectModelResolverFactory; - -/** - * ResolverFactoryInit - Initialize the Resolver Factory, and hook it up to - * the database. - * - * @version $Id$ - * - * @plexus.component - * role="org.apache.maven.archiva.web.startup.ResolverFactoryInit" - * role-hint="default" - */ -public class ResolverFactoryInit -{ - /** - * @plexus.requirement role-hint="database" - */ - private ProjectModelResolver databaseResolver; - - /** - * @plexus.requirement - * role="org.apache.maven.archiva.repository.project.resolvers.ProjectModelResolutionListener" - * role-hint="model-to-db" - */ - private ProjectModelToDatabaseListener modelToDbListener; - - /** - * The resolver factorying being initialized. - * - * @plexus.requirement - */ - private ProjectModelResolverFactory resolverFactory; - - public void startup() - throws ArchivaException - { - if ( !resolverFactory.getCurrentResolverStack().hasResolver( databaseResolver ) ) - { - resolverFactory.getCurrentResolverStack().prependProjectModelResolver( databaseResolver ); - } - resolverFactory.getCurrentResolverStack().addListener( modelToDbListener ); - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/database/DatabaseAction-validation.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/database/DatabaseAction-validation.xml deleted file mode 100644 index 5743b6a43..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/org/apache/maven/archiva/web/action/admin/database/DatabaseAction-validation.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - ~ 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. - --> - -<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" - "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> -<validators> - <field name="cron"> - <field-validator type="requiredstring"> - <message>You must enter a cron expression.</message> - </field-validator> - <field-validator type="crontab"> - <message>Invalid cron expression value(s).</message> - </field-validator> - </field> -</validators>
\ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml index 8df1acfdd..b147fd6e5 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml @@ -440,19 +440,6 @@ </result> </action> - <!-- .\ DATABASE \.________________________________________________ --> - - <action name="database" class="databaseAction" method="input"> - <result name="input">/WEB-INF/jsp/admin/database.jsp</result> - <result name="success" type="redirect-action"> - <param name="actionName">database</param> - </result> - </action> - - <action name="updateDatabase" class="schedulerAction" method="updateDatabase"> - <result type="redirect-action">database</result> - </action> - <!-- .\ CONFIGURATION \.___________________________________________ --> <action name="configureAppearance" class="organisationInfo"> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml index 314fda406..a9200f97f 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml @@ -51,10 +51,8 @@ <bean name="administrationService" lazy-init="true" scope="singleton" class="org.apache.archiva.web.xmlrpc.services.AdministrationServiceImpl"> <constructor-arg ref="archivaConfiguration"/> <constructor-arg ref="repositoryContentConsumers"/> - <constructor-arg ref="databaseConsumers"/> <constructor-arg ref="repositoryContentFactory"/> <constructor-arg ref="artifactDAO#jdo"/> - <constructor-arg ref="archivaTaskScheduler#database"/> <constructor-arg ref="archivaTaskScheduler#repository"/> <constructor-arg> <bean class="org.apache.maven.archiva.repository.events.RepositoryListenerFactoryBean" /> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/database.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/database.jsp deleted file mode 100644 index 59324ff4b..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/database.jsp +++ /dev/null @@ -1,122 +0,0 @@ -<%-- - ~ 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. - --%> - -<%@ taglib prefix="s" uri="/struts-tags"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> -<%@ taglib prefix="redback" uri="http://plexus.codehaus.org/redback/taglib-1.0" %> -<%@ taglib prefix="archiva" uri="/WEB-INF/taglib.tld" %> - -<html> -<head> -<title>Administration - Database</title> -<s:head /> -</head> - -<body> - -<h1>Administration - Database</h1> - -<div id="contentArea"> - -<s:actionerror /> -<s:actionmessage /> - -<c:url var="iconDeleteUrl" value="/images/icons/delete.gif" /> -<c:url var="iconCreateUrl" value="/images/icons/create.png" /> - -<div class="admin"> - -<h2>Database - Unprocessed Artifacts Scanning</h2> - - <s:form method="post" action="database!updateSchedule" - namespace="/admin" validate="false" theme="simple"> - <table> - <s:textfield name="cron" label="Cron" size="40" theme="xhtml" /> - <tr> - <td colspan="2"> - <s:submit value="Update Cron" /> - </td> - </tr> - </table> - </s:form> - - <s:form action="updateDatabase" theme="simple"> - <s:submit value="Update Database Now"/> - </s:form> - -<h2>Database - Unprocessed Artifacts Scanning</h2> - -<c:choose> - <c:when test="${empty (unprocessedConsumers)}"> - <%-- No Consumers. Eeek! --%> - <strong>There are no consumers for unprocessed artifacts.</strong> - </c:when> - <c:otherwise> - <%-- Display the consumers. --%> - - <s:form method="post" action="database!updateUnprocessedConsumers" - namespace="/admin" validate="false" theme="simple"> - <table class="consumers"> - <tr> - <th> </th> - <th>Enabled?</th> - <th>ID</th> - <th>Description</th> - </tr> - <c:forEach items="${unprocessedConsumers}" var="consumer" varStatus="i"> - <c:choose> - <c:when test='${(i.index)%2 eq 0}'> - <c:set var="bgcolor" value="even" scope="page" /> - </c:when> - <c:otherwise> - <c:set var="bgcolor" value="odd" scope="page" /> - </c:otherwise> - </c:choose> - - <tr> - <td class="${bgcolor}"> - <input type="checkbox" name="enabledUnprocessedConsumers" theme="simple" value="${consumer.id}" <c:if test="${consumer.enabled}">checked</c:if> /> - </td> - <td class="${bgcolor}"> - <c:if test="${consumer.enabled}"> - <strong>enabled</strong> - </c:if> - </td> - <td class="${bgcolor}"> - <code>${consumer.id}</code> - </td> - <td class="${bgcolor}">${consumer.description}</td> - </tr> - </c:forEach> - <tr> - <td colspan="4"> - <s:submit value="Update Consumers" /> - </td> - </tr> - </table> - </s:form> - - </c:otherwise> -</c:choose> - -</div> -</div> -</body> -</html> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp index 52ec32bbe..b91f70952 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp @@ -24,8 +24,8 @@ <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib prefix="my" tagdir="/WEB-INF/tags" %> <%@ taglib prefix="redback" uri="http://plexus.codehaus.org/redback/taglib-1.0" %> -<%@ page import="org.apache.maven.archiva.web.startup.ArchivaVersion" %> <%@ page import="java.util.Calendar" %> +<%@ page import="org.apache.maven.archiva.web.startup.ArchivaVersion" %> <html> <head> @@ -141,9 +141,6 @@ <li class="none"> <my:currentWWUrl action="repositoryScanning" namespace="/admin">Repository Scanning</my:currentWWUrl> </li> - <li class="none"> - <my:currentWWUrl action="database" namespace="/admin">Database</my:currentWWUrl> - </li> <%-- TODO: future options here. * Repository Syncing Connectors. (rsync, ftp, scp, etc...) * Web Services (enable / disable), role based? diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/database/DatabaseActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/database/DatabaseActionTest.java deleted file mode 100644 index 361c1dd4b..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/database/DatabaseActionTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.apache.maven.archiva.web.action.admin.database; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.ArrayList; -import java.util.List; - -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.Configuration; -import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; -import org.easymock.MockControl; - -/** - * DatabaseActionTest - */ -public class DatabaseActionTest - extends PlexusInSpringTestCase -{ - private DatabaseAction action; - - private MockControl archivaConfigControl; - - private ArchivaConfiguration archivaConfig; - - private Configuration config; - - protected void setUp() - throws Exception - { - super.setUp(); - - archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class ); - archivaConfig = (ArchivaConfiguration) archivaConfigControl.getMock(); - - action = new DatabaseAction(); - - config = new Configuration(); - - DatabaseScanningConfiguration databaseScanningConfig = new DatabaseScanningConfiguration(); - - List<String> cleanUpConsumers = new ArrayList<String>(); - cleanUpConsumers.add( "not-present-remove-db-artifact" ); - cleanUpConsumers.add( "not-present-remove-db-project" ); - cleanUpConsumers.add( "not-present-remove-indexed" ); - - List<String> unprocessedConsumers = new ArrayList<String>(); - unprocessedConsumers.add( "update-db-bytecode-stats" ); - unprocessedConsumers.add( "update-db-project" ); - unprocessedConsumers.add( "validate-repository-metadata" ); - - databaseScanningConfig.setCleanupConsumers( cleanUpConsumers ); - databaseScanningConfig.setUnprocessedConsumers( unprocessedConsumers ); - - config.setDatabaseScanning( databaseScanningConfig ); - - setUpEnabledUnproccessedConsumers(); - - action.setArchivaConfiguration( archivaConfig ); - } - - protected void tearDown() - throws Exception - { - super.tearDown(); - } - - public void testUpdateUnprocessedConsumers() - throws Exception - { - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - - archivaConfig.save( config ); - archivaConfigControl.replay(); - - String returnString = action.updateUnprocessedConsumers(); - - List<String> results = config.getDatabaseScanning().getUnprocessedConsumers(); - - assertEquals( action.SUCCESS, returnString ); - assertEquals( 3, results.size() ); - } - - public void testDisableAllUnprocessedConsumers( ) - throws Exception - { - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - - archivaConfig.save( config ); - archivaConfigControl.replay(); - - action.setEnabledUnprocessedConsumers( null ); - - String returnString = action.updateUnprocessedConsumers(); - - List<String> results = config.getDatabaseScanning().getUnprocessedConsumers(); - - assertEquals( action.SUCCESS, returnString ); - assertEquals( 0, results.size() ); - } - - private void setUpEnabledUnproccessedConsumers( ) - { - List<String> enabledUnprocessedConsumer = new ArrayList<String>(); - - enabledUnprocessedConsumer.add( "update-db-bytecode-stats" ); - enabledUnprocessedConsumer.add( "update-db-project" ); - enabledUnprocessedConsumer.add( "validate-repository-metadata" ); - - action.setEnabledUnprocessedConsumers( enabledUnprocessedConsumer ); - } -} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoryArchivaDAOStub.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoryArchivaDAOStub.java index 0f17dd28c..ef5e908de 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoryArchivaDAOStub.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoryArchivaDAOStub.java @@ -24,7 +24,6 @@ import java.util.List; import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.ArtifactDAO; -import org.apache.maven.archiva.database.ProjectModelDAO; import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO; import org.apache.maven.archiva.database.RepositoryProblemDAO; import org.apache.maven.archiva.database.SimpleConstraint; @@ -41,11 +40,6 @@ public class AbstractManagedRepositoryArchivaDAOStub /** * @plexus.requirement role-hint="jdo" */ - private ProjectModelDAO projectModelDAO; - - /** - * @plexus.requirement role-hint="jdo" - */ private ArtifactDAO artifactDAO; /** @@ -68,11 +62,6 @@ public class AbstractManagedRepositoryArchivaDAOStub return artifactDAO; } - public ProjectModelDAO getProjectModelDAO() - { - return projectModelDAO; - } - public RepositoryProblemDAO getRepositoryProblemDAO() { throw new UnsupportedOperationException( "query not implemented for stub" ); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ArchivaDAOStub.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ArchivaDAOStub.java index 116313905..b0e78bff6 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ArchivaDAOStub.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ArchivaDAOStub.java @@ -8,7 +8,6 @@ import junit.framework.Assert; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.ArtifactDAO; -import org.apache.maven.archiva.database.ProjectModelDAO; import org.apache.maven.archiva.database.RepositoryContentStatisticsDAO; import org.apache.maven.archiva.database.RepositoryProblemDAO; import org.apache.maven.archiva.database.SimpleConstraint; @@ -48,8 +47,6 @@ public class ArchivaDAOStub private ArtifactDAO artifactDao; - private ProjectModelDAO projectDao; - private List<String> versions; private List<String> groups; @@ -95,11 +92,6 @@ public class ArchivaDAOStub return artifactDao; } - public ProjectModelDAO getProjectModelDAO() - { - return projectDao; - } - public RepositoryProblemDAO getRepositoryProblemDAO() { throw new UnsupportedOperationException( "method not implemented for stub" ); @@ -115,11 +107,6 @@ public class ArchivaDAOStub this.artifactDao = artifactDao; } - public void setProjectDao( ProjectModelDAO projectDao ) - { - this.projectDao = projectDao; - } - public void setVersions( List<String> versions ) { this.versions = versions; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java index 8d8c4b2b9..2f33c5058 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java @@ -19,6 +19,11 @@ package org.apache.maven.archiva.web.action.admin.repositories; * under the License. */ +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import com.opensymphony.xwork2.Action; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; @@ -27,21 +32,15 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration; -import org.apache.maven.archiva.model.ArchivaProjectModel; import org.apache.maven.archiva.security.ArchivaRoleConstants; import org.codehaus.plexus.redback.role.RoleManager; import org.codehaus.plexus.redback.role.RoleManagerException; -import org.codehaus.redback.integration.interceptor.SecureActionBundle; -import org.codehaus.redback.integration.interceptor.SecureActionException; import org.codehaus.plexus.registry.RegistryException; import org.codehaus.plexus.spring.PlexusInSpringTestCase; +import org.codehaus.redback.integration.interceptor.SecureActionBundle; +import org.codehaus.redback.integration.interceptor.SecureActionException; import org.easymock.MockControl; -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - /** * DeleteManagedRepositoryActionTest * @@ -319,14 +318,4 @@ public class DeleteManagedRepositoryActionTest roleManager.removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID ); roleManagerControl.replay(); } - - protected ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version ) - { - ArchivaProjectModel projectModel = new ArchivaProjectModel(); - projectModel.setGroupId( groupId ); - projectModel.setArtifactId( artifactId ); - projectModel.setVersion( version ); - - return projectModel; - } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ProjectModelDAOStub.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ProjectModelDAOStub.java deleted file mode 100644 index e18b2b5ff..000000000 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ProjectModelDAOStub.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.apache.maven.archiva.web.action.admin.repositories; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.List; - -import org.apache.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.Constraint; -import org.apache.maven.archiva.database.ObjectNotFoundException; -import org.apache.maven.archiva.database.ProjectModelDAO; -import org.apache.maven.archiva.model.ArchivaProjectModel; - -/** - * ProjectModelDAOStub - * - * @version - */ -public class ProjectModelDAOStub - implements ProjectModelDAO -{ - - public ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version ) - { - // TODO Auto-generated method stub - return null; - } - - public void deleteProjectModel( ArchivaProjectModel model ) - throws ArchivaDatabaseException - { - // TODO Auto-generated method stub - - } - - public ArchivaProjectModel getProjectModel( String groupId, String artifactId, String version ) - throws ObjectNotFoundException, ArchivaDatabaseException - { - ArchivaProjectModel projectModel = new ArchivaProjectModel(); - projectModel.setGroupId( groupId ); - projectModel.setArtifactId( artifactId ); - projectModel.setVersion( version ); - - return projectModel; - } - - public List<ArchivaProjectModel> queryProjectModels( Constraint constraint ) - throws ObjectNotFoundException, ArchivaDatabaseException - { - // TODO Auto-generated method stub - return null; - } - - public ArchivaProjectModel saveProjectModel( ArchivaProjectModel model ) - throws ArchivaDatabaseException - { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.xml index e2ebee50c..e31b34bbd 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/DeleteArtifactActionTest.xml @@ -36,11 +36,6 @@ <implementation>org.apache.maven.archiva.web.action.admin.repositories.RepositoryProblemDAOStub</implementation> </component> <component> - <role>org.apache.maven.archiva.database.ProjectModelDAO</role> - <role-hint>jdo</role-hint> - <implementation>org.apache.maven.archiva.web.action.admin.repositories.ProjectModelDAOStub</implementation> - </component> - <component> <role>org.apache.maven.archiva.database.ArtifactDAO</role> <role-hint>jdo</role-hint> <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArtifactDAOStub</implementation> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoriesActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoriesActionTest.xml index afb64ee15..030af3bff 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoriesActionTest.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/AbstractManagedRepositoriesActionTest.xml @@ -61,11 +61,6 @@ <field-name>artifactDAO</field-name> </requirement> <requirement> - <role>org.apache.maven.archiva.database.ProjectModelDAO</role> - <role-hint>jdo</role-hint> - <field-name>projectModelDAO</field-name> - </requirement> - <requirement> <role>org.apache.maven.archiva.database.RepositoryContentStatisticsDAO</role> <role-hint>jdo</role-hint> <field-name>repoContentStatisticsDAO</field-name> @@ -78,11 +73,6 @@ <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArtifactDAOStub</implementation> </component> <component> - <role>org.apache.maven.archiva.database.ProjectModelDAO</role> - <role-hint>jdo</role-hint> - <implementation>org.apache.maven.archiva.web.action.admin.repositories.ProjectModelDAOStub</implementation> - </component> - <component> <role>org.apache.maven.archiva.database.RepositoryContentStatisticsDAO</role> <role-hint>jdo</role-hint> <implementation>org.apache.maven.archiva.web.action.admin.repositories.RepositoryContentStatisticsDAOStub</implementation> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.xml index f4d20ee61..de0cd78db 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.xml @@ -48,11 +48,6 @@ <field-name>artifactDAO</field-name> </requirement> <requirement> - <role>org.apache.maven.archiva.database.ProjectModelDAO</role> - <role-hint>jdo</role-hint> - <field-name>projectModelDAO</field-name> - </requirement> - <requirement> <role>org.apache.maven.archiva.database.RepositoryContentStatisticsDAO</role> <role-hint>jdo</role-hint> <field-name>repoContentStatisticsDAO</field-name> @@ -65,11 +60,6 @@ <implementation>org.apache.maven.archiva.web.action.admin.repositories.ArtifactDAOStub</implementation> </component> <component> - <role>org.apache.maven.archiva.database.ProjectModelDAO</role> - <role-hint>jdo</role-hint> - <implementation>org.apache.maven.archiva.web.action.admin.repositories.ProjectModelDAOStub</implementation> - </component> - <component> <role>org.apache.maven.archiva.database.RepositoryContentStatisticsDAO</role> <role-hint>jdo</role-hint> <implementation>org.apache.maven.archiva.web.action.admin.repositories.RepositoryContentStatisticsDAOStub</implementation> diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java index 814933446..ba44c60b3 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java @@ -21,11 +21,10 @@ package org.apache.archiva.web.xmlrpc.api; import java.util.List; +import com.atlassian.xmlrpc.ServiceObject; import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; -import com.atlassian.xmlrpc.ServiceObject; - @ServiceObject( "AdministrationService" ) public interface AdministrationService { @@ -37,30 +36,6 @@ public interface AdministrationService * @throws Exception */ public Boolean executeRepositoryScanner( String repoId ) throws Exception; - - /** - * Executes the database scanner. - * - * @return - * @throws Exception - */ - public Boolean executeDatabaseScanner() throws Exception; - - /** - * Gets all available database consumers. - * @return - */ - public List<String> getAllDatabaseConsumers(); - - /** - * Configures (enable or disable) database consumer. - * - * @param consumerId id of the database consumer - * @param enable flag whether to enable or disable the specified consumer - * @return - * @throws Exception - */ - public Boolean configureDatabaseConsumer( String consumerId, boolean enable ) throws Exception; /** * Gets all available repository consumers. diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java index 15a42a74a..8709be444 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-client/src/main/java/org/apache/archiva/web/xmlrpc/client/SampleClient.java @@ -22,15 +22,14 @@ package org.apache.archiva.web.xmlrpc.client; import java.net.URL; import java.util.List; -import org.apache.archiva.web.xmlrpc.api.AdministrationService; -import org.apache.archiva.web.xmlrpc.api.PingService; -import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; -import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; - import com.atlassian.xmlrpc.AuthenticationInfo; import com.atlassian.xmlrpc.Binder; import com.atlassian.xmlrpc.BindingException; import com.atlassian.xmlrpc.DefaultBinder; +import org.apache.archiva.web.xmlrpc.api.AdministrationService; +import org.apache.archiva.web.xmlrpc.api.PingService; +import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; +import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; /** * TestClient @@ -92,28 +91,14 @@ public class SampleClient System.out.println( consumer ); } - System.out.println( "\n******** Database Consumers ********" ); - List<String> dbConsumers = adminService.getAllDatabaseConsumers(); - for( String consumer : dbConsumers ) - { - System.out.println( consumer ); - } - Boolean success = adminService.configureRepositoryConsumer( "internal", "repository-purge", true ); System.out.println( "\nConfigured repo consumer 'repository-purge' : " + ( (Boolean) success ).booleanValue() ); - success = adminService.configureDatabaseConsumer( "update-db-bytecode-stats", false ); - System.out.println( "\nConfigured db consumer 'update-db-bytecode-stats' : " + - ( (Boolean) success ).booleanValue() ); - success = adminService.executeRepositoryScanner( "internal" ); System.out.println( "\nExecuted repo scanner of repository 'internal' : " + ( (Boolean) success ).booleanValue() ); - success = adminService.executeDatabaseScanner(); - System.out.println( "\nExecuted database scanner : " + ( (Boolean) success ).booleanValue() ); - /* delete artifact */ /* * NOTE: before enabling & invoking deleteArtifact, make sure that the repository and artifact exists first! diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml index c332556dc..56108f745 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml @@ -60,10 +60,6 @@ </dependency> <dependency> <groupId>org.apache.archiva</groupId> - <artifactId>archiva-scheduler-database</artifactId> - </dependency> - <dependency> - <groupId>org.apache.archiva</groupId> <artifactId>archiva-security</artifactId> </dependency> <dependency> diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java index c2aceb607..d1a2357d7 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java @@ -24,8 +24,6 @@ import java.util.Collection; import java.util.List; import org.apache.archiva.repository.scanner.RepositoryContentConsumers; -import org.apache.archiva.scheduler.database.DatabaseArchivaTaskScheduler; -import org.apache.archiva.scheduler.database.DatabaseTask; import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; import org.apache.archiva.scheduler.repository.RepositoryTask; import org.apache.archiva.web.xmlrpc.api.AdministrationService; @@ -33,7 +31,6 @@ import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; -import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; @@ -43,8 +40,6 @@ import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.maven.archiva.database.ArchivaDatabaseException; import org.apache.maven.archiva.database.ArtifactDAO; import org.apache.maven.archiva.database.constraints.ArtifactVersionsConstraint; -import org.apache.maven.archiva.database.updater.DatabaseConsumers; -import org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer; import org.apache.maven.archiva.model.ArchivaArtifact; import org.apache.maven.archiva.model.VersionedReference; import org.apache.maven.archiva.repository.ContentNotFoundException; @@ -71,70 +66,28 @@ public class AdministrationServiceImpl private RepositoryContentConsumers repoConsumersUtil; - private DatabaseConsumers dbConsumersUtil; - private RepositoryContentFactory repoFactory; private ArtifactDAO artifactDAO; - private DatabaseArchivaTaskScheduler databaseTaskScheduler; - private RepositoryArchivaTaskScheduler repositoryTaskScheduler; private Collection<RepositoryListener> listeners; public AdministrationServiceImpl( ArchivaConfiguration archivaConfig, RepositoryContentConsumers repoConsumersUtil, - DatabaseConsumers dbConsumersUtil, RepositoryContentFactory repoFactory, - ArtifactDAO artifactDAO, DatabaseArchivaTaskScheduler databaseTaskScheduler, + RepositoryContentFactory repoFactory, ArtifactDAO artifactDAO, RepositoryArchivaTaskScheduler repositoryTaskScheduler, Collection<RepositoryListener> listeners ) { this.archivaConfiguration = archivaConfig; this.repoConsumersUtil = repoConsumersUtil; - this.dbConsumersUtil = dbConsumersUtil; this.repoFactory = repoFactory; this.artifactDAO = artifactDAO; - this.databaseTaskScheduler = databaseTaskScheduler; this.repositoryTaskScheduler = repositoryTaskScheduler; this.listeners = listeners; } /** - * @see AdministrationService#configureDatabaseConsumer(String, boolean) - */ - public Boolean configureDatabaseConsumer( String consumerId, boolean enable ) throws Exception - { - List<DatabaseUnprocessedArtifactConsumer> unprocessedConsumers = - dbConsumersUtil.getAvailableUnprocessedConsumers(); - - boolean found = false; - - for( DatabaseUnprocessedArtifactConsumer consumer : unprocessedConsumers ) - { - if( consumer.getId().equals( consumerId ) ) - { - found = true; - break; - } - } - - if( !found ) - { - throw new Exception( "Invalid database consumer." ); - } - - Configuration config = archivaConfiguration.getConfiguration(); - DatabaseScanningConfiguration dbScanningConfig = config.getDatabaseScanning(); - - dbScanningConfig.addUnprocessedConsumer( consumerId ); - - config.setDatabaseScanning( dbScanningConfig ); - saveConfiguration( config ); - - return new Boolean( true ); - } - - /** * @see AdministrationService#configureRepositoryConsumer(String, String, boolean) */ public Boolean configureRepositoryConsumer( String repoId, String consumerId, boolean enable ) @@ -260,24 +213,6 @@ public class AdministrationServiceImpl } /** - * @see AdministrationService#executeDatabaseScanner() - */ - public Boolean executeDatabaseScanner() throws Exception - { - if ( databaseTaskScheduler.isProcessingDatabaseTask() ) - { - return false; - } - - log.info( "Queueing database task on request from administration service" ); - DatabaseTask task = new DatabaseTask(); - - databaseTaskScheduler.queueTask( task ); - - return new Boolean( true ); - } - - /** * @see AdministrationService#executeRepositoryScanner(String) */ public Boolean executeRepositoryScanner( String repoId ) throws Exception @@ -302,23 +237,6 @@ public class AdministrationServiceImpl } /** - * @see AdministrationService#getAllDatabaseConsumers() - */ - public List<String> getAllDatabaseConsumers() - { - List<String> consumers = new ArrayList<String>(); - - List<DatabaseUnprocessedArtifactConsumer> unprocessedConsumers = dbConsumersUtil.getAvailableUnprocessedConsumers(); - - for( DatabaseUnprocessedArtifactConsumer consumer : unprocessedConsumers ) - { - consumers.add( consumer.getId() ); - } - - return consumers; - } - - /** * @see AdministrationService#getAllRepositoryConsumers() */ public List<String> getAllRepositoryConsumers() diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java index 022f35cc9..642e1be4b 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java @@ -26,8 +26,6 @@ import java.util.Collections; import java.util.List; import org.apache.archiva.repository.scanner.RepositoryContentConsumers; -import org.apache.archiva.scheduler.database.DatabaseArchivaTaskScheduler; -import org.apache.archiva.scheduler.database.DatabaseTask; import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; import org.apache.archiva.scheduler.repository.RepositoryTask; import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; @@ -36,7 +34,6 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; -import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; import org.apache.maven.archiva.configuration.FileTypes; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; @@ -44,8 +41,6 @@ import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration; import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer; import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.maven.archiva.database.ArtifactDAO; -import org.apache.maven.archiva.database.updater.DatabaseConsumers; -import org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer; import org.apache.maven.archiva.model.ArchivaArtifact; import org.apache.maven.archiva.model.ArchivaArtifactModel; import org.apache.maven.archiva.model.ArtifactReference; @@ -83,8 +78,6 @@ public class AdministrationServiceImplTest private RepositoryArchivaTaskScheduler repositoryTaskScheduler; - private DatabaseArchivaTaskScheduler databaseTaskScheduler; - // repository consumers private MockControl repoConsumerUtilsControl; @@ -102,18 +95,7 @@ public class AdministrationServiceImplTest private InvalidRepositoryContentConsumer checkMetadataConsumer; - // database consumers - private MockControl dbConsumersUtilControl; - - private DatabaseConsumers dbConsumersUtil; - - private MockControl unprocessedConsumersControl; - - private DatabaseUnprocessedArtifactConsumer processArtifactConsumer; - - private DatabaseUnprocessedArtifactConsumer processPomConsumer; - - // delete artifact + // delete artifact private MockControl repoFactoryControl; private RepositoryContentFactory repositoryFactory; @@ -139,9 +121,6 @@ public class AdministrationServiceImplTest configControl = MockClassControl.createControl( Configuration.class ); config = ( Configuration ) configControl.getMock(); - databaseTaskSchedulerControl = MockClassControl.createControl( DatabaseArchivaTaskScheduler.class ); - databaseTaskScheduler = (DatabaseArchivaTaskScheduler) databaseTaskSchedulerControl.getMock(); - repositoryTaskSchedulerControl = MockClassControl.createControl( RepositoryArchivaTaskScheduler.class ); repositoryTaskScheduler = (RepositoryArchivaTaskScheduler) repositoryTaskSchedulerControl.getMock(); @@ -157,14 +136,6 @@ public class AdministrationServiceImplTest checkPomConsumer = ( InvalidRepositoryContentConsumer ) invalidContentConsumerControl.getMock(); checkMetadataConsumer = ( InvalidRepositoryContentConsumer ) invalidContentConsumerControl.getMock(); - // db consumers - dbConsumersUtilControl = MockClassControl.createControl( DatabaseConsumers.class ); - dbConsumersUtil = ( DatabaseConsumers ) dbConsumersUtilControl.getMock(); - - unprocessedConsumersControl = MockControl.createControl( DatabaseUnprocessedArtifactConsumer.class ); - processArtifactConsumer = ( DatabaseUnprocessedArtifactConsumer ) unprocessedConsumersControl.getMock(); - processPomConsumer = ( DatabaseUnprocessedArtifactConsumer ) unprocessedConsumersControl.getMock(); - // delete artifact repoFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class ); repositoryFactory = ( RepositoryContentFactory ) repoFactoryControl.getMock(); @@ -176,137 +147,12 @@ public class AdministrationServiceImplTest listener = (RepositoryListener) listenerControl.getMock(); service = - new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, dbConsumersUtil, repositoryFactory, - artifactDao, databaseTaskScheduler, repositoryTaskScheduler, + new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, repositoryFactory, + artifactDao, repositoryTaskScheduler, Collections.singletonList( listener ) ); } -/* Tests for database consumers */ - - public void testGetAllDbConsumers() - throws Exception - { - recordDbConsumers(); - - dbConsumersUtilControl.replay(); - unprocessedConsumersControl.replay(); - - List<String> dbConsumers = service.getAllDatabaseConsumers(); - - dbConsumersUtilControl.verify(); - unprocessedConsumersControl.verify(); - - assertNotNull( dbConsumers ); - assertEquals( 2, dbConsumers.size() ); - assertTrue( dbConsumers.contains( "process-artifact" ) ); - assertTrue( dbConsumers.contains( "process-pom" ) ); - } - - public void testConfigureValidDatabaseConsumer() - throws Exception - { - DatabaseScanningConfiguration dbScanning = new DatabaseScanningConfiguration(); - dbScanning.addCleanupConsumer( "cleanup-index" ); - dbScanning.addCleanupConsumer( "cleanup-database" ); - dbScanning.addUnprocessedConsumer( "process-artifact" ); - - recordDbConsumers(); - - // test enable "process-pom" db consumer - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.getDatabaseScanning(), dbScanning ); - - config.setDatabaseScanning( dbScanning ); - configControl.setMatcher( MockControl.ALWAYS_MATCHER ); - configControl.setVoidCallable(); - - archivaConfig.save( config ); - archivaConfigControl.setVoidCallable(); - - dbConsumersUtilControl.replay(); - unprocessedConsumersControl.replay(); - archivaConfigControl.replay(); - configControl.replay(); - - try - { - boolean success = service.configureDatabaseConsumer( "process-pom", true ); - assertTrue( success ); - } - catch ( Exception e ) - { - fail( "An exception should not have been thrown." ); - } - - dbConsumersUtilControl.verify(); - unprocessedConsumersControl.verify(); - archivaConfigControl.verify(); - configControl.verify(); - - // test disable "process-pom" db consumer - dbConsumersUtilControl.reset(); - unprocessedConsumersControl.reset(); - archivaConfigControl.reset(); - configControl.reset(); - - dbScanning.addUnprocessedConsumer( "process-pom" ); - - recordDbConsumers(); - - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.getDatabaseScanning(), dbScanning ); - - config.setDatabaseScanning( dbScanning ); - configControl.setMatcher( MockControl.ALWAYS_MATCHER ); - configControl.setVoidCallable(); - - archivaConfig.save( config ); - archivaConfigControl.setVoidCallable(); - - dbConsumersUtilControl.replay(); - unprocessedConsumersControl.replay(); - archivaConfigControl.replay(); - configControl.replay(); - - try - { - boolean success = service.configureDatabaseConsumer( "process-pom", false ); - assertTrue( success ); - } - catch ( Exception e ) - { - fail( "An exception should not have been thrown." ); - } - - dbConsumersUtilControl.verify(); - unprocessedConsumersControl.verify(); - archivaConfigControl.verify(); - configControl.verify(); - } - - public void testConfigureInvalidDatabaseConsumer() - throws Exception - { - recordDbConsumers(); - - dbConsumersUtilControl.replay(); - unprocessedConsumersControl.replay(); - - try - { - service.configureDatabaseConsumer( "invalid-consumer", true ); - fail( "An exception should have been thrown." ); - } - catch ( Exception e ) - { - assertEquals( "Invalid database consumer.", e.getMessage() ); - } - - dbConsumersUtilControl.verify(); - unprocessedConsumersControl.verify(); - } - -/* Tests for repository consumers */ + /* Tests for repository consumers */ public void testGetAllRepoConsumers() throws Exception @@ -707,43 +553,7 @@ public class AdministrationServiceImplTest configControl.verify(); } -/* Tests for db scanning */ - - public void testExecuteDbScannerDbNotBeingScanned() - throws Exception - { - DatabaseTask task = new DatabaseTask(); - - databaseTaskSchedulerControl.expectAndReturn( databaseTaskScheduler.isProcessingDatabaseTask(), false ); - - databaseTaskScheduler.queueTask( task ); - databaseTaskSchedulerControl.setMatcher( MockControl.ALWAYS_MATCHER ); - databaseTaskSchedulerControl.setVoidCallable(); - - databaseTaskSchedulerControl.replay(); - - boolean success = service.executeDatabaseScanner(); - - databaseTaskSchedulerControl.verify(); - - assertTrue( success ); - } - - public void testExecuteDbScannerDbIsBeingScanned() - throws Exception - { - databaseTaskSchedulerControl.expectAndReturn( databaseTaskScheduler.isProcessingDatabaseTask(), true ); - - databaseTaskSchedulerControl.replay(); - - boolean success = service.executeDatabaseScanner(); - - databaseTaskSchedulerControl.verify(); - - assertFalse( success ); - } - -/* Tests for querying repositories */ + /* Tests for querying repositories */ public void testGetAllManagedRepositories() throws Exception @@ -859,19 +669,7 @@ public class AdministrationServiceImplTest invalidContentConsumerControl.expectAndReturn( checkPomConsumer.getId(), "check-pom" ); invalidContentConsumerControl.expectAndReturn( checkMetadataConsumer.getId(), "check-metadata" ); } - - private void recordDbConsumers() - { - List<DatabaseUnprocessedArtifactConsumer> unprocessedConsumers = - new ArrayList<DatabaseUnprocessedArtifactConsumer>(); - unprocessedConsumers.add( processArtifactConsumer ); - unprocessedConsumers.add( processPomConsumer ); - - dbConsumersUtilControl.expectAndReturn( dbConsumersUtil.getAvailableUnprocessedConsumers(), unprocessedConsumers ); - unprocessedConsumersControl.expectAndReturn( processArtifactConsumer.getId(), "process-artifact" ); - unprocessedConsumersControl.expectAndReturn( processPomConsumer.getId(), "process-pom" ); - } - + private void recordInManagedLegacyRepoContent( MockControl fileTypesControl, FileTypes fileTypes, MockControl pathParserControl, PathParser parser ) throws LayoutException @@ -936,4 +734,4 @@ public class AdministrationServiceImplTest return aRef; } -}
\ No newline at end of file +} |