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 includes; - - /** - * @plexus.requirement role-hint="effective-project-cache" - */ - private Cache effectiveProjectCache; - - public ProjectModelToDatabaseConsumer() - { - includes = new ArrayList(); - includes.add( "pom" ); - } - - public void beginScan() - { - /* nothing to do here */ - } - - public void completeScan() - { - /* nothing to do here */ - } - - public List 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 @@ - - - - - - - - org.apache.maven.archiva.database.jdo.JdoAccess - archiva - org.apache.maven.archiva.database.jdo.JdoAccess - - - org.codehaus.plexus.jdo.JdoFactory - archiva - - - - - - - org.codehaus.plexus.jdo.JdoFactory - archiva - org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory - - - - org.hsqldb.jdbcDriver - jdbc:hsqldb:mem:TESTDB - sa - - - - org.jpox.PersistenceManagerFactoryImpl - - - javax.jdo.PersistenceManagerFactoryClass - org.jpox.PersistenceManagerFactoryImpl - - - org.jpox.autoCreateSchema - true - - - - - - - org.codehaus.plexus.cache.Cache - effective-project-cache - org.codehaus.plexus.cache.ehcache.EhcacheCache - Effective Project Cache - - 600 - true - ${java.io.tmpdir}/archiva/effectiveproject - true - 1000 - LRU - effective-project-cache - false - - - 2700 - - 1800 - - - - 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 @@ * under the License. */ -import org.apache.commons.lang.StringUtils; - import java.io.Serializable; +import org.apache.commons.lang.StringUtils; + /** *

* AbstractArtifactKey - a artifact reference to a versioned project. @@ -44,14 +44,6 @@ * Type * * - * {@link AbstractProjectKey} - * Yes - * Yes - *   - *   - *   - * - * * {@link AbstractVersionedKey} * Yes * Yes 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; - -/** - *

- * 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. - *

- * - *

- * If you require things like "Version" or "Type", consider the other keys below. - *

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Key TypeGroup IDArtifact IDVersionClassifierType
{@link AbstractProjectKey}YesYes   
{@link AbstractVersionedKey}YesYesYes  
{@link AbstractArtifactKey}YesYesYesYesYes
- * - *

- * NOTE: This is a jpox required compound key handler class. - *

- * - * @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 @@ * under the License. */ -import org.apache.commons.lang.StringUtils; - import java.io.Serializable; +import org.apache.commons.lang.StringUtils; + /** *

* AbstractVersionedKey - a versioned reference to a Project. @@ -44,14 +44,6 @@ * Type * * - * {@link AbstractProjectKey} - * Yes - * Yes - *   - *   - *   - * - * * {@link AbstractVersionedKey} * Yes * Yes 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 @@ import java.util.ArrayList; import java.util.Enumeration; -import java.util.Iterator; import java.util.List; import java.util.Properties; @@ -32,43 +31,6 @@ */ 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 static ArtifactReference clone( ArtifactReference artifactReference ) 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 static Properties clone( Properties properties ) 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 static List cloneArtifactReferences( List cloneDependencies( List dependencies ) - { - if ( dependencies == null ) - { - return null; - } - - List ret = new ArrayList(); - - for ( Dependency dep : dependencies ) - { - if ( dep == null ) - { - // Skip null dependency. - continue; - } - - ret.add( clone( dep ) ); - } - - return ret; - } - - public static List cloneExclusions( List exclusions ) - { - if ( exclusions == null ) - { - return null; - } - - List ret = new ArrayList(); - - for ( Exclusion exclusion : exclusions ) - { - Exclusion cloned = new Exclusion(); - - cloned.setGroupId( exclusion.getGroupId() ); - cloned.setArtifactId( exclusion.getArtifactId() ); - - ret.add( cloned ); - } - - return ret; - } - - public static List cloneIndividuals( List individuals ) - { - if ( individuals == null ) - { - return individuals; - } - - List ret = new ArrayList(); - - Iterator 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 cloneLicenses( List licenses ) - { - if ( licenses == null ) - { - return null; - } - - List ret = new ArrayList(); - - 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 cloneMailingLists( List mailingLists ) - { - if ( mailingLists == null ) - { - return null; - } - - List ret = new ArrayList(); - - for ( MailingList mailingList : mailingLists ) - { - if ( mailingList == null ) - { - // Skip null mailing list. - continue; - } - - ret.add( clone( mailingList ) ); - } - - return ret; - } - - public static List clonePlugins( List plugins ) - { - return cloneArtifactReferences( plugins ); - } - - public static List cloneReports( List reports ) - { - return cloneArtifactReferences( reports ); - } - - public static List cloneRepositories( List repositories ) - { - if ( repositories == null ) - { - return null; - } - - List ret = new ArrayList(); - - 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 cloneRoles( List roles ) - { - return cloneSimpleStringList( roles ); - } - private static List cloneSimpleStringList( List 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 @@ */ 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. - artifacts 1.0.0+ @@ -51,14 +41,6 @@ * - - projects - 1.0.0+ - - ArchivaProjectModel - * - - repositoryProblems 1.0.0+ @@ -86,127 +68,6 @@ - - - - - - ArchivaProjectModel - 1.0.0+ - - - groupId - true - 1.0.0+ - String - true - - The Group ID of the repository content. - - - - artifactId - true - 1.0.0+ - String - true - - The Artifact ID of the repository content. - - - - version - true - 1.0.0+ - String - true - - The version of the repository content. - - - - parentProject - false - 1.0.0+ - false - - VersionedReference - 1 - - - The content key for a parent reference. - - - - packaging - false - 1.0.0+ - true - String - - The declared packaging for this project model. - - - - name - false - 1.0.0+ - false - String - - The name of this project. - - - - description - false - 1.0.0+ - false - String - - The description of this project. - - - - origin - false - 1.0.0+ - true - String - - The Origin of this Model. (Filesystem, Proxy, or Deploy) - - - - whenIndexed - false - 1.0.0+ - false - Date - - The timestamp when this model was indexed. - - - - url - false - 1.0.0+ - false - String - - The URL for the project's homepage. - - - - organization - false - 1.0.0+ - false - - Organization - - - - licenses - false - 1.0.0+ - false - - License - * - - - - mailingLists - 1.0.0+ - The mailing lists. - false - - MailingList - * - - - - issueManagement - 1.0.0+ - - - IssueManagement - - - - ciManagement - 1.0.0+ - - - CiManagement - - - - scm - 1.0.0+ - - - - Scm - - - - individuals - 1.0.0+ - - The list of individuals around this project. - - - Individual - * - - - - dependencies - 1.0.0+ - - - Dependency - * - - - - dependencyManagement - 1.0.0+ - - The list of dependency management settings. - - - Dependency - * - - - - repositories - 1.0.0+ - - The list project repositories in use by this project. - - - ProjectRepository - * - - - - plugins - 1.0.0+ - - The list of plugins that this project uses. - - - ArtifactReference - * - - - - reports - 1.0.0+ - - The list of reports that this project uses. - - - ArtifactReference - * - - - - buildExtensions - 1.0.0+ - - The list of build extensions that this project uses. - - - ArtifactReference - * - - - - properties - 1.0.0+ - - Properties - - String - * - - - - relocation - 1.0.0+ - If relocated, this is the new location reference - - VersionedReference - 1 - - - - - - 1.0.0+ - - - - 1.0.0+ - - - - - - - MailingList - A Mailing List - 1.0.0+ - - - name - 1.0.0+ - The name of the mailing list. - String - - - subscribeAddress - 1.0.0+ - The email address to subscribe to this mailing list. - String - - - unsubscribeAddress - 1.0.0+ - The email address to unsubscribe to this mailing list. - String - - - postAddress - 1.0.0+ - The email address to post to this mailing list. - String - - - mainArchiveUrl - 1.0.0+ - The url to the archive for this mailing list. - String - - - otherArchives - 1.0.0+ - The email address to subscribe to this mailing list. - - String - * - - - - - - 1.0.0+ - - - - - - - Organization - Specifies the organization that produces this project. - 1.0.0+ - - - name - true - 1.0.0+ - - String - - - organizationName - 1.2.1+ - - String - - - url - 1.0.0+ - - String - - - favicon - 1.0.0+ - /images/org-logo.png) or an absolute URL - (e.g., http://my.corp/logo.png). This value is used - when generating the project documentation. - ]]> - String - - - - - 1.0.0+ - - - - - - - License - - 1.0.0+ - - - id - true - 1.0.0+ - int - - The type of license. - - - - name - 1.0.0+ - - String - - - url - 1.0.0+ - - String - - - comments - - Addendum information pertaining to this license. - - 1.0.0+ - String - - - - - 1.0.0+ - - - - - - - IssueManagement - - Information about the issue tracking (or bug tracking) system used to manage this project. - - 1.0.0+ - - - url - true - 1.0.0+ - - String - - - issueManagementUrl - 1.2.1+ - - String - - - system - 1.0.0+ - - String - - - - - 1.0.0+ - - - - - - - CiManagement - 1.0.0+ - - - url - 1.0.0+ - true - - - String - - - ciUrl - 1.2.1+ - - - String - - - system - 1.0.0+ - - continuum.]]> - String - - - - - 1.0.0+ - - - - - - - Individual - - Description of a person who has contributed to the project. - This includes contributors and commitors. - - 1.0.0+ - - - email - true - 1.0.0+ - - String - - - individualEmail - 1.2.1+ - - String - - - name - 1.0.0+ - - String - - - principal - 1.0.0+ - - The RedBack (plexus security) principal associated with this Invididual. - - String - - - commitor - 1.0.0+ - - The flag if this user is a developer and/or commitor. - - boolean - - - url - 1.0.0+ - - String - - - - organization - organisation - 1.0.0+ - - String - - - organizationUrl - organisationUrl - 1.0.0+ - - String - - - roles - 1.0.0+ - role element, the body of which is a - role name. This can also be used to describe the contribution. - ]]> - - String - * - - - - timezone - 1.0.0+ - - String - - - properties - 1.0.0+ - - Properties - - String - * - - - - - - 1.0.0+ - - - - - - - Dependency - 1.0.0+ - - - groupId - 1.0.0+ - String - true - - The Group ID of the repository content. - - - - artifactId - 1.0.0+ - String - true - - The Artifact ID of the repository content. - - - - version - 1.0.0+ - String - false - - The version of the repository content. - - - - classifier - 1.0.0+ - String - false - - jdk14 and jdk15. - ]]> - - - type - 1.0.0+ - String - true - jar. 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 jar, war, ejb-client and test-jar. - New types can be defined by plugins that set - extensions to true, so this is not a complete list. - ]]> - jar - - - transitive - 1.0.0+ - false - True if the dependency is only here due a transitive resolution - boolean - - - - fromParent - 1.0.0+ - false - True if the dependency is only here due a parent pom - boolean - - - - url - 1.0.0+ - - String - - - scope - 1.0.0+ - compile, runtime, test, - system, and provided. 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 - the - dependency mechanism. - ]]> - - String - - - systemPath - 1.0.0+ - discouraged 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. ${java.home}. - ]]> - String - - - exclusions - 1.0.0+ - - Lists a set of artifacts that should be excluded from this dependency's artifact list when it comes to - calculating transitive dependencies. - - - Exclusion - * - - - - optional - 1.0.0+ - - 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. - - boolean - false - - - - - 1.0.0+ - - - - 1.0.0+ - - - - - - - Exclusion - 1.0.0+ - - - groupId - 1.0.0+ - - String - true - - - artifactId - 1.0.0+ - - String - true - - - - - 1.0.0+ - - - - - - - Scm - 1.0.0+ - - - connection - 1.0.0+ - URL format - and list of supported SCMs. - This connection is read-only. - ]]> - String - - - developerConnection - 1.0.0+ - connection, but for developers, i.e. this scm connection - will not be read only. - ]]> - String - - - url - 1.0.0+ - - - String - - - - - 1.0.0+ - - - - - - - ProjectRepository - 1.0.0+ - - - id - 1.0.0+ - settings.xml file, for example. - ]]> - String - - - name - 1.0.0+ - - String - - - url - 1.0.0+ - protocol://hostname/path. - ]]> - String - - - layout - 1.0.0+ - legacy or - default. - ]]> - String - default - - - plugins - 1.0.0+ - - Flag indicating if this repository is for plugin resolution. - - boolean - - - releases - 1.0.0+ - - Flag indicating if this repository has release versioned artifacts. - - boolean - - - snapshots - 1.0.0+ - - Flag indicating if this repository has snapshot versioned artifacts. - - boolean - - - - - 1.0.0+ - - - - - - - 2700 - - 1800 - - - - 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 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) 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: 2.0.5 - * 1.0-beta-2 1.0-alpha-10-SNAPSHOT - */ - 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 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 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 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 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 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 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 expectedList, - List effectiveList ) - { - assertEquivalentLists( listId, expectedList, effectiveList ); - - Map expectedMap = getIndividualsMap( expectedList ); - Map effectiveMap = getIndividualsMap( effectiveList ); - - Iterator 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 expectedList, - List effectiveList ) - { - assertEquivalentLists( listId, expectedList, effectiveList ); - - Map expectedMap = getDependencyMap( expectedList ); - Map effectiveMap = getDependencyMap( effectiveList ); - - Iterator it = expectedMap.keySet().iterator(); - while ( it.hasNext() ) - { - String key = it.next(); - - assertTrue( "Should exist in Effective [" + listId + "] list: " + key, effectiveMap.containsKey( key ) ); - } - } - - private Map getIndividualsMap( List individuals ) - { - Map map = new HashMap(); - Iterator it = individuals.iterator(); - while ( it.hasNext() ) - { - Individual individual = it.next(); - String key = individual.getEmail(); - map.put( key, individual ); - } - return map; - } - - private Map getDependencyMap( List deps ) - { - Map map = new HashMap(); - Iterator 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 deps = new ArrayList(); - - 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 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 @@ - - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - mock - org.apache.maven.archiva.repository.MockConfiguration - - - - org.codehaus.plexus.cache.Cache - effective-project-cache - org.codehaus.plexus.cache.ehcache.EhcacheCache - Effective Project Cache - - 600 - true - ${java.io.tmpdir}/archiva/effectiveproject - true - 1000 - LRU - effective-project-cache - false - - - 2700 - - 1800 - - - - 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 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 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 void deleteArtifact( ManagedRepositoryContent repository, ArchivaArtifact { // 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 selectedRepositoryIds = null; - - private List groupIds = null; - - private List artifacts = null; - - private List 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 getArtifacts() - { - return artifacts; - } - - public List getGroupIds() - { - return groupIds; - } - - public String getSelectedArtifactId() - { - return selectedArtifactId; - } - - public String getSelectedGroupId() - { - return selectedGroupId; - } - - public List 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 artifacts ) - { - this.artifacts = artifacts; - } - - public void setGroupIds( List groupIds ) - { - this.groupIds = groupIds; - } - - public void setVersions( List versions ) - { - this.versions = versions; - } - - public List getSelectedRepositoryIds() - { - return selectedRepositoryIds; - } - - public void setSelectedRepositoryIds( List 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 = "."; - - /** - *

- * Filter out excessive groupId naming. (to provide a tree-ish view of the list of groupIds). - *

- * - *
-     *  // Input List
-     *  commons-lang
-     *  com.jsch
-     *  org.apache.apache
-     *  org.apache.maven
-     *  org.codehaus.modello
-     *  // Filtered List
-     *  commons-lang
-     *  com.jsch
-     *  org
-     * 
- * - *
-     *  // 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
-     * 
- * - * @param groups the list of groupIds. - * @return - */ - public static List filterGroups( List groups ) - { - GroupTreeNode tree = buildGroupTree( groups ); - return collateGroups( tree ); - } - - public static GroupTreeNode buildGroupTree( List 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 collateGroups( GroupTreeNode rootNode ) - { - List groups = new ArrayList(); - 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 children = new TreeMap(); - - 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 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 @@ * 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 * @@ -49,11 +48,6 @@ public class JdoArchivaDAO */ private ArtifactDAO artifactDAO; - /** - * @plexus.requirement role-hint="jdo" - */ - private ProjectModelDAO projectModelDAO; - /** * @plexus.requirement role-hint="jdo" */ @@ -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 ArtifactDAO getArtifactDAO() 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 queryProjectModels( Constraint constraint ) - throws ObjectNotFoundException, ArchivaDatabaseException - { - return (List) 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 resolverList ) - { - /* do nothing */ - } - - public void resolutionStart( VersionedReference projectRef, List 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 getSelectedUnprocessedConsumers() - { - List ret = new ArrayList(); - 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 getAvailableUnprocessedConsumers() - { - return new ArrayList( 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 unprocessedArtifacts = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( false ) ); - - beginConsumerLifecycle( dbConsumers.getSelectedUnprocessedConsumers() ); - - try - { - // Process each consumer. - Predicate predicate = UnprocessedArtifactPredicate.getInstance(); - - Iterator it = IteratorUtils.filteredIterator( unprocessedArtifacts.iterator(), predicate ); - while ( it.hasNext() ) - { - ArchivaArtifact artifact = it.next(); - updateUnprocessed( artifact ); - } - } - finally - { - endConsumerLifecycle( dbConsumers.getSelectedUnprocessedConsumers() ); - } - } - - private void endConsumerLifecycle( List consumers ) - { - for ( ArchivaArtifactConsumer consumer : consumers ) - { - consumer.completeScan(); - } - } - - private void beginConsumerLifecycle( List consumers ) - { - for ( ArchivaArtifactConsumer consumer : consumers ) - { - consumer.beginScan(); - } - } - - public void updateUnprocessed( ArchivaArtifact artifact ) - throws ArchivaDatabaseException - { - List 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 @@ - - - - - - - - - \ 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.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 @@ protected void setUp() 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 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 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 exprs = new ArrayList(); - 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 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 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 getIncludedTypes() - { - List types = new ArrayList(); - 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 @@ - - - org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer - test-db-unprocessed - org.apache.maven.archiva.database.updater.TestDatabaseUnprocessedConsumer - 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 @@ - - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - configured - - - org.apache.maven.archiva.policies.PreDownloadPolicy - prePolicies - - - org.apache.maven.archiva.policies.PostDownloadPolicy - postPolicies - - - - - org.codehaus.plexus.registry.Registry - configured - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - - - - - 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 @@ - - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - configured - - - org.apache.maven.archiva.policies.PreDownloadPolicy - prePolicies - - - org.apache.maven.archiva.policies.PostDownloadPolicy - postPolicies - - - - - org.codehaus.plexus.registry.Registry - configured - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - - - - - 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 @@ - - - 4.0.0 - - archiva-scheduler - org.apache.archiva - 1.3-SNAPSHOT - - archiva-scheduler-database - Archiva Base :: Scheduled Tasks :: Database - - - org.apache.archiva - archiva-scheduler-api - - - org.apache.archiva - archiva-configuration - - - org.apache.archiva - archiva-database - - - org.codehaus.plexus - plexus-quartz - - - org.slf4j - slf4j-api - - - org.slf4j - slf4j-simple - test - - - hsqldb - hsqldb - test - - - org.codehaus.plexus - plexus-spring - test - - - - - - org.codehaus.plexus - plexus-component-metadata - - - merge - - merge-metadata - - - - ${basedir}/src/main/resources/META-INF/plexus/components.xml - ${project.build.outputDirectory}/META-INF/plexus/components.xml - - - - - - - - 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, 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 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 @@ - - - - - - - - org.codehaus.plexus.taskqueue.TaskQueue - database-update - org.codehaus.plexus.taskqueue.DefaultTaskQueue - plexus-configurable - - - - - - - - - - - - org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor - database-update - org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor - singleton - - - org.codehaus.plexus.taskqueue.execution.TaskExecutor - database-update - - - org.codehaus.plexus.taskqueue.TaskQueue - database-update - - - - database-update - - - - 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 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 artifactList = adao.queryArtifacts( null ); - assertNotNull( "Artifact list should not be null.", artifactList ); - assertEquals( "Artifact list size", 1, artifactList.size() ); - - // Test for unprocessed artifacts. - List 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 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 getIncludedTypes() - { - List types = new ArrayList(); - 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 @@ - - - - - - javax.sql - jdbc - 2.0 - 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 @@ - - - - - javax.sql - jdbc - 2.0 - 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 @@ - - - - - javax.sql - jdbc - 2.0 - - - 2.0 - - - 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 @@ - - - - - javax.sql - jdbc - 2.0 - 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 @@ - - - - 4.0.0 - org.apache.maven - A - 1.0 - Maven Test Repository Artifact Discovery - war - 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 @@ - - - - 4.0.0 - org.apache.maven - B - 1.0 - Maven Test Repository Artifact Discovery - pom - 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 @@ - - - - 4.0.0 - org.apache.maven - B - 2.0 - Maven Test Repository Artifact Discovery - pom - 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 @@ - - - - 4.0.0 - org.apache.maven - C - 1.0 - Maven Test Repository Artifact Discovery - war - 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 @@ - - - - - org.apache.maven - \ 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 @@ - - - - 4.0.0 - org.apache.testgroup - discovery - 1.0 - Maven Test Repository Artifact Discovery - pom - 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 @@ - - - - - org.apache.testgroup - discovery - 1.0 - \ 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 @@ - - - - - org.apache.testgroup - discovery - \ 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 @@ - - - - - - - testRepo - Archiva Test Repository - ${basedir}/src/test/repositories/default-repository - default - true - false - true - 0 0 * * * ? - - - - - - - - - - - artifacts - - **/*.pom - **/*.jar - **/*.ear - **/*.war - **/*.car - **/*.sar - **/*.mar - **/*.rar - **/*.dtd - **/*.tld - **/*.tar.gz - **/*.tar.bz2 - **/*.zip - - - - indexable-content - - **/*.txt - **/*.TXT - **/*.block - **/*.config - **/*.pom - **/*.xml - **/*.xsd - **/*.dtd - **/*.tld - - - - auto-remove - - **/*.bak - **/*~ - **/*- - - - - ignored - - **/.htaccess - **/KEYS - **/*.rb - **/*.sh - **/.svn/** - **/.DAV/** - - - - - update-db-artifact - create-missing-checksums - update-db-repository-metadata - validate-checksum - validate-signature - index-content - auto-remove - auto-rename - - - update-db-bad-content - - - - - 0 0 * * * ? - - test-db-unprocessed - update-db-artifact - - - test-db-cleanup - - - - 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 @@ - - - - - - - org.codehaus.plexus.taskqueue.execution.TaskExecutor - test-database-update - org.apache.archiva.scheduler.database.ArchivaDatabaseUpdateTaskExecutor - - - - org.apache.maven.archiva.database.updater.DatabaseUpdater - jdo - databaseUpdater - - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - configured - - - org.apache.maven.archiva.policies.PreDownloadPolicy - prePolicies - - - org.apache.maven.archiva.policies.PostDownloadPolicy - postPolicies - - - - - - org.codehaus.plexus.registry.Registry - configured - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - - - - - org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer - test-db-unprocessed - org.apache.archiva.scheduler.database.TestDatabaseUnprocessedConsumer - - - - - org.codehaus.plexus.jdo.JdoFactory - archiva - org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory - - org.jpox.PersistenceManagerFactoryImpl - - - javax.jdo.PersistenceManagerFactoryClass - org.jpox.PersistenceManagerFactoryImpl - - - - - - - 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 @@ archiva-scheduler-api archiva-scheduler-indexing - archiva-scheduler-database archiva-scheduler-repository - \ No newline at end of file + 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 @@ -37,10 +37,6 @@ org.apache.archiva archiva-scheduler-repository - - org.apache.archiva - archiva-scheduler-database - org.apache.archiva archiva-indexer 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.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 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 @@ * 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 String scanRepository() 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 list = new ArrayList(); - - private List selectedIds; - - public AddAdminDatabaseConsumerClosure( List 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 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 -{ - 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 unprocessedConsumers; - - /** - * List of enabled {@link AdminDatabaseConsumer} objects for unprocessed artifacts. - */ - private List 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 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 getEnabledUnprocessedConsumers() - { - return enabledUnprocessedConsumers; - } - - public void setEnabledUnprocessedConsumers( List enabledUnprocessedConsumers ) - { - this.enabledUnprocessedConsumers = enabledUnprocessedConsumers; - } - - public ArchivaConfiguration getArchivaConfiguration() - { - return archivaConfiguration; - } - - public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration ) - { - this.archivaConfiguration = archivaConfiguration; - } - - private void filterAddedConsumers( List oldList, List newList ) - { - for ( String consumer : newList ) - { - if ( !oldList.contains( consumer ) ) - { - triggerAuditEvent( consumer, AuditEvent.ENABLE_DB_CONSUMER ); - } - } - } - - private void filterRemovedConsumers( List oldList, List newList ) - { - for ( String consumer : oldList ) - { - if ( !newList.contains( consumer ) ) - { - triggerAuditEvent( consumer, AuditEvent.DISABLE_DB_CONSUMER ); - } - } - } - - private void disableAllEnabledConsumers( List 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 @@ * 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.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 @@ private void cleanupDatabase( String repoId ) { 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.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 void contextInitialized( ServletContextEvent contextEvent ) 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 @@ - - - - - - - - You must enter a cron expression. - - - Invalid cron expression value(s). - - - \ 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 @@ - - - - /WEB-INF/jsp/admin/database.jsp - - database - - - - - database - - 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 @@ - - 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" %> - - - -Administration - Database - - - - - -

Administration - Database

- -
- - - - - - - -
- -

Database - Unprocessed Artifacts Scanning

- - - - - - - -
- -
-
- - - - - -

Database - Unprocessed Artifacts Scanning

- - - - <%-- No Consumers. Eeek! --%> - There are no consumers for unprocessed artifacts. - - - <%-- Display the consumers. --%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 Enabled?IDDescription
- checked /> - - - enabled - - - ${consumer.id} - ${consumer.description}
- -
-
- -
-
- -
-
- - 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" %> @@ -140,9 +140,6 @@
  • Repository Scanning -
  • -
  • - Database
  • <%-- TODO: future options here. * Repository Syncing Connectors. (rsync, ftp, scp, etc...) 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 cleanUpConsumers = new ArrayList(); - cleanUpConsumers.add( "not-present-remove-db-artifact" ); - cleanUpConsumers.add( "not-present-remove-db-project" ); - cleanUpConsumers.add( "not-present-remove-indexed" ); - - List unprocessedConsumers = new ArrayList(); - 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 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 results = config.getDatabaseScanning().getUnprocessedConsumers(); - - assertEquals( action.SUCCESS, returnString ); - assertEquals( 0, results.size() ); - } - - private void setUpEnabledUnproccessedConsumers( ) - { - List enabledUnprocessedConsumer = new ArrayList(); - - 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 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; @@ -38,11 +37,6 @@ public class AbstractManagedRepositoryArchivaDAOStub implements ArchivaDAO { - /** - * @plexus.requirement role-hint="jdo" - */ - private ProjectModelDAO projectModelDAO; - /** * @plexus.requirement role-hint="jdo" */ @@ -68,11 +62,6 @@ public ArtifactDAO getArtifactDAO() 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 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 versions; private List groups; @@ -95,11 +92,6 @@ public ArtifactDAO getArtifactDAO() return artifactDao; } - public ProjectModelDAO getProjectModelDAO() - { - return projectDao; - } - public RepositoryProblemDAO getRepositoryProblemDAO() { throw new UnsupportedOperationException( "method not implemented for stub" ); @@ -115,11 +107,6 @@ public void setArtifactDao( ArtifactDAO artifactDao ) this.artifactDao = artifactDao; } - public void setProjectDao( ProjectModelDAO projectDao ) - { - this.projectDao = projectDao; - } - public void setVersions( List 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 @@ * 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.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 @@ private void prepareRoleManagerMock() 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 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 @@ -35,11 +35,6 @@ jdo org.apache.maven.archiva.web.action.admin.repositories.RepositoryProblemDAOStub - - org.apache.maven.archiva.database.ProjectModelDAO - jdo - org.apache.maven.archiva.web.action.admin.repositories.ProjectModelDAOStub - org.apache.maven.archiva.database.ArtifactDAO jdo 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 @@ -60,11 +60,6 @@ jdo artifactDAO - - org.apache.maven.archiva.database.ProjectModelDAO - jdo - projectModelDAO - org.apache.maven.archiva.database.RepositoryContentStatisticsDAO jdo @@ -77,11 +72,6 @@ jdo org.apache.maven.archiva.web.action.admin.repositories.ArtifactDAOStub - - org.apache.maven.archiva.database.ProjectModelDAO - jdo - org.apache.maven.archiva.web.action.admin.repositories.ProjectModelDAOStub - org.apache.maven.archiva.database.RepositoryContentStatisticsDAO jdo 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 @@ -47,11 +47,6 @@ jdo artifactDAO - - org.apache.maven.archiva.database.ProjectModelDAO - jdo - projectModelDAO - org.apache.maven.archiva.database.RepositoryContentStatisticsDAO jdo @@ -64,11 +59,6 @@ jdo org.apache.maven.archiva.web.action.admin.repositories.ArtifactDAOStub - - org.apache.maven.archiva.database.ProjectModelDAO - jdo - org.apache.maven.archiva.web.action.admin.repositories.ProjectModelDAOStub - org.apache.maven.archiva.database.RepositoryContentStatisticsDAO jdo 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 @@ 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 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 @@ 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 static void main( String[] args ) System.out.println( consumer ); } - System.out.println( "\n******** Database Consumers ********" ); - List 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 @@ -58,10 +58,6 @@ org.apache.archiva archiva-scheduler-repository
    - - org.apache.archiva - archiva-scheduler-database - org.apache.archiva archiva-security 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.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.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.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,69 +66,27 @@ public class AdministrationServiceImpl private RepositoryContentConsumers repoConsumersUtil; - private DatabaseConsumers dbConsumersUtil; - private RepositoryContentFactory repoFactory; private ArtifactDAO artifactDAO; - private DatabaseArchivaTaskScheduler databaseTaskScheduler; - private RepositoryArchivaTaskScheduler repositoryTaskScheduler; private Collection listeners; public AdministrationServiceImpl( ArchivaConfiguration archivaConfig, RepositoryContentConsumers repoConsumersUtil, - DatabaseConsumers dbConsumersUtil, RepositoryContentFactory repoFactory, - ArtifactDAO artifactDAO, DatabaseArchivaTaskScheduler databaseTaskScheduler, + RepositoryContentFactory repoFactory, ArtifactDAO artifactDAO, RepositoryArchivaTaskScheduler repositoryTaskScheduler, Collection 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 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) */ @@ -259,24 +212,6 @@ public Boolean deleteArtifact( String repoId, String groupId, String artifactId, return new Boolean( true ); } - /** - * @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) */ @@ -301,23 +236,6 @@ public Boolean executeRepositoryScanner( String repoId ) throws Exception return new Boolean( true ); } - /** - * @see AdministrationService#getAllDatabaseConsumers() - */ - public List getAllDatabaseConsumers() - { - List consumers = new ArrayList(); - - List unprocessedConsumers = dbConsumersUtil.getAvailableUnprocessedConsumers(); - - for( DatabaseUnprocessedArtifactConsumer consumer : unprocessedConsumers ) - { - consumers.add( consumer.getId() ); - } - - return consumers; - } - /** * @see AdministrationService#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.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.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.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 @@ protected void setUp() 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 @@ protected void setUp() 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 @@ protected void setUp() 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 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 void testExecuteRepoScannerRepoDoesNotExist() 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 @@ private void recordRepoConsumers() invalidContentConsumerControl.expectAndReturn( checkPomConsumer.getId(), "check-pom" ); invalidContentConsumerControl.expectAndReturn( checkMetadataConsumer.getId(), "check-metadata" ); } - - private void recordDbConsumers() - { - List unprocessedConsumers = - new ArrayList(); - 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 @@ private ArtifactReference createArtifactReference( String artifactId, String gro return aRef; } -} \ No newline at end of file +} diff --git a/pom.xml b/pom.xml index 3337ae4af..57d3ccfe2 100644 --- a/pom.xml +++ b/pom.xml @@ -348,11 +348,6 @@ archiva-converter 1.3-SNAPSHOT - - org.apache.archiva - archiva-dependency-graph - 1.3-SNAPSHOT - org.apache.archiva archiva-core-consumers @@ -418,11 +413,6 @@ archiva-scheduler-repository 1.3-SNAPSHOT - - org.apache.archiva - archiva-scheduler-database - 1.3-SNAPSHOT - org.apache.archiva archiva-scheduler-indexing