diff options
author | Joakim Erdfelt <joakime@apache.org> | 2007-05-22 15:48:23 +0000 |
---|---|---|
committer | Joakim Erdfelt <joakime@apache.org> | 2007-05-22 15:48:23 +0000 |
commit | 18454da4e7ee29279bd3f847c25e8930448c566a (patch) | |
tree | 53496096194694c215fb2c621d6fb3a795c33acf /archiva-database | |
parent | 8e4c990b3b4d4da66bc8d4b818cd2990158547e5 (diff) | |
download | archiva-18454da4e7ee29279bd3f847c25e8930448c566a.tar.gz archiva-18454da4e7ee29279bd3f847c25e8930448c566a.zip |
[MRM-346]: Show Artifact results in error 500.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@540614 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-database')
-rw-r--r-- | archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java index 4a3938f1d..b02cf1106 100644 --- a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java +++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoAccess.java @@ -31,10 +31,9 @@ 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.PMFConfiguration; import org.jpox.SchemaTool; -import sun.security.action.GetLongAction; - import java.io.File; import java.io.PrintStream; import java.net.URL; @@ -79,23 +78,37 @@ public class JdoAccess 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 ); @@ -352,7 +365,7 @@ public class JdoAccess + "> 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() ); |