You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by jo...@apache.org on 2007/04/19 14:25:29 UTC
svn commit: r530395 [2/4] - in
/maven/archiva/branches/archiva-jpox-database-refactor:
archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/
archiva-base/archiva-configuration/src/main/mdo/
archiva-base/archiva-config...
Modified: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayoutTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayoutTest.java?view=diff&rev=530395&r1=530394&r2=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayoutTest.java (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayoutTest.java Thu Apr 19 05:25:11 2007
@@ -21,9 +21,18 @@
import org.apache.maven.archiva.model.ArchivaArtifact;
import org.apache.maven.archiva.model.ArtifactReference;
+import org.apache.maven.archiva.model.ProjectReference;
+import org.apache.maven.archiva.model.VersionedReference;
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
import org.apache.maven.archiva.repository.layout.LayoutException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
/**
* DefaultBidirectionalRepositoryLayoutTest
*
@@ -33,191 +42,451 @@
public class DefaultBidirectionalRepositoryLayoutTest
extends AbstractBidirectionalRepositoryLayoutTestCase
{
- private BidirectionalRepositoryLayout layout;
-
- protected void setUp()
- throws Exception
+ class LayoutExample
{
- super.setUp();
+ public String groupId;
- layout = (BidirectionalRepositoryLayout) lookup( BidirectionalRepositoryLayout.class.getName(), "default" );
- }
+ public String artifactId;
- public void testToPathBasic()
- {
- ArchivaArtifact artifact = createArtifact( "com.foo", "foo-tool", "1.0", "", "jar" );
+ public String version;
- assertEquals( "com/foo/foo-tool/1.0/foo-tool-1.0.jar", layout.toPath( artifact ) );
- }
+ public String classifier;
- public void testToPathEjbClient()
- {
- ArchivaArtifact artifact = createArtifact( "com.foo", "foo-client", "1.0", "", "ejb-client" );
+ public String type;
- assertEquals( "com/foo/foo-client/1.0/foo-client-1.0.jar", layout.toPath( artifact ) );
- }
+ public String path;
- public void testToPathWithClassifier()
- {
- ArchivaArtifact artifact = createArtifact( "com.foo.lib", "foo-lib", "2.1-alpha-1", "sources", "java-source" );
+ public LayoutExample( String groupId, String artifactId, String version, String classifier, String type )
+ {
+ super();
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.version = version;
+ this.classifier = classifier;
+ this.type = type;
+ }
- assertEquals( "com/foo/lib/foo-lib/2.1-alpha-1/foo-lib-2.1-alpha-1-sources.jar", layout.toPath( artifact ) );
- }
+ public boolean isSuitableForArtifactTest()
+ {
+ return ( this.type != null ) && ( this.classifier != null ) && ( this.version != null );
+ }
- public void testToPathUsingUniqueSnapshot()
- {
- ArchivaArtifact artifact = createArtifact( "com.foo", "foo-connector", "2.1-20060822.123456-35", "", "jar" );
+ public boolean isSuitableForVersionedTest()
+ {
+ return ( this.type == null ) && ( this.classifier == null ) && ( this.version != null );
+ }
- assertEquals( "com/foo/foo-connector/2.1-SNAPSHOT/foo-connector-2.1-20060822.123456-35.jar", layout
- .toPath( artifact ) );
+ public boolean isSuitableForProjectTest()
+ {
+ return ( this.type == null ) && ( this.classifier == null ) && ( this.version == null );
+ }
}
- public void testTimestampedSnapshotRoundtrip()
- throws LayoutException
+ class InvalidExample
{
- String originalPath = "org/apache/maven/test/get-metadata-snapshot/1.0-SNAPSHOT/get-metadata-snapshot-1.0-20050831.101112-1.jar";
- ArchivaArtifact artifact = layout.toArtifact( originalPath );
- assertArtifact( artifact, "org.apache.maven.test", "get-metadata-snapshot", "1.0-20050831.101112-1", "", "jar" );
+ public String path;
- assertEquals( originalPath, layout.toPath( artifact ) );
+ public String reason;
- ArtifactReference aref = new ArtifactReference();
- aref.setGroupId( artifact.getGroupId() );
- aref.setArtifactId( artifact.getArtifactId() );
- aref.setVersion( artifact.getVersion() );
- aref.setClassifier( artifact.getClassifier() );
- aref.setType( artifact.getType() );
+ public boolean hasFilename;
- assertEquals( originalPath, layout.toPath( aref ) );
+ public InvalidExample( String path, boolean hasFilename, String reason )
+ {
+ super();
+ this.path = path;
+ this.hasFilename = hasFilename;
+ this.reason = reason;
+ }
}
- public void testToArtifactBasicSimpleGroupId()
- throws LayoutException
- {
- ArchivaArtifact artifact = layout.toArtifact( "commons-lang/commons-lang/2.1/commons-lang-2.1.jar" );
- assertArtifact( artifact, "commons-lang", "commons-lang", "2.1", "", "jar" );
- }
+ private BidirectionalRepositoryLayout layout;
- public void testToArtifactBasicLongGroupId()
- throws LayoutException
+ public List /*<LayoutExample>*/getGoodExamples()
{
- ArchivaArtifact artifact = layout.toArtifact( "com/foo/foo-tool/1.0/foo-tool-1.0.jar" );
- assertArtifact( artifact, "com.foo", "foo-tool", "1.0", "", "jar" );
- }
+ List ret = new ArrayList();
- public void testToArtifactEjbClient()
- throws LayoutException
- {
- ArchivaArtifact artifact = layout.toArtifact( "com/foo/foo-client/1.0/foo-client-1.0.jar" );
- // The type is correct. as we cannot possibly know this is an ejb client without parsing the pom
- assertArtifact( artifact, "com.foo", "foo-client", "1.0", "", "jar" );
- }
+ LayoutExample example;
- public void testToArtifactWithClassifier()
- throws LayoutException
- {
- ArchivaArtifact artifact = layout
- .toArtifact( "com/foo/lib/foo-lib/2.1-alpha-1/foo-lib-2.1-alpha-1-sources.jar" );
- // The 'java-source' type is correct. You might be thinking of extension, which we are not testing here.
- assertArtifact( artifact, "com.foo.lib", "foo-lib", "2.1-alpha-1", "sources", "java-source" );
+ // Artifact References
+ example = new LayoutExample( "com.foo", "foo-tool", "1.0", "", "jar" );
+ example.path = "com/foo/foo-tool/1.0/foo-tool-1.0.jar";
+ ret.add( example );
+
+ example = new LayoutExample( "com.foo", "foo-client", "1.0", "", "ejb-client" );
+ example.path = "com/foo/foo-client/1.0/foo-client-1.0.jar";
+ ret.add( example );
+
+ example = new LayoutExample( "com.foo.lib", "foo-lib", "2.1-alpha-1", "sources", "java-source" );
+ example.path = "com/foo/lib/foo-lib/2.1-alpha-1/foo-lib-2.1-alpha-1-sources.jar";
+ ret.add( example );
+
+ example = new LayoutExample( "com.foo", "foo-connector", "2.1-20060822.123456-35", "", "jar" );
+ example.path = "com/foo/foo-connector/2.1-SNAPSHOT/foo-connector-2.1-20060822.123456-35.jar";
+ ret.add( example );
+
+ example = new LayoutExample( "org.apache.maven.test", "get-metadata-snapshot", "1.0-20050831.101112-1", "",
+ "jar" );
+ example.path = "org/apache/maven/test/get-metadata-snapshot/1.0-SNAPSHOT/get-metadata-snapshot-1.0-20050831.101112-1.jar";
+ ret.add( example );
+
+ example = new LayoutExample( "commons-lang", "commons-lang", "2.1", "", "jar" );
+ example.path = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar";
+ ret.add( example );
+
+ example = new LayoutExample( "com.foo", "foo-tool", "1.0", "", "jar" );
+ example.path = "com/foo/foo-tool/1.0/foo-tool-1.0.jar";
+ ret.add( example );
+
+ // Versioned References (done here by setting classifier and type to null)
+ example = new LayoutExample( "com.foo", "foo-tool", "1.0", null, null );
+ example.path = "com/foo/foo-tool/1.0/foo-tool-1.0.jar";
+ ret.add( example );
+
+ example = new LayoutExample( "com.foo", "foo-tool", "1.0", null, null );
+ example.path = "com/foo/foo-tool/1.0/";
+ ret.add( example );
+
+ example = new LayoutExample( "com.foo", "foo-tool", "1.0", null, null );
+ example.path = "com/foo/foo-tool/1.0";
+ ret.add( example );
+
+ example = new LayoutExample( "com.foo", "foo-connector", "2.1-20060822.123456-35", null, null );
+ example.path = "com/foo/foo-connector/2.1-SNAPSHOT/foo-connector-2.1-20060822.123456-35.jar";
+ ret.add( example );
+
+ example = new LayoutExample( "com.foo", "foo-connector", "2.1-20060822.123456-35", null, null );
+ example.path = "com/foo/foo-connector/2.1-SNAPSHOT/";
+ ret.add( example );
+
+ example = new LayoutExample( "com.foo", "foo-connector", "2.1-20060822.123456-35", null, null );
+ example.path = "com/foo/foo-connector/2.1-SNAPSHOT";
+ ret.add( example );
+
+ return ret;
}
- public void testToArtifactUsingUniqueSnapshot()
- throws LayoutException
+ public List /*<InvalidExample>*/getInvalidPaths()
{
- ArchivaArtifact artifact = layout
- .toArtifact( "com/foo/foo-connector/2.1-SNAPSHOT/foo-connector-2.1-20060822.123456-35.jar" );
- assertSnapshotArtifact( artifact, "com.foo", "foo-connector", "2.1-20060822.123456-35", "", "jar" );
+ List ret = new ArrayList();
+
+ InvalidExample example;
+
+ example = new InvalidExample( "invalid/invalid/1/invalid-1", false, "missing type" );
+ ret.add( example );
+
+ example = new InvalidExample( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar", true,
+ "non snapshot artifact inside of a snapshot dir" );
+ ret.add( example );
+
+ example = new InvalidExample( "invalid/invalid-1.0.jar", true, "path is too short" );
+ ret.add( example );
+
+ example = new InvalidExample( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar", true,
+ "Timestamped Snapshot artifact not inside of an Snapshot dir" );
+ ret.add( example );
+
+ example = new InvalidExample( "invalid/invalid/1.0/invalid-2.0.jar", true,
+ "version mismatch between path and artifact" );
+ ret.add( example );
+
+ example = new InvalidExample( "invalid/invalid/1.0/invalid-1.0b.jar", true,
+ "version mismatch between path and artifact" );
+ ret.add( example );
+
+ example = new InvalidExample( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar",
+ true, "wrong artifact id" );
+
+ return ret;
}
- public void testInvalidMissingType()
+ public void testArtifactToPath()
{
- try
+ Iterator it = getGoodExamples().iterator();
+ while ( it.hasNext() )
{
- layout.toArtifact( "invalid/invalid/1/invalid-1" );
- fail( "Should have detected missing type." );
+ LayoutExample example = (LayoutExample) it.next();
+ if ( example.isSuitableForArtifactTest() )
+ {
+ ArchivaArtifact artifact = createArtifact( example.groupId, example.artifactId, example.version,
+ example.classifier, example.type );
+ assertEquals( "Artifact <" + artifact + "> to path:", example.path, layout.toPath( artifact ) );
+ }
}
- catch ( LayoutException e )
+ }
+
+ public void testArtifactReferenceToPath()
+ {
+ Iterator it = getGoodExamples().iterator();
+ while ( it.hasNext() )
{
- /* expected path */
+ LayoutExample example = (LayoutExample) it.next();
+ if ( example.isSuitableForArtifactTest() )
+ {
+ ArtifactReference reference = new ArtifactReference();
+ reference.setGroupId( example.groupId );
+ reference.setArtifactId( example.artifactId );
+ reference.setVersion( example.version );
+ reference.setClassifier( example.classifier );
+ reference.setType( example.type );
+
+ assertEquals( "ArtifactReference <" + reference + "> to path:", example.path, layout.toPath( reference ) );
+ }
}
}
- public void testInvalidNonSnapshotInSnapshotDir()
+ public void testVersionedReferenceToPath()
{
- try
+ Iterator it = getGoodExamples().iterator();
+ while ( it.hasNext() )
{
- layout.toArtifact( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" );
- fail( "Should have detected non snapshot artifact inside of a snapshot dir." );
+ LayoutExample example = (LayoutExample) it.next();
+ if ( example.isSuitableForVersionedTest() && example.isSuitableForArtifactTest() )
+ {
+ VersionedReference reference = new VersionedReference();
+ reference.setGroupId( example.groupId );
+ reference.setArtifactId( example.artifactId );
+ reference.setVersion( example.version );
+
+ assertEquals( "VersionedReference <" + reference + "> to path:", example.path, layout
+ .toPath( reference ) );
+ }
}
- catch ( LayoutException e )
+ }
+
+ public void testProjectReferenceToPath()
+ {
+ Iterator it = getGoodExamples().iterator();
+ while ( it.hasNext() )
{
- /* expected path */
+ LayoutExample example = (LayoutExample) it.next();
+ if ( example.isSuitableForProjectTest() && example.isSuitableForVersionedTest()
+ && example.isSuitableForArtifactTest() )
+ {
+ ProjectReference reference = new ProjectReference();
+ reference.setGroupId( example.groupId );
+ reference.setArtifactId( example.artifactId );
+
+ assertEquals( "ProjectReference <" + reference + "> to path:", example.path, layout.toPath( reference ) );
+ }
}
}
- public void testInvalidPathTooShort()
+ public void testInvalidPathToArtifact()
{
- try
+ Iterator it = getInvalidPaths().iterator();
+ while ( it.hasNext() )
{
- layout.toArtifact( "invalid/invalid-1.0.jar" );
- fail( "Should have detected that path is too short." );
+ InvalidExample example = (InvalidExample) it.next();
+
+ try
+ {
+ layout.toArtifact( example.path );
+ fail( "Should have thrown a LayoutException on the invalid path [" + example.path + "] because of ["
+ + example.reason + "]" );
+ }
+ catch ( LayoutException e )
+ {
+ /* expected path */
+ }
}
- catch ( LayoutException e )
+ }
+
+ public void testInvalidPathToArtifactReference()
+ {
+ Iterator it = getInvalidPaths().iterator();
+ while ( it.hasNext() )
{
- /* expected path */
+ InvalidExample example = (InvalidExample) it.next();
+
+ try
+ {
+ layout.toArtifactReference( example.path );
+ fail( "Should have thrown a LayoutException on the invalid path [" + example.path + "] because of ["
+ + example.reason + "]" );
+ }
+ catch ( LayoutException e )
+ {
+ /* expected path */
+ }
}
}
- public void testInvalidTimestampSnapshotNotInSnapshotDir()
+ public void testInvalidPathToVersionedReference()
{
- try
+ Iterator it = getInvalidPaths().iterator();
+ while ( it.hasNext() )
{
- layout.toArtifact( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" );
- fail( "Shoult have detected Timestamped Snapshot artifact not inside of an Snapshot dir is invalid." );
+ InvalidExample example = (InvalidExample) it.next();
+
+ try
+ {
+ layout.toVersionedReference( example.path );
+ if ( example.hasFilename )
+ {
+ fail( "Should have thrown a LayoutException on the invalid path [" + example.path
+ + "] because of [" + example.reason + "]" );
+ }
+ }
+ catch ( LayoutException e )
+ {
+ /* expected path */
+ }
}
- catch ( LayoutException e )
+ }
+
+ public void testInvalidPathToProjectReference()
+ {
+ Iterator it = getInvalidPaths().iterator();
+ while ( it.hasNext() )
{
- /* expected path */
+ InvalidExample example = (InvalidExample) it.next();
+
+ try
+ {
+ layout.toProjectReference( example.path );
+ if ( example.hasFilename )
+ {
+ fail( "Should have thrown a LayoutException on the invalid path [" + example.path
+ + "] because of [" + example.reason + "]" );
+ }
+ }
+ catch ( LayoutException e )
+ {
+ /* expected path */
+ }
}
}
- public void testInvalidVersionPathMismatch()
+ public void testPathToArtifact()
+ throws LayoutException
{
- try
+ Iterator it = getGoodExamples().iterator();
+ while ( it.hasNext() )
{
- layout.toArtifact( "invalid/invalid/1.0/invalid-2.0.jar" );
- fail( "Should have detected version mismatch between path and artifact." );
+ LayoutExample example = (LayoutExample) it.next();
+ if ( example.isSuitableForArtifactTest() )
+ {
+ ArchivaArtifact artifact = layout.toArtifact( example.path );
+ assertArtifact( artifact, example.groupId, example.artifactId, example.version, example.classifier,
+ example.type );
+ }
}
- catch ( LayoutException e )
+ }
+
+ /* TODO: Fix layout object to pass test.
+ public void testPathToArtifactReference()
+ throws LayoutException
+ {
+ Iterator it = getGoodExamples().iterator();
+ while ( it.hasNext() )
{
- /* expected path */
+ LayoutExample example = (LayoutExample) it.next();
+ if ( example.isSuitableForArtifactTest() )
+ {
+ ArtifactReference reference = layout.toArtifactReference( example.path );
+ assertArtifactReference( reference, example.groupId, example.artifactId, example.version,
+ example.classifier, example.type );
+ }
}
}
+ */
- public void testInvalidVersionPathMismatchAlt()
+ /* TODO: Fix layout object to pass test.
+ public void testPathToVersionedReference()
+ throws LayoutException
{
- try
+ Iterator it = getGoodExamples().iterator();
+ while ( it.hasNext() )
{
- layout.toArtifact( "invalid/invalid/1.0/invalid-1.0b.jar" );
- fail( "Should have version mismatch between directory and artifact." );
+ LayoutExample example = (LayoutExample) it.next();
+ if ( example.isSuitableForVersionedTest() )
+ {
+ VersionedReference reference = layout.toVersionedReference( example.path );
+
+ assertVersionedReference( reference, example.groupId, example.artifactId, example.version );
+ }
}
- catch ( LayoutException e )
+ }
+ */
+
+ public void testPathToProjectReference()
+ throws LayoutException
+ {
+ Iterator it = getGoodExamples().iterator();
+ while ( it.hasNext() )
{
- /* expected path */
+ LayoutExample example = (LayoutExample) it.next();
+ if ( example.isSuitableForProjectTest() )
+ {
+ ProjectReference reference = layout.toProjectReference( example.path );
+
+ assertProjectReference( reference, example.groupId, example.artifactId );
+ }
}
}
- public void testInvalidArtifactIdForPath()
+ public void testRoundtripArtifactToPathToArtifact()
+ throws LayoutException
{
- try
+ Iterator it = getGoodExamples().iterator();
+ while ( it.hasNext() )
{
- layout.toArtifact( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar" );
- fail( "Should have detected wrong artifact Id." );
+ LayoutExample example = (LayoutExample) it.next();
+ if ( example.isSuitableForArtifactTest() )
+ {
+ ArchivaArtifact artifact = createArtifact( example.groupId, example.artifactId, example.version,
+ example.classifier, example.type );
+ String testPath = layout.toPath( artifact );
+ assertEquals( "Artifact <" + artifact + "> to path:", example.path, testPath );
+ ArchivaArtifact testArtifact = layout.toArtifact( testPath );
+ assertArtifact( testArtifact, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
+ artifact.getClassifier(), artifact.getType() );
+ }
}
- catch ( LayoutException e )
+ }
+
+ public void testRoundtripPathToArtifactToPath()
+ throws LayoutException
+ {
+ Iterator it = getGoodExamples().iterator();
+ while ( it.hasNext() )
{
- /* expected path */
+ LayoutExample example = (LayoutExample) it.next();
+ if ( example.isSuitableForArtifactTest() )
+ {
+ ArchivaArtifact artifact = layout.toArtifact( example.path );
+ assertArtifact( artifact, example.groupId, example.artifactId, example.version, example.classifier,
+ example.type );
+ String testPath = layout.toPath( artifact );
+ assertEquals( "Artifact <" + artifact + "> to path:", example.path, testPath );
+ }
}
+ }
+
+ public void testTimestampedSnapshotRoundtrip()
+ throws LayoutException
+ {
+ String originalPath = "org/apache/maven/test/get-metadata-snapshot/1.0-SNAPSHOT/get-metadata-snapshot-1.0-20050831.101112-1.jar";
+ ArchivaArtifact artifact = layout.toArtifact( originalPath );
+ assertArtifact( artifact, "org.apache.maven.test", "get-metadata-snapshot", "1.0-20050831.101112-1", "", "jar" );
+
+ assertEquals( originalPath, layout.toPath( artifact ) );
+
+ ArtifactReference aref = new ArtifactReference();
+ aref.setGroupId( artifact.getGroupId() );
+ aref.setArtifactId( artifact.getArtifactId() );
+ aref.setVersion( artifact.getVersion() );
+ aref.setClassifier( artifact.getClassifier() );
+ aref.setType( artifact.getType() );
+
+ assertEquals( originalPath, layout.toPath( aref ) );
+ }
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ layout = (BidirectionalRepositoryLayout) lookup( BidirectionalRepositoryLayout.class.getName(), "default" );
}
}
Modified: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/pom.xml
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/pom.xml?view=diff&rev=530395&r1=530394&r2=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/pom.xml (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/pom.xml Thu Apr 19 05:25:11 2007
@@ -107,6 +107,7 @@
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.7</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
Modified: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java?view=diff&rev=530395&r1=530394&r2=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java Thu Apr 19 05:25:11 2007
@@ -34,4 +34,6 @@
ProjectModelDAO getProjectModelDAO();
RepositoryDAO getRepositoryDAO();
+
+ RepositoryProblemDAO getRepositoryProblemDAO();
}
Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryProblemDAO.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryProblemDAO.java?view=auto&rev=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryProblemDAO.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryProblemDAO.java Thu Apr 19 05:25:11 2007
@@ -0,0 +1,63 @@
+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.RepositoryProblem;
+
+import java.util.List;
+
+/**
+ * RepositoryProblemDAO
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public interface RepositoryProblemDAO
+{
+ /* 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)
+ *
+ * List .queryDatabaseObject( Constraint ) throws ObjectNotFoundException, DatabaseException;
+ * DatabaseObject .saveDatabaseObject( DatabaseObject ) throws DatabaseException;
+ *
+ * (Optional Methods)
+ *
+ * DatabaseObject .createDatabaseObject( Required Params ) ;
+ * 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 List /*<RepositoryProblem>*/queryRepositoryProblems( Constraint constraint )
+ throws ObjectNotFoundException, ArchivaDatabaseException;
+
+ public RepositoryProblem saveRepositoryProblem( RepositoryProblem problem )
+ throws ArchivaDatabaseException;
+
+ public void deleteRepositoryProblem( RepositoryProblem problem )
+ throws ArchivaDatabaseException;
+}
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryProblemDAO.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryProblemDAO.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryProblemDAO.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraint.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraint.java?view=auto&rev=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraint.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraint.java Thu Apr 19 05:25:11 2007
@@ -0,0 +1,52 @@
+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.Constraint;
+
+/**
+ * ArtifactsBySha1ChecksumConstraint
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class ArtifactsBySha1ChecksumConstraint
+ extends AbstractConstraint
+ implements Constraint
+{
+ private String whereClause;
+
+ public ArtifactsBySha1ChecksumConstraint( String desiredChecksum )
+ {
+ whereClause = "this.checksumSHA1 == desiredChecksum";
+ declParams = new String[] { "String desiredChecksum" };
+ params = new Object[] { desiredChecksum };
+ }
+
+ public String getSortColumn()
+ {
+ return "groupId";
+ }
+
+ public String getWhereCondition()
+ {
+ return whereClause;
+ }
+}
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraint.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraint.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraint.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraint.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraint.java?view=auto&rev=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraint.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraint.java Thu Apr 19 05:25:11 2007
@@ -0,0 +1,60 @@
+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.Constraint;
+
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * Constraint for artifacts that are of a certain age (in days) or older.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class OlderArtifactsByAgeConstraint
+ extends AbstractConstraint
+ implements Constraint
+{
+ private String whereClause;
+
+ public OlderArtifactsByAgeConstraint( int daysOld )
+ {
+ Calendar cal = Calendar.getInstance();
+ cal.add( Calendar.DAY_OF_MONTH, ( -1 ) * daysOld );
+ Date cutoffDate = cal.getTime();
+
+ whereClause = "this.lastModified <= cutoffDate";
+ declImports = new String[] { "import java.util.Date" };
+ declParams = new String[] { "java.util.Date cutoffDate" };
+ params = new Object[] { cutoffDate };
+ }
+
+ public String getSortColumn()
+ {
+ return "groupId";
+ }
+
+ public String getWhereCondition()
+ {
+ return whereClause;
+ }
+}
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraint.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraint.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraint.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraint.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraint.java?view=auto&rev=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraint.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraint.java Thu Apr 19 05:25:11 2007
@@ -0,0 +1,60 @@
+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.Constraint;
+
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * Constraint for snapshot artifacts that are of a certain age (in days) or older.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class OlderSnapshotArtifactsByAgeConstraint
+ extends AbstractConstraint
+ implements Constraint
+{
+ private String whereClause;
+
+ public OlderSnapshotArtifactsByAgeConstraint( int daysOld )
+ {
+ Calendar cal = Calendar.getInstance();
+ cal.add( Calendar.DAY_OF_MONTH, ( -1 ) * daysOld );
+ Date cutoffDate = cal.getTime();
+
+ whereClause = "this.lastModified <= cutoffDate && this.snapshot == true";
+ declImports = new String[] { "import java.util.Date" };
+ declParams = new String[] { "java.util.Date cutoffDate" };
+ params = new Object[] { cutoffDate };
+ }
+
+ public String getSortColumn()
+ {
+ return "groupId";
+ }
+
+ public String getWhereCondition()
+ {
+ return whereClause;
+ }
+}
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraint.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraint.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraint.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraint.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraint.java?view=auto&rev=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraint.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraint.java Thu Apr 19 05:25:11 2007
@@ -0,0 +1,61 @@
+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.Constraint;
+
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * Constraint for artifacts that are of a certain age (in days) or newer.
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RecentArtifactsByAgeConstraint
+ extends AbstractConstraint
+ implements Constraint
+{
+ private String whereClause;
+
+ public RecentArtifactsByAgeConstraint( int daysOld )
+ {
+ Calendar cal = Calendar.getInstance();
+ // Extra subtraction of 1 done to allow for lastModified that occur on the day represented by 'daysOld'.
+ cal.add( Calendar.DAY_OF_MONTH, (( -1 ) * daysOld) - 1 );
+ Date cutoffDate = cal.getTime();
+
+ whereClause = "this.lastModified >= cutoffDate";
+ declImports = new String[] { "import java.util.Date" };
+ declParams = new String[] { "java.util.Date cutoffDate" };
+ params = new Object[] { cutoffDate };
+ }
+
+ public String getSortColumn()
+ {
+ return "groupId";
+ }
+
+ public String getWhereCondition()
+ {
+ return whereClause;
+ }
+}
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraint.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraint.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraint.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByTypeConstraint.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByTypeConstraint.java?view=auto&rev=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByTypeConstraint.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByTypeConstraint.java Thu Apr 19 05:25:11 2007
@@ -0,0 +1,52 @@
+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.Constraint;
+
+/**
+ * RepositoryProblemByTypeConstraint
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RepositoryProblemByTypeConstraint
+ extends AbstractConstraint
+ implements Constraint
+{
+ private String whereClause;
+
+ public RepositoryProblemByTypeConstraint( String desiredType )
+ {
+ whereClause = "type == desiredType";
+ declParams = new String[] { "String desiredType" };
+ params = new Object[] { desiredType };
+ }
+
+ public String getSortColumn()
+ {
+ return "groupId";
+ }
+
+ public String getWhereCondition()
+ {
+ return whereClause;
+ }
+}
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByTypeConstraint.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByTypeConstraint.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByTypeConstraint.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java?view=diff&rev=530395&r1=530394&r2=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java (original)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java Thu Apr 19 05:25:11 2007
@@ -23,6 +23,7 @@
import org.apache.maven.archiva.database.ArtifactDAO;
import org.apache.maven.archiva.database.ProjectModelDAO;
import org.apache.maven.archiva.database.RepositoryDAO;
+import org.apache.maven.archiva.database.RepositoryProblemDAO;
import org.codehaus.plexus.logging.AbstractLogEnabled;
/**
@@ -51,6 +52,11 @@
* @plexus.requirement role-hint="jdo"
*/
private RepositoryDAO repositoryDAO;
+
+ /**
+ * @plexus.requirement role-hint="jdo"
+ */
+ private RepositoryProblemDAO repositoryProblemDAO;
public ArtifactDAO getArtifactDAO()
{
@@ -65,5 +71,10 @@
public RepositoryDAO getRepositoryDAO()
{
return repositoryDAO;
+ }
+
+ public RepositoryProblemDAO getRepositoryProblemDAO()
+ {
+ return repositoryProblemDAO;
}
}
Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryProblemDAO.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryProblemDAO.java?view=auto&rev=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryProblemDAO.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryProblemDAO.java Thu Apr 19 05:25:11 2007
@@ -0,0 +1,63 @@
+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.RepositoryProblemDAO;
+import org.apache.maven.archiva.model.RepositoryProblem;
+
+import java.util.List;
+
+/**
+ * JdoRepositoryProblemDAO
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ *
+ * @plexus.component role-hint="jdo"
+ */
+public class JdoRepositoryProblemDAO
+ implements RepositoryProblemDAO
+{
+ /**
+ * @plexus.requirement role-hint="archiva"
+ */
+ private JdoAccess jdo;
+
+ public List queryRepositoryProblems( Constraint constraint )
+ throws ObjectNotFoundException, ArchivaDatabaseException
+ {
+ return jdo.getAllObjects( RepositoryProblem.class, constraint );
+ }
+
+ public RepositoryProblem saveRepositoryProblem( RepositoryProblem problem )
+ throws ArchivaDatabaseException
+ {
+ return (RepositoryProblem) jdo.saveObject( problem );
+ }
+
+ public void deleteRepositoryProblem( RepositoryProblem problem )
+ throws ArchivaDatabaseException
+ {
+ jdo.removeObject( problem );
+ }
+}
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryProblemDAO.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryProblemDAO.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryProblemDAO.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraintTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraintTest.java?view=auto&rev=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraintTest.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraintTest.java Thu Apr 19 05:25:11 2007
@@ -0,0 +1,112 @@
+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.ArchivaDAO;
+import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * ArtifactsBySha1ChecksumConstraintTest
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class ArtifactsBySha1ChecksumConstraintTest
+ extends AbstractArchivaDatabaseTestCase
+{
+ private static final String HASH3 = "f3f653289f3217c65324830ab3415bc92feddefa";
+
+ private static final String HASH2 = "a49810ad3eba8651677ab57cd40a0f76fdef9538";
+
+ private static final String HASH1 = "232f01b24b1617c46a3d4b0ab3415bc9237dcdec";
+
+ private ArtifactDAO artifactDao;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
+ artifactDao = dao.getArtifactDAO();
+ }
+
+ public ArchivaArtifact createArtifact( String artifactId, String version )
+ {
+ ArchivaArtifact artifact = artifactDao.createArtifact( "org.apache.maven.archiva.test", artifactId, version,
+ "", "jar" );
+ artifact.getModel().setLastModified( new Date() );
+ artifact.getModel().setRepositoryId( "testable_repo" );
+ return artifact;
+ }
+
+ public void testConstraint()
+ throws Exception
+ {
+ ArchivaArtifact artifact;
+
+ // Setup artifacts in fresh DB.
+ artifact = createArtifact( "test-one", "1.0" );
+ artifact.getModel().setChecksumSHA1( HASH1 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-one", "1.1" );
+ artifact.getModel().setChecksumSHA1( HASH1 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-one", "1.2" );
+ artifact.getModel().setChecksumSHA1( HASH1 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "1.0" );
+ artifact.getModel().setChecksumSHA1( HASH1 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "2.0" );
+ artifact.getModel().setChecksumSHA1( HASH3 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "2.1" );
+ artifact.getModel().setChecksumSHA1( HASH2 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "3.0" );
+ artifact.getModel().setChecksumSHA1( HASH2 );
+ artifactDao.saveArtifact( artifact );
+
+ assertConstraint( "Artifacts by SHA1 Checksum", 4, new ArtifactsBySha1ChecksumConstraint( HASH1 ) );
+ assertConstraint( "Artifacts by SHA1 Checksum", 2, new ArtifactsBySha1ChecksumConstraint( HASH2 ) );
+ assertConstraint( "Artifacts by SHA1 Checksum", 1, new ArtifactsBySha1ChecksumConstraint( HASH3 ) );
+ }
+
+ private void assertConstraint( String msg, int count, ArtifactsBySha1ChecksumConstraint constraint )
+ throws Exception
+ {
+ List results = artifactDao.queryArtifacts( constraint );
+ assertNotNull( msg + ": Not Null", results );
+ assertEquals( msg + ": Results.size", count, results.size() );
+ }
+
+}
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraintTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraintTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsBySha1ChecksumConstraintTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraintTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraintTest.java?view=auto&rev=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraintTest.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraintTest.java Thu Apr 19 05:25:11 2007
@@ -0,0 +1,103 @@
+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.ArchivaDAO;
+import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * OlderArtifactsByAgeConstraintTest
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class OlderArtifactsByAgeConstraintTest
+ extends AbstractArchivaDatabaseTestCase
+{
+ private ArtifactDAO artifactDao;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
+ artifactDao = dao.getArtifactDAO();
+ }
+
+ public ArchivaArtifact createArtifact( String artifactId, String version, int daysOld )
+ {
+ ArchivaArtifact artifact = artifactDao.createArtifact( "org.apache.maven.archiva.test", artifactId, version,
+ "", "jar" );
+ Calendar cal = Calendar.getInstance();
+ cal.add( Calendar.DAY_OF_MONTH, ( -1 ) * daysOld );
+ artifact.getModel().setLastModified( cal.getTime() );
+ artifact.getModel().setRepositoryId( "testable_repo" );
+ return artifact;
+ }
+
+ public void testConstraint()
+ throws Exception
+ {
+ ArchivaArtifact artifact;
+
+ // Setup artifacts in fresh DB.
+ artifact = createArtifact( "test-one", "1.0", 200 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-one", "1.1", 100 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-one", "1.2", 50 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "1.0", 200 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "2.0", 150 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "2.1", 100 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "3.0", 5 );
+ artifactDao.saveArtifact( artifact );
+
+ assertConstraint( 6, new OlderArtifactsByAgeConstraint( 7 ) );
+ assertConstraint( 5, new OlderArtifactsByAgeConstraint( 90 ) );
+ assertConstraint( 5, new OlderArtifactsByAgeConstraint( 100 ) );
+ assertConstraint( 3, new OlderArtifactsByAgeConstraint( 150 ) );
+ assertConstraint( 0, new OlderArtifactsByAgeConstraint( 9000 ) );
+ }
+
+ private void assertConstraint( int expectedHits, Constraint constraint )
+ throws Exception
+ {
+ List results = artifactDao.queryArtifacts( constraint );
+ assertNotNull( "Older Artifacts By Age: Not Null", results );
+ assertEquals( "Older Artifacts By Age: Results.size", expectedHits, results.size() );
+ }
+}
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraintTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraintTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderArtifactsByAgeConstraintTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraintTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraintTest.java?view=auto&rev=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraintTest.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraintTest.java Thu Apr 19 05:25:11 2007
@@ -0,0 +1,118 @@
+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.ArchivaDAO;
+import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * OlderArtifactsByAgeConstraintTest
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class OlderSnapshotArtifactsByAgeConstraintTest
+ extends AbstractArchivaDatabaseTestCase
+{
+ private ArtifactDAO artifactDao;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
+ artifactDao = dao.getArtifactDAO();
+ }
+
+ public ArchivaArtifact createArtifact( String artifactId, String version, int daysOld )
+ {
+ ArchivaArtifact artifact = artifactDao.createArtifact( "org.apache.maven.archiva.test", artifactId, version,
+ "", "jar" );
+ Calendar cal = Calendar.getInstance();
+ cal.add( Calendar.DAY_OF_MONTH, ( -1 ) * daysOld );
+ artifact.getModel().setLastModified( cal.getTime() );
+ artifact.getModel().setRepositoryId( "testable_repo" );
+ return artifact;
+ }
+
+ public void testConstraint()
+ throws Exception
+ {
+ ArchivaArtifact artifact;
+
+ // Setup artifacts in fresh DB.
+ artifact = createArtifact( "test-one", "1.0", 200 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-one", "1.1-SNAPSHOT", 110 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-one", "1.1", 100 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-one", "1.2-20060923.005752-2", 55 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-one", "1.2-SNAPSHOT", 52 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-one", "1.2", 50 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "1.0-20060828.144210-1", 220 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "1.0-SNAPSHOT", 210 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "1.0", 200 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "2.0", 150 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "2.1", 100 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "3.0", 5 );
+ artifactDao.saveArtifact( artifact );
+
+ assertConstraint( 5, new OlderSnapshotArtifactsByAgeConstraint( 7 ) );
+ assertConstraint( 3, new OlderSnapshotArtifactsByAgeConstraint( 90 ) );
+ assertConstraint( 3, new OlderSnapshotArtifactsByAgeConstraint( 100 ) );
+ assertConstraint( 2, new OlderSnapshotArtifactsByAgeConstraint( 150 ) );
+ assertConstraint( 0, new OlderSnapshotArtifactsByAgeConstraint( 500 ) );
+ }
+
+ private void assertConstraint( int expectedHits, Constraint constraint )
+ throws Exception
+ {
+ List results = artifactDao.queryArtifacts( constraint );
+ assertNotNull( "Older Snapshot Artifacts By Age: Not Null", results );
+ assertEquals( "Older Snapshot Artifacts By Age: Results.size", expectedHits, results.size() );
+ }
+}
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraintTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraintTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/OlderSnapshotArtifactsByAgeConstraintTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java?view=auto&rev=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java Thu Apr 19 05:25:11 2007
@@ -0,0 +1,104 @@
+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.ArchivaDAO;
+import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.database.Constraint;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * RecentArtifactsByAgeConstraintTest
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class RecentArtifactsByAgeConstraintTest
+ extends AbstractArchivaDatabaseTestCase
+{
+ private ArtifactDAO artifactDao;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
+ artifactDao = dao.getArtifactDAO();
+ }
+
+ public ArchivaArtifact createArtifact( String artifactId, String version, int daysOld )
+ {
+ ArchivaArtifact artifact = artifactDao.createArtifact( "org.apache.maven.archiva.test", artifactId, version,
+ "", "jar" );
+ Calendar cal = Calendar.getInstance();
+ cal.add( Calendar.DAY_OF_MONTH, ( -1 ) * daysOld );
+ artifact.getModel().setLastModified( cal.getTime() );
+ artifact.getModel().setRepositoryId( "testable_repo" );
+ return artifact;
+ }
+
+ public void testConstraint()
+ throws Exception
+ {
+ ArchivaArtifact artifact;
+
+ // Setup artifacts in fresh DB.
+ artifact = createArtifact( "test-one", "1.0", 200 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-one", "1.1", 100 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-one", "1.2", 50 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "1.0", 200 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "2.0", 150 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "2.1", 100 );
+ artifactDao.saveArtifact( artifact );
+
+ artifact = createArtifact( "test-two", "3.0", 5 );
+ artifactDao.saveArtifact( artifact );
+
+ assertConstraint( 0, new RecentArtifactsByAgeConstraint( 2 ) );
+ assertConstraint( 1, new RecentArtifactsByAgeConstraint( 7 ) );
+ assertConstraint( 2, new RecentArtifactsByAgeConstraint( 90 ) );
+ assertConstraint( 4, new RecentArtifactsByAgeConstraint( 100 ) );
+ assertConstraint( 5, new RecentArtifactsByAgeConstraint( 150 ) );
+ assertConstraint( 7, new RecentArtifactsByAgeConstraint( 9000 ) );
+ }
+
+ private void assertConstraint( int expectedHits, Constraint constraint )
+ throws Exception
+ {
+ List results = artifactDao.queryArtifacts( constraint );
+ assertNotNull( "Recent Artifacts By Age: Not Null", results );
+ assertEquals( "Recent Artifacts By Age: Results.size", expectedHits, results.size() );
+ }
+}
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RecentArtifactsByAgeConstraintTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Apr 19 05:25:11 2007
@@ -0,0 +1,15 @@
+target
+*~
+.*.swp
+*.log
+*.patch
+*.diff
+*.ipr
+*.iws
+*.iml
+.classpath
+.project
+.m2eclipse
+.settings
+.wtpmodules
+cobertura.ser
Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/pom.xml
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/pom.xml?view=auto&rev=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/pom.xml (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/pom.xml Thu Apr 19 05:25:11 2007
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.maven.archiva</groupId>
+ <artifactId>archiva-reporting</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>archiva-artifact-reports</artifactId>
+ <name>Archiva Reporting :: Artifact Reports</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.archiva</groupId>
+ <artifactId>archiva-report-manager</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.archiva</groupId>
+ <artifactId>archiva-database</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.archiva</groupId>
+ <artifactId>archiva-repository-layer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus.registry</groupId>
+ <artifactId>plexus-registry-commons</artifactId>
+ <version>1.0-alpha-2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.7</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>1.2_Java1.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-slf4j-logging</artifactId>
+ <version>1.1-alpha-1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/pom.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReport.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReport.java?view=auto&rev=530395
==============================================================================
--- maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReport.java (added)
+++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReport.java Thu Apr 19 05:25:11 2007
@@ -0,0 +1,80 @@
+package org.apache.maven.archiva.reporting.artifact;
+
+/*
+ * 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.Constraint;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.database.constraints.RepositoryProblemByTypeConstraint;
+import org.apache.maven.archiva.reporting.DataLimits;
+import org.apache.maven.archiva.reporting.DynamicReportSource;
+
+import java.util.List;
+
+/**
+ * DuplicateArtifactReport
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ *
+ * @plexus.component role="org.apache.maven.archiva.reporting.DynamicReportSource"
+ * role-hint="duplicate-artifacts"
+ */
+public class DuplicateArtifactReport
+ implements DynamicReportSource
+{
+ public static final String PROBLEM_TYPE_DUPLICATE_ARTIFACTS = "duplicate-artifacts";
+
+ /**
+ * @plexus.configuration default-value="Duplicate Artifact Report"
+ */
+ private String name;
+
+ /**
+ * @plexus.requirement
+ */
+ private ArchivaDAO dao;
+
+ private Constraint constraint;
+
+ public DuplicateArtifactReport()
+ {
+ constraint = new RepositoryProblemByTypeConstraint( PROBLEM_TYPE_DUPLICATE_ARTIFACTS );
+ }
+
+ public List getData()
+ throws ObjectNotFoundException, ArchivaDatabaseException
+ {
+ return dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint );
+ }
+
+ public List getData( DataLimits limits )
+ throws ObjectNotFoundException, ArchivaDatabaseException
+ {
+ // TODO: implement limits.
+ return dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint );
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReport.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactReport.java
------------------------------------------------------------------------------
svn:mime-type = text/plain