From 209df33fed2f3181dc754197648e4b48c61cb1d4 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Wed, 2 Dec 2009 10:23:42 +0000 Subject: [PATCH] [MRM-1025] remove model fields that are not used for clarity git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@886101 13f79535-47bb-0310-9956-ffa450edef68 --- .../ArtifactUpdateDatabaseConsumer.java | 12 +- .../archiva-base/archiva-model/pom.xml | 2 +- .../src/main/mdo/archiva-base.xml | 80 +---------- .../archiva/model/ArchivaArtifactTest.java | 46 ------ .../metadata/RepositoryMetadataReader.java | 7 +- .../ArtifactsProcessedConstraint.java | 16 +-- .../database/constraints/AllTests.java | 1 - .../ArtifactsProcessedConstraintTest.java | 133 ------------------ .../database/jdo/JdoArtifactDAOTest.java | 5 +- ...ivaRepositoryScanningTaskExecutorTest.java | 9 +- 10 files changed, 20 insertions(+), 291 deletions(-) delete mode 100644 archiva-modules/archiva-base/archiva-model/src/test/java/org/apache/maven/archiva/model/ArchivaArtifactTest.java delete mode 100644 archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraintTest.java diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java index db2200006..6ddd82eac 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-database-consumers/src/main/java/org/apache/maven/archiva/consumers/database/ArtifactUpdateDatabaseConsumer.java @@ -19,6 +19,11 @@ package org.apache.maven.archiva.consumers.database; * under the License. */ +import java.io.File; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ConfigurationNames; import org.apache.maven.archiva.configuration.FileTypes; @@ -41,11 +46,6 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationExce import org.codehaus.plexus.registry.Registry; import org.codehaus.plexus.registry.RegistryListener; -import java.io.File; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - /** * ArtifactUpdateDatabaseConsumer - Take an artifact off of disk and put it into the repository. * @@ -193,8 +193,6 @@ public class ArtifactUpdateDatabaseConsumer artifact.getModel().setLastModified( new Date( artifactFile.lastModified() ) ); artifact.getModel().setSize( artifactFile.length() ); - artifact.getModel().setOrigin( "FileSystem" ); - artifact.getModel().setWhenProcessed( null ); // set this to when the artifact was first discovered in the repo if ( artifact.getModel().getWhenGathered() == null ) diff --git a/archiva-modules/archiva-base/archiva-model/pom.xml b/archiva-modules/archiva-base/archiva-model/pom.xml index 90249d6b8..d6c78b7b7 100755 --- a/archiva-modules/archiva-base/archiva-model/pom.xml +++ b/archiva-modules/archiva-base/archiva-model/pom.xml @@ -70,7 +70,7 @@ org.codehaus.modello modello-maven-plugin - 1.2.1 + 1.3.0 false src/main/mdo/archiva-base.xml 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 0c9a400f0..e4947df67 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 @@ -5,7 +5,10 @@ xsd.target-namespace="http://archiva.apache.org/model/1.2.0"> archiva-base-model ArchivaBaseModel - 1.2.1 + + 1.3.0 Archiva Model @@ -220,47 +223,6 @@ The size of the artifact on disk. - - platform - false - 1.0.0+ - String - true - - The platform of this artifact. (default: "java") - - java - - - whenIndexed - false - 1.0.0+ - Date - false - - The timestamp when this artifact was indexed. - - - - whenProcessed - false - 1.0.0+ - Date - false - - When this artifact's contents was processed. - - - - origin - false - 1.0.0+ - String - false - - The origin of this artifact. (Filesystem, Proxy, Deploy) - - whenGathered false @@ -279,20 +241,6 @@ private static final long serialVersionUID = -6292417108113887384L; ]]> - - 1.0.0+ - - @@ -443,26 +391,6 @@ The size of the artifact on disk. - - whenIndexed - false - 1.0.0+ - Date - false - - The timestamp when this artifact was indexed. - - - - origin - false - 1.0.0+ - String - false - - The origin of this artifact. (Filesystem, Proxy, Deploy) - - diff --git a/archiva-modules/archiva-base/archiva-model/src/test/java/org/apache/maven/archiva/model/ArchivaArtifactTest.java b/archiva-modules/archiva-base/archiva-model/src/test/java/org/apache/maven/archiva/model/ArchivaArtifactTest.java deleted file mode 100644 index 3ad4d4415..000000000 --- a/archiva-modules/archiva-base/archiva-model/src/test/java/org/apache/maven/archiva/model/ArchivaArtifactTest.java +++ /dev/null @@ -1,46 +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 java.util.Date; - -import org.codehaus.plexus.spring.PlexusInSpringTestCase; - -/** - * ArchivaModelClonerTest - * - * @version $Id: ArchivaModelClonerTest.java 525951 2007-04-05 20:11:19Z joakime $ - */ -public class ArchivaArtifactTest - extends PlexusInSpringTestCase -{ - public void testArtifactModelProcessed() - { - ArchivaArtifactModel model = new ArchivaArtifactModel(); - - assertNull( "whenProcessed", model.getWhenProcessed() ); - assertFalse( "isProcessed", model.isProcessed() ); - - model.setWhenProcessed( new Date() ); - - assertTrue( "isProcessed", model.isProcessed() ); - } - -} diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataReader.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataReader.java index a6fc50b82..e587bdd74 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataReader.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataReader.java @@ -19,6 +19,9 @@ package org.apache.maven.archiva.repository.metadata; * under the License. */ +import java.io.File; +import java.util.Date; + import org.apache.commons.lang.math.NumberUtils; import org.apache.maven.archiva.model.ArchivaRepositoryMetadata; import org.apache.maven.archiva.model.Plugin; @@ -27,9 +30,6 @@ import org.apache.maven.archiva.xml.XMLException; import org.apache.maven.archiva.xml.XMLReader; import org.dom4j.Element; -import java.io.File; -import java.util.Date; - /** * RepositoryMetadataReader - read maven-metadata.xml files. * @@ -60,7 +60,6 @@ public class RepositoryMetadataReader metadata.setVersion( xml.getElementText( "//metadata/version" ) ); metadata.setFileLastModified( new Date( metadataFile.lastModified() ) ); metadata.setFileSize( metadataFile.length() ); - metadata.setWhenIndexed( null ); metadata.setLastUpdated( xml.getElementText( "//metadata/versioning/lastUpdated" ) ); metadata.setLatestVersion( xml.getElementText( "//metadata/versioning/latest" ) ); diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraint.java index 5c234e209..324964c15 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraint.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraint.java @@ -19,10 +19,10 @@ package org.apache.maven.archiva.database.constraints; * under the License. */ -import org.apache.maven.archiva.database.Constraint; - import java.util.Date; +import org.apache.maven.archiva.database.Constraint; + /** * ArtifactsProcessedConstraint * @@ -34,18 +34,6 @@ public class ArtifactsProcessedConstraint { private String whereClause; - public ArtifactsProcessedConstraint( boolean isProcessed ) - { - if ( isProcessed ) - { - whereClause = "whenProcessed != null"; - } - else - { - whereClause = "whenProcessed == null"; - } - } - /** * A Constraint showing artifacts processed since date provided. * @param since diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/AllTests.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/AllTests.java index f2394570b..a9b926e37 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/AllTests.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/AllTests.java @@ -34,7 +34,6 @@ public class AllTests { TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.database.constraints" ); //$JUnit-BEGIN$ - suite.addTestSuite( ArtifactsProcessedConstraintTest.class ); suite.addTestSuite( ArtifactsByChecksumConstraintTest.class ); suite.addTestSuite( OlderArtifactsByAgeConstraintTest.class ); suite.addTestSuite( UniqueGroupIdConstraintTest.class ); diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraintTest.java deleted file mode 100644 index 65719df90..000000000 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsProcessedConstraintTest.java +++ /dev/null @@ -1,133 +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 java.util.Date; -import java.util.List; - -import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase; -import org.apache.maven.archiva.database.ArtifactDAO; -import org.apache.maven.archiva.model.ArchivaArtifact; - -/** - * ArtifactsProcessedConstraintTest - * - * @version $Id$ - */ -public class ArtifactsProcessedConstraintTest - extends AbstractArchivaDatabaseTestCase -{ - 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; - } - - public void assertResults( String type, List results, String expectedArtifacts[] ) - { - assertNotNull( "Results[" + type + "] should not be null.", results ); - assertEquals( "Results[" + type + "].size", expectedArtifacts.length, results.size() ); - - for ( int i = 0; i < expectedArtifacts.length; i++ ) - { - String artifactId = expectedArtifacts[i]; - - int found = 0; - for ( ArchivaArtifact artifact : results ) - { - if ( artifactId.equals( artifact.getArtifactId() ) ) - { - found++; - } - } - - if ( found <= 0 ) - { - fail( "Results[" + type + "] - Did not find expected artifact ID [" + artifactId + "]" ); - } - - if ( found > 1 ) - { - fail( "Results[" + type + "] - Expected to find 1 copy of artifact ID [" + artifactId - + "], yet found <" + found + "> instead." ); - } - } - } - - @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", - "2006/08/22 19:01:00" ) ); - 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 ) ); - } - - public void testNotProcessed() - throws Exception - { - List results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( false ) ); - assertResults( "not-processed", results, new String[] { "archiva-common", "archiva-database" } ); - } - - public void testProcessed() - throws Exception - { - List results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( true ) ); - assertResults( "processed", results, new String[] { "archiva-utils", "archiva-old" } ); - } - - public void testSinceRecent() - throws Exception - { - Date since = toDate( "2006/01/01 12:00:00" ); - List results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( since ) ); - assertResults( "processed", results, new String[] { "archiva-utils" } ); - } - - public void testSinceOld() - throws Exception - { - Date since = toDate( "2001/01/01 12:00:00" ); - List results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( since ) ); - assertResults( "processed", results, new String[] { "archiva-utils", "archiva-old" } ); - } -} diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArtifactDAOTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArtifactDAOTest.java index a21e3ecb2..987880fbb 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArtifactDAOTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArtifactDAOTest.java @@ -21,7 +21,6 @@ package org.apache.maven.archiva.database.jdo; import java.util.Date; import java.util.List; - import javax.jdo.JDOHelper; import javax.jdo.spi.JDOImplHelper; @@ -67,7 +66,6 @@ public class JdoArtifactDAOTest // Set some mandatory values artifact.getModel().setLastModified( new Date() ); - artifact.getModel().setOrigin( "test" ); // Save it. ArchivaArtifact savedArtifact = artiDao.saveArtifact( artifact ); @@ -90,7 +88,7 @@ public class JdoArtifactDAOTest assertEquals( "jar", firstArtifact.getType() ); // Change value and save. - savedArtifact.getModel().setOrigin( "changed" ); + savedArtifact.getModel().setLastModified( new Date() ); artiDao.saveArtifact( savedArtifact ); // Test that only 1 object is saved. @@ -103,7 +101,6 @@ public class JdoArtifactDAOTest // Test expected values. assertEquals( "archiva-test-module", actualArtifact.getArtifactId() ); - assertEquals( "changed", actualArtifact.getModel().getOrigin() ); // Test that only 1 object is saved. assertEquals( 1, artiDao.queryArtifacts( null ).size() ); diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorTest.java index a79db2a81..fe7ce034e 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorTest.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorTest.java @@ -32,7 +32,6 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration; 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.apache.maven.archiva.model.RepositoryContentStatistics; import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory; @@ -174,7 +173,7 @@ public class ArchivaRepositoryScanningTaskExecutorTest taskExecutor.executeTask( repoTask ); ArtifactDAO adao = dao.getArtifactDAO(); - List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) ); + List unprocessedResultList = adao.queryArtifacts( null ); assertNotNull( unprocessedResultList ); assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size() ); @@ -215,7 +214,7 @@ public class ArchivaRepositoryScanningTaskExecutorTest taskExecutor.executeTask( repoTask ); ArtifactDAO adao = dao.getArtifactDAO(); - List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) ); + List unprocessedResultList = adao.queryArtifacts( null ); assertNotNull( unprocessedResultList ); assertEquals("Incorrect number of unprocessed artifacts detected. No new artifacts should have been found.", 0, unprocessedResultList.size() ); @@ -232,7 +231,7 @@ public class ArchivaRepositoryScanningTaskExecutorTest taskExecutor.executeTask( repoTask ); - unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) ); + unprocessedResultList = adao.queryArtifacts( null ); assertNotNull( unprocessedResultList ); assertEquals( "Incorrect number of unprocessed artifacts detected. One new artifact should have been found.", 1, unprocessedResultList.size() ); } @@ -272,7 +271,7 @@ public class ArchivaRepositoryScanningTaskExecutorTest taskExecutor.executeTask( repoTask ); ArtifactDAO adao = dao.getArtifactDAO(); - List unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) ); + List unprocessedResultList = adao.queryArtifacts( null ); assertNotNull( unprocessedResultList ); assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size() ); -- 2.39.5