git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@891130 13f79535-47bb-0310-9956-ffa450edef68tags/archiva-1.4-M1
@@ -24,7 +24,6 @@ import java.io.FilenameFilter; | |||
import java.util.List; | |||
import java.util.Set; | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import org.apache.maven.archiva.model.ArtifactReference; | |||
import org.apache.maven.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.maven.archiva.repository.audit.AuditEvent; | |||
@@ -55,33 +54,6 @@ public abstract class AbstractRepositoryPurge | |||
this.listeners = listeners; | |||
} | |||
/** | |||
* Get all files from the directory that matches the specified filename. | |||
* | |||
* @param dir the directory to be scanned | |||
* @param filename the filename to be matched | |||
* @return | |||
*/ | |||
protected File[] getFiles( File dir, String filename ) | |||
{ | |||
FilenameFilter filter = new ArtifactFilenameFilter( filename ); | |||
File[] files = dir.listFiles( filter ); | |||
return files; | |||
} | |||
protected String toRelativePath( File artifactFile ) | |||
{ | |||
String artifactPath = artifactFile.getAbsolutePath(); | |||
if ( artifactPath.startsWith( repository.getRepoRoot() ) ) | |||
{ | |||
artifactPath = artifactPath.substring( repository.getRepoRoot().length() ); | |||
} | |||
return artifactPath; | |||
} | |||
/** | |||
* Purge the repo. Update db and index of removed artifacts. | |||
* | |||
@@ -94,14 +66,11 @@ public abstract class AbstractRepositoryPurge | |||
for ( ArtifactReference reference : references ) | |||
{ | |||
File artifactFile = repository.toFile( reference ); | |||
ArchivaArtifact artifact = | |||
new ArchivaArtifact( reference.getGroupId(), reference.getArtifactId(), reference.getVersion(), | |||
reference.getClassifier(), reference.getType(), repository.getId() ); | |||
for ( RepositoryListener listener : listeners ) | |||
{ | |||
listener.deleteArtifact( repository, artifact ); | |||
listener.deleteArtifact( repository.getId(), reference.getGroupId(), reference.getArtifactId(), | |||
reference.getVersion(), artifactFile.getName() ); | |||
} | |||
// TODO: this needs to be logged |
@@ -177,7 +177,8 @@ public class CleanupReleasedSnapshotsRepositoryPurge | |||
// TODO: looks incomplete, might not delete related artifacts? | |||
for ( RepositoryListener listener : listeners ) | |||
{ | |||
listener.deleteArtifact( repository, artifact ); | |||
listener.deleteArtifact( repository.getId(), artifact.getGroupId(), artifact.getArtifactId(), | |||
artifact.getVersion(), artifactFile.getName() ); | |||
} | |||
needsMetadataUpdate = true; |
@@ -76,8 +76,8 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest | |||
String repoRoot = prepareTestRepos(); | |||
// test listeners for the correct artifacts | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.apache.maven.plugins", "maven-plugin-plugin", | |||
"2.3-SNAPSHOT", "maven-plugin" ) ); | |||
listener.deleteArtifact( getRepository().getId(), "org.apache.maven.plugins", "maven-plugin-plugin", | |||
"2.3-SNAPSHOT", "maven-plugin-plugin-2.3-SNAPSHOT.jar" ); | |||
listenerControl.replay(); | |||
repoPurge.process( CleanupReleasedSnapshotsRepositoryPurgeTest.PATH_TO_RELEASED_SNAPSHOT_IN_SAME_REPO ); | |||
@@ -133,9 +133,8 @@ public class CleanupReleasedSnapshotsRepositoryPurgeTest | |||
String repoRoot = prepareTestRepos(); | |||
// test listeners for the correct artifacts | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.apache.archiva", | |||
"released-artifact-in-diff-repo", "1.0-SNAPSHOT", | |||
"jar" ) ); | |||
listener.deleteArtifact( getRepository().getId(), "org.apache.archiva", "released-artifact-in-diff-repo", | |||
"1.0-SNAPSHOT", "released-artifact-in-diff-repo-1.0-SNAPSHOT.jar" ); | |||
listenerControl.replay(); | |||
repoPurge.process( PATH_TO_RELEASED_SNAPSHOT_IN_DIFF_REPO ); |
@@ -21,10 +21,8 @@ package org.apache.maven.archiva.consumers.core.repository; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.Calendar; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import org.apache.commons.lang.time.DateUtils; | |||
@@ -52,9 +50,9 @@ public class DaysOldRepositoryPurgeTest | |||
{ | |||
File dir = new File( dirPath ); | |||
File[] contents = dir.listFiles(); | |||
for ( int i = 0; i < contents.length; i++ ) | |||
for ( File content : contents ) | |||
{ | |||
contents[i].setLastModified( lastModified ); | |||
content.setLastModified( lastModified ); | |||
} | |||
} | |||
@@ -74,10 +72,10 @@ public class DaysOldRepositoryPurgeTest | |||
setLastModified( projectRoot + "/2.2-SNAPSHOT/", 1179382029 ); | |||
// test listeners for the correct artifacts | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.apache.maven.plugins", "maven-install-plugin", | |||
"2.2-SNAPSHOT", "maven-plugin" ) ); | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.apache.maven.plugins", "maven-install-plugin", | |||
"2.2-SNAPSHOT", "pom" ) ); | |||
listener.deleteArtifact( getRepository().getId(), "org.apache.maven.plugins", "maven-install-plugin", | |||
"2.2-SNAPSHOT", "maven-install-plugin-2.2-SNAPSHOT.jar" ); | |||
listener.deleteArtifact( getRepository().getId(), "org.apache.maven.plugins", "maven-install-plugin", | |||
"2.2-SNAPSHOT", "maven-install-plugin-2.2-SNAPSHOT.pom" ); | |||
listenerControl.replay(); | |||
repoPurge.process( PATH_TO_BY_DAYS_OLD_ARTIFACT ); | |||
@@ -122,10 +120,10 @@ public class DaysOldRepositoryPurgeTest | |||
setLastModified( projectRoot + "/1.1.2-SNAPSHOT/", 1179382029 ); | |||
// test listeners for the correct artifacts | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.apache.maven.plugins", "maven-assembly-plugin", | |||
"1.1.2-20070427.065136-1", "maven-plugin" ) ); | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.apache.maven.plugins", "maven-assembly-plugin", | |||
"1.1.2-20070427.065136-1", "pom" ) ); | |||
listener.deleteArtifact( getRepository().getId(), "org.apache.maven.plugins", "maven-assembly-plugin", | |||
"1.1.2-20070427.065136-1", "maven-assembly-plugin-1.1.2-20070427.065136-1.jar" ); | |||
listener.deleteArtifact( getRepository().getId(), "org.apache.maven.plugins", "maven-assembly-plugin", | |||
"1.1.2-20070427.065136-1", "maven-assembly-plugin-1.1.2-20070427.065136-1.pom" ); | |||
listenerControl.replay(); | |||
repoPurge.process( PATH_TO_TEST_ORDER_OF_DELETION ); | |||
@@ -205,18 +203,11 @@ public class DaysOldRepositoryPurgeTest | |||
createFiles( versionRoot ); | |||
List<String> versions = new ArrayList<String>(); | |||
versions.add( "1.4.3-20070113.163208-4" ); | |||
versions.add( "1.4.3-" + year + mon + day + "." + hr + min + sec + "-5" ); | |||
versions.add( "1.4.3-" + year + mon + day + "." + hr + min + sec + "-6" ); | |||
versions.add( "1.4.3-" + year + mon + day + "." + hr + min + sec + "-7" ); | |||
versions.add( "1.4.3-SNAPSHOT" ); | |||
// test listeners for the correct artifacts | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.codehaus.plexus", "plexus-utils", | |||
"1.4.3-20070113.163208-4", "jar" ) ); | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.codehaus.plexus", "plexus-utils", | |||
"1.4.3-20070113.163208-4", "pom" ) ); | |||
listener.deleteArtifact( getRepository().getId(), "org.codehaus.plexus", "plexus-utils", | |||
"1.4.3-20070113.163208-4", "plexus-utils-1.4.3-20070113.163208-4.jar" ); | |||
listener.deleteArtifact( getRepository().getId(), "org.codehaus.plexus", "plexus-utils", | |||
"1.4.3-20070113.163208-4", "plexus-utils-1.4.3-20070113.163208-4.pom" ); | |||
listenerControl.replay(); | |||
repoPurge.process( PATH_TO_BY_DAYS_OLD_METADATA_DRIVEN_ARTIFACT ); | |||
@@ -234,20 +225,19 @@ public class DaysOldRepositoryPurgeTest | |||
assertExists( versionRoot + "/plexus-utils-1.4.3-SNAPSHOT.jar" ); | |||
assertExists( versionRoot + "/plexus-utils-1.4.3-SNAPSHOT.pom" ); | |||
for ( int i = 0; i < extensions.length; i++ ) | |||
for ( String extension : extensions ) | |||
{ | |||
assertExists( versionRoot + "/plexus-utils-1.4.3-" + year + mon + day + "." + hr + min + sec + | |||
extensions[i] ); | |||
assertExists( versionRoot + "/plexus-utils-1.4.3-" + year + mon + day + "." + hr + min + sec + extension ); | |||
} | |||
} | |||
private void createFiles( String versionRoot ) | |||
throws IOException | |||
{ | |||
for ( int i = 0; i < extensions.length; i++ ) | |||
for ( String extension : extensions ) | |||
{ | |||
File file = | |||
new File( versionRoot, "/plexus-utils-1.4.3-" + year + mon + day + "." + hr + min + sec + extensions[i] ); | |||
new File( versionRoot, "/plexus-utils-1.4.3-" + year + mon + day + "." + hr + min + sec + extension ); | |||
file.createNewFile(); | |||
} | |||
} |
@@ -43,8 +43,6 @@ public class RetentionCountRepositoryPurgeTest | |||
/** | |||
* Test if the artifact to be processed was a jar. | |||
* | |||
* @throws Exception | |||
*/ | |||
public void testIfAJarWasFound() | |||
throws Exception | |||
@@ -52,14 +50,14 @@ public class RetentionCountRepositoryPurgeTest | |||
String repoRoot = prepareTestRepos(); | |||
// test listeners for the correct artifacts | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.jruby.plugins", "jruby-rake-plugin", | |||
"1.0RC1-20070504.153317-1", "jar" ) ); | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.jruby.plugins", "jruby-rake-plugin", | |||
"1.0RC1-20070504.153317-1", "pom" ) ); | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.jruby.plugins", "jruby-rake-plugin", | |||
"1.0RC1-20070504.160758-2", "jar" ) ); | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.jruby.plugins", "jruby-rake-plugin", | |||
"1.0RC1-20070504.160758-2", "pom" ) ); | |||
listener.deleteArtifact( getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin", | |||
"1.0RC1-20070504.153317-1", "jruby-rake-plugin-1.0RC1-20070504.153317-1.jar" ); | |||
listener.deleteArtifact( getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin", | |||
"1.0RC1-20070504.153317-1", "jruby-rake-plugin-1.0RC1-20070504.153317-1.pom" ); | |||
listener.deleteArtifact( getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin", | |||
"1.0RC1-20070504.160758-2", "jruby-rake-plugin-1.0RC1-20070504.160758-2.jar" ); | |||
listener.deleteArtifact( getRepository().getId(), "org.jruby.plugins", "jruby-rake-plugin", | |||
"1.0RC1-20070504.160758-2", "jruby-rake-plugin-1.0RC1-20070504.160758-2.pom" ); | |||
listenerControl.replay(); | |||
repoPurge.process( PATH_TO_BY_RETENTION_COUNT_ARTIFACT ); | |||
@@ -101,8 +99,6 @@ public class RetentionCountRepositoryPurgeTest | |||
/** | |||
* Test if the artifact to be processed is a pom | |||
* | |||
* @throws Exception | |||
*/ | |||
public void testIfAPomWasFound() | |||
throws Exception | |||
@@ -110,10 +106,10 @@ public class RetentionCountRepositoryPurgeTest | |||
String repoRoot = prepareTestRepos(); | |||
// test listeners for the correct artifacts | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.codehaus.castor", "castor-anttasks", | |||
"1.1.2-20070427.065136-1", "jar" ) ); | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.codehaus.castor", "castor-anttasks", | |||
"1.1.2-20070427.065136-1", "pom" ) ); | |||
listener.deleteArtifact( getRepository().getId(), "org.codehaus.castor", "castor-anttasks", | |||
"1.1.2-20070427.065136-1", "castor-anttasks-1.1.2-20070427.065136-1.jar" ); | |||
listener.deleteArtifact( getRepository().getId(), "org.codehaus.castor", "castor-anttasks", | |||
"1.1.2-20070427.065136-1", "castor-anttasks-1.1.2-20070427.065136-1.pom" ); | |||
listenerControl.replay(); | |||
repoPurge.process( PATH_TO_BY_RETENTION_COUNT_POM ); | |||
@@ -158,10 +154,10 @@ public class RetentionCountRepositoryPurgeTest | |||
String repoRoot = prepareTestRepos(); | |||
// test listeners for the correct artifacts | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.apache.maven.plugins", "maven-assembly-plugin", | |||
"1.1.2-20070427.065136-1", "maven-plugin" ) ); | |||
listener.deleteArtifact( getRepository(), createArtifact( "org.apache.maven.plugins", "maven-assembly-plugin", | |||
"1.1.2-20070427.065136-1", "pom" ) ); | |||
listener.deleteArtifact( getRepository().getId(), "org.apache.maven.plugins", "maven-assembly-plugin", | |||
"1.1.2-20070427.065136-1", "maven-assembly-plugin-1.1.2-20070427.065136-1.jar" ); | |||
listener.deleteArtifact( getRepository().getId(), "org.apache.maven.plugins", "maven-assembly-plugin", | |||
"1.1.2-20070427.065136-1", "maven-assembly-plugin-1.1.2-20070427.065136-1.pom" ); | |||
listenerControl.replay(); | |||
repoPurge.process( PATH_TO_TEST_ORDER_OF_DELETION ); |
@@ -20,40 +20,6 @@ | |||
<component-set> | |||
<components> | |||
<!-- JdoAccess --> | |||
<component> | |||
<role>org.apache.maven.archiva.database.jdo.JdoAccess</role> | |||
<role-hint>archiva</role-hint> | |||
<implementation>org.apache.maven.archiva.database.jdo.JdoAccess</implementation> | |||
<requirements> | |||
<requirement> | |||
<role>org.codehaus.plexus.jdo.JdoFactory</role> | |||
<role-hint>archiva</role-hint> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<!-- JDO Factory --> | |||
<component> | |||
<role>org.codehaus.plexus.jdo.JdoFactory</role> | |||
<role-hint>archiva</role-hint> | |||
<implementation>org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory</implementation> | |||
<configuration> | |||
<persistenceManagerFactoryClass>org.jpox.PersistenceManagerFactoryImpl</persistenceManagerFactoryClass> | |||
<driverName>org.hsqldb.jdbcDriver</driverName> | |||
<userName>sa</userName> | |||
<password></password> | |||
<url>jdbc:hsqldb:mem:testdb</url> | |||
<otherProperties> | |||
<property> | |||
<name>javax.jdo.PersistenceManagerFactoryClass</name> | |||
<value>org.jpox.PersistenceManagerFactoryImpl</value> | |||
</property> | |||
</otherProperties> | |||
</configuration> | |||
</component> | |||
<component> | |||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> | |||
<role-hint>cleanup-released-snapshots</role-hint> |
@@ -1,69 +0,0 @@ | |||
<?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"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-consumers</artifactId> | |||
<version>1.3-SNAPSHOT</version> | |||
</parent> | |||
<artifactId>archiva-database-consumers</artifactId> | |||
<name>Archiva Consumers :: Database Consumers</name> | |||
<dependencies> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-database</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-configuration</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-consumer-api</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-repository-layer</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.plexus</groupId> | |||
<artifactId>plexus-spring</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.plexus</groupId> | |||
<artifactId>plexus-digest</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>hsqldb</groupId> | |||
<artifactId>hsqldb</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.slf4j</groupId> | |||
<artifactId>slf4j-simple</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@@ -1,276 +0,0 @@ | |||
package org.apache.maven.archiva.consumers.database; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.io.File; | |||
import java.util.ArrayList; | |||
import java.util.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.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; | |||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer; | |||
import org.apache.maven.archiva.consumers.ConsumerException; | |||
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; | |||
import org.apache.maven.archiva.database.ArchivaDAO; | |||
import org.apache.maven.archiva.database.ArchivaDatabaseException; | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import org.apache.maven.archiva.model.ArtifactReference; | |||
import org.apache.maven.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.maven.archiva.repository.RepositoryContentFactory; | |||
import org.apache.maven.archiva.repository.RepositoryException; | |||
import org.apache.maven.archiva.repository.layout.LayoutException; | |||
import org.codehaus.plexus.digest.Digester; | |||
import org.codehaus.plexus.digest.DigesterException; | |||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; | |||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; | |||
import org.codehaus.plexus.registry.Registry; | |||
import org.codehaus.plexus.registry.RegistryListener; | |||
/** | |||
* ArtifactUpdateDatabaseConsumer - Take an artifact off of disk and put it into the repository. | |||
* | |||
* @version $Id$ | |||
* @plexus.component role="org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer" | |||
* role-hint="update-db-artifact" | |||
* instantiation-strategy="per-lookup" | |||
*/ | |||
public class ArtifactUpdateDatabaseConsumer | |||
extends AbstractMonitoredConsumer | |||
implements KnownRepositoryContentConsumer, RegistryListener, Initializable | |||
{ | |||
private static final String TYPE_NOT_ARTIFACT = "file-not-artifact"; | |||
private static final String DB_ERROR = "db-error"; | |||
private static final String CHECKSUM_CALCULATION = "checksum-calc"; | |||
/** | |||
* @plexus.configuration default-value="update-db-artifact" | |||
*/ | |||
private String id; | |||
/** | |||
* @plexus.configuration default-value="Update the Artifact in the Database" | |||
*/ | |||
private String description; | |||
/** | |||
* @plexus.requirement role-hint="jdo" | |||
*/ | |||
private ArchivaDAO dao; | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ArchivaConfiguration configuration; | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private FileTypes filetypes; | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private RepositoryContentFactory repositoryFactory; | |||
/** | |||
* @plexus.requirement role-hint="sha1" | |||
*/ | |||
private Digester digestSha1; | |||
/** | |||
* @plexus.requirement role-hint="md5"; | |||
*/ | |||
private Digester digestMd5; | |||
private ManagedRepositoryContent repository; | |||
private File repositoryDir; | |||
private List<String> includes = new ArrayList<String>(); | |||
private Date whenGathered; | |||
public String getId() | |||
{ | |||
return this.id; | |||
} | |||
public String getDescription() | |||
{ | |||
return this.description; | |||
} | |||
public boolean isPermanent() | |||
{ | |||
return true; | |||
} | |||
public List<String> getExcludes() | |||
{ | |||
return getDefaultArtifactExclusions(); | |||
} | |||
public List<String> getIncludes() | |||
{ | |||
return this.includes; | |||
} | |||
public void beginScan( ManagedRepositoryConfiguration repo, Date whenGathered ) | |||
throws ConsumerException | |||
{ | |||
try | |||
{ | |||
this.repository = repositoryFactory.getManagedRepositoryContent( repo.getId() ); | |||
this.repositoryDir = new File( repository.getRepoRoot() ); | |||
this.whenGathered = whenGathered; | |||
} | |||
catch(RepositoryException e) | |||
{ | |||
throw new ConsumerException( "Unable to start ArtifactUpdateDatabaseConsumer: " + e.getMessage(), e ); | |||
} | |||
} | |||
public void processFile( String path ) | |||
throws ConsumerException | |||
{ | |||
ArchivaArtifact artifact = getLiveArtifact( path ); | |||
if ( artifact == null ) | |||
{ | |||
return; | |||
} | |||
try | |||
{ | |||
if( artifact.getModel().getRepositoryId() == null ) | |||
{ | |||
artifact.getModel().setRepositoryId( this.repository.getId() ); | |||
} | |||
// Calculate the hashcodes. | |||
File artifactFile = new File( this.repositoryDir, path ); | |||
try | |||
{ | |||
artifact.getModel().setChecksumMD5( digestMd5.calc( artifactFile ) ); | |||
} | |||
catch ( DigesterException e ) | |||
{ | |||
triggerConsumerWarning( CHECKSUM_CALCULATION, | |||
"Unable to calculate the MD5 checksum: " + e.getMessage() ); | |||
} | |||
try | |||
{ | |||
artifact.getModel().setChecksumSHA1( digestSha1.calc( artifactFile ) ); | |||
} | |||
catch ( DigesterException e ) | |||
{ | |||
triggerConsumerWarning( CHECKSUM_CALCULATION, | |||
"Unable to calculate the SHA1 checksum: " + e.getMessage() ); | |||
} | |||
artifact.getModel().setLastModified( new Date( artifactFile.lastModified() ) ); | |||
artifact.getModel().setSize( artifactFile.length() ); | |||
// set this to when the artifact was first discovered in the repo | |||
if ( artifact.getModel().getWhenGathered() == null ) | |||
{ | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
} | |||
dao.getArtifactDAO().saveArtifact( artifact ); | |||
} | |||
catch ( ArchivaDatabaseException e ) | |||
{ | |||
triggerConsumerError( DB_ERROR, "Unable to save artifact to database: " + e.getMessage() ); | |||
} | |||
} | |||
/** | |||
* Get a Live Artifact from a Path. | |||
* <p/> | |||
* Will resolve the artifact details from the path, and then return a database live version | |||
* of that artifact. Suitable for modification and saving (without the need to check for | |||
* existance in database prior to save.) | |||
* | |||
* @param path the path to work from. | |||
* @return the artifact that is suitable for database saving. | |||
*/ | |||
public ArchivaArtifact getLiveArtifact( String path ) | |||
{ | |||
try | |||
{ | |||
ArtifactReference artifact = repository.toArtifactReference( path ); | |||
ArchivaArtifact liveArtifact = dao.getArtifactDAO().createArtifact( artifact.getGroupId(), | |||
artifact.getArtifactId(), | |||
artifact.getVersion(), | |||
artifact.getClassifier(), | |||
artifact.getType(), | |||
repository.getId()); | |||
return liveArtifact; | |||
} | |||
catch ( LayoutException e ) | |||
{ | |||
triggerConsumerError( TYPE_NOT_ARTIFACT, | |||
"Path " + path + " cannot be converted to artifact: " + e.getMessage() ); | |||
return null; | |||
} | |||
} | |||
public void completeScan() | |||
{ | |||
/* do nothing */ | |||
} | |||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue ) | |||
{ | |||
if ( ConfigurationNames.isRepositoryScanning( propertyName ) ) | |||
{ | |||
initIncludes(); | |||
} | |||
} | |||
public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue ) | |||
{ | |||
/* do nothing */ | |||
} | |||
private void initIncludes() | |||
{ | |||
includes.clear(); | |||
includes.addAll( filetypes.getFileTypePatterns( FileTypes.ARTIFACTS ) ); | |||
} | |||
public void initialize() | |||
throws InitializationException | |||
{ | |||
configuration.addChangeListener( this ); | |||
initIncludes(); | |||
} | |||
} |
@@ -1,203 +0,0 @@ | |||
<?xml version="1.0" encoding="ISO-8859-1"?> | |||
<!-- | |||
~ Licensed to the Apache Software Foundation (ASF) under one | |||
~ or more contributor license agreements. See the NOTICE file | |||
~ distributed with this work for additional information | |||
~ regarding copyright ownership. The ASF licenses this file | |||
~ to you under the Apache License, Version 2.0 (the | |||
~ "License"); you may not use this file except in compliance | |||
~ with the License. You may obtain a copy of the License at | |||
~ | |||
~ http://www.apache.org/licenses/LICENSE-2.0 | |||
~ | |||
~ Unless required by applicable law or agreed to in writing, | |||
~ software distributed under the License is distributed on an | |||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
~ KIND, either express or implied. See the License for the | |||
~ specific language governing permissions and limitations | |||
~ under the License. | |||
--> | |||
<configuration> | |||
<version>1</version> | |||
<repositories> | |||
<repository> | |||
<id>internal</id> | |||
<name>Archiva Managed Internal Repository</name> | |||
<url>file://${appserver.base}/repositories/internal</url> | |||
<layout>default</layout> | |||
<releases>true</releases> | |||
<snapshots>false</snapshots> | |||
<indexed>true</indexed> | |||
<refreshCronExpression>0 0 * * * ?</refreshCronExpression> | |||
</repository> | |||
<repository> | |||
<id>snapshots</id> | |||
<name>Archiva Managed Snapshot Repository</name> | |||
<url>file://${appserver.base}/repositories/internal</url> | |||
<layout>default</layout> | |||
<releases>false</releases> | |||
<snapshots>true</snapshots> | |||
<indexed>true</indexed> | |||
<refreshCronExpression>0 0,30 * * * ?</refreshCronExpression> | |||
</repository> | |||
<repository> | |||
<id>central</id> | |||
<name>Central Repository</name> | |||
<url>http://repo1.maven.org/maven2</url> | |||
<layout>default</layout> | |||
<releases>true</releases> | |||
<snapshots>false</snapshots> | |||
<indexed>false</indexed> | |||
</repository> | |||
<repository> | |||
<id>maven2-repository.dev.java.net</id> | |||
<name>Java.net Repository for Maven 2</name> | |||
<url>https://maven2-repository.dev.java.net/nonav/repository</url> | |||
<layout>default</layout> | |||
<releases>true</releases> | |||
<snapshots>false</snapshots> | |||
<indexed>false</indexed> | |||
</repository> | |||
<repository> | |||
<id>test-repo</id> | |||
<name>Test Repository</name> | |||
<url>file://${appserver.base}/repositories/test-repo</url> | |||
<layout>default</layout> | |||
<releases>true</releases> | |||
<snapshots>true</snapshots> | |||
<indexed>true</indexed> | |||
<refreshCronExpression>0 0 * * * ?</refreshCronExpression> | |||
<daysOlder>0</daysOlder> | |||
<retentionCount>2</retentionCount> | |||
</repository> | |||
</repositories> | |||
<proxyConnectors> | |||
<proxyConnector> | |||
<sourceRepoId>internal</sourceRepoId> | |||
<targetRepoId>central</targetRepoId> | |||
<proxyId/> | |||
<snapshotsPolicy>disabled</snapshotsPolicy> | |||
<releasePolicy>never</releasePolicy> | |||
<failurePolicy>not-found</failurePolicy> | |||
</proxyConnector> | |||
<proxyConnector> | |||
<sourceRepoId>internal</sourceRepoId> | |||
<targetRepoId>maven2-repository.dev.java.net</targetRepoId> | |||
<proxyId/> | |||
<snapshotsPolicy>disabled</snapshotsPolicy> | |||
<releasePolicy>never</releasePolicy> | |||
<failurePolicy>not-found</failurePolicy> | |||
<whiteListPatterns> | |||
<whiteListPattern>javax/**</whiteListPattern> | |||
</whiteListPatterns> | |||
</proxyConnector> | |||
</proxyConnectors> | |||
<networkProxies> | |||
<networkProxy> | |||
<id>example</id> | |||
<protocol>http</protocol> | |||
<host>proxy.mycompany.com</host> | |||
<port>8080</port> | |||
<username>myself</username> | |||
<password>mypass</password> | |||
</networkProxy> | |||
</networkProxies> | |||
<repositoryScanning> | |||
<fileTypes> | |||
<fileType> | |||
<id>artifacts</id> | |||
<patterns> | |||
<pattern>**/*.pom</pattern> | |||
<pattern>**/*.jar</pattern> | |||
<pattern>**/*.ear</pattern> | |||
<pattern>**/*.war</pattern> | |||
<pattern>**/*.car</pattern> | |||
<pattern>**/*.sar</pattern> | |||
<pattern>**/*.mar</pattern> | |||
<pattern>**/*.rar</pattern> | |||
<pattern>**/*.dtd</pattern> | |||
<pattern>**/*.tld</pattern> | |||
<pattern>**/*.tar.gz</pattern> | |||
<pattern>**/*.tar.bz2</pattern> | |||
<pattern>**/*.zip</pattern> | |||
</patterns> | |||
</fileType> | |||
<fileType> | |||
<id>indexable-content</id> | |||
<patterns> | |||
<pattern>**/*.txt</pattern> | |||
<pattern>**/*.TXT</pattern> | |||
<pattern>**/*.block</pattern> | |||
<pattern>**/*.config</pattern> | |||
<pattern>**/*.pom</pattern> | |||
<pattern>**/*.xml</pattern> | |||
<pattern>**/*.xsd</pattern> | |||
<pattern>**/*.dtd</pattern> | |||
<pattern>**/*.tld</pattern> | |||
</patterns> | |||
</fileType> | |||
<fileType> | |||
<id>auto-remove</id> | |||
<patterns> | |||
<pattern>**/*.bak</pattern> | |||
<pattern>**/*~</pattern> | |||
<pattern>**/*-</pattern> | |||
</patterns> | |||
</fileType> | |||
<fileType> | |||
<id>ignored</id> | |||
<patterns> | |||
<pattern>**/.htaccess</pattern> | |||
<pattern>**/KEYS</pattern> | |||
<pattern>**/*.rb</pattern> | |||
<pattern>**/*.sh</pattern> | |||
<pattern>**/.svn/**</pattern> | |||
<pattern>**/.DAV/**</pattern> | |||
</patterns> | |||
</fileType> | |||
</fileTypes> | |||
<knownContentConsumers> | |||
<knownContentConsumer>update-db-artifact</knownContentConsumer> | |||
<knownContentConsumer>create-missing-checksums</knownContentConsumer> | |||
<knownContentConsumer>update-db-repository-metadata</knownContentConsumer> | |||
<knownContentConsumer>validate-checksum</knownContentConsumer> | |||
<knownContentConsumer>validate-signature</knownContentConsumer> | |||
<knownContentConsumer>index-content</knownContentConsumer> | |||
<knownContentConsumer>auto-remove</knownContentConsumer> | |||
<knownContentConsumer>auto-rename</knownContentConsumer> | |||
<knownContentConsumer>repository-purge</knownContentConsumer> | |||
</knownContentConsumers> | |||
<invalidContentConsumers> | |||
<invalidContentConsumer>update-db-bad-content</invalidContentConsumer> | |||
</invalidContentConsumers> | |||
</repositoryScanning> | |||
<databaseScanning> | |||
<cronExpression>0 0 * * * ?</cronExpression> | |||
<unprocessedConsumers> | |||
<unprocessedConsumer>index-artifact</unprocessedConsumer> | |||
<unprocessedConsumer>update-db-project</unprocessedConsumer> | |||
<unprocessedConsumer>validate-repository-metadata</unprocessedConsumer> | |||
<unprocessedConsumer>index-archive-toc</unprocessedConsumer> | |||
<unprocessedConsumer>update-db-bytecode-stats</unprocessedConsumer> | |||
<unprocessedConsumer>index-public-methods</unprocessedConsumer> | |||
</unprocessedConsumers> | |||
<cleanupConsumers> | |||
<cleanupConsumer>not-present-remove-db-artifact</cleanupConsumer> | |||
<cleanupConsumer>not-present-remove-db-project</cleanupConsumer> | |||
<cleanupConsumer>not-present-remove-indexed</cleanupConsumer> | |||
</cleanupConsumers> | |||
</databaseScanning> | |||
<webapp> | |||
<ui> | |||
<showFindArtifacts>true</showFindArtifacts> | |||
<appletFindEnabled>true</appletFindEnabled> | |||
</ui> | |||
</webapp> | |||
</configuration> |
@@ -1,79 +0,0 @@ | |||
package org.apache.maven.archiva.consumers.database; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.io.File; | |||
import org.apache.maven.archiva.common.utils.BaseFile; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.FileType; | |||
import org.apache.maven.archiva.configuration.FileTypes; | |||
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; | |||
import org.apache.maven.archiva.consumers.functors.ConsumerWantsFilePredicate; | |||
import org.codehaus.plexus.spring.PlexusInSpringTestCase; | |||
public class ArtifactUpdateDatabaseConsumerTest | |||
extends PlexusInSpringTestCase | |||
{ | |||
private File repoLocation; | |||
protected KnownRepositoryContentConsumer consumer; | |||
protected void setUp() | |||
throws Exception | |||
{ | |||
super.setUp(); | |||
ArchivaConfiguration archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.ROLE ); | |||
FileType fileType = | |||
(FileType) archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 ); | |||
assertEquals( FileTypes.ARTIFACTS, fileType.getId() ); | |||
fileType.addPattern( "**/*.xml" ); | |||
repoLocation = getTestFile( "target/test-" + getName() + "/test-repo" ); | |||
consumer = | |||
(KnownRepositoryContentConsumer) lookup( KnownRepositoryContentConsumer.class, "update-db-artifact" ); | |||
} | |||
public void testConsumption() | |||
{ | |||
File localFile = | |||
new File( repoLocation, "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata.xml" ); | |||
ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate(); | |||
BaseFile baseFile = new BaseFile( repoLocation, localFile ); | |||
predicate.setBasefile( baseFile ); | |||
assertFalse( predicate.evaluate( consumer ) ); | |||
} | |||
public void testConsumptionOfOtherMetadata() | |||
{ | |||
File localFile = | |||
new File( repoLocation, "org/apache/maven/plugins/maven-plugin-plugin/2.4.1/maven-metadata-central.xml" ); | |||
ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate(); | |||
BaseFile baseFile = new BaseFile( repoLocation, localFile ); | |||
predicate.setBasefile( baseFile ); | |||
assertFalse( predicate.evaluate( consumer ) ); | |||
} | |||
} |
@@ -1,56 +0,0 @@ | |||
<?xml version="1.0" encoding="ISO-8859-1"?> | |||
<!-- | |||
~ Licensed to the Apache Software Foundation (ASF) under one | |||
~ or more contributor license agreements. See the NOTICE file | |||
~ distributed with this work for additional information | |||
~ regarding copyright ownership. The ASF licenses this file | |||
~ to you under the Apache License, Version 2.0 (the | |||
~ "License"); you may not use this file except in compliance | |||
~ with the License. You may obtain a copy of the License at | |||
~ | |||
~ http://www.apache.org/licenses/LICENSE-2.0 | |||
~ | |||
~ Unless required by applicable law or agreed to in writing, | |||
~ software distributed under the License is distributed on an | |||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
~ KIND, either express or implied. See the License for the | |||
~ specific language governing permissions and limitations | |||
~ under the License. | |||
--> | |||
<component-set> | |||
<components> | |||
<!-- JdoAccess --> | |||
<component> | |||
<role>org.apache.maven.archiva.database.jdo.JdoAccess</role> | |||
<role-hint>archiva</role-hint> | |||
<implementation>org.apache.maven.archiva.database.jdo.JdoAccess</implementation> | |||
<requirements> | |||
<requirement> | |||
<role>org.codehaus.plexus.jdo.JdoFactory</role> | |||
<role-hint>archiva</role-hint> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<!-- JDO Factory --> | |||
<component> | |||
<role>org.codehaus.plexus.jdo.JdoFactory</role> | |||
<role-hint>archiva</role-hint> | |||
<implementation>org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory</implementation> | |||
<configuration> | |||
<persistenceManagerFactoryClass>org.jpox.PersistenceManagerFactoryImpl</persistenceManagerFactoryClass> | |||
<driverName>org.hsqldb.jdbcDriver</driverName> | |||
<userName>sa</userName> | |||
<password></password> | |||
<url>jdbc:hsqldb:mem:testdb</url> | |||
<otherProperties> | |||
<property> | |||
<name>javax.jdo.PersistenceManagerFactoryClass</name> | |||
<value>org.jpox.PersistenceManagerFactoryImpl</value> | |||
</property> | |||
</otherProperties> | |||
</configuration> | |||
</component> | |||
</components> | |||
</component-set> |
@@ -1,5 +0,0 @@ | |||
<project> | |||
<groupId>org.apache.maven.archiva</groupId> | |||
<artifactId>do-not-cleanup-artifact-test</artifactId> | |||
<version>1.0</version> | |||
</project> |
@@ -1,39 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project</artifactId> | |||
<version>2.4.4</version> | |||
</parent> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project-api</artifactId> | |||
<name>Test Project API</name> | |||
<dependencies> | |||
<dependency> | |||
<groupId>javax.activation</groupId> | |||
<artifactId>activation</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>stax</groupId> | |||
<artifactId>stax-api</artifactId> | |||
</dependency> | |||
</dependencies> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<artifactId>maven-source-plugin</artifactId> | |||
<executions> | |||
<execution> | |||
<phase>package</phase> | |||
<goals> | |||
<goal>jar</goal> | |||
</goals> | |||
</execution> | |||
</executions> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
</project> |
@@ -1,77 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project-broker-pom</artifactId> | |||
<version>2.4.4</version> | |||
</parent> | |||
<artifactId>test-project-broker-ejb</artifactId> | |||
<name>Test Project Broker EJB</name> | |||
<packaging>ejb</packaging> | |||
<dependencies> | |||
<dependency> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project-common</artifactId> | |||
<type>test-jar</type> | |||
<version>${pom.version}</version> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project-common</artifactId> | |||
<version>${pom.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project-api</artifactId> | |||
<version>${pom.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-httpclient</groupId> | |||
<artifactId>commons-httpclient</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-id</groupId> | |||
<artifactId>commons-id</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-discovery</groupId> | |||
<artifactId>commons-discovery</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-logging</groupId> | |||
<artifactId>commons-logging</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>log4j</groupId> | |||
<artifactId>log4j</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework</groupId> | |||
<artifactId>spring-mock</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.jms</groupId> | |||
<artifactId>jms</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.servlet</groupId> | |||
<artifactId>servlet-api</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.activation</groupId> | |||
<artifactId>activation</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.mail</groupId> | |||
<artifactId>mail</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.management</groupId> | |||
<artifactId>jmxri</artifactId> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@@ -1,16 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project</artifactId> | |||
<version>2.4.4</version> | |||
</parent> | |||
<artifactId>test-project-broker-pom</artifactId> | |||
<name>Test Project Broker POM</name> | |||
<packaging>pom</packaging> | |||
<modules> | |||
<module>broker-ejb</module> | |||
</modules> | |||
</project> |
@@ -1,119 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project</artifactId> | |||
<version>2.4.4</version> | |||
</parent> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project-common</artifactId> | |||
<name>Test Project Commons</name> | |||
<dependencies> | |||
<dependency> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project-api</artifactId> | |||
<version>${pom.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-id</groupId> | |||
<artifactId>commons-id</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-discovery</groupId> | |||
<artifactId>commons-discovery</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework</groupId> | |||
<artifactId>spring</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-lang</groupId> | |||
<artifactId>commons-lang</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-collections</groupId> | |||
<artifactId>commons-collections</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-logging</groupId> | |||
<artifactId>commons-logging</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-httpclient</groupId> | |||
<artifactId>commons-httpclient</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>log4j</groupId> | |||
<artifactId>log4j</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>stax</groupId> | |||
<artifactId>stax-api</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.woodstox</groupId> | |||
<artifactId>wstx-asl</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.castor</groupId> | |||
<artifactId>castor</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>xerces</groupId> | |||
<artifactId>xerces</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.activation</groupId> | |||
<artifactId>activation</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.jms</groupId> | |||
<artifactId>jms</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.ejb</groupId> | |||
<artifactId>ejb</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.servlet</groupId> | |||
<artifactId>servlet-api</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.mail</groupId> | |||
<artifactId>mail</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.management</groupId> | |||
<artifactId>jmxri</artifactId> | |||
</dependency> | |||
</dependencies> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<artifactId>maven-source-plugin</artifactId> | |||
<executions> | |||
<execution> | |||
<phase>package</phase> | |||
<goals> | |||
<goal>jar</goal> | |||
</goals> | |||
</execution> | |||
</executions> | |||
</plugin> | |||
<plugin> | |||
<artifactId>maven-jar-plugin</artifactId> | |||
<executions> | |||
<execution> | |||
<phase>package</phase> | |||
<goals> | |||
<goal>test-jar</goal> | |||
</goals> | |||
</execution> | |||
</executions> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
</project> |
@@ -1,75 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project-endpoint-pom</artifactId> | |||
<version>2.4.4</version> | |||
</parent> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project-endpoint-ejb</artifactId> | |||
<name>Test Project Endpoint EJB</name> | |||
<packaging>ejb</packaging> | |||
<dependencies> | |||
<dependency> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project-common</artifactId> | |||
<version>${pom.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project-api</artifactId> | |||
<version>${pom.version}</version> | |||
</dependency> | |||
<dependency> | |||
<!-- for tests only --> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project-common</artifactId> | |||
<version>${pom.version}</version> | |||
<type>test-jar</type> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-id</groupId> | |||
<artifactId>commons-id</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-discovery</groupId> | |||
<artifactId>commons-discovery</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-logging</groupId> | |||
<artifactId>commons-logging</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>log4j</groupId> | |||
<artifactId>log4j</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.jms</groupId> | |||
<artifactId>jms</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.activation</groupId> | |||
<artifactId>activation</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.mail</groupId> | |||
<artifactId>mail</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>xml-apis</groupId> | |||
<artifactId>xml-apis</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.management</groupId> | |||
<artifactId>jmxri</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.servlet</groupId> | |||
<artifactId>servlet-api</artifactId> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@@ -1,16 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project</artifactId> | |||
<version>2.4.4</version> | |||
</parent> | |||
<artifactId>test-project-endpoint-pom</artifactId> | |||
<name>Test Project Endpoint POM</name> | |||
<packaging>pom</packaging> | |||
<modules> | |||
<module>endpoint-ejb</module> | |||
</modules> | |||
</project> |
@@ -1,161 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project> | |||
<modelVersion>4.0.0</modelVersion> | |||
<groupId>test-project</groupId> | |||
<artifactId>test-project</artifactId> | |||
<name>Test Project</name> | |||
<version>2.4.4</version> | |||
<packaging>pom</packaging> | |||
<organization> | |||
<name>Company</name> | |||
<url>http://www.company.com/</url> | |||
</organization> | |||
<inceptionYear>2002</inceptionYear> | |||
<modules> | |||
<module>api</module> | |||
<module>common</module> | |||
<module>broker</module> | |||
<module>endpoint</module> | |||
</modules> | |||
<dependencies> | |||
<dependency> | |||
<groupId>junit</groupId> | |||
<artifactId>junit</artifactId> | |||
<version>3.8.1</version> | |||
<scope>test</scope> | |||
</dependency> | |||
</dependencies> | |||
<dependencyManagement> | |||
<dependencies> | |||
<!-- common version strategy --> | |||
<dependency> | |||
<groupId>javax.activation</groupId> | |||
<artifactId>activation</artifactId> | |||
<version>1.0.2</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.jms</groupId> | |||
<artifactId>jms</artifactId> | |||
<version>1.0.2</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.ejb</groupId> | |||
<artifactId>ejb</artifactId> | |||
<version>2.0</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.servlet</groupId> | |||
<artifactId>servlet-api</artifactId> | |||
<version>2.4</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.mail</groupId> | |||
<artifactId>mail</artifactId> | |||
<version>1.4</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>xml-apis</groupId> | |||
<artifactId>xml-apis</artifactId> | |||
<version>2.0.2</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-logging</groupId> | |||
<artifactId>commons-logging</artifactId> | |||
<version>1.0.4</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-lang</groupId> | |||
<artifactId>commons-lang</artifactId> | |||
<version>2.1</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-collections</groupId> | |||
<artifactId>commons-collections</artifactId> | |||
<version>3.2</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework</groupId> | |||
<artifactId>spring</artifactId> | |||
<version>2.0.7</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework</groupId> | |||
<artifactId>spring-mock</artifactId> | |||
<version>2.0.7</version> | |||
<scope>test</scope> | |||
<exclusions> | |||
<exclusion> | |||
<groupId>org.springframework</groupId> | |||
<artifactId>spring-jdbc</artifactId> | |||
</exclusion> | |||
<exclusion> | |||
<groupId>org.springframework</groupId> | |||
<artifactId>spring-web</artifactId> | |||
</exclusion> | |||
</exclusions> | |||
</dependency> | |||
<dependency> | |||
<groupId>log4j</groupId> | |||
<artifactId>log4j</artifactId> | |||
<version>1.2.8</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-discovery</groupId> | |||
<artifactId>commons-discovery</artifactId> | |||
<version>0.2</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-id</groupId> | |||
<artifactId>commons-id</artifactId> | |||
<version>0.1-dev</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.castor</groupId> | |||
<artifactId>castor</artifactId> | |||
<version>1.0.5-xml</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>xerces</groupId> | |||
<artifactId>xerces</artifactId> | |||
<version>2.4.0</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-httpclient</groupId> | |||
<artifactId>commons-httpclient</artifactId> | |||
<version>3.1</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>stax</groupId> | |||
<artifactId>stax-api</artifactId> | |||
<version>1.0.1</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.woodstox</groupId> | |||
<artifactId>wstx-asl</artifactId> | |||
<version>3.2.1</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.thoughtworks.xstream</groupId> | |||
<artifactId>xstream</artifactId> | |||
<version>1.2.2</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.management</groupId> | |||
<artifactId>jmxri</artifactId> | |||
<version>1.2.1</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
</dependencies> | |||
</dependencyManagement> | |||
</project> |
@@ -33,7 +33,6 @@ | |||
<modules> | |||
<module>archiva-consumer-api</module> | |||
<module>archiva-core-consumers</module> | |||
<module>archiva-database-consumers</module> | |||
<module>archiva-lucene-consumers</module> | |||
<module>archiva-signature-consumers</module> | |||
<module>archiva-dependency-tree-consumer</module> |
@@ -144,6 +144,16 @@ public class TestMetadataRepository | |||
return null; //To change body of implemented methods use File | Settings | File Templates. | |||
} | |||
public void deleteArtifact( String repositoryId, String namespace, String project, String version, String id ) | |||
{ | |||
//To change body of implemented methods use File | Settings | File Templates. | |||
} | |||
public void deleteRepository( String repoId ) | |||
{ | |||
//To change body of implemented methods use File | Settings | File Templates. | |||
} | |||
public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, | |||
String projectVersion ) | |||
{ |
@@ -67,6 +67,10 @@ | |||
<artifactId>slf4j-simple</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>metadata-model</artifactId> | |||
</dependency> | |||
</dependencies> | |||
<build> | |||
<plugins> |
@@ -1,8 +1,5 @@ | |||
package org.apache.maven.archiva.repository.events; | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import org.apache.maven.archiva.repository.ManagedRepositoryContent; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
@@ -31,7 +28,6 @@ public interface RepositoryListener | |||
{ | |||
/** | |||
* Event for the deletion of a given artifact. | |||
* @param artifactPath the path to the artifact that was deleted. | |||
*/ | |||
void deleteArtifact( ManagedRepositoryContent repository, ArchivaArtifact artifact ); | |||
void deleteArtifact( String repositoryId, String namespace, String project, String version, String id ); | |||
} |
@@ -1,103 +0,0 @@ | |||
<?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.archiva</groupId> | |||
<artifactId>archiva-modules</artifactId> | |||
<version>1.3-SNAPSHOT</version> | |||
</parent> | |||
<modelVersion>4.0.0</modelVersion> | |||
<artifactId>archiva-database</artifactId> | |||
<name>Archiva Database</name> | |||
<dependencies> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-repository-layer</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-consumer-api</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-configuration</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-model</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.plexus</groupId> | |||
<artifactId>plexus-spring</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.plexus</groupId> | |||
<artifactId>plexus-component-api</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.plexus</groupId> | |||
<artifactId>plexus-jdo2</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>jpox</groupId> | |||
<artifactId>jpox</artifactId> | |||
<scope>compile</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-lang</groupId> | |||
<artifactId>commons-lang</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-io</groupId> | |||
<artifactId>commons-io</artifactId> | |||
</dependency> | |||
<!-- TEST DEPS --> | |||
<dependency> | |||
<groupId>org.codehaus.plexus.registry</groupId> | |||
<artifactId>plexus-registry-commons</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>hsqldb</groupId> | |||
<artifactId>hsqldb</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.derby</groupId> | |||
<artifactId>derbytools</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.slf4j</groupId> | |||
<artifactId>slf4j-simple</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
</dependencies> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.codehaus.plexus</groupId> | |||
<artifactId>plexus-component-metadata</artifactId> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
</project> |
@@ -1,43 +0,0 @@ | |||
package org.apache.maven.archiva.database; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.util.List; | |||
/** | |||
* ArchivaDAO - The interface for all content within the database. | |||
* | |||
* @version $Id$ | |||
*/ | |||
public interface ArchivaDAO | |||
{ | |||
public static final String ROLE = ArchivaDAO.class.getName(); | |||
/** | |||
* Perform a simple query against the database. | |||
* | |||
* @param constraint the constraint to use. | |||
* @return the List of results. | |||
*/ | |||
List<?> query( SimpleConstraint constraint ); | |||
ArtifactDAO getArtifactDAO(); | |||
} |
@@ -1,41 +0,0 @@ | |||
package org.apache.maven.archiva.database; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
/** | |||
* ArchivaDatabaseException | |||
* | |||
* @version $Id$ | |||
*/ | |||
public class ArchivaDatabaseException | |||
extends Exception | |||
{ | |||
public ArchivaDatabaseException( String message, Throwable cause ) | |||
{ | |||
super( message, cause ); | |||
} | |||
public ArchivaDatabaseException( String message ) | |||
{ | |||
super( message ); | |||
} | |||
} |
@@ -1,69 +0,0 @@ | |||
package org.apache.maven.archiva.database; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import java.util.List; | |||
/** | |||
* ArtifactDAO | |||
* | |||
* @version $Id$ | |||
*/ | |||
public interface ArtifactDAO | |||
{ | |||
/* NOTE TO ARCHIVA DEVELOPERS. | |||
* | |||
* Please keep this interface clean and lean. | |||
* We don't want a repeat of the Continuum Store. | |||
* You should have the following methods per object type ... | |||
* | |||
* (Required Methods) | |||
* | |||
* DatabaseObject .createDatabaseObject( Required Params ) ; | |||
* List .queryDatabaseObject( Constraint ) throws ObjectNotFoundException, DatabaseException; | |||
* DatabaseObject .saveDatabaseObject( DatabaseObject ) throws DatabaseException; | |||
* | |||
* (Optional Methods) | |||
* | |||
* DatabaseObject .getDatabaseObject( Id ) throws ObjectNotFoundException, DatabaseException; | |||
* List .getDatabaseObjects() throws ObjectNotFoundException, DatabaseException; | |||
* void .deleteDatabaseObject( DatabaseObject ) throws DatabaseException; | |||
* | |||
* This is the only list of options created in this DAO. | |||
*/ | |||
public ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String classifier, | |||
String type, String repositoryId ); | |||
public ArchivaArtifact getArtifact( String groupId, String artifactId, String version, String classifier, | |||
String type, String repositoryId ) | |||
throws ObjectNotFoundException, ArchivaDatabaseException; | |||
public List<ArchivaArtifact> queryArtifacts( Constraint constraint ) | |||
throws ObjectNotFoundException, ArchivaDatabaseException; | |||
public ArchivaArtifact saveArtifact( ArchivaArtifact artifact ) | |||
throws ArchivaDatabaseException; | |||
public void deleteArtifact( ArchivaArtifact artifact ) | |||
throws ArchivaDatabaseException; | |||
} |
@@ -1,42 +0,0 @@ | |||
package org.apache.maven.archiva.database; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
/** | |||
* Constraint - a generic object for dealing with database constraints. | |||
* | |||
* @version $Id$ | |||
* @see DeclarativeConstraint | |||
* @see SimpleConstraint | |||
*/ | |||
public interface Constraint | |||
{ | |||
public static final String ASCENDING = "ascending"; | |||
public static final String DESCENDING = "descending"; | |||
/** | |||
* Get the fetch limits on the object. | |||
* | |||
* @return the fetch limits on the object. (can be null) (O/RM specific) | |||
*/ | |||
public String getFetchLimits(); | |||
} |
@@ -1,104 +0,0 @@ | |||
package org.apache.maven.archiva.database; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
/** | |||
* DeclarativeConstraint | |||
* | |||
* @version $Id$ | |||
*/ | |||
public interface DeclarativeConstraint | |||
extends Constraint | |||
{ | |||
/** | |||
* Get the declared imports used for this query. (optional) | |||
* <p/> | |||
* NOTE: This is DAO implementation specific. | |||
* | |||
* @return the imports. (can be null) | |||
*/ | |||
public abstract String[] getDeclaredImports(); | |||
/** | |||
* Get the declared parameters used for this query. (optional) | |||
* <p/> | |||
* NOTE: This is DAO implementation specific. | |||
* | |||
* @return the parameters. (can be null) | |||
*/ | |||
public abstract String[] getDeclaredParameters(); | |||
/** | |||
* The JDOQL filter to apply to the query. (optional) | |||
* <p/> | |||
* NOTE: This is DAO implementation specific. | |||
* | |||
* @return the filter to apply. (can be null) | |||
*/ | |||
public abstract String getFilter(); | |||
/** | |||
* Get the parameters used for this query. (required if using {@link #getDeclaredParameters()} ) | |||
* <p/> | |||
* NOTE: This is DAO implementation specific. | |||
* | |||
* @return the parameters. (can be null) | |||
*/ | |||
public abstract Object[] getParameters(); | |||
/** | |||
* Get the sort direction name. | |||
* | |||
* @return the sort direction name. ("ASC" or "DESC") (only valid if {@link #getSortColumn()} is specified.) | |||
*/ | |||
public abstract String getSortDirection(); | |||
/** | |||
* Get the sort column name. | |||
* | |||
* @return the sort column name. (can be null) | |||
*/ | |||
public abstract String getSortColumn(); | |||
/** | |||
* Get the variables used within the query. | |||
* <p/> | |||
* NOTE: This is DAO implementation specific. | |||
* | |||
* @return the variables used within the query. | |||
*/ | |||
public abstract String[] getVariables(); | |||
/** | |||
* Get the SELECT WHERE (condition) value for the constraint. | |||
* | |||
* @return the equivalent of the SELECT WHERE (condition) value for this constraint. (can be null) | |||
*/ | |||
public abstract String getWhereCondition(); | |||
/** | |||
* Get the declared range used for this query. (optional) | |||
* <p/> | |||
* NOTE: This is DAO implementation specific. | |||
* | |||
* @return the range. (can be null) | |||
*/ | |||
public abstract int[] getRange(); | |||
} |
@@ -1,52 +0,0 @@ | |||
package org.apache.maven.archiva.database; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
/** | |||
* ObjectNotFoundException | |||
* | |||
* @version $Id$ | |||
*/ | |||
public class ObjectNotFoundException | |||
extends ArchivaDatabaseException | |||
{ | |||
private Object id; | |||
public ObjectNotFoundException( String message, Throwable cause, Object id ) | |||
{ | |||
super( message, cause ); | |||
this.id = id; | |||
} | |||
public ObjectNotFoundException( String message, Throwable cause ) | |||
{ | |||
super( message, cause ); | |||
} | |||
public ObjectNotFoundException( String message ) | |||
{ | |||
super( message ); | |||
} | |||
public Object getId() | |||
{ | |||
return id; | |||
} | |||
} |
@@ -1,53 +0,0 @@ | |||
package org.apache.maven.archiva.database; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import org.apache.maven.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.maven.archiva.repository.events.RepositoryListener; | |||
/** | |||
* Process repository management events and respond appropriately. | |||
* | |||
* @plexus.component role="org.apache.maven.archiva.repository.events.RepositoryListener" role-hint="database" | |||
*/ | |||
public class RepositoryDatabaseEventListener | |||
implements RepositoryListener | |||
{ | |||
/** | |||
* @plexus.requirement role-hint="jdo" | |||
*/ | |||
private ArtifactDAO artifactDAO; | |||
public void deleteArtifact( ManagedRepositoryContent repository, ArchivaArtifact artifact ) | |||
{ | |||
try | |||
{ | |||
ArchivaArtifact queriedArtifact = | |||
artifactDAO.getArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), | |||
artifact.getClassifier(), artifact.getType(), repository.getId() ); | |||
artifactDAO.deleteArtifact( queriedArtifact ); | |||
} | |||
catch ( ArchivaDatabaseException e ) | |||
{ | |||
// ignored | |||
} | |||
} | |||
} |
@@ -1,59 +0,0 @@ | |||
package org.apache.maven.archiva.database; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
/** | |||
* SimpleConstraint | |||
* | |||
* @version $Id$ | |||
*/ | |||
public interface SimpleConstraint extends Constraint | |||
{ | |||
/** | |||
* Get the parameters used for this query. (required if using parameterized SQL) | |||
* | |||
* NOTE: This is DAO implementation specific. | |||
* | |||
* @return the parameters. (can be null) | |||
*/ | |||
public Object[] getParameters(); | |||
/** | |||
* Get the SELECT query value for the constraint. | |||
* | |||
* @return the SELECT value for this constraint. (can be null) | |||
*/ | |||
public abstract String getSelectSql(); | |||
/** | |||
* For simple Constraints the results class must be specified. | |||
* | |||
* @return the result class. | |||
*/ | |||
public Class<?> getResultClass(); | |||
/** | |||
* When working with result classes that are not persistable, | |||
* it is advisable to tell the underlying DAO to not do the persistable related efforts. | |||
* | |||
* @return true if result classes are persistable. | |||
*/ | |||
public boolean isResultsPersistable(); | |||
} |
@@ -1,163 +0,0 @@ | |||
package org.apache.maven.archiva.database.constraints; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import org.apache.maven.archiva.database.Constraint; | |||
import org.apache.maven.archiva.database.DeclarativeConstraint; | |||
/** | |||
* AbstractDeclarativeConstraint | |||
* | |||
* @version $Id$ | |||
*/ | |||
public abstract class AbstractDeclarativeConstraint | |||
implements DeclarativeConstraint | |||
{ | |||
protected String[] declImports; | |||
protected String[] declParams; | |||
protected String[] variables; | |||
protected Object[] params; | |||
protected int[] range; | |||
protected String sortDirection = Constraint.ASCENDING; | |||
public String getFilter() | |||
{ | |||
return null; | |||
} | |||
public String getFetchLimits() | |||
{ | |||
return null; | |||
} | |||
public String[] getDeclaredImports() | |||
{ | |||
return declImports; | |||
} | |||
public String[] getDeclaredParameters() | |||
{ | |||
return declParams; | |||
} | |||
public Object[] getParameters() | |||
{ | |||
return params; | |||
} | |||
public String getSortDirection() | |||
{ | |||
return sortDirection; | |||
} | |||
public String[] getVariables() | |||
{ | |||
return variables; | |||
} | |||
public int[] getRange() | |||
{ | |||
return range; | |||
} | |||
@Override | |||
public boolean equals( Object o ) | |||
{ | |||
if ( this == o ) | |||
{ | |||
return true; | |||
} | |||
if ( o == null || getClass() != o.getClass() ) | |||
{ | |||
return false; | |||
} | |||
AbstractDeclarativeConstraint that = (AbstractDeclarativeConstraint) o; | |||
if ( !Arrays.equals( declImports, that.declImports ) ) | |||
{ | |||
return false; | |||
} | |||
if ( !Arrays.equals( declParams, that.declParams ) ) | |||
{ | |||
return false; | |||
} | |||
// Probably incorrect - comparing Object[] arrays with Arrays.equals | |||
if ( !Arrays.equals( params, that.params ) ) | |||
{ | |||
return false; | |||
} | |||
if ( !Arrays.equals( range, that.range ) ) | |||
{ | |||
return false; | |||
} | |||
if ( sortDirection != null ? !sortDirection.equals( that.sortDirection ) : that.sortDirection != null ) | |||
{ | |||
return false; | |||
} | |||
if ( !Arrays.equals( variables, that.variables ) ) | |||
{ | |||
return false; | |||
} | |||
return true; | |||
} | |||
@Override | |||
public int hashCode() | |||
{ | |||
int result = declImports != null ? Arrays.hashCode( declImports ) : 0; | |||
result = 31 * result + ( declParams != null ? Arrays.hashCode( declParams ) : 0 ); | |||
result = 31 * result + ( variables != null ? Arrays.hashCode( variables ) : 0 ); | |||
result = 31 * result + ( params != null ? Arrays.hashCode( params ) : 0 ); | |||
result = 31 * result + ( range != null ? Arrays.hashCode( range ) : 0 ); | |||
result = 31 * result + ( sortDirection != null ? sortDirection.hashCode() : 0 ); | |||
return result; | |||
} | |||
@Override | |||
public String toString() | |||
{ | |||
List<Integer> r = null; | |||
if ( range != null ) | |||
{ | |||
r = new ArrayList<Integer>(); | |||
for ( int i : range ) | |||
{ | |||
r.add( i ); | |||
} | |||
} | |||
return "AbstractDeclarativeConstraint{" + "declImports=" + | |||
( declImports == null ? null : Arrays.asList( declImports ) ) + ", declParams=" + | |||
( declParams == null ? null : Arrays.asList( declParams ) ) + ", variables=" + | |||
( variables == null ? null : Arrays.asList( variables ) ) + ", params=" + | |||
( params == null ? null : Arrays.asList( params ) ) + ", range=" + r + ", sortDirection='" + sortDirection + | |||
'\'' + '}'; | |||
} | |||
} |
@@ -1,48 +0,0 @@ | |||
package org.apache.maven.archiva.database.constraints; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.maven.archiva.database.SimpleConstraint; | |||
/** | |||
* Simple Constraint abstract for working with nearly-raw SQL strings. | |||
* | |||
* @version $Id$ | |||
*/ | |||
public abstract class AbstractSimpleConstraint | |||
implements SimpleConstraint | |||
{ | |||
protected Object[] params; | |||
public Object[] getParameters() | |||
{ | |||
return params; | |||
} | |||
public String getFetchLimits() | |||
{ | |||
return null; | |||
} | |||
public boolean isResultsPersistable() | |||
{ | |||
return false; | |||
} | |||
} |
@@ -1,72 +0,0 @@ | |||
package org.apache.maven.archiva.database.constraints; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.maven.archiva.database.Constraint; | |||
/** | |||
* ArtifactVersionsConstraint | |||
* | |||
* @version | |||
*/ | |||
public class ArtifactVersionsConstraint | |||
extends AbstractDeclarativeConstraint | |||
implements Constraint | |||
{ | |||
private String whereClause = ""; | |||
private String sortColumn = "repositoryId"; | |||
public ArtifactVersionsConstraint( String repoId, String groupId, String artifactId, boolean includeWhenGathered ) | |||
{ | |||
if( repoId != null ) | |||
{ | |||
whereClause = "repositoryId.equals(selectedRepoId) && groupId.equals(selectedGroupId) && artifactId.equals(selectedArtifactId) " | |||
+ ( includeWhenGathered ? "&& whenGathered != null" : "" ); | |||
declParams = new String[] { "String selectedRepoId", "String selectedGroupId", "String selectedArtifactId" }; | |||
params = new Object[] { repoId, groupId, artifactId }; | |||
} | |||
else | |||
{ | |||
whereClause = | |||
"groupId.equals(selectedGroupId) && artifactId.equals(selectedArtifactId) " + | |||
( includeWhenGathered ? "&& whenGathered != null" : "" ); | |||
declParams = new String[] { "String selectedGroupId", "String selectedArtifactId" }; | |||
params = new Object[] { groupId, artifactId }; | |||
} | |||
} | |||
public ArtifactVersionsConstraint( String repoId, String groupId, String artifactId, String sortColumn ) | |||
{ | |||
this( repoId, groupId, artifactId, true ); | |||
this.sortColumn = sortColumn; | |||
} | |||
public String getSortColumn() | |||
{ | |||
return sortColumn; | |||
} | |||
public String getWhereCondition() | |||
{ | |||
return whereClause; | |||
} | |||
} |
@@ -1,76 +0,0 @@ | |||
package org.apache.maven.archiva.database.constraints; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.util.Date; | |||
import org.apache.maven.archiva.database.Constraint; | |||
/** | |||
* ArtifactsByRepositoryConstraint | |||
* | |||
* @version | |||
*/ | |||
public class ArtifactsByRepositoryConstraint | |||
extends AbstractDeclarativeConstraint | |||
implements Constraint | |||
{ | |||
private String whereClause; | |||
private String sortColumn = "groupId"; | |||
public ArtifactsByRepositoryConstraint( String repoId ) | |||
{ | |||
whereClause = "repositoryId == repoId"; | |||
declParams = new String[] { "String repoId" }; | |||
params = new Object[] { repoId }; | |||
} | |||
public ArtifactsByRepositoryConstraint( String repoId, Date targetWhenGathered, String sortColumn, boolean isBefore ) | |||
{ | |||
String condition = isBefore ? "<=" : ">="; | |||
declImports = new String[] { "import java.util.Date" }; | |||
whereClause = "this.repositoryId == repoId && this.whenGathered " + condition + " targetWhenGathered"; | |||
declParams = new String[] { "String repoId", "Date targetWhenGathered" }; | |||
params = new Object[] { repoId, targetWhenGathered }; | |||
this.sortColumn = sortColumn; | |||
} | |||
public ArtifactsByRepositoryConstraint( String repoId, String type, Date before, String sortColumn ) | |||
{ | |||
declImports = new String[] { "import java.util.Date" }; | |||
whereClause = | |||
"this.repositoryId == repoId && this.type == type && this.whenGathered <= before"; | |||
declParams = new String[] { "String repoId", "String type", "Date before" }; | |||
params = new Object[] { repoId, type, before }; | |||
this.sortColumn = sortColumn; | |||
} | |||
public String getSortColumn() | |||
{ | |||
return sortColumn; | |||
} | |||
public String getWhereCondition() | |||
{ | |||
return whereClause; | |||
} | |||
} |
@@ -1,598 +0,0 @@ | |||
package org.apache.maven.archiva.database.jdo; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.commons.lang.StringUtils; | |||
import org.apache.maven.archiva.database.ArchivaDatabaseException; | |||
import org.apache.maven.archiva.database.Constraint; | |||
import org.apache.maven.archiva.database.DeclarativeConstraint; | |||
import org.apache.maven.archiva.database.ObjectNotFoundException; | |||
import org.apache.maven.archiva.database.SimpleConstraint; | |||
import org.apache.maven.archiva.database.constraints.AbstractSimpleConstraint; | |||
import org.apache.maven.archiva.model.CompoundKey; | |||
import org.codehaus.plexus.jdo.JdoFactory; | |||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; | |||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; | |||
import java.io.PrintStream; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import javax.jdo.Extent; | |||
import javax.jdo.JDOException; | |||
import javax.jdo.JDOHelper; | |||
import javax.jdo.JDOObjectNotFoundException; | |||
import javax.jdo.JDOUserException; | |||
import javax.jdo.PersistenceManager; | |||
import javax.jdo.PersistenceManagerFactory; | |||
import javax.jdo.Query; | |||
import javax.jdo.Transaction; | |||
import javax.jdo.datastore.DataStoreCache; | |||
import javax.jdo.listener.InstanceLifecycleEvent; | |||
import javax.jdo.listener.InstanceLifecycleListener; | |||
import javax.jdo.listener.StoreLifecycleListener; | |||
import javax.jdo.spi.Detachable; | |||
import javax.jdo.spi.PersistenceCapable; | |||
/** | |||
* JdoAccess | |||
* | |||
* @version $Id$ | |||
* @plexus.component role="org.apache.maven.archiva.database.jdo.JdoAccess" role-hint="archiva" | |||
*/ | |||
public class JdoAccess | |||
implements Initializable, InstanceLifecycleListener, StoreLifecycleListener | |||
{ | |||
/** | |||
* @plexus.requirement role-hint="archiva" | |||
*/ | |||
private JdoFactory jdoFactory; | |||
private PersistenceManagerFactory pmf; | |||
public void initialize() | |||
throws InitializationException | |||
{ | |||
pmf = jdoFactory.getPersistenceManagerFactory(); | |||
/* Primitive (and failed) attempt at creating the schema on startup. | |||
Just to prevent the multiple stack trace warnings on auto-gen of schema. | |||
// Create the schema (if needed) | |||
URL jdoFileUrls[] = new URL[] { getClass().getResource( "/org/apache/maven/archiva/model/package.jdo" ) }; | |||
File propsFile = null; // intentional | |||
boolean verbose = true; | |||
try | |||
{ | |||
String connectionFactoryName = pmf.getConnectionFactoryName(); | |||
if ( StringUtils.isNotBlank( connectionFactoryName ) && connectionFactoryName.startsWith( "java:comp" ) ) | |||
{ | |||
// We have a JNDI datasource! | |||
String jndiDatasource = connectionFactoryName; | |||
System.setProperty( PMFConfiguration.JDO_DATASTORE_URL_PROPERTY, jndiDatasource ); | |||
} | |||
// TODO: figure out how to get the jdbc driver details from JNDI to pass into SchemaTool. | |||
SchemaTool.createSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose, null ); | |||
} | |||
catch ( Exception e ) | |||
{ | |||
getLogger().error( "Unable to create schema: " + e.getMessage(), e ); | |||
} | |||
pmf.getPersistenceManager(); | |||
*/ | |||
// Add the lifecycle listener. | |||
pmf.addInstanceLifecycleListener( this, null ); | |||
} | |||
public static void dumpObjectState( PrintStream out, Object o ) | |||
{ | |||
final String STATE = "[STATE] "; | |||
final String INDENT = " "; | |||
if ( o == null ) | |||
{ | |||
out.println( STATE + "Object is null." ); | |||
return; | |||
} | |||
out.println( STATE + "Object " + o.getClass().getName() ); | |||
if ( !( o instanceof PersistenceCapable ) ) | |||
{ | |||
out.println( INDENT + "is NOT PersistenceCapable (not a jdo object?)" ); | |||
return; | |||
} | |||
out.println( INDENT + "is PersistenceCapable." ); | |||
if ( o instanceof Detachable ) | |||
{ | |||
out.println( INDENT + "is Detachable" ); | |||
} | |||
out.println( INDENT + "is new : " + Boolean.toString( JDOHelper.isNew( o ) ) ); | |||
out.println( INDENT + "is transactional : " + Boolean.toString( JDOHelper.isTransactional( o ) ) ); | |||
out.println( INDENT + "is deleted : " + Boolean.toString( JDOHelper.isDeleted( o ) ) ); | |||
out.println( INDENT + "is detached : " + Boolean.toString( JDOHelper.isDetached( o ) ) ); | |||
out.println( INDENT + "is dirty : " + Boolean.toString( JDOHelper.isDirty( o ) ) ); | |||
out.println( INDENT + "is persistent : " + Boolean.toString( JDOHelper.isPersistent( o ) ) ); | |||
out.println( INDENT + "object id : " + JDOHelper.getObjectId( o ) ); | |||
} | |||
public PersistenceManager getPersistenceManager() | |||
{ | |||
PersistenceManager pm = pmf.getPersistenceManager(); | |||
pm.getFetchPlan().setMaxFetchDepth( -1 ); | |||
return pm; | |||
} | |||
public void enableCache( Class<?> clazz ) | |||
{ | |||
DataStoreCache cache = pmf.getDataStoreCache(); | |||
cache.pinAll( clazz, false ); // Pin all objects of type clazz from now on | |||
} | |||
public Object saveObject( Object object ) | |||
{ | |||
return saveObject( object, null ); | |||
} | |||
public Object saveObject( Object object, String[] fetchGroups ) | |||
{ | |||
PersistenceManager pm = getPersistenceManager(); | |||
Transaction tx = pm.currentTransaction(); | |||
try | |||
{ | |||
tx.begin(); | |||
if ( ( JDOHelper.getObjectId( object ) != null ) && !JDOHelper.isDetached( object ) ) | |||
{ | |||
// This is a fatal error that means we need to fix our code. | |||
// Leave it as a JDOUserException, it's intentional. | |||
throw new JDOUserException( "Existing object is not detached: " + object, object ); | |||
} | |||
if ( fetchGroups != null ) | |||
{ | |||
for ( int i = 0; i >= fetchGroups.length; i++ ) | |||
{ | |||
pm.getFetchPlan().addGroup( fetchGroups[i] ); | |||
} | |||
} | |||
pm.makePersistent( object ); | |||
object = pm.detachCopy( object ); | |||
tx.commit(); | |||
return object; | |||
} | |||
finally | |||
{ | |||
rollbackIfActive( tx ); | |||
} | |||
} | |||
public List<?> getAllObjects( Class<?> clazz ) | |||
{ | |||
return queryObjects( clazz, null ); | |||
} | |||
public List<?> queryObjects( Class<?> clazz, Constraint constraint ) | |||
{ | |||
PersistenceManager pm = getPersistenceManager(); | |||
Transaction tx = pm.currentTransaction(); | |||
try | |||
{ | |||
tx.begin(); | |||
List<?> result = null; | |||
if ( constraint != null ) | |||
{ | |||
if ( constraint instanceof DeclarativeConstraint ) | |||
{ | |||
result = processConstraint( pm, clazz, (DeclarativeConstraint) constraint ); | |||
} | |||
else if ( constraint instanceof AbstractSimpleConstraint ) | |||
{ | |||
result = processConstraint( pm, (SimpleConstraint) constraint ); | |||
} | |||
else | |||
{ | |||
result = processUnconstrained( pm, clazz ); | |||
} | |||
} | |||
else | |||
{ | |||
result = processUnconstrained( pm, clazz ); | |||
} | |||
result = (List<?>) pm.detachCopyAll( result ); | |||
tx.commit(); | |||
return result; | |||
} | |||
finally | |||
{ | |||
rollbackIfActive( tx ); | |||
} | |||
} | |||
public List<?> queryObjects( SimpleConstraint constraint ) | |||
{ | |||
PersistenceManager pm = getPersistenceManager(); | |||
Transaction tx = pm.currentTransaction(); | |||
try | |||
{ | |||
tx.begin(); | |||
List<?> result = processConstraint( pm, constraint ); | |||
// Only detach if results are known to be persistable. | |||
if ( constraint.isResultsPersistable() ) | |||
{ | |||
result = (List<?>) pm.detachCopyAll( result ); | |||
} | |||
else | |||
{ | |||
List<Object> copiedResults = new ArrayList<Object>(); | |||
copiedResults.addAll( result ); | |||
result = copiedResults; | |||
} | |||
tx.commit(); | |||
return result; | |||
} | |||
finally | |||
{ | |||
rollbackIfActive( tx ); | |||
} | |||
} | |||
private List<?> processUnconstrained( PersistenceManager pm, Class<?> clazz ) | |||
{ | |||
Extent extent = pm.getExtent( clazz, true ); | |||
Query query = pm.newQuery( extent ); | |||
return (List<?>) query.execute(); | |||
} | |||
private List<?> processConstraint( PersistenceManager pm, SimpleConstraint constraint ) | |||
{ | |||
Query query = pm.newQuery( constraint.getSelectSql() ); | |||
if ( constraint.getResultClass() == null ) | |||
{ | |||
throw new IllegalStateException( "Unable to use a SimpleConstraint with a null result class." ); | |||
} | |||
query.setResultClass( constraint.getResultClass() ); | |||
if ( constraint.getFetchLimits() != null ) | |||
{ | |||
pm.getFetchPlan().addGroup( constraint.getFetchLimits() ); | |||
} | |||
if ( constraint.getParameters() != null ) | |||
{ | |||
return processParameterizedQuery( query, constraint.getParameters() ); | |||
} | |||
return (List<?>) query.execute(); | |||
} | |||
private List<?> processConstraint( PersistenceManager pm, Class<?> clazz, DeclarativeConstraint constraint ) | |||
{ | |||
Extent extent = pm.getExtent( clazz, true ); | |||
Query query = pm.newQuery( extent ); | |||
if ( constraint.getFilter() != null ) | |||
{ | |||
query.setFilter( constraint.getFilter() ); | |||
} | |||
if ( constraint.getVariables() != null ) | |||
{ | |||
query.declareVariables( StringUtils.join( constraint.getVariables(), "; " ) ); | |||
} | |||
if ( constraint.getSortColumn() != null ) | |||
{ | |||
String ordering = constraint.getSortColumn(); | |||
if ( constraint.getSortDirection() != null ) | |||
{ | |||
ordering += " " + constraint.getSortDirection(); | |||
} | |||
query.setOrdering( ordering ); | |||
} | |||
if ( constraint.getFetchLimits() != null ) | |||
{ | |||
pm.getFetchPlan().addGroup( constraint.getFetchLimits() ); | |||
} | |||
if ( constraint.getWhereCondition() != null ) | |||
{ | |||
query.setFilter( constraint.getWhereCondition() ); | |||
} | |||
if ( constraint.getDeclaredImports() != null ) | |||
{ | |||
query.declareImports( StringUtils.join( constraint.getDeclaredImports(), ", " ) ); | |||
} | |||
if ( constraint.getRange() != null ) | |||
{ | |||
query.setRange( constraint.getRange()[0], constraint.getRange()[1] ); | |||
} | |||
if ( constraint.getDeclaredParameters() != null ) | |||
{ | |||
if ( constraint.getParameters() == null ) | |||
{ | |||
throw new JDOException( "Unable to use query, there are declared parameters, " | |||
+ "but no parameter objects to use." ); | |||
} | |||
if ( constraint.getParameters().length != constraint.getDeclaredParameters().length ) | |||
{ | |||
throw new JDOException( "Unable to use query, there are <" + constraint.getDeclaredParameters().length | |||
+ "> declared parameters, yet there are <" + constraint.getParameters().length | |||
+ "> parameter objects to use. This should be equal." ); | |||
} | |||
query.declareParameters( StringUtils.join( constraint.getDeclaredParameters(), ", " ) ); | |||
return processParameterizedQuery( query, constraint.getParameters() ); | |||
} | |||
else | |||
{ | |||
return (List<?>) query.execute(); | |||
} | |||
} | |||
private List<?> processParameterizedQuery( Query query, Object parameters[] ) | |||
{ | |||
switch ( parameters.length ) | |||
{ | |||
case 1: | |||
return (List<?>) query.execute( parameters[0] ); | |||
case 2: | |||
return (List<?>) query.execute( parameters[0], parameters[1] ); | |||
case 3: | |||
return (List<?>) query.execute( parameters[0], parameters[1], parameters[2] ); | |||
default: | |||
throw new JDOException( "Unable to use more than 3 parameters." ); | |||
} | |||
} | |||
public Object getObjectById( Class<?> clazz, Object id, String fetchGroup ) | |||
throws ObjectNotFoundException, ArchivaDatabaseException | |||
{ | |||
if ( id == null ) | |||
{ | |||
throw new ObjectNotFoundException( "Unable to get object '" + clazz.getName() + "' from jdo using null id." ); | |||
} | |||
PersistenceManager pm = getPersistenceManager(); | |||
Transaction tx = pm.currentTransaction(); | |||
try | |||
{ | |||
tx.begin(); | |||
if ( fetchGroup != null ) | |||
{ | |||
pm.getFetchPlan().addGroup( fetchGroup ); | |||
} | |||
Object objectId = null; | |||
if ( id instanceof CompoundKey ) | |||
{ | |||
objectId = pm.newObjectIdInstance( clazz, id.toString() ); | |||
} | |||
else | |||
{ | |||
objectId = pm.newObjectIdInstance( clazz, id ); | |||
} | |||
Object object = pm.getObjectById( objectId ); | |||
object = pm.detachCopy( object ); | |||
tx.commit(); | |||
return object; | |||
} | |||
catch ( JDOObjectNotFoundException e ) | |||
{ | |||
throw new ObjectNotFoundException( "Unable to find Database Object [" + id + "] of type " + clazz.getName() | |||
+ " using " + ( ( fetchGroup == null ) ? "no fetch-group" : "a fetch-group of [" + fetchGroup + "]" ), | |||
e, id ); | |||
} | |||
catch ( JDOException e ) | |||
{ | |||
throw new ArchivaDatabaseException( "Error in JDO during get of Database object id [" + id + "] of type " | |||
+ clazz.getName() + " using " | |||
+ ( ( fetchGroup == null ) ? "no fetch-group" : "a fetch-group of [" + fetchGroup + "]" ), e ); | |||
} | |||
finally | |||
{ | |||
rollbackIfActive( tx ); | |||
} | |||
} | |||
public Object getObjectById( Class<?> clazz, String id, String fetchGroup ) | |||
throws ObjectNotFoundException, ArchivaDatabaseException | |||
{ | |||
if ( StringUtils.isEmpty( id ) ) | |||
{ | |||
throw new ObjectNotFoundException( "Unable to get object '" + clazz.getName() | |||
+ "' from jdo using null/empty id." ); | |||
} | |||
return getObjectById( clazz, (Object) id, fetchGroup ); | |||
} | |||
public boolean objectExists( Object object ) | |||
{ | |||
return ( JDOHelper.getObjectId( object ) != null ); | |||
} | |||
public boolean objectExistsById( Class<?> clazz, String id ) | |||
throws ArchivaDatabaseException | |||
{ | |||
try | |||
{ | |||
Object o = getObjectById( clazz, id, null ); | |||
return ( o != null ); | |||
} | |||
catch ( ObjectNotFoundException e ) | |||
{ | |||
return false; | |||
} | |||
} | |||
public void removeObject( Object o ) | |||
throws ArchivaDatabaseException | |||
{ | |||
if ( o == null ) | |||
{ | |||
throw new ArchivaDatabaseException( "Unable to remove null object" ); | |||
} | |||
PersistenceManager pm = getPersistenceManager(); | |||
Transaction tx = pm.currentTransaction(); | |||
try | |||
{ | |||
tx.begin(); | |||
o = pm.getObjectById( pm.getObjectId( o ) ); | |||
pm.deletePersistent( o ); | |||
tx.commit(); | |||
} | |||
finally | |||
{ | |||
rollbackIfActive( tx ); | |||
} | |||
} | |||
public void rollbackIfActive( Transaction tx ) | |||
{ | |||
PersistenceManager pm = tx.getPersistenceManager(); | |||
try | |||
{ | |||
if ( tx.isActive() ) | |||
{ | |||
tx.rollback(); | |||
} | |||
} | |||
finally | |||
{ | |||
closePersistenceManager( pm ); | |||
} | |||
} | |||
public void closePersistenceManager( PersistenceManager pm ) | |||
{ | |||
try | |||
{ | |||
pm.close(); | |||
} | |||
catch ( JDOUserException e ) | |||
{ | |||
// ignore | |||
} | |||
} | |||
public void postDelete( InstanceLifecycleEvent evt ) | |||
{ | |||
PersistenceCapable obj = ( (PersistenceCapable) evt.getSource() ); | |||
if ( obj == null ) | |||
{ | |||
// Do not track null objects. | |||
// These events are typically a product of an internal lifecycle event. | |||
return; | |||
} | |||
} | |||
public void preDelete( InstanceLifecycleEvent evt ) | |||
{ | |||
// ignore | |||
} | |||
public void postStore( InstanceLifecycleEvent evt ) | |||
{ | |||
// PersistenceCapable obj = ( (PersistenceCapable) evt.getSource() ); | |||
} | |||
public void preStore( InstanceLifecycleEvent evt ) | |||
{ | |||
// ignore | |||
} | |||
public void removeAll( Class<?> aClass ) | |||
{ | |||
PersistenceManager pm = getPersistenceManager(); | |||
Transaction tx = pm.currentTransaction(); | |||
try | |||
{ | |||
tx.begin(); | |||
Query query = pm.newQuery( aClass ); | |||
query.deletePersistentAll(); | |||
tx.commit(); | |||
} | |||
finally | |||
{ | |||
rollbackIfActive( tx ); | |||
} | |||
} | |||
public JdoFactory getJdoFactory() | |||
{ | |||
return jdoFactory; | |||
} | |||
} |
@@ -1,63 +0,0 @@ | |||
package org.apache.maven.archiva.database.jdo; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.util.List; | |||
import org.apache.maven.archiva.database.ArchivaDAO; | |||
import org.apache.maven.archiva.database.ArtifactDAO; | |||
import org.apache.maven.archiva.database.SimpleConstraint; | |||
/** | |||
* JdoArchivaDAO | |||
* | |||
* @version $Id$ | |||
* | |||
* @plexus.component role-hint="jdo" | |||
*/ | |||
public class JdoArchivaDAO | |||
implements ArchivaDAO | |||
{ | |||
/** | |||
* @plexus.requirement role-hint="archiva" | |||
*/ | |||
private JdoAccess jdo; | |||
/** | |||
* @plexus.requirement role-hint="jdo" | |||
*/ | |||
private ArtifactDAO artifactDAO; | |||
public JdoArchivaDAO() | |||
{ | |||
super(); //To change body of overridden methods use File | Settings | File Templates. | |||
} | |||
public List<?> query( SimpleConstraint constraint ) | |||
{ | |||
return jdo.queryObjects( constraint ); | |||
} | |||
public ArtifactDAO getArtifactDAO() | |||
{ | |||
return artifactDAO; | |||
} | |||
} |
@@ -1,120 +0,0 @@ | |||
package org.apache.maven.archiva.database.jdo; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import org.apache.maven.archiva.database.ArchivaDatabaseException; | |||
import org.apache.maven.archiva.database.ArtifactDAO; | |||
import org.apache.maven.archiva.database.Constraint; | |||
import org.apache.maven.archiva.database.ObjectNotFoundException; | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import org.apache.maven.archiva.model.ArchivaArtifactModel; | |||
import org.apache.maven.archiva.model.jpox.ArchivaArtifactModelKey; | |||
/** | |||
* JdoArtifactDAO | |||
* | |||
* @version $Id$ | |||
* | |||
* @plexus.component role-hint="jdo" | |||
*/ | |||
public class JdoArtifactDAO | |||
implements ArtifactDAO | |||
{ | |||
/** | |||
* @plexus.requirement role-hint="archiva" | |||
*/ | |||
private JdoAccess jdo; | |||
/* .\ Archiva Artifact \. _____________________________________________________________ */ | |||
public ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String classifier, | |||
String type, String repositoryId ) | |||
{ | |||
ArchivaArtifact artifact; | |||
try | |||
{ | |||
artifact = getArtifact( groupId, artifactId, version, classifier, type, repositoryId ); | |||
} | |||
catch ( ArchivaDatabaseException e ) | |||
{ | |||
artifact = new ArchivaArtifact( groupId, artifactId, version, classifier, type, repositoryId ); | |||
} | |||
return artifact; | |||
} | |||
public ArchivaArtifact getArtifact( String groupId, String artifactId, String version, String classifier, | |||
String type, String repositoryId ) | |||
throws ObjectNotFoundException, ArchivaDatabaseException | |||
{ | |||
ArchivaArtifactModelKey key = new ArchivaArtifactModelKey(); | |||
key.setGroupId( groupId ); | |||
key.setArtifactId( artifactId ); | |||
key.setVersion( version ); | |||
key.setClassifier( classifier ); | |||
key.setType( type ); | |||
key.setRepositoryId( repositoryId ); | |||
ArchivaArtifactModel model = (ArchivaArtifactModel) jdo.getObjectById( ArchivaArtifactModel.class, key, null ); | |||
return new ArchivaArtifact( model ); | |||
} | |||
@SuppressWarnings("unchecked") | |||
public List<ArchivaArtifact> queryArtifacts( Constraint constraint ) | |||
throws ObjectNotFoundException, ArchivaDatabaseException | |||
{ | |||
List<ArchivaArtifactModel> results = (List<ArchivaArtifactModel>) jdo.queryObjects( ArchivaArtifactModel.class, constraint ); | |||
if ( results == null ) | |||
{ | |||
return null; | |||
} | |||
List<ArchivaArtifact> ret = new ArrayList<ArchivaArtifact>(); | |||
for ( ArchivaArtifactModel model : results ) | |||
{ | |||
ret.add( new ArchivaArtifact( model ) ); | |||
} | |||
return ret; | |||
} | |||
public ArchivaArtifact saveArtifact( ArchivaArtifact artifact ) | |||
throws ArchivaDatabaseException | |||
{ | |||
ArchivaArtifactModel model = (ArchivaArtifactModel) jdo.saveObject( artifact.getModel() ); | |||
if ( model == null ) | |||
{ | |||
return null; | |||
} | |||
return new ArchivaArtifact( model ); | |||
} | |||
public void deleteArtifact( ArchivaArtifact artifact ) | |||
throws ArchivaDatabaseException | |||
{ | |||
jdo.removeObject( artifact.getModel() ); | |||
} | |||
} |
@@ -1,26 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> | |||
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" | |||
"http://ibatis.apache.org/dtd/sql-map-2.dtd"> | |||
<sqlMap namespace="ArtifactKey"> | |||
<select id="getArtifactKey" resultClass="org.apache.maven.archiva.database.artifact.ArtifactKey"> | |||
SELECT | |||
ARTIFACT_KEY as id | |||
GROUP_ID as groupId, | |||
ARTIFACT_ID as artifactId, | |||
VERSION as version, | |||
CLASSIFER as classifier, | |||
TYPE as type, | |||
FROM ARTIFACT_KEYS | |||
WHERE ARTIFACT_KEY = #value# | |||
</select> | |||
<insert id="addArtifactKey" parameterClass="org.apache.maven.archiva.database.artifact.ArtifactKey"> | |||
INSERT INTO | |||
ARTIFACT_KEYS ( GROUP_ID, ARTIFACT_ID, VERSION_ID, CLASSIFIER, TYPE ) | |||
VALUES (#groupId#, #artifactId#, #version# ) | |||
</insert> | |||
</sqlMap> |
@@ -1,87 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> | |||
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" | |||
"http://ibatis.apache.org/dtd/sql-map-2.dtd"> | |||
<sqlMap namespace="CreateTables"> | |||
<!-- .\ ARTIFACT \.________________________________________________________________________________________ --> | |||
<statement id="createArtifactKeys"> | |||
CREATE TABLE ArtifactKeys ( | |||
GROUP_ID varchar (100) not null, | |||
ARTIFACT_ID varchar (100) not null, | |||
VERSION varchar (50) not null, | |||
CLASSIFIER varchar (50), | |||
TYPE varchar (20), | |||
ARTIFACT_KEY integer generated always as identity ( start with 1 ), | |||
primary key ( GROUP_ID, ARTIFACT_ID, VERSION, CLASSIFIER, TYPE ) | |||
) | |||
</statement> | |||
<statement id="dropArtifactKeys"> | |||
DROP TABLE ArtifactKeys | |||
</statement> | |||
<!-- .\ METADATA \.________________________________________________________________________________________ --> | |||
<!-- | |||
METADATA_KEYS is the index table for all other tables | |||
need to make the lookup on this table fast, perhaps by indexing the combination of g:a:v in a lookup column | |||
TODO: Ensure that there is never a duplicate of the multi-part complex key (groupId, artifactId, version) | |||
--> | |||
<statement id="createMetadataKeys"> | |||
CREATE TABLE MetadataKeys ( | |||
metadataKey integer generated always as identity ( start with 1 ) primary key, | |||
groupId varchar(100) not null, | |||
artifactId varchar(100) not null, | |||
version varchar(100) not null | |||
) | |||
</statement> | |||
<statement id="dropMetadataKeys"> | |||
DROP TABLE MetadataKeys | |||
</statement> | |||
<statement id="createRepositoryMetadata"> | |||
CREATE TABLE RepositoryMetadata ( | |||
metadataKey integer not null, | |||
id integer generated always as identity ( start with 1 ) primary key, | |||
latest varchar(100) not null, | |||
release varchar(100) not null, | |||
lastUpdated integer, | |||
snapshotTimestamp integer, | |||
snapshotBuildNumber integer, | |||
snapshotLocalCopy char(1), | |||
foreign key( metadataKey ) references MetadataKeys( metadataKey ) | |||
) | |||
</statement> | |||
<statement id="dropRepositoryMetadata"> | |||
DROP TABLE RepositoryMetadata | |||
</statement> | |||
<statement id="createHealthMetadata"> | |||
CREATE TABLE HealthMetadata ( | |||
metadataKey integer not null, | |||
id integer generated always as identity ( start with 1 ) primary key, | |||
processId varchar(100) not null, | |||
problemId varchar(100) not null, | |||
message varchar(8000) not null, | |||
foreign key( metadataKey ) references MetadataKeys( metadataKey ) | |||
) | |||
</statement> | |||
<statement id="createVersionsMetadata"> | |||
CREATE TABLE VersionMetadata ( | |||
metadataKey integer not null, | |||
id integer generated always as identity ( start with 1 ) primary key, | |||
version varchar(100) not null, | |||
foreign key( metadataKey ) references MetadataKeys( metadataKey ) | |||
) | |||
</statement> | |||
</sqlMap> |
@@ -1,33 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> | |||
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" | |||
"http://ibatis.apache.org/dtd/sql-map-2.dtd"> | |||
<sqlMap namespace="MetadataKey"> | |||
<!-- | |||
this query can be improved by adding a lookup index based on these trinity of values | |||
--> | |||
<select id="getMetadataKey" resultClass="org.apache.maven.archiva.database.key.MetadataKey"> | |||
SELECT | |||
metadataKey, | |||
groupId, | |||
artifactId, | |||
version | |||
FROM MetadataKeys | |||
WHERE groupId = #groupId# and artifactId = #artifactId# and version = #version# | |||
</select> | |||
<insert id="addMetadataKey" parameterClass="org.apache.maven.artifact.repository.metadata.Metadata"> | |||
INSERT INTO | |||
MetadataKeys ( groupId, artifactId, version ) | |||
VALUES ( #groupId#, #artifactId#, #version# ) | |||
</insert> | |||
<delete id="removeMetadataKey" parameterClass="org.apache.maven.archiva.database.key.MetadataKey"> | |||
DELETE FROM | |||
MetadataKeys | |||
WHERE metadataKey=#metadataKey# | |||
</delete> | |||
</sqlMap> |
@@ -1,50 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> | |||
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" | |||
"http://ibatis.apache.org/dtd/sql-map-2.dtd"> | |||
<!-- | |||
metadataKey integer not null, | |||
id integer generated always as identity ( start with 1 ) primary key, | |||
latest varchar(100) not null, | |||
release varchar(100) not null, | |||
lastUpdated integer not null, | |||
snapshotTimestamp integer not null, | |||
snapshotBuildNumber integer not null, | |||
snapshotLocalCopy char(1) not null, | |||
foreign key( metadataKey ) references MetadataKeys( metadataKey ) | |||
--> | |||
<sqlMap namespace="RepositoryMetadata"> | |||
<select id="getRepositoryMetadata" | |||
parameterClass="org.apache.maven.archiva.database.key.MetadataKey" | |||
resultClass="org.apache.maven.artifact.repository.metadata.Metadata"> | |||
SELECT | |||
mk.groupId AS groupId, | |||
mk.artifactId AS artifactId, | |||
mk.version AS baseVersion, | |||
rm.latest AS latest, | |||
rm.release AS release, | |||
rm.lastUpdated AS lastUpdated | |||
FROM RepositoryMetadata rm, MetadataKeys mk | |||
WHERE | |||
mk.metadataKey = rm.metadataKey | |||
AND mk.metadataKey = #metadataKey# | |||
</select> | |||
<!-- | |||
<insert id="addRepositoryMetadata" parameterClass="org.apache.maven.artifact.repository.metadata.Metadata"> | |||
INSERT INTO | |||
RepositoryMetadata ( latest, release, lastUpdated ) | |||
VALUES ( #latest#, #release#, #lastUpdated# ) | |||
</insert> | |||
--> | |||
<delete id="removeRepositoryMetadata" parameterClass="org.apache.maven.archiva.database.key.MetadataKey"> | |||
DELETE FROM | |||
RepositoryMetadata | |||
WHERE metadataKey=#metadataKey# | |||
</delete> | |||
</sqlMap> |
@@ -1,181 +0,0 @@ | |||
package org.apache.maven.archiva.database; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.io.File; | |||
import java.net.URL; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Date; | |||
import java.util.Map; | |||
import java.util.Properties; | |||
import javax.jdo.PersistenceManager; | |||
import javax.jdo.PersistenceManagerFactory; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.apache.maven.archiva.model.ArtifactReference; | |||
import org.apache.maven.archiva.model.VersionedReference; | |||
import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory; | |||
import org.codehaus.plexus.jdo.JdoFactory; | |||
import org.codehaus.plexus.spring.PlexusInSpringTestCase; | |||
import org.jpox.SchemaTool; | |||
/** | |||
* AbstractArchivaDatabaseTestCase | |||
* | |||
* @version $Id$ | |||
*/ | |||
public abstract class AbstractArchivaDatabaseTestCase | |||
extends PlexusInSpringTestCase | |||
{ | |||
private static final String TIMESTAMP = "yyyy/MM/dd HH:mm:ss"; | |||
protected ArchivaDAO dao; | |||
@Override | |||
protected void setUp() | |||
throws Exception | |||
{ | |||
super.setUp(); | |||
DefaultConfigurableJdoFactory jdoFactory = (DefaultConfigurableJdoFactory) lookup( JdoFactory.ROLE, "archiva" ); | |||
assertEquals( DefaultConfigurableJdoFactory.class.getName(), jdoFactory.getClass().getName() ); | |||
jdoFactory.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" ); | |||
/* derby version | |||
File derbyDbDir = new File( "target/plexus-home/testdb" ); | |||
if ( derbyDbDir.exists() ) | |||
{ | |||
FileUtils.deleteDirectory( derbyDbDir ); | |||
} | |||
jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.apache.derby.jdbc.EmbeddedDriver" ) ); | |||
jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:derby:" + derbyDbDir.getAbsolutePath() + ";create=true" ) ); | |||
*/ | |||
jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.hsqldb.jdbcDriver" ) ); | |||
jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:hsqldb:mem:" + getName() ) ); | |||
jdoFactory.setUserName( System.getProperty( "jdo.test.user", "sa" ) ); | |||
jdoFactory.setPassword( System.getProperty( "jdo.test.pass", "" ) ); | |||
jdoFactory.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" ); | |||
jdoFactory.setProperty( "org.jpox.poid.transactionIsolation", "READ_COMMITTED" ); | |||
jdoFactory.setProperty( "org.jpox.autoCreateSchema", "true" ); | |||
jdoFactory.setProperty( "javax.jdo.option.RetainValues", "true" ); | |||
jdoFactory.setProperty( "javax.jdo.option.RestoreValues", "true" ); | |||
// jdoFactory.setProperty( "org.jpox.autoCreateColumns", "true" ); | |||
jdoFactory.setProperty( "org.jpox.validateTables", "true" ); | |||
jdoFactory.setProperty( "org.jpox.validateColumns", "true" ); | |||
jdoFactory.setProperty( "org.jpox.validateConstraints", "true" ); | |||
Properties properties = jdoFactory.getProperties(); | |||
for ( Map.Entry<Object,Object> entry : properties.entrySet() ) | |||
{ | |||
System.setProperty( (String) entry.getKey(), (String) entry.getValue() ); | |||
} | |||
URL jdoFileUrls[] = new URL[] { getClass().getResource( "/org/apache/maven/archiva/model/package.jdo" ) }; | |||
if ( ( jdoFileUrls == null ) || ( jdoFileUrls[0] == null ) ) | |||
{ | |||
fail( "Unable to process test " + getName() + " - missing package.jdo." ); | |||
} | |||
File propsFile = null; // intentional | |||
boolean verbose = true; | |||
SchemaTool.deleteSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose ); | |||
SchemaTool.createSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose, null ); | |||
PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory(); | |||
assertNotNull( pmf ); | |||
PersistenceManager pm = pmf.getPersistenceManager(); | |||
pm.close(); | |||
this.dao = (ArchivaDAO) lookup( ArchivaDAO.class.getName(), "jdo" ); | |||
} | |||
protected Date toDate( String txt ) | |||
throws Exception | |||
{ | |||
SimpleDateFormat sdf = new SimpleDateFormat( TIMESTAMP ); | |||
return sdf.parse( txt ); | |||
} | |||
protected String fromDate( Date date ) | |||
throws Exception | |||
{ | |||
SimpleDateFormat sdf = new SimpleDateFormat( TIMESTAMP ); | |||
return sdf.format( date ); | |||
} | |||
protected VersionedReference toVersionedReference( String id ) | |||
{ | |||
String parts[] = StringUtils.splitPreserveAllTokens( id, ':' ); | |||
assertEquals( "Should have 3 parts [" + id + "]", 3, parts.length ); | |||
VersionedReference ref = new VersionedReference(); | |||
ref.setGroupId( parts[0] ); | |||
ref.setArtifactId( parts[1] ); | |||
ref.setVersion( parts[2] ); | |||
assertTrue( "Group ID should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getGroupId() ) ); | |||
assertTrue( "Artifact ID should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getArtifactId() ) ); | |||
assertTrue( "Version should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getVersion() ) ); | |||
return ref; | |||
} | |||
protected ArtifactReference toArtifactReference( String id ) | |||
{ | |||
String parts[] = StringUtils.splitPreserveAllTokens( id, ':' ); | |||
assertEquals( "Should have 6 parts [" + id + "]", 6, parts.length ); | |||
ArtifactReference ref = new ArtifactReference(); | |||
ref.setGroupId( parts[0] ); | |||
ref.setArtifactId( parts[1] ); | |||
ref.setVersion( parts[2] ); | |||
ref.setClassifier( parts[3] ); | |||
ref.setType( parts[4] ); | |||
assertTrue( "Group ID should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getGroupId() ) ); | |||
assertTrue( "Artifact ID should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getArtifactId() ) ); | |||
assertTrue( "Version should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getVersion() ) ); | |||
// Blank string is ok for classifier, NULL is not. | |||
assertNotNull( "Classifier should not be null [" + id + "]", ref.getClassifier() ); | |||
assertTrue( "Type should not be blank [" + id + "]", StringUtils.isNotBlank( ref.getType() ) ); | |||
return ref; | |||
} | |||
} |
@@ -1,151 +0,0 @@ | |||
package org.apache.maven.archiva.database; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.util.Date; | |||
import java.util.List; | |||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import org.apache.maven.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.maven.archiva.repository.events.RepositoryListener; | |||
import org.codehaus.plexus.spring.PlexusToSpringUtils; | |||
public class RepositoryDatabaseEventListenerTest | |||
extends AbstractArchivaDatabaseTestCase | |||
{ | |||
private RepositoryListener listener; | |||
@Override | |||
protected void setUp() | |||
throws Exception | |||
{ | |||
super.setUp(); | |||
listener = (RepositoryListener) lookup( RepositoryListener.class.getName(), "database" ); | |||
} | |||
@SuppressWarnings("unchecked") | |||
public void testWiring() | |||
{ | |||
List<RepositoryListener> listeners = | |||
PlexusToSpringUtils.lookupList( PlexusToSpringUtils.buildSpringId( RepositoryListener.class ), | |||
getApplicationContext() ); | |||
assertEquals( 1, listeners.size() ); | |||
assertEquals( listener, listeners.get( 0 ) ); | |||
} | |||
public ArchivaArtifact createArtifact( String artifactId, String version, ArtifactDAO artifactDao, String type ) | |||
{ | |||
ArchivaArtifact artifact = | |||
artifactDao.createArtifact( "org.apache.maven.archiva.test", artifactId, version, "", type, "testable_repo" ); | |||
artifact.getModel().setLastModified( new Date() ); | |||
artifact.getModel().setRepositoryId( "testable_repo" ); | |||
return artifact; | |||
} | |||
public void testDeleteArtifact() | |||
throws Exception | |||
{ | |||
ArtifactDAO artifactDao = (ArtifactDAO) lookup( ArtifactDAO.class.getName(), "jdo" ); | |||
ArchivaArtifact pomArtifact = createPom( artifactDao ); | |||
ArchivaArtifact jarArtifact = createJar( artifactDao ); | |||
assertEquals( pomArtifact, artifactDao.getArtifact( "org.apache.maven.archiva.test", "test-artifact", "1.0", | |||
null, "pom", "testable_repo" ) ); | |||
assertEquals( jarArtifact, artifactDao.getArtifact( "org.apache.maven.archiva.test", "test-artifact", "1.0", | |||
null, "jar", "testable_repo" ) ); | |||
jarArtifact = new ArchivaArtifact( "org.apache.maven.archiva.test", "test-artifact", "1.0", null, "jar", "testable_repo" ); | |||
ManagedRepositoryContent repository = | |||
(ManagedRepositoryContent) lookup( ManagedRepositoryContent.class.getName(), "default" ); | |||
ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration(); | |||
configuration.setId("testable_repo"); | |||
repository.setRepository(configuration); | |||
listener.deleteArtifact( repository, jarArtifact ); | |||
try | |||
{ | |||
artifactDao.getArtifact( "org.apache.maven.archiva.test", "test-artifact", "1.0", null, "jar", "testable_repo" ); | |||
fail( "Should not find artifact" ); | |||
} | |||
catch ( ObjectNotFoundException e ) | |||
{ | |||
assertTrue( true ); | |||
} | |||
assertEquals( pomArtifact, artifactDao.getArtifact( "org.apache.maven.archiva.test", "test-artifact", "1.0", | |||
null, "pom", "testable_repo" ) ); | |||
} | |||
private ArchivaArtifact createJar( ArtifactDAO artifactDao ) | |||
throws ArchivaDatabaseException | |||
{ | |||
ArchivaArtifact artifact = createArtifact( "test-artifact", "1.0", artifactDao, "jar" ); | |||
artifactDao.saveArtifact( artifact ); | |||
return artifact; | |||
} | |||
public void testDeletePomArtifact() | |||
throws Exception | |||
{ | |||
ArtifactDAO artifactDao = (ArtifactDAO) lookup( ArtifactDAO.class.getName(), "jdo" ); | |||
ArchivaArtifact pomArtifact = createPom( artifactDao ); | |||
ArchivaArtifact jarArtifact = createJar( artifactDao ); | |||
assertEquals( pomArtifact, artifactDao.getArtifact( "org.apache.maven.archiva.test", "test-artifact", "1.0", | |||
null, "pom", "testable_repo" ) ); | |||
assertEquals( jarArtifact, artifactDao.getArtifact( "org.apache.maven.archiva.test", "test-artifact", "1.0", | |||
null, "jar", "testable_repo" ) ); | |||
pomArtifact = new ArchivaArtifact( "org.apache.maven.archiva.test", "test-artifact", "1.0", null, "pom", "testable_repo" ); | |||
ManagedRepositoryContent repository = | |||
(ManagedRepositoryContent) lookup( ManagedRepositoryContent.class.getName(), "default" ); | |||
ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration(); | |||
configuration.setId("testable_repo"); | |||
repository.setRepository(configuration); | |||
listener.deleteArtifact( repository, pomArtifact ); | |||
try | |||
{ | |||
artifactDao.getArtifact( "org.apache.maven.archiva.test", "test-artifact", "1.0", null, "pom", "testable_repo" ); | |||
fail( "Should not find artifact" ); | |||
} | |||
catch ( ObjectNotFoundException e ) | |||
{ | |||
assertTrue( true ); | |||
} | |||
assertEquals( jarArtifact, artifactDao.getArtifact( "org.apache.maven.archiva.test", "test-artifact", "1.0", | |||
null, "jar", "testable_repo" ) ); | |||
} | |||
private ArchivaArtifact createPom( ArtifactDAO artifactDao ) | |||
throws ArchivaDatabaseException | |||
{ | |||
ArchivaArtifact artifact = createArtifact( "test-artifact", "1.0", artifactDao, "pom" ); | |||
artifactDao.saveArtifact( artifact ); | |||
return artifact; | |||
} | |||
} |
@@ -1,107 +0,0 @@ | |||
package org.apache.maven.archiva.database.constraints; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.util.Calendar; | |||
import java.util.Date; | |||
import java.util.List; | |||
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; | |||
/** | |||
* ArtifactVersionsConstraintTest | |||
* | |||
* @version | |||
*/ | |||
public class ArtifactVersionsConstraintTest | |||
extends AbstractArchivaDatabaseTestCase | |||
{ | |||
private ArtifactDAO artifactDao; | |||
public static final String TEST_REPO = "test-repo"; | |||
@Override | |||
public void setUp() | |||
throws Exception | |||
{ | |||
super.setUp(); | |||
ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" ); | |||
artifactDao = dao.getArtifactDAO(); | |||
} | |||
private ArchivaArtifact createArtifact( String groupId, String artifactId, String version ) | |||
{ | |||
ArchivaArtifact artifact = artifactDao.createArtifact( groupId, artifactId, version, null, "jar", TEST_REPO ); | |||
artifact.getModel().setLastModified( new Date() ); | |||
artifact.getModel().setRepositoryId( TEST_REPO ); | |||
return artifact; | |||
} | |||
private void populateDb() | |||
throws Exception | |||
{ | |||
Date whenGathered = Calendar.getInstance().getTime(); | |||
whenGathered.setTime( 123456789 ); | |||
ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0" ); | |||
artifact.getModel().setWhenGathered( null ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.2" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0" ); | |||
artifact.getModel().setRepositoryId( "different-repo" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
} | |||
public void testQueryAllVersionsOfArtifactAcrossRepos() throws Exception | |||
{ | |||
populateDb(); | |||
assertConstraint( "Artifacts By Repository", 3, | |||
new ArtifactVersionsConstraint( null, "org.apache.archiva", "artifact-one", true ) ); | |||
} | |||
public void testQueryAllVersionsOfArtifactInARepo() throws Exception | |||
{ | |||
populateDb(); | |||
assertConstraint( "Artifacts By Repository", 2, | |||
new ArtifactVersionsConstraint( TEST_REPO, "org.apache.archiva", "artifact-one", true ) ); | |||
} | |||
private void assertConstraint( String msg, int count, ArtifactVersionsConstraint constraint ) | |||
throws Exception | |||
{ | |||
List<ArchivaArtifact> results = artifactDao.queryArtifacts( constraint ); | |||
assertNotNull( msg + ": Not Null", results ); | |||
assertEquals( msg + ": Results.size", count, results.size() ); | |||
} | |||
} |
@@ -1,174 +0,0 @@ | |||
package org.apache.maven.archiva.database.constraints; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.util.Calendar; | |||
import java.util.Date; | |||
import java.util.List; | |||
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; | |||
/** | |||
* ArtifactsByRepositoryConstraintTest | |||
* | |||
* @version | |||
*/ | |||
public class ArtifactsByRepositoryConstraintTest | |||
extends AbstractArchivaDatabaseTestCase | |||
{ | |||
private ArtifactDAO artifactDao; | |||
public void setUp() | |||
throws Exception | |||
{ | |||
super.setUp(); | |||
ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" ); | |||
artifactDao = dao.getArtifactDAO(); | |||
} | |||
private ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String type ) | |||
{ | |||
ArchivaArtifact artifact = artifactDao.createArtifact( groupId, artifactId, version, null, type, "test-repo" ); | |||
artifact.getModel().setLastModified( new Date() ); | |||
artifact.getModel().setRepositoryId( "test-repo" ); | |||
return artifact; | |||
} | |||
public void testQueryAllArtifactsInRepo() | |||
throws Exception | |||
{ | |||
Date whenGathered = Calendar.getInstance().getTime(); | |||
whenGathered.setTime( 123456789 ); | |||
ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0", "jar" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1", "jar" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.0.2", "jar" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0", "jar" ); | |||
artifact.getModel().setRepositoryId( "different-repo" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
assertConstraint( "Artifacts By Repository", 3, new ArtifactsByRepositoryConstraint( "test-repo" ) ); | |||
} | |||
public void testQueryArtifactsInRepoWithWhenGathered() | |||
throws Exception | |||
{ | |||
Date whenGathered = Calendar.getInstance().getTime(); | |||
ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0", "jar" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1", "jar" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.2", "jar" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0", "jar" ); | |||
artifact.getModel().setRepositoryId( "different-repo" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
Date olderWhenGathered = Calendar.getInstance().getTime(); | |||
olderWhenGathered.setTime( 123456789 ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.1-SNAPSHOT", "jar" ); | |||
artifact.getModel().setWhenGathered( olderWhenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-three", "2.0-beta-1", "jar" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
assertConstraint( "Artifacts By Repository and When Gathered", 4, | |||
new ArtifactsByRepositoryConstraint( "test-repo", whenGathered, "repositoryId", false ) ); | |||
} | |||
public void testQueryArtifactsInRepoByType() | |||
throws Exception | |||
{ | |||
Calendar cal = Calendar.getInstance(); | |||
cal.set( 2008, 9, 1 ); | |||
Date whenGathered = cal.getTime(); | |||
ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0", "jar" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1", "jar" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.2", "jar" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.1-SNAPSHOT", "war" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-three", "2.0-beta-1", "war" ); | |||
artifact.getModel().setWhenGathered( whenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
Calendar cal2 = Calendar.getInstance(); | |||
cal2.set( 2008, 12, 12 ); | |||
Date diffWhenGathered = cal2.getTime(); | |||
artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0", "jar" ); | |||
artifact.getModel().setWhenGathered( diffWhenGathered ); | |||
artifactDao.saveArtifact( artifact ); | |||
cal2 = Calendar.getInstance(); | |||
cal2.set( 2008, 10, 30 ); | |||
Date before = cal2.getTime(); | |||
assertConstraint( "Artifacts of Type 'jar' By Repository and When Gathered", 3, | |||
new ArtifactsByRepositoryConstraint( "test-repo", "jar", before, "whenGathered" ) ); | |||
assertConstraint( "Artifacts of Type 'war' By Repository and When Gathered", 2, | |||
new ArtifactsByRepositoryConstraint( "test-repo", "war", before, "whenGathered" ) ); | |||
} | |||
private void assertConstraint( String msg, int count, ArtifactsByRepositoryConstraint constraint ) | |||
throws Exception | |||
{ | |||
List<ArchivaArtifact> results = artifactDao.queryArtifacts( constraint ); | |||
assertNotNull( msg + ": Not Null", results ); | |||
assertEquals( msg + ": Results.size", count, results.size() ); | |||
} | |||
} |
@@ -1,36 +0,0 @@ | |||
package org.apache.maven.archiva.database.jdo; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase; | |||
/** | |||
* JdoArchivaDAOTest | |||
* | |||
* @version $Id$ | |||
*/ | |||
public class JdoArchivaDAOTest | |||
extends AbstractArchivaDatabaseTestCase | |||
{ | |||
public void testSubDAOs() | |||
{ | |||
assertNotNull( "Artifact DAO", dao.getArtifactDAO() ); | |||
} | |||
} |
@@ -1,112 +0,0 @@ | |||
package org.apache.maven.archiva.database.jdo; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.util.Date; | |||
import java.util.List; | |||
import javax.jdo.JDOHelper; | |||
import javax.jdo.spi.JDOImplHelper; | |||
import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase; | |||
import org.apache.maven.archiva.database.ArtifactDAO; | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import org.apache.maven.archiva.model.ArchivaArtifactModel; | |||
import org.apache.maven.archiva.model.jpox.ArchivaArtifactModelKey; | |||
/** | |||
* JdoArtifactDAOTest | |||
* | |||
* @version $Id$ | |||
*/ | |||
public class JdoArtifactDAOTest | |||
extends AbstractArchivaDatabaseTestCase | |||
{ | |||
public void testArtifactKey() | |||
{ | |||
Object o = JDOImplHelper.getInstance().newObjectIdInstance( ArchivaArtifactModel.class, "foo:bar:1.0::jar:testrepo" ); | |||
assertNotNull( "Key should not be null.", o ); | |||
assertTrue( "Key should be an instance of " + ArchivaArtifactModelKey.class.getName(), | |||
( o instanceof ArchivaArtifactModelKey ) ); | |||
ArchivaArtifactModelKey key = (ArchivaArtifactModelKey) o; | |||
assertEquals( "foo", key.groupId ); | |||
assertEquals( "bar", key.artifactId ); | |||
assertEquals( "1.0", key.version ); | |||
assertEquals( "", key.classifier ); | |||
assertEquals( "jar", key.type ); | |||
assertEquals("testrepo", key.repositoryId); | |||
} | |||
public void testArtifactCRUD() | |||
throws Exception | |||
{ | |||
ArtifactDAO artiDao = dao.getArtifactDAO(); | |||
// Create it | |||
ArchivaArtifact artifact = artiDao.createArtifact( "org.apache.maven.archiva", "archiva-test-module", "1.0", | |||
"", "jar", "testrepo" ); | |||
assertNotNull( artifact ); | |||
// Set some mandatory values | |||
artifact.getModel().setLastModified( new Date() ); | |||
// Save it. | |||
ArchivaArtifact savedArtifact = artiDao.saveArtifact( artifact ); | |||
assertNotNull( savedArtifact ); | |||
String savedKeyId = JDOHelper.getObjectId( savedArtifact.getModel() ).toString(); | |||
assertEquals( "org.apache.maven.archiva:archiva-test-module:1.0::jar:testrepo", savedKeyId ); | |||
// Test that something has been saved. | |||
List<ArchivaArtifact> artifacts = artiDao.queryArtifacts( null ); | |||
assertNotNull( artifacts ); | |||
assertEquals( 1, artifacts.size() ); | |||
// Test that retrieved object is what we expect. | |||
ArchivaArtifact firstArtifact = (ArchivaArtifact) artifacts.get( 0 ); | |||
assertNotNull( firstArtifact ); | |||
assertEquals( "org.apache.maven.archiva", firstArtifact.getGroupId() ); | |||
assertEquals( "archiva-test-module", firstArtifact.getArtifactId() ); | |||
assertEquals( "1.0", firstArtifact.getVersion() ); | |||
assertEquals( "", firstArtifact.getClassifier() ); | |||
assertEquals( "jar", firstArtifact.getType() ); | |||
// Change value and save. | |||
savedArtifact.getModel().setLastModified( new Date() ); | |||
artiDao.saveArtifact( savedArtifact ); | |||
// Test that only 1 object is saved. | |||
assertEquals( 1, artiDao.queryArtifacts( null ).size() ); | |||
// Get the specific artifact. | |||
ArchivaArtifact actualArtifact = artiDao.getArtifact( "org.apache.maven.archiva", "archiva-test-module", "1.0", | |||
null, "jar", "testrepo" ); | |||
assertNotNull( actualArtifact ); | |||
// Test expected values. | |||
assertEquals( "archiva-test-module", actualArtifact.getArtifactId() ); | |||
// Test that only 1 object is saved. | |||
assertEquals( 1, artiDao.queryArtifacts( null ).size() ); | |||
// Delete object. | |||
artiDao.deleteArtifact( actualArtifact ); | |||
assertEquals( 0, artiDao.queryArtifacts( null ).size() ); | |||
} | |||
} |
@@ -1,19 +0,0 @@ | |||
<component-set> | |||
<components> | |||
<component> | |||
<role>org.codehaus.plexus.jdo.JdoFactory</role> | |||
<role-hint>archiva</role-hint> | |||
<implementation>org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory</implementation> | |||
<configuration> | |||
<persistenceManagerFactoryClass>org.jpox.PersistenceManagerFactoryImpl</persistenceManagerFactoryClass> | |||
<otherProperties> | |||
<property> | |||
<name>javax.jdo.PersistenceManagerFactoryClass</name> | |||
<value>org.jpox.PersistenceManagerFactoryImpl</value> | |||
</property> | |||
</otherProperties> | |||
</configuration> | |||
</component> | |||
</components> | |||
</component-set> | |||
@@ -1,152 +0,0 @@ | |||
<?xml version="1.0" encoding="ISO-8859-1"?> | |||
<!-- | |||
~ Licensed to the Apache Software Foundation (ASF) under one | |||
~ or more contributor license agreements. See the NOTICE file | |||
~ distributed with this work for additional information | |||
~ regarding copyright ownership. The ASF licenses this file | |||
~ to you under the Apache License, Version 2.0 (the | |||
~ "License"); you may not use this file except in compliance | |||
~ with the License. You may obtain a copy of the License at | |||
~ | |||
~ http://www.apache.org/licenses/LICENSE-2.0 | |||
~ | |||
~ Unless required by applicable law or agreed to in writing, | |||
~ software distributed under the License is distributed on an | |||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
~ KIND, either express or implied. See the License for the | |||
~ specific language governing permissions and limitations | |||
~ under the License. | |||
--> | |||
<configuration> | |||
<repositories> | |||
<repository> | |||
<id>internal</id> | |||
<name>Archiva Managed Internal Repository</name> | |||
<url>file://${appserver.home}/repositories/internal</url> | |||
<layout>default</layout> | |||
<releases>true</releases> | |||
<snapshots>false</snapshots> | |||
<indexed>true</indexed> | |||
<refreshCronExpression>0 0 * * * ?</refreshCronExpression> | |||
</repository> | |||
<repository> | |||
<id>snapshots</id> | |||
<name>Archiva Managed Snapshot Repository</name> | |||
<url>file://${appserver.home}/repositories/internal</url> | |||
<layout>default</layout> | |||
<releases>false</releases> | |||
<snapshots>true</snapshots> | |||
<indexed>true</indexed> | |||
<refreshCronExpression>0 0,30 * * * ?</refreshCronExpression> | |||
</repository> | |||
<repository> | |||
<id>central</id> | |||
<name>Central Repository</name> | |||
<url>http://repo1.maven.org/maven2</url> | |||
<layout>default</layout> | |||
<releases>true</releases> | |||
<snapshots>false</snapshots> | |||
<indexed>false</indexed> | |||
</repository> | |||
<repository> | |||
<id>maven2-repository.dev.java.net</id> | |||
<name>Java.net Repository for Maven 2</name> | |||
<url>https://maven2-repository.dev.java.net/nonav/repository</url> | |||
<layout>default</layout> | |||
<releases>true</releases> | |||
<snapshots>false</snapshots> | |||
<indexed>false</indexed> | |||
</repository> | |||
</repositories> | |||
<proxyConnectors /> | |||
<networkProxies /> | |||
<repositoryScanning> | |||
<fileTypes> | |||
<fileType> | |||
<id>artifacts</id> | |||
<patterns> | |||
<pattern>**/*.pom</pattern> | |||
<pattern>**/*.jar</pattern> | |||
<pattern>**/*.ear</pattern> | |||
<pattern>**/*.war</pattern> | |||
<pattern>**/*.car</pattern> | |||
<pattern>**/*.sar</pattern> | |||
<pattern>**/*.mar</pattern> | |||
<pattern>**/*.rar</pattern> | |||
<pattern>**/*.dtd</pattern> | |||
<pattern>**/*.tld</pattern> | |||
<pattern>**/*.tar.gz</pattern> | |||
<pattern>**/*.tar.bz2</pattern> | |||
<pattern>**/*.zip</pattern> | |||
</patterns> | |||
</fileType> | |||
<fileType> | |||
<id>indexable-content</id> | |||
<patterns> | |||
<pattern>**/*.txt</pattern> | |||
<pattern>**/*.TXT</pattern> | |||
<pattern>**/*.block</pattern> | |||
<pattern>**/*.config</pattern> | |||
<pattern>**/*.pom</pattern> | |||
<pattern>**/*.xml</pattern> | |||
<pattern>**/*.xsd</pattern> | |||
<pattern>**/*.dtd</pattern> | |||
<pattern>**/*.tld</pattern> | |||
</patterns> | |||
</fileType> | |||
<fileType> | |||
<id>auto-remove</id> | |||
<patterns> | |||
<pattern>**/*.bak</pattern> | |||
<pattern>**/*~</pattern> | |||
<pattern>**/*-</pattern> | |||
</patterns> | |||
</fileType> | |||
<fileType> | |||
<id>ignored</id> | |||
<patterns> | |||
<pattern>**/.htaccess</pattern> | |||
<pattern>**/KEYS</pattern> | |||
<pattern>**/*.rb</pattern> | |||
<pattern>**/*.sh</pattern> | |||
<pattern>**/.svn/**</pattern> | |||
<pattern>**/.DAV/**</pattern> | |||
</patterns> | |||
</fileType> | |||
</fileTypes> | |||
<knownContentConsumers> | |||
<knownContentConsumer>update-db-artifact</knownContentConsumer> | |||
<knownContentConsumer>create-missing-checksums</knownContentConsumer> | |||
<knownContentConsumer>update-db-repository-metadata</knownContentConsumer> | |||
<knownContentConsumer>validate-checksum</knownContentConsumer> | |||
<knownContentConsumer>validate-signature</knownContentConsumer> | |||
<knownContentConsumer>index-content</knownContentConsumer> | |||
<knownContentConsumer>auto-remove</knownContentConsumer> | |||
<knownContentConsumer>auto-rename</knownContentConsumer> | |||
</knownContentConsumers> | |||
<invalidContentConsumers> | |||
<invalidContentConsumer>update-db-bad-content</invalidContentConsumer> | |||
</invalidContentConsumers> | |||
</repositoryScanning> | |||
<databaseScanning> | |||
<cronExpression>0 0 * * * ?</cronExpression> | |||
<unprocessedConsumers> | |||
<unprocessedConsumer>test-db-unprocessed</unprocessedConsumer> | |||
<unprocessedConsumer>index-artifact</unprocessedConsumer> | |||
<unprocessedConsumer>update-db-project</unprocessedConsumer> | |||
<unprocessedConsumer>validate-repository-metadata</unprocessedConsumer> | |||
<unprocessedConsumer>index-archive-toc</unprocessedConsumer> | |||
<unprocessedConsumer>update-db-bytecode-stats</unprocessedConsumer> | |||
<unprocessedConsumer>index-public-methods</unprocessedConsumer> | |||
</unprocessedConsumers> | |||
<cleanupConsumers> | |||
<cleanupConsumer>test-db-cleanup</cleanupConsumer> | |||
</cleanupConsumers> | |||
</databaseScanning> | |||
</configuration> |
@@ -1,229 +0,0 @@ | |||
<?xml version="1.0" ?> | |||
<!-- | |||
~ Copyright 2005-2006 The Apache Software Foundation. | |||
~ | |||
~ Licensed under the Apache License, Version 2.0 (the "License"); | |||
~ you may not use this file except in compliance with the License. | |||
~ You may obtain a copy of the License at | |||
~ | |||
~ http://www.apache.org/licenses/LICENSE-2.0 | |||
~ | |||
~ Unless required by applicable law or agreed to in writing, software | |||
~ distributed under the License is distributed on an "AS IS" BASIS, | |||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
~ See the License for the specific language governing permissions and | |||
~ limitations under the License. | |||
--> | |||
<project | |||
xmlns="http://maven.apache.org/POM/4.0.0" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>org.apache.maven.shared</groupId> | |||
<artifactId>maven-shared-components</artifactId> | |||
<version>3</version> | |||
</parent> | |||
<artifactId>maven-shared-jar</artifactId> | |||
<packaging>jar</packaging> | |||
<version>1.0-SNAPSHOT</version> | |||
<name>Maven Shared Jar Utils</name> | |||
<scm> | |||
<connection>scm:svn:http://svn.apache.org/repos/asf/maven/sandbox/maven-shared-jar</connection> | |||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/sandbox/maven-shared-jar</developerConnection> | |||
<url>http://svn.apache.org/viewcvs.cgi/maven/sandbox/maven-shared-jar</url> | |||
</scm> | |||
<organization> | |||
<name>Apache</name> | |||
</organization> | |||
<issueManagement> | |||
<system>jira</system> | |||
</issueManagement> | |||
<ciManagement> | |||
<system>continuum</system> | |||
</ciManagement> | |||
<developers> | |||
<developer> | |||
<id>joakime</id> | |||
<email>joakime@apache.org</email> | |||
<name>Joakim Erdfelt</name> | |||
</developer> | |||
</developers> | |||
<contributors> | |||
<contributor> | |||
<name>Someone Else</name> | |||
</contributor> | |||
</contributors> | |||
<licenses> | |||
<license> | |||
<url>http://www.apache.org/licenses/LICENSE-2.0</url> | |||
</license> | |||
</licenses> | |||
<mailingLists> | |||
<mailingList> | |||
<name>Shared Mailing List</name> | |||
</mailingList> | |||
</mailingLists> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.codehaus.plexus</groupId> | |||
<artifactId>plexus-maven-plugin</artifactId> | |||
<executions> | |||
<execution> | |||
<goals> | |||
<goal>descriptor</goal> | |||
</goals> | |||
</execution> | |||
</executions> | |||
</plugin> | |||
<plugin> | |||
<groupId>org.codehaus.mojo</groupId> | |||
<artifactId>cobertura-maven-plugin</artifactId> | |||
<executions> | |||
<execution> | |||
<goals> | |||
<goal>clean</goal> | |||
</goals> | |||
</execution> | |||
</executions> | |||
</plugin> | |||
</plugins> | |||
<extensions> | |||
<extension> | |||
<groupId>org.apache.maven.wagon</groupId> | |||
<artifactId>wagon-webdav</artifactId> | |||
<version>1.0-beta-2</version> | |||
</extension> | |||
</extensions> | |||
</build> | |||
<reporting> | |||
<plugins> | |||
<plugin> | |||
<artifactId>maven-project-info-reports-plugin</artifactId> | |||
</plugin> | |||
<plugin> | |||
<artifactId>maven-javadoc-plugin</artifactId> | |||
</plugin> | |||
<plugin> | |||
<artifactId>maven-surefire-report-plugin</artifactId> | |||
</plugin> | |||
<plugin> | |||
<groupId>org.codehaus.mojo</groupId> | |||
<artifactId>changelog-maven-plugin</artifactId> | |||
<!-- Changelog has been moved to org.apache.maven.plugins | |||
Need to adjust this location in the future to point to | |||
the finalized copy of this plugin. | |||
<artifactId>maven-changelog-plugin</artifactId> | |||
--> | |||
</plugin> | |||
<plugin> | |||
<artifactId>maven-jxr-plugin</artifactId> | |||
</plugin> | |||
<plugin> | |||
<artifactId>maven-checkstyle-plugin</artifactId> | |||
</plugin> | |||
<plugin> | |||
<artifactId>maven-pmd-plugin</artifactId> | |||
<configuration> | |||
<linkXref>true</linkXref> | |||
<rulesets> | |||
<ruleset>rulesets/basic.xml</ruleset> | |||
<ruleset>rulesets/codesize.xml</ruleset> | |||
<ruleset>rulesets/controversial.xml</ruleset> | |||
<ruleset>rulesets/coupling.xml</ruleset> | |||
<ruleset>rulesets/finalizers.xml</ruleset> | |||
<ruleset>rulesets/imports.xml</ruleset> | |||
<ruleset>rulesets/junit.xml</ruleset> | |||
<ruleset>rulesets/logging-jakarta-commons.xml</ruleset> | |||
<ruleset>rulesets/naming.xml</ruleset> | |||
<ruleset>rulesets/optimizations.xml</ruleset> | |||
<ruleset>rulesets/strictexception.xml</ruleset> | |||
<ruleset>rulesets/strings.xml</ruleset> | |||
<ruleset>rulesets/sunsecure.xml</ruleset> | |||
<ruleset>rulesets/unusedcode.xml</ruleset> | |||
</rulesets> | |||
</configuration> | |||
</plugin> | |||
<plugin> | |||
<groupId>org.codehaus.mojo</groupId> | |||
<artifactId>cobertura-maven-plugin</artifactId> | |||
</plugin> | |||
</plugins> | |||
</reporting> | |||
<repositories> | |||
<repository> | |||
<id>snapshots.codehaus</id> | |||
<url>http://snapshots.repository.codehaus.org/</url> | |||
<releases> | |||
<enabled>false</enabled> | |||
</releases> | |||
<snapshots> | |||
<enabled>true</enabled> | |||
</snapshots> | |||
</repository> | |||
</repositories> | |||
<dependencyManagement> | |||
<dependencies> | |||
<dependency> | |||
<groupId>org.apache.maven</groupId> | |||
<artifactId>maven-model</artifactId> | |||
<version>2.0.5</version> | |||
</dependency> | |||
</dependencies> | |||
</dependencyManagement> | |||
<dependencies> | |||
<dependency> | |||
<groupId>org.apache.maven</groupId> | |||
<artifactId>maven-model</artifactId> | |||
<scope>compile</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.maven</groupId> | |||
<artifactId>maven-artifact-manager</artifactId> | |||
<version>2.0.2</version> | |||
<scope>compile</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.plexus</groupId> | |||
<artifactId>plexus-digest</artifactId> | |||
<version>1.0</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.bcel</groupId> | |||
<artifactId>bcel</artifactId> | |||
<version>5.2</version> | |||
<scope>compile</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-collections</groupId> | |||
<artifactId>commons-collections</artifactId> | |||
<version>3.1</version> | |||
<scope>compile</scope> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@@ -49,10 +49,6 @@ | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-proxy</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-database</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-repository-layer</artifactId> | |||
@@ -65,10 +61,6 @@ | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-core-consumers</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-database-consumers</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-metadata-consumer</artifactId> |
@@ -24,6 +24,7 @@ import java.text.DateFormat; | |||
import java.text.SimpleDateFormat; | |||
import java.util.ArrayList; | |||
import java.util.Calendar; | |||
import java.util.Collection; | |||
import java.util.Collections; | |||
import java.util.Date; | |||
import java.util.List; | |||
@@ -33,14 +34,12 @@ import com.opensymphony.xwork2.Preparable; | |||
import com.opensymphony.xwork2.Validateable; | |||
import org.apache.archiva.checksum.ChecksumAlgorithm; | |||
import org.apache.archiva.checksum.ChecksummedFile; | |||
import org.apache.archiva.metadata.model.ArtifactMetadata; | |||
import org.apache.archiva.metadata.repository.MetadataRepository; | |||
import org.apache.maven.archiva.common.utils.VersionComparator; | |||
import org.apache.maven.archiva.common.utils.VersionUtil; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; | |||
import org.apache.maven.archiva.database.ArchivaDatabaseException; | |||
import org.apache.maven.archiva.database.ArtifactDAO; | |||
import org.apache.maven.archiva.database.constraints.ArtifactVersionsConstraint; | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import org.apache.maven.archiva.model.ArchivaRepositoryMetadata; | |||
import org.apache.maven.archiva.model.VersionedReference; | |||
import org.apache.maven.archiva.repository.ContentNotFoundException; | |||
@@ -62,7 +61,7 @@ import org.apache.maven.archiva.security.UserRepositories; | |||
/** | |||
* Delete an artifact. Metadata will be updated if one exists, otherwise it would be created. | |||
* | |||
* | |||
* @plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteArtifactAction" instantiation-strategy="per-lookup" | |||
*/ | |||
public class DeleteArtifactAction | |||
@@ -110,14 +109,16 @@ public class DeleteArtifactAction | |||
private RepositoryContentFactory repositoryFactory; | |||
/** | |||
* @plexus.requirement role-hint="jdo" | |||
* @plexus.requirement role="org.apache.maven.archiva.repository.events.RepositoryListener" | |||
*/ | |||
private ArtifactDAO artifactDAO; | |||
/** @plexus.requirement role="org.apache.maven.archiva.repository.events.RepositoryListener" */ | |||
private List<RepositoryListener> listeners; | |||
private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[] { ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 }; | |||
private ChecksumAlgorithm[] algorithms = new ChecksumAlgorithm[]{ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5}; | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private MetadataRepository metadataRepository; | |||
public String getGroupId() | |||
{ | |||
@@ -217,6 +218,7 @@ public class DeleteArtifactAction | |||
throw new ContentNotFoundException( groupId + ":" + artifactId + ":" + version ); | |||
} | |||
// TODO: this should be in the storage mechanism so that it is all tied together | |||
// delete from file system | |||
repository.deleteVersion( ref ); | |||
@@ -225,40 +227,31 @@ public class DeleteArtifactAction | |||
updateMetadata( metadata, metadataFile, lastUpdatedTimestamp ); | |||
ArtifactVersionsConstraint constraint = | |||
new ArtifactVersionsConstraint( repositoryId, groupId, artifactId, false ); | |||
List<ArchivaArtifact> artifacts = null; | |||
Collection<ArtifactMetadata> artifacts = | |||
metadataRepository.getArtifacts( repositoryId, groupId, artifactId, version ); | |||
try | |||
for ( ArtifactMetadata artifact : artifacts ) | |||
{ | |||
artifacts = artifactDAO.queryArtifacts( constraint ); | |||
if ( artifacts != null ) | |||
if ( artifact.getVersion().equals( version ) ) | |||
{ | |||
for ( ArchivaArtifact artifact : artifacts ) | |||
metadataRepository.deleteArtifact( artifact.getRepositoryId(), artifact.getNamespace(), | |||
artifact.getProject(), artifact.getVersion(), | |||
artifact.getId() ); | |||
// TODO: move into the metadata repository proper - need to differentiate attachment of | |||
// repository metadata to an artifact | |||
for ( RepositoryListener listener : listeners ) | |||
{ | |||
if ( artifact.getVersion().equals( version ) ) | |||
{ | |||
for ( RepositoryListener listener : listeners ) | |||
{ | |||
listener.deleteArtifact( repository, artifact ); | |||
} | |||
} | |||
listener.deleteArtifact( repository.getId(), artifact.getNamespace(), artifact.getProject(), | |||
artifact.getVersion(), artifact.getId() ); | |||
} | |||
} | |||
} | |||
catch ( ArchivaDatabaseException e ) | |||
{ | |||
addActionError( "Error occurred while cleaning up database: " + e.getMessage() ); | |||
return ERROR; | |||
} | |||
String msg = | |||
"Artifact \'" + groupId + ":" + artifactId + ":" + version + | |||
"\' was successfully deleted from repository \'" + repositoryId + "\'"; | |||
String msg = "Artifact \'" + groupId + ":" + artifactId + ":" + version + | |||
"\' was successfully deleted from repository \'" + repositoryId + "\'"; | |||
triggerAuditEvent( repositoryId, groupId + ":" + artifactId + ":" + version, | |||
AuditEvent.REMOVE_FILE ); | |||
triggerAuditEvent( repositoryId, groupId + ":" + artifactId + ":" + version, AuditEvent.REMOVE_FILE ); | |||
addActionMessage( msg ); | |||
@@ -302,7 +295,7 @@ public class DeleteArtifactAction | |||
/** | |||
* Update artifact level metadata. Creates one if metadata does not exist after artifact deletion. | |||
* | |||
* | |||
* @param metadata | |||
*/ | |||
private void updateMetadata( ArchivaRepositoryMetadata metadata, File metadataFile, Date lastUpdatedTimestamp ) |
@@ -24,17 +24,12 @@ import java.util.List; | |||
import java.util.Map; | |||
import com.opensymphony.xwork2.Preparable; | |||
import org.apache.archiva.metadata.repository.MetadataRepository; | |||
import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; | |||
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; | |||
import org.apache.maven.archiva.database.ArchivaDatabaseException; | |||
import org.apache.maven.archiva.database.ArtifactDAO; | |||
import org.apache.maven.archiva.database.Constraint; | |||
import org.apache.maven.archiva.database.ObjectNotFoundException; | |||
import org.apache.maven.archiva.database.constraints.ArtifactsByRepositoryConstraint; | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import org.apache.maven.archiva.repository.audit.AuditEvent; | |||
import org.codehaus.plexus.redback.role.RoleManagerException; | |||
@@ -53,14 +48,14 @@ public class DeleteManagedRepositoryAction | |||
private String repoid; | |||
/** | |||
* @plexus.requirement role-hint="jdo" | |||
* @plexus.requirement | |||
*/ | |||
private ArtifactDAO artifactDao; | |||
private RepositoryStatisticsManager repositoryStatisticsManager; | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private RepositoryStatisticsManager repositoryStatisticsManager; | |||
private MetadataRepository metadataRepository; | |||
public void prepare() | |||
{ | |||
@@ -128,17 +123,12 @@ public class DeleteManagedRepositoryAction | |||
addActionError( "Unable to delete repository: " + e.getMessage() ); | |||
result = ERROR; | |||
} | |||
catch ( ArchivaDatabaseException e ) | |||
{ | |||
addActionError( "Unable to delete repositoy: " + e.getMessage() ); | |||
result = ERROR; | |||
} | |||
return result; | |||
} | |||
private void cleanupRepositoryData( ManagedRepositoryConfiguration cleanupRepository ) | |||
throws RoleManagerException, ArchivaDatabaseException | |||
throws RoleManagerException | |||
{ | |||
removeRepositoryRoles( cleanupRepository ); | |||
cleanupDatabase( cleanupRepository.getId() ); | |||
@@ -169,31 +159,8 @@ public class DeleteManagedRepositoryAction | |||
} | |||
private void cleanupDatabase( String repoId ) | |||
throws ArchivaDatabaseException | |||
{ | |||
Constraint constraint = new ArtifactsByRepositoryConstraint( repoId ); | |||
List<ArchivaArtifact> artifacts = artifactDao.queryArtifacts( constraint ); | |||
for ( ArchivaArtifact artifact : artifacts ) | |||
{ | |||
log.info( "Removing artifact " + artifact + " from the database." ); | |||
try | |||
{ | |||
artifactDao.deleteArtifact( artifact ); | |||
} | |||
catch ( ObjectNotFoundException oe ) | |||
{ | |||
log.info( "Project model of artifact " + artifact + " does not exist in the database. " + | |||
"Moving on to the next artifact." ); | |||
} | |||
catch ( ArchivaDatabaseException ae ) | |||
{ | |||
log.info( "Unable to delete artifact " + artifact + " from the database. " + | |||
"Moving on to the next artifact." ); | |||
} | |||
} | |||
metadataRepository.deleteRepository( repoId ); | |||
} | |||
public ManagedRepositoryConfiguration getRepository() | |||
@@ -221,8 +188,8 @@ public class DeleteManagedRepositoryAction | |||
this.repositoryStatisticsManager = repositoryStatisticsManager; | |||
} | |||
public void setArtifactDao( ArtifactDAO artifactDao ) | |||
public void setMetadataRepository( MetadataRepository metadataRepository ) | |||
{ | |||
this.artifactDao = artifactDao; | |||
this.metadataRepository = metadataRepository; | |||
} | |||
} |
@@ -183,6 +183,16 @@ public class TestMetadataRepository | |||
return null; //To change body of implemented methods use File | Settings | File Templates. | |||
} | |||
public void deleteArtifact( String repositoryId, String namespace, String project, String version, String id ) | |||
{ | |||
//To change body of implemented methods use File | Settings | File Templates. | |||
} | |||
public void deleteRepository( String repoId ) | |||
{ | |||
//To change body of implemented methods use File | Settings | File Templates. | |||
} | |||
public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, | |||
String projectVersion ) | |||
{ |
@@ -1,54 +0,0 @@ | |||
package org.apache.maven.archiva.web.action.admin.repositories; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.util.List; | |||
import org.apache.maven.archiva.database.ArchivaDAO; | |||
import org.apache.maven.archiva.database.ArtifactDAO; | |||
import org.apache.maven.archiva.database.SimpleConstraint; | |||
/** | |||
* Stub class for Archiva DAO to avoid having to set up a database for tests. | |||
* | |||
* @todo a mock would be better, but that won't play nicely with Plexus injection. | |||
*/ | |||
public class ArchivaDAOStub | |||
implements ArchivaDAO | |||
{ | |||
private ArtifactDAO artifactDao; | |||
public List<?> query( SimpleConstraint constraint ) | |||
{ | |||
throw new UnsupportedOperationException(); | |||
} | |||
public ArtifactDAO getArtifactDAO() | |||
{ | |||
return artifactDao; | |||
} | |||
public void setArtifactDao( ArtifactDAO artifactDao ) | |||
{ | |||
this.artifactDao = artifactDao; | |||
} | |||
} |
@@ -1,89 +0,0 @@ | |||
package org.apache.maven.archiva.web.action.admin.repositories; | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one | |||
* or more contributor license agreements. See the NOTICE file | |||
* distributed with this work for additional information | |||
* regarding copyright ownership. The ASF licenses this file | |||
* to you under the Apache License, Version 2.0 (the | |||
* "License"); you may not use this file except in compliance | |||
* with the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, | |||
* software distributed under the License is distributed on an | |||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |||
* KIND, either express or implied. See the License for the | |||
* specific language governing permissions and limitations | |||
* under the License. | |||
*/ | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import org.apache.maven.archiva.database.ArchivaDatabaseException; | |||
import org.apache.maven.archiva.database.ArtifactDAO; | |||
import org.apache.maven.archiva.database.Constraint; | |||
import org.apache.maven.archiva.database.ObjectNotFoundException; | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import org.apache.maven.archiva.model.ArchivaArtifactModel; | |||
/** | |||
* ArtifactDAOStub | |||
* | |||
* @version | |||
*/ | |||
public class ArtifactDAOStub | |||
implements ArtifactDAO | |||
{ | |||
public ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String classifier, | |||
String type, String repositoryId ) | |||
{ | |||
// TODO Auto-generated method stub | |||
return null; | |||
} | |||
public void deleteArtifact( ArchivaArtifact artifact ) | |||
throws ArchivaDatabaseException | |||
{ | |||
// TODO Auto-generated method stub | |||
} | |||
public ArchivaArtifact getArtifact( String groupId, String artifactId, String version, String classifier, | |||
String type, String repositoryId ) | |||
throws ObjectNotFoundException, ArchivaDatabaseException | |||
{ | |||
// TODO Auto-generated method stub | |||
return null; | |||
} | |||
public List<ArchivaArtifact> queryArtifacts( Constraint constraint ) | |||
throws ObjectNotFoundException, ArchivaDatabaseException | |||
{ | |||
List<ArchivaArtifact> artifacts = new ArrayList<ArchivaArtifact>(); | |||
ArchivaArtifactModel model = new ArchivaArtifactModel(); | |||
model.setGroupId( "org.apache.maven.archiva" ); | |||
model.setArtifactId( "test-artifact" ); | |||
model.setVersion( "1.0" ); | |||
model.setType( "jar" ); | |||
model.setRepositoryId( "repo-ident" ); | |||
ArchivaArtifact artifact = new ArchivaArtifact( model ); | |||
artifacts.add( artifact ); | |||
return artifacts; | |||
} | |||
public ArchivaArtifact saveArtifact( ArchivaArtifact artifact ) | |||
throws ArchivaDatabaseException | |||
{ | |||
// TODO Auto-generated method stub | |||
return null; | |||
} | |||
} |
@@ -25,6 +25,7 @@ import java.util.Collections; | |||
import java.util.List; | |||
import com.opensymphony.xwork2.Action; | |||
import org.apache.archiva.metadata.repository.MetadataRepository; | |||
import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager; | |||
import org.apache.maven.archiva.configuration.ArchivaConfiguration; | |||
import org.apache.maven.archiva.configuration.Configuration; | |||
@@ -88,7 +89,12 @@ public class DeleteManagedRepositoryActionTest | |||
repositoryStatisticsManager = (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock(); | |||
action.setRepositoryStatisticsManager( repositoryStatisticsManager ); | |||
action.setArtifactDao( new ArtifactDAOStub() ); | |||
MockControl metadataRepositoryControl = MockControl.createControl( MetadataRepository.class ); | |||
MetadataRepository metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock(); | |||
metadataRepository.deleteRepository( REPO_ID ); | |||
action.setMetadataRepository( metadataRepository ); | |||
metadataRepositoryControl.replay(); | |||
} | |||
public void testSecureActionBundle() |
@@ -33,7 +33,6 @@ import org.apache.archiva.metadata.repository.stats.RepositoryStatistics; | |||
import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager; | |||
import org.apache.archiva.reports.RepositoryProblemFacet; | |||
import org.apache.commons.io.IOUtils; | |||
import org.apache.maven.archiva.database.ArchivaDatabaseException; | |||
import org.codehaus.plexus.spring.PlexusInSpringTestCase; | |||
import org.easymock.MockControl; | |||
@@ -247,7 +246,7 @@ public class GenerateReportActionTest | |||
} | |||
public void testDownloadStatisticsSingleRepo() | |||
throws IOException, ArchivaDatabaseException | |||
throws IOException | |||
{ | |||
Date date = new Date(); | |||
repositoryStatisticsManagerControl.expectAndReturn( | |||
@@ -269,7 +268,7 @@ public class GenerateReportActionTest | |||
} | |||
public void testDownloadStatisticsMultipleRepos() | |||
throws IOException, ArchivaDatabaseException | |||
throws IOException | |||
{ | |||
repositoryStatisticsManagerControl.expectAndReturn( | |||
repositoryStatisticsManager.getStatisticsInRange( SNAPSHOTS, null, null ), |
@@ -19,22 +19,6 @@ | |||
<plexus> | |||
<components> | |||
<component> | |||
<role>org.apache.maven.archiva.database.ArchivaDAO</role> | |||
<role-hint>jdo</role-hint> | |||
<implementation>org.apache.maven.archiva.web.action.admin.repositories.ArchivaDAOStub</implementation> | |||
<requirements> | |||
<requirement> | |||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> | |||
<field-name>configuration</field-name> | |||
</requirement> | |||
</requirements> | |||
</component> | |||
<component> | |||
<role>org.apache.maven.archiva.database.ArtifactDAO</role> | |||
<role-hint>jdo</role-hint> | |||
<implementation>org.apache.maven.archiva.web.action.admin.repositories.ArtifactDAOStub</implementation> | |||
</component> | |||
<component> | |||
<role>org.apache.maven.archiva.security.UserRepositories</role> | |||
<role-hint>default</role-hint> |
@@ -144,6 +144,16 @@ public class TestMetadataRepository | |||
return null; //To change body of implemented methods use File | Settings | File Templates. | |||
} | |||
public void deleteArtifact( String repositoryId, String namespace, String project, String version, String id ) | |||
{ | |||
//To change body of implemented methods use File | Settings | File Templates. | |||
} | |||
public void deleteRepository( String repoId ) | |||
{ | |||
//To change body of implemented methods use File | Settings | File Templates. | |||
} | |||
public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, | |||
String projectVersion ) | |||
{ |
@@ -42,10 +42,6 @@ | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-xmlrpc-security</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-database</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-xmlrpc-api</artifactId> |
@@ -23,6 +23,8 @@ import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import org.apache.archiva.metadata.model.ArtifactMetadata; | |||
import org.apache.archiva.metadata.repository.MetadataRepository; | |||
import org.apache.archiva.repository.scanner.RepositoryContentConsumers; | |||
import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; | |||
import org.apache.archiva.scheduler.repository.RepositoryTask; | |||
@@ -37,10 +39,6 @@ import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; | |||
import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration; | |||
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer; | |||
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; | |||
import org.apache.maven.archiva.database.ArchivaDatabaseException; | |||
import org.apache.maven.archiva.database.ArtifactDAO; | |||
import org.apache.maven.archiva.database.constraints.ArtifactVersionsConstraint; | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import org.apache.maven.archiva.model.VersionedReference; | |||
import org.apache.maven.archiva.repository.ContentNotFoundException; | |||
import org.apache.maven.archiva.repository.ManagedRepositoryContent; | |||
@@ -68,23 +66,23 @@ public class AdministrationServiceImpl | |||
private RepositoryContentFactory repoFactory; | |||
private ArtifactDAO artifactDAO; | |||
private RepositoryArchivaTaskScheduler repositoryTaskScheduler; | |||
private Collection<RepositoryListener> listeners; | |||
private MetadataRepository metadataRepository; | |||
public AdministrationServiceImpl( ArchivaConfiguration archivaConfig, RepositoryContentConsumers repoConsumersUtil, | |||
RepositoryContentFactory repoFactory, ArtifactDAO artifactDAO, | |||
RepositoryContentFactory repoFactory, MetadataRepository metadataRepository, | |||
RepositoryArchivaTaskScheduler repositoryTaskScheduler, | |||
Collection<RepositoryListener> listeners ) | |||
{ | |||
this.archivaConfiguration = archivaConfig; | |||
this.repoConsumersUtil = repoConsumersUtil; | |||
this.repoFactory = repoFactory; | |||
this.artifactDAO = artifactDAO; | |||
this.repositoryTaskScheduler = repositoryTaskScheduler; | |||
this.listeners = listeners; | |||
this.metadataRepository = metadataRepository; | |||
} | |||
/** | |||
@@ -142,7 +140,7 @@ public class AdministrationServiceImpl | |||
config.setRepositoryScanning( repoScanningConfig ); | |||
saveConfiguration( config ); | |||
return new Boolean( true ); | |||
return true; | |||
} | |||
/** | |||
@@ -151,6 +149,8 @@ public class AdministrationServiceImpl | |||
public Boolean deleteArtifact( String repoId, String groupId, String artifactId, String version ) | |||
throws Exception | |||
{ | |||
// TODO: remove duplication with web | |||
Configuration config = archivaConfiguration.getConfiguration(); | |||
ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( repoId ); | |||
@@ -170,28 +170,23 @@ public class AdministrationServiceImpl | |||
// delete from file system | |||
repoContent.deleteVersion( ref ); | |||
ArtifactVersionsConstraint constraint = new ArtifactVersionsConstraint( repoId, groupId, artifactId, false ); | |||
List<ArchivaArtifact> artifacts = null; | |||
Collection<ArtifactMetadata> artifacts = | |||
metadataRepository.getArtifacts( repoId, groupId, artifactId, version ); | |||
try | |||
{ | |||
artifacts = artifactDAO.queryArtifacts( constraint ); | |||
} | |||
catch ( ArchivaDatabaseException e ) | |||
for ( ArtifactMetadata artifact : artifacts ) | |||
{ | |||
throw new Exception( "Error occurred while cleaning up database." ); | |||
} | |||
if ( artifacts != null ) | |||
{ | |||
for ( ArchivaArtifact artifact : artifacts ) | |||
if ( artifact.getVersion().equals( version ) ) | |||
{ | |||
if ( artifact.getVersion().equals( version ) ) | |||
metadataRepository.deleteArtifact( artifact.getRepositoryId(), artifact.getNamespace(), | |||
artifact.getProject(), artifact.getVersion(), | |||
artifact.getId() ); | |||
// TODO: move into the metadata repository proper - need to differentiate attachment of | |||
// repository metadata to an artifact | |||
for ( RepositoryListener listener : listeners ) | |||
{ | |||
for ( RepositoryListener listener : listeners ) | |||
{ | |||
listener.deleteArtifact( repoContent, artifact ); | |||
} | |||
listener.deleteArtifact( repoId, artifact.getNamespace(), artifact.getProject(), | |||
artifact.getVersion(), artifact.getId() ); | |||
} | |||
} | |||
} | |||
@@ -209,7 +204,7 @@ public class AdministrationServiceImpl | |||
throw new Exception( "Repository exception occurred." ); | |||
} | |||
return new Boolean( true ); | |||
return true; | |||
} | |||
/** | |||
@@ -233,7 +228,7 @@ public class AdministrationServiceImpl | |||
repositoryTaskScheduler.queueTask( task ); | |||
return new Boolean( true ); | |||
return true; | |||
} | |||
/** |
@@ -25,6 +25,8 @@ import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import org.apache.archiva.metadata.model.ArtifactMetadata; | |||
import org.apache.archiva.metadata.repository.MetadataRepository; | |||
import org.apache.archiva.repository.scanner.RepositoryContentConsumers; | |||
import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler; | |||
import org.apache.archiva.scheduler.repository.RepositoryTask; | |||
@@ -40,9 +42,6 @@ import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; | |||
import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration; | |||
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer; | |||
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; | |||
import org.apache.maven.archiva.database.ArtifactDAO; | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import org.apache.maven.archiva.model.ArchivaArtifactModel; | |||
import org.apache.maven.archiva.model.ArtifactReference; | |||
import org.apache.maven.archiva.repository.RepositoryContentFactory; | |||
import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent; | |||
@@ -74,8 +73,6 @@ public class AdministrationServiceImplTest | |||
private MockControl repositoryTaskSchedulerControl; | |||
private MockControl databaseTaskSchedulerControl; | |||
private RepositoryArchivaTaskScheduler repositoryTaskScheduler; | |||
// repository consumers | |||
@@ -100,16 +97,14 @@ public class AdministrationServiceImplTest | |||
private RepositoryContentFactory repositoryFactory; | |||
private MockControl artifactDaoControl; | |||
private ArtifactDAO artifactDao; | |||
private MockControl listenerControl; | |||
private RepositoryListener listener; | |||
private MockControl cleanupConsumersControl; | |||
private MockControl metadataRepositoryControl; | |||
private MetadataRepository metadataRepository; | |||
protected void setUp() | |||
throws Exception | |||
{ | |||
@@ -140,15 +135,15 @@ public class AdministrationServiceImplTest | |||
repoFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class ); | |||
repositoryFactory = ( RepositoryContentFactory ) repoFactoryControl.getMock(); | |||
artifactDaoControl = MockControl.createControl( ArtifactDAO.class ); | |||
artifactDao = ( ArtifactDAO ) artifactDaoControl.getMock(); | |||
metadataRepositoryControl = MockControl.createControl( MetadataRepository.class ); | |||
metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock(); | |||
listenerControl = MockControl.createControl( RepositoryListener.class ); | |||
listener = (RepositoryListener) listenerControl.getMock(); | |||
service = | |||
new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, repositoryFactory, | |||
artifactDao, repositoryTaskScheduler, | |||
metadataRepository, repositoryTaskScheduler, | |||
Collections.singletonList( listener ) ); | |||
} | |||
@@ -305,19 +300,23 @@ public class AdministrationServiceImplTest | |||
repoFactoryControl.expectAndReturn( repositoryFactory.getManagedRepositoryContent( "internal" ), repoContent ); | |||
List<ArchivaArtifact> artifacts = getArtifacts(); | |||
artifactDao.queryArtifacts( null ); | |||
artifactDaoControl.setMatcher( MockControl.ALWAYS_MATCHER ); | |||
artifactDaoControl.setReturnValue( artifacts ); | |||
listener.deleteArtifact( repoContent, artifacts.get( 0 ) ); | |||
List<ArtifactMetadata> artifacts = getArtifacts(); | |||
ArtifactMetadata artifact = artifacts.get( 0 ); | |||
metadataRepositoryControl.expectAndReturn( | |||
metadataRepository.getArtifacts( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), | |||
artifact.getVersion() ), artifacts ); | |||
metadataRepository.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), | |||
artifact.getVersion(), artifact.getId() ); | |||
listener.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), | |||
artifact.getVersion(), artifact.getId() ); | |||
listenerControl.setVoidCallable( 1 ); | |||
archivaConfigControl.replay(); | |||
configControl.replay(); | |||
repoFactoryControl.replay(); | |||
artifactDaoControl.replay(); | |||
metadataRepositoryControl.replay(); | |||
listenerControl.replay(); | |||
boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" ); | |||
@@ -326,7 +325,7 @@ public class AdministrationServiceImplTest | |||
archivaConfigControl.verify(); | |||
configControl.verify(); | |||
repoFactoryControl.verify(); | |||
artifactDaoControl.verify(); | |||
metadataRepositoryControl.verify(); | |||
listenerControl.verify(); | |||
assertFalse( new File( managedRepo.getLocation(), "org/apache/archiva/archiva-test/1.0" ).exists() ); | |||
@@ -356,19 +355,23 @@ public class AdministrationServiceImplTest | |||
recordInManagedLegacyRepoContent( fileTypesControl, fileTypes, pathParserControl, parser ); | |||
List<ArchivaArtifact> artifacts = getArtifacts(); | |||
artifactDao.queryArtifacts( null ); | |||
artifactDaoControl.setMatcher( MockControl.ALWAYS_MATCHER ); | |||
artifactDaoControl.setReturnValue( artifacts ); | |||
listener.deleteArtifact( repoContent, artifacts.get( 0 ) ); | |||
List<ArtifactMetadata> artifacts = getArtifacts(); | |||
ArtifactMetadata artifact = artifacts.get( 0 ); | |||
metadataRepositoryControl.expectAndReturn( | |||
metadataRepository.getArtifacts( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), | |||
artifact.getVersion() ), artifacts ); | |||
metadataRepository.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), | |||
artifact.getVersion(), artifact.getId() ); | |||
listener.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), | |||
artifact.getVersion(), artifact.getId() ); | |||
listenerControl.setVoidCallable( 1 ); | |||
archivaConfigControl.replay(); | |||
configControl.replay(); | |||
repoFactoryControl.replay(); | |||
artifactDaoControl.replay(); | |||
metadataRepositoryControl.replay(); | |||
listenerControl.replay(); | |||
fileTypesControl.replay(); | |||
pathParserControl.replay(); | |||
@@ -379,7 +382,7 @@ public class AdministrationServiceImplTest | |||
archivaConfigControl.verify(); | |||
configControl.verify(); | |||
repoFactoryControl.verify(); | |||
artifactDaoControl.verify(); | |||
metadataRepositoryControl.verify(); | |||
listenerControl.verify(); | |||
fileTypesControl.verify(); | |||
pathParserControl.verify(); | |||
@@ -576,8 +579,8 @@ public class AdministrationServiceImplTest | |||
assertNotNull( repos ); | |||
assertEquals( 2, repos.size() ); | |||
assertManagedRepo( ( ManagedRepository ) repos.get( 0 ), managedRepos.get( 0 ) ); | |||
assertManagedRepo( ( ManagedRepository ) repos.get( 1 ), managedRepos.get( 1 ) ); | |||
assertManagedRepo( repos.get( 0 ), managedRepos.get( 0 ) ); | |||
assertManagedRepo( repos.get( 1 ), managedRepos.get( 1 ) ); | |||
} | |||
public void testGetAllRemoteRepositories() | |||
@@ -601,8 +604,8 @@ public class AdministrationServiceImplTest | |||
assertNotNull( repos ); | |||
assertEquals( 2, repos.size() ); | |||
assertRemoteRepo( (RemoteRepository) repos.get( 0 ), remoteRepos.get( 0 ) ); | |||
assertRemoteRepo( (RemoteRepository) repos.get( 1 ), remoteRepos.get( 1 ) ); | |||
assertRemoteRepo( repos.get( 0 ), remoteRepos.get( 0 ) ); | |||
assertRemoteRepo( repos.get( 1 ), remoteRepos.get( 1 ) ); | |||
} | |||
/* private methods */ | |||
@@ -708,18 +711,16 @@ public class AdministrationServiceImplTest | |||
pathParserControl.expectAndReturn( parser.toArtifactReference( at11j ), aRef ); | |||
} | |||
private List<ArchivaArtifact> getArtifacts() | |||
private List<ArtifactMetadata> getArtifacts() | |||
{ | |||
List<ArchivaArtifact> artifacts = new ArrayList<ArchivaArtifact>(); | |||
ArchivaArtifactModel model = new ArchivaArtifactModel(); | |||
model.setRepositoryId( "internal" ); | |||
model.setGroupId( "org.apache.archiva" ); | |||
model.setArtifactId( "archiva-test" ); | |||
model.setVersion( "1.0" ); | |||
model.setType( "jar" ); | |||
ArchivaArtifact artifact = new ArchivaArtifact( model ); | |||
List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>(); | |||
ArtifactMetadata artifact = new ArtifactMetadata(); | |||
artifact.setId( "archiva-test-1.0.jar" ); | |||
artifact.setProject( "archiva-test" ); | |||
artifact.setVersion( "1.0" ); | |||
artifact.setNamespace( "org.apache.archiva" ); | |||
artifact.setRepositoryId( "internal" ); | |||
artifacts.add( artifact ); | |||
return artifacts; | |||
} |
@@ -66,4 +66,8 @@ public interface MetadataRepository | |||
Collection<String> getRepositories(); | |||
List<ArtifactMetadata> getArtifactsByChecksum( String repoId, String checksum ); | |||
void deleteArtifact( String repositoryId, String namespace, String project, String version, String id ); | |||
void deleteRepository( String repoId ); | |||
} |
@@ -104,4 +104,14 @@ public class TestMetadataRepository | |||
{ | |||
return null; //To change body of implemented methods use File | Settings | File Templates. | |||
} | |||
public void deleteArtifact( String repositoryId, String namespace, String project, String version, String id ) | |||
{ | |||
//To change body of implemented methods use File | Settings | File Templates. | |||
} | |||
public void deleteRepository( String repoId ) | |||
{ | |||
//To change body of implemented methods use File | Settings | File Templates. | |||
} | |||
} |
@@ -468,6 +468,45 @@ public class FileMetadataRepository | |||
return artifacts; | |||
} | |||
public void deleteArtifact( String repositoryId, String namespace, String project, String version, String id ) | |||
{ | |||
File directory = new File( this.directory, repositoryId + "/" + namespace + "/" + project + "/" + version ); | |||
Properties properties = readOrCreateProperties( directory, PROJECT_VERSION_METADATA_KEY ); | |||
properties.remove( "artifact:updated:" + id ); | |||
properties.remove( "artifact:whenGathered:" + id ); | |||
properties.remove( "artifact:size:" + id ); | |||
properties.remove( "artifact:md5:" + id ); | |||
properties.remove( "artifact:sha1:" + id ); | |||
properties.remove( "artifact:version:" + id ); | |||
try | |||
{ | |||
writeProperties( properties, directory, PROJECT_VERSION_METADATA_KEY ); | |||
} | |||
catch ( IOException e ) | |||
{ | |||
// TODO | |||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. | |||
} | |||
} | |||
public void deleteRepository( String repoId ) | |||
{ | |||
File directory = new File( this.directory, repoId ); | |||
try | |||
{ | |||
FileUtils.deleteDirectory( directory ); | |||
} | |||
catch ( IOException e ) | |||
{ | |||
// TODO | |||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. | |||
} | |||
} | |||
private void getArtifactsByChecksum( List<ArtifactMetadata> artifacts, String repositoryId, String ns, | |||
String checksum ) | |||
{ |
@@ -436,6 +436,48 @@ public class FileMetadataRepositoryTest | |||
repository.getArtifactsByChecksum( TEST_REPO_ID, "not a checksum" ) ); | |||
} | |||
public void testDeleteArtifact() | |||
{ | |||
ArtifactMetadata artifact = createArtifact(); | |||
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact ); | |||
assertEquals( Collections.singletonList( artifact ), new ArrayList<ArtifactMetadata>( | |||
repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ) ); | |||
repository.deleteArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact.getId() ); | |||
assertTrue( | |||
repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ).isEmpty() ); | |||
} | |||
public void testDeleteRepository() | |||
{ | |||
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE ); | |||
ProjectMetadata project1 = new ProjectMetadata(); | |||
project1.setNamespace( TEST_NAMESPACE ); | |||
project1.setId( "project1" ); | |||
repository.updateProject( TEST_REPO_ID, project1 ); | |||
ProjectMetadata project2 = new ProjectMetadata(); | |||
project2.setNamespace( TEST_NAMESPACE ); | |||
project2.setId( "project2" ); | |||
repository.updateProject( TEST_REPO_ID, project2 ); | |||
ArtifactMetadata artifact1 = createArtifact(); | |||
artifact1.setProject( "project1" ); | |||
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, "project1", TEST_PROJECT_VERSION, artifact1 ); | |||
ArtifactMetadata artifact2 = createArtifact(); | |||
artifact2.setProject( "project2" ); | |||
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, "project2", TEST_PROJECT_VERSION, artifact2 ); | |||
assertEquals( Arrays.asList( artifact1, artifact2 ), new ArrayList<ArtifactMetadata>( | |||
repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ) ) ); | |||
repository.deleteRepository( TEST_REPO_ID ); | |||
assertTrue( repository.getArtifactsByDateRange( TEST_REPO_ID, null, null ).isEmpty() ); | |||
} | |||
private ProjectMetadata createProject() | |||
{ | |||
return createProject( TEST_NAMESPACE ); |
@@ -20,8 +20,6 @@ package org.apache.archiva.reports; | |||
*/ | |||
import org.apache.archiva.metadata.repository.MetadataRepository; | |||
import org.apache.maven.archiva.model.ArchivaArtifact; | |||
import org.apache.maven.archiva.repository.ManagedRepositoryContent; | |||
import org.apache.maven.archiva.repository.events.RepositoryListener; | |||
/** | |||
@@ -37,12 +35,10 @@ public class RepositoryProblemEventListener | |||
*/ | |||
private MetadataRepository metadataRepository; | |||
public void deleteArtifact( ManagedRepositoryContent repository, ArchivaArtifact artifact ) | |||
public void deleteArtifact( String repositoryId, String namespace, String project, String version, String id ) | |||
{ | |||
String name = | |||
RepositoryProblemFacet.createName( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), | |||
repository.toFile( artifact ).getName() ); | |||
String name = RepositoryProblemFacet.createName( namespace, project, version, id ); | |||
metadataRepository.removeMetadataFacet( repository.getId(), RepositoryProblemFacet.FACET_ID, name ); | |||
metadataRepository.removeMetadataFacet( repositoryId, RepositoryProblemFacet.FACET_ID, name ); | |||
} | |||
} |
@@ -456,6 +456,8 @@ public class RepositoryStatisticsManagerTest | |||
stats.setTotalProjectCount( 5 ); | |||
stats.setTotalGroupCount( 4 ); | |||
stats.setTotalFileCount( 56345 ); | |||
stats.setTotalCountForType( "jar", 10 ); | |||
stats.setTotalCountForType( "pom", 10 ); | |||
return stats; | |||
} | |||
@@ -513,13 +515,13 @@ public class RepositoryStatisticsManagerTest | |||
Arrays.asList( "1.3-SNAPSHOT", "1.3" ) ); | |||
metadataRepositoryControl.expectAndReturn( | |||
metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT" ), | |||
Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "jar" ), | |||
createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", | |||
Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", "jar" ), | |||
createArtifact( "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT", | |||
"pom" ) ) ); | |||
metadataRepositoryControl.expectAndReturn( | |||
metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3" ), | |||
Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "jar" ), | |||
createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "pom" ) ) ); | |||
Arrays.asList( createArtifact( "org.apache.archiva", "metadata-model", "1.3", "jar" ), | |||
createArtifact( "org.apache.archiva", "metadata-model", "1.3", "pom" ) ) ); | |||
metadataRepositoryControl.expectAndReturn( | |||
metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache.maven" ), Arrays.asList() ); | |||
metadataRepositoryControl.expectAndReturn( | |||
@@ -529,8 +531,8 @@ public class RepositoryStatisticsManagerTest | |||
Arrays.asList( "2.2.1" ) ); | |||
metadataRepositoryControl.expectAndReturn( | |||
metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.maven", "maven-model", "2.2.1" ), | |||
Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "2.2.1", "jar" ), | |||
createArtifact( "org.apache.archiva", "metadata-repository-api", "2.2.1", "pom" ) ) ); | |||
Arrays.asList( createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "jar" ), | |||
createArtifact( "org.apache.archiva", "maven-model", "2.2.1", "pom" ) ) ); | |||
metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus" ), | |||
Arrays.asList( "plexus" ) ); | |||
metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org" ), |
@@ -29,7 +29,6 @@ | |||
<url>http://archiva.apache.org/ref/${project.version}</url> | |||
<modules> | |||
<module>archiva-base</module> | |||
<module>archiva-database</module> | |||
<module>archiva-scheduler</module> | |||
<module>archiva-web</module> | |||
<module>metadata</module> |
@@ -359,16 +359,6 @@ | |||
<artifactId>archiva-core-consumers</artifactId> | |||
<version>1.3-SNAPSHOT</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-database</artifactId> | |||
<version>1.3-SNAPSHOT</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-database-consumers</artifactId> | |||
<version>1.3-SNAPSHOT</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.archiva</groupId> | |||
<artifactId>archiva-indexer</artifactId> |