* 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;
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.
*
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 )
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
<configuration>
- <version>1.2.1</version>
+ <version>1.3.0</version>
<packageWithVersion>false</packageWithVersion>
<models>
<model>src/main/mdo/archiva-base.xml</model>
xsd.target-namespace="http://archiva.apache.org/model/1.2.0">
<id>archiva-base-model</id>
<name>ArchivaBaseModel</name>
- <version>1.2.1</version>
+ <!-- Note that we've outright removed old model information instead of setting the finish version to be 1.2.1.
+ if for any reason this model needs to be retained for some other use (eg, migration), then those may need to be
+ restored. Otherwise, the previous archiva-model artifact can be used if necessary -->
+ <version>1.3.0</version>
<description>Archiva Model</description>
<defaults>
<default>
The size of the artifact on disk.
</description>
</field>
- <field stash.maxSize="16">
- <name>platform</name>
- <identifier>false</identifier>
- <version>1.0.0+</version>
- <type>String</type>
- <required>true</required>
- <description>
- The platform of this artifact. (default: "java")
- </description>
- <defaultValue>java</defaultValue>
- </field>
- <field>
- <name>whenIndexed</name>
- <identifier>false</identifier>
- <version>1.0.0+</version>
- <type>Date</type>
- <required>false</required>
- <description>
- The timestamp when this artifact was indexed.
- </description>
- </field>
- <field>
- <name>whenProcessed</name>
- <identifier>false</identifier>
- <version>1.0.0+</version>
- <type>Date</type>
- <required>false</required>
- <description>
- When this artifact's contents was processed.
- </description>
- </field>
- <field>
- <name>origin</name>
- <identifier>false</identifier>
- <version>1.0.0+</version>
- <type>String</type>
- <required>false</required>
- <description>
- The origin of this artifact. (Filesystem, Proxy, Deploy)
- </description>
- </field>
<field>
<name>whenGathered</name>
<identifier>false</identifier>
private static final long serialVersionUID = -6292417108113887384L;
]]></code>
</codeSegment>
- <codeSegment>
- <version>1.0.0+</version>
- <code><![CDATA[
- /**
- * Identify if this artifact's contents have been processed or not.
- *
- * @return true if the artifact's contents have been processed.
- */
- public boolean isProcessed()
- {
- return !(whenProcessed == null);
- }
- ]]></code>
- </codeSegment>
</codeSegments>
</class>
The size of the artifact on disk.
</description>
</field>
- <field>
- <name>whenIndexed</name>
- <identifier>false</identifier>
- <version>1.0.0+</version>
- <type>Date</type>
- <required>false</required>
- <description>
- The timestamp when this artifact was indexed.
- </description>
- </field>
- <field>
- <name>origin</name>
- <identifier>false</identifier>
- <version>1.0.0+</version>
- <type>String</type>
- <required>false</required>
- <description>
- The origin of this artifact. (Filesystem, Proxy, Deploy)
- </description>
- </field>
</fields>
<codeSegments>
<codeSegment>
+++ /dev/null
-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() );
- }
-
-}
* 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;
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.
*
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" ) );
* under the License.
*/
-import org.apache.maven.archiva.database.Constraint;
-
import java.util.Date;
+import org.apache.maven.archiva.database.Constraint;
+
/**
* 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
{
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 );
+++ /dev/null
-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<ArchivaArtifact> 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<ArchivaArtifact> results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( false ) );
- assertResults( "not-processed", results, new String[] { "archiva-common", "archiva-database" } );
- }
-
- public void testProcessed()
- throws Exception
- {
- List<ArchivaArtifact> 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<ArchivaArtifact> 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<ArchivaArtifact> results = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( since ) );
- assertResults( "processed", results, new String[] { "archiva-utils", "archiva-old" } );
- }
-}
import java.util.Date;
import java.util.List;
-
import javax.jdo.JDOHelper;
import javax.jdo.spi.JDOImplHelper;
// Set some mandatory values
artifact.getModel().setLastModified( new Date() );
- artifact.getModel().setOrigin( "test" );
// Save it.
ArchivaArtifact savedArtifact = artiDao.saveArtifact( artifact );
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.
// 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() );
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;
taskExecutor.executeTask( repoTask );
ArtifactDAO adao = dao.getArtifactDAO();
- List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
+ List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( null );
assertNotNull( unprocessedResultList );
assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size() );
taskExecutor.executeTask( repoTask );
ArtifactDAO adao = dao.getArtifactDAO();
- List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
+ List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( null );
assertNotNull( unprocessedResultList );
assertEquals("Incorrect number of unprocessed artifacts detected. No new artifacts should have been found.", 0, unprocessedResultList.size() );
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() );
}
taskExecutor.executeTask( repoTask );
ArtifactDAO adao = dao.getArtifactDAO();
- List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
+ List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( null );
assertNotNull( unprocessedResultList );
assertEquals("Incorrect number of unprocessed artifacts detected.", 8, unprocessedResultList.size() );