[MRM-346]: Show Artifact results in error 500.

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@540343 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joakim Erdfelt 2007-05-21 23:01:36 +00:00
parent 72be8679ef
commit ec549451bb
16 changed files with 425 additions and 6 deletions

View File

@ -79,6 +79,8 @@ import java.io.Serializable;
public class AbstractArtifactKey
implements CompoundKey, Serializable
{
private static final long serialVersionUID = 1084250769223555422L;
/**
* The Group ID. (JPOX Requires this remain public)
*/

View File

@ -79,6 +79,8 @@ import java.io.Serializable;
public class AbstractProjectKey
implements CompoundKey, Serializable
{
private static final long serialVersionUID = 4949927971768396064L;
/**
* The Group ID. (JPOX Requires this remain public)
*/

View File

@ -79,6 +79,8 @@ import java.io.Serializable;
public class AbstractVersionedKey
implements CompoundKey, Serializable
{
private static final long serialVersionUID = -5389698374243146150L;
/**
* The Group ID. (JPOX Requires this remain public)
*/

View File

@ -33,6 +33,7 @@ public class ArchivaArtifactJavaDetailsKey
extends AbstractArtifactKey
implements Serializable
{
private static final long serialVersionUID = -2565748477203220905L;
public ArchivaArtifactJavaDetailsKey()
{

View File

@ -33,6 +33,8 @@ public class ArchivaArtifactModelKey
extends AbstractArtifactKey
implements Serializable
{
private static final long serialVersionUID = -6381910527697704289L;
public ArchivaArtifactModelKey()
{
super();

View File

@ -33,6 +33,7 @@ public class ArchivaProjectModelKey
extends AbstractVersionedKey
implements Serializable
{
private static final long serialVersionUID = 7789859208617327581L;
public ArchivaProjectModelKey()
{

View File

@ -33,6 +33,7 @@ public class ArchivaRepositoryMetadataKey
extends AbstractVersionedKey
implements Serializable
{
private static final long serialVersionUID = -7288079965200698253L;
public ArchivaRepositoryMetadataKey()
{

View File

@ -33,6 +33,7 @@ public class ArtifactReferenceKey
extends AbstractArtifactKey
implements Serializable
{
private static final long serialVersionUID = 2107985498806534183L;
public ArtifactReferenceKey()
{

View File

@ -33,6 +33,8 @@ public class ProjectReferenceKey
extends AbstractProjectKey
implements Serializable
{
private static final long serialVersionUID = 7803774484166902823L;
public ProjectReferenceKey()
{
super();

View File

@ -33,6 +33,7 @@ public class VersionedReferenceKey
extends AbstractVersionedKey
implements Serializable
{
private static final long serialVersionUID = -5040195285240958302L;
public VersionedReferenceKey()
{

View File

@ -74,6 +74,14 @@
</association>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = 3259707008803111764L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<!-- _______________________________________________________________
@ -168,6 +176,14 @@
<defaultValue>false</defaultValue>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = 6823195399928260795L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<!-- _______________________________________________________________
@ -362,6 +378,12 @@
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = -6292417108113887384L;
]]></code>
</codeSegment>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
/**
* Identify if this artifact's contents have been processed or not.
*
@ -473,6 +495,12 @@
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = -4774236779581844880L;
]]></code>
</codeSegment>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
/**
* Identify this implementation as a set of java details.
*
@ -638,6 +666,12 @@
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = 914715358219606100L;
]]></code>
</codeSegment>
<codeSegment>
<version>1.0.0</version>
<code>
@ -681,6 +715,14 @@
<description>The incremental build number of the snapshot.</description>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = -1251466956496493405L;
]]></code>
</codeSegment>
</codeSegments>
</class>
@ -727,6 +769,14 @@
</description>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = 8947981859537138991L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<class stash.storable="true"
@ -775,6 +825,14 @@
</description>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = -6990353165677563113L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<class stash.storable="true"
@ -851,6 +909,12 @@
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = -6116764846682178732L;
]]></code>
</codeSegment>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
public static String toKey( ArtifactReference artifactReference )
{
StringBuffer key = new StringBuffer();
@ -1165,6 +1229,12 @@
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = -4216128775884469616L;
]]></code>
</codeSegment>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
public Dependency asDependency()
{
Dependency dep = new Dependency();
@ -1227,6 +1297,14 @@
</association>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = 843006855864469245L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<class stash.storable="true"
@ -1261,7 +1339,16 @@
<type>String</type>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = -7782212828768434535L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<class stash.storable="true"
jpox.table="LICENSES">
<name>License</name>
@ -1302,7 +1389,16 @@
<type>String</type>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = 6078130909089038238L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<class stash.storable="true"
jpox.table="ISSUE_MANAGEMENT">
<name>IssueManagement</name>
@ -1325,6 +1421,14 @@
<type>String</type>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = -8881904886381224821L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<class>
@ -1347,6 +1451,14 @@
<type>String</type>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = 7592740408468517476L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<class stash.storable="true">
@ -1441,6 +1553,14 @@
</association>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = -3847642264665088605L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<class stash.storable="true"
@ -1574,6 +1694,12 @@
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = -5401218809636164002L;
]]></code>
</codeSegment>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
public String toString()
{
return Dependency.toKey( this );
@ -1636,7 +1762,16 @@
<required>true</required>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = 5655957444245343314L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<class stash.storable="true"
jpox.table="SCM">
<name>Scm</name>
@ -1672,7 +1807,16 @@
<type>String</type>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = 4075086167850885575L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<class stash.storable="true"
jpox.table="PROJECT_REPOSITORIES">
<name>ProjectRepository</name>
@ -1738,6 +1882,14 @@
<type>boolean</type>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = 8906309721278091848L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<!-- _______________________________________________________________
@ -1829,6 +1981,14 @@
</description>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = -3426958367216659565L;
]]></code>
</codeSegment>
</codeSegments>
</class>
<!-- _______________________________________________________________
@ -1899,6 +2059,12 @@
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private static final long serialVersionUID = -7113629916828442780L;
]]></code>
</codeSegment>
<codeSegment>
<version>1.0.0+</version>
<code><![CDATA[
private transient long startTimestamp;
public void triggerStart()

View File

@ -113,15 +113,15 @@ public class ProjectModel400Reader
}
}
private ArtifactReference getArtifactReference( Element elemPlugin )
private ArtifactReference getArtifactReference( Element elemPlugin, String defaultType )
{
ArtifactReference reference = new ArtifactReference();
reference.setGroupId( elemPlugin.elementTextTrim( "groupId" ) );
reference.setGroupId( StringUtils.defaultString( elemPlugin.elementTextTrim( "groupId" ) ) );
reference.setArtifactId( elemPlugin.elementTextTrim( "artifactId" ) );
reference.setVersion( elemPlugin.elementTextTrim( "version" ) );
reference.setClassifier( elemPlugin.elementTextTrim( "classifier" ) );
reference.setType( elemPlugin.elementTextTrim( "type" ) );
reference.setVersion( StringUtils.defaultString( elemPlugin.elementTextTrim( "version" ) ) );
reference.setClassifier( StringUtils.defaultString( elemPlugin.elementTextTrim( "classifier" ) ) );
reference.setType( StringUtils.defaultIfEmpty( elemPlugin.elementTextTrim( "type" ), defaultType ) );
return reference;
}
@ -420,7 +420,7 @@ public class ProjectModel400Reader
{
Element elemPlugin = (Element) it.next();
plugins.add( getArtifactReference( elemPlugin ) );
plugins.add( getArtifactReference( elemPlugin, "maven-plugin" ) );
}
return plugins;

View File

@ -103,6 +103,11 @@
<artifactId>plexus-registry-commons</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.archiva</groupId>
<artifactId>archiva-repository-layer</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>

View File

@ -28,10 +28,16 @@ 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.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.jpox.SchemaTool;
import sun.security.action.GetLongAction;
import java.io.File;
import java.io.PrintStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@ -59,6 +65,7 @@ import javax.jdo.spi.PersistenceCapable;
* @plexus.component role="org.apache.maven.archiva.database.jdo.JdoAccess" role-hint="archiva"
*/
public class JdoAccess
extends AbstractLogEnabled
implements Initializable, InstanceLifecycleListener, StoreLifecycleListener
{
/**
@ -73,6 +80,24 @@ public class JdoAccess
{
pmf = jdoFactory.getPersistenceManagerFactory();
// 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
{
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 );
}

View File

@ -23,7 +23,9 @@ import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
import org.apache.maven.archiva.database.ProjectModelDAO;
import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.model.jpox.ArchivaProjectModelKey;
import org.apache.maven.archiva.repository.project.ProjectModelReader;
import java.io.File;
import java.util.Date;
import java.util.List;
@ -108,4 +110,35 @@ public class JdoProjectModelDAOTest
projectDao.deleteProjectModel( actualModel );
assertEquals( 0, projectDao.queryProjectModels( null ).size() );
}
public void testSaveGetRealProjectModel()
throws Exception
{
String groupId = "org.apache.maven.shared";
String artifactId = "maven-shared-jar";
String version = "1.0-SNAPSHOT";
ProjectModelDAO projectDao = dao.getProjectModelDAO();
ProjectModelReader modelReader = (ProjectModelReader) lookup( ProjectModelReader.class, "model400" );
File pomFile = getTestFile( "src/test/resources/projects/maven-shared-jar-1.0-SNAPSHOT.pom" );
assertTrue( "pom file should exist: " + pomFile.getAbsolutePath(), pomFile.exists() && pomFile.isFile() );
ArchivaProjectModel model = modelReader.read( pomFile );
assertNotNull( "Model should not be null.", model );
// Fill in missing (mandatory) fields
model.setGroupId( groupId );
model.setOrigin( "testcase" );
projectDao.saveProjectModel( model );
ArchivaProjectModel savedModel = projectDao.getProjectModel( groupId, artifactId, version );
assertNotNull( "Project model should not be null.", savedModel );
// Test proper detachment of sub-objects.
assertNotNull( "model.parent != null", savedModel.getParentProject() );
}
}

View File

@ -0,0 +1,175 @@
<?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>
<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>
</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>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0.2</version>
<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>