Issue #1910 Add some tests of the LifecycleManager SubmitObjects functionality
Change-Id: Ieb1544cb52cf108836b157e3d800c470fa5cf3e1 Former-commit-id:58b6899672
[formerly c4344f5402fe33e7e47515adc3b54913f9c13617] Former-commit-id:255aea053b
This commit is contained in:
parent
e44d3a8715
commit
67e49201d6
17 changed files with 786 additions and 162 deletions
|
@ -3,5 +3,6 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="res"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
|
||||
http://www.springframework.org/schema/tx
|
||||
http://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
|
||||
<!-- This file should only contain beans used on a running EDEX instance. -->
|
||||
|
||||
<bean id="ebxmlDbValidationStrategy"
|
||||
class="com.raytheon.uf.edex.registry.ebxml.dao.EbxmlPostgresValidationStrategy" />
|
||||
|
||||
<!-- start service -->
|
||||
<bean id="queryServiceFactory" class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
|
||||
init-method="create">
|
||||
<property name="serviceClass"
|
||||
value="oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.QueryManager" />
|
||||
<property name="address">
|
||||
<bean factory-bean="ServiceUrlFactory" factory-method="getServiceAddress">
|
||||
<constructor-arg value="queryManager" />
|
||||
<constructor-arg value="${EBXML_QUERY_SERVICE_SOAP_PORT}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="serviceBean" ref="queryServiceSoapImpl" />
|
||||
<property name="inInterceptors">
|
||||
<list>
|
||||
<ref bean="XACMLPolicyEnforcementPoint" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- start service -->
|
||||
<bean id="notificationServiceFactory" class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
|
||||
init-method="create">
|
||||
<property name="serviceClass"
|
||||
value="oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.NotificationListener" />
|
||||
<property name="address">
|
||||
<bean factory-bean="ServiceUrlFactory" factory-method="getServiceAddress">
|
||||
<constructor-arg value="notificationListener" />
|
||||
<constructor-arg value="${EBXML_QUERY_SERVICE_SOAP_PORT}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="serviceBean" ref="notificationServiceImpl" />
|
||||
</bean>
|
||||
|
||||
<!-- start service -->
|
||||
<bean id="lcmServiceFactory" class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
|
||||
init-method="create">
|
||||
<property name="serviceClass"
|
||||
value="oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager" />
|
||||
<property name="address">
|
||||
<bean factory-bean="ServiceUrlFactory" factory-method="getServiceAddress">
|
||||
<constructor-arg value="lifecycleManager" />
|
||||
<constructor-arg value="${EBXML_QUERY_SERVICE_SOAP_PORT}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="serviceBean" ref="lcmServiceImpl" />
|
||||
<property name="inInterceptors">
|
||||
<list>
|
||||
<ref bean="XACMLPolicyEnforcementPoint" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- start service -->
|
||||
<bean id="validatorServiceFactory" class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
|
||||
init-method="create">
|
||||
<property name="serviceClass"
|
||||
value="oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.Validator" />
|
||||
<property name="address">
|
||||
<bean factory-bean="ServiceUrlFactory" factory-method="getServiceAddress">
|
||||
<constructor-arg value="validator" />
|
||||
<constructor-arg value="${EBXML_QUERY_SERVICE_SOAP_PORT}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="serviceBean" ref="validatorServiceImpl" />
|
||||
</bean>
|
||||
|
||||
<!-- start service -->
|
||||
<bean id="catalogerServiceFactory" class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
|
||||
init-method="create">
|
||||
<property name="serviceClass"
|
||||
value="oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.Cataloger" />
|
||||
<property name="address">
|
||||
<bean factory-bean="ServiceUrlFactory" factory-method="getServiceAddress">
|
||||
<constructor-arg value="cataloger" />
|
||||
<constructor-arg value="${EBXML_QUERY_SERVICE_SOAP_PORT}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="serviceBean" ref="catalogerServiceImpl" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -1,128 +1,50 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
|
||||
http://www.springframework.org/schema/tx
|
||||
http://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
|
||||
<bean id="ServiceUrlFactory"
|
||||
class="com.raytheon.uf.edex.registry.ebxml.util.ServiceUrlFactory" />
|
||||
<bean id="DbInit" class="com.raytheon.uf.edex.registry.ebxml.dao.DbInit">
|
||||
<property name="lcm" ref="lcmServiceImpl" />
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
<property name="xacmlAdmin" ref="XACMLPolicyAdministrator" />
|
||||
</bean>
|
||||
<bean id="ServiceUrlFactory"
|
||||
class="com.raytheon.uf.edex.registry.ebxml.util.ServiceUrlFactory" />
|
||||
<bean id="DbInit" class="com.raytheon.uf.edex.registry.ebxml.dao.DbInit">
|
||||
<property name="dbValidationStrategy" ref="ebxmlDbValidationStrategy" />
|
||||
<property name="lcm" ref="lcmServiceImpl" />
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
<property name="xacmlAdmin" ref="XACMLPolicyAdministrator" />
|
||||
</bean>
|
||||
|
||||
<bean id="pwCallback"
|
||||
class="com.raytheon.uf.edex.registry.ebxml.acp.PasswordCallback" />
|
||||
<bean id="pwCallback"
|
||||
class="com.raytheon.uf.edex.registry.ebxml.acp.PasswordCallback" />
|
||||
|
||||
<bean id="WsSecurity" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
|
||||
<constructor-arg>
|
||||
<map>
|
||||
<entry key="action" value="UsernameToken" />
|
||||
<entry key="passwordType" value="PasswordText" />
|
||||
<entry key="passwordCallbackRef">
|
||||
<ref bean="pwCallback" />
|
||||
</entry>
|
||||
</map>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
<bean id="WsSecurity" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
|
||||
<constructor-arg>
|
||||
<map>
|
||||
<entry key="action" value="UsernameToken" />
|
||||
<entry key="passwordType" value="PasswordText" />
|
||||
<entry key="passwordCallbackRef">
|
||||
<ref bean="pwCallback" />
|
||||
</entry>
|
||||
</map>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="XACMLPolicyEnforcementPoint"
|
||||
class="com.raytheon.uf.edex.registry.acp.xacml.XACMLPolicyEnforcementPoint">
|
||||
<property name="xacmlContextHandler" ref="XACMLContextHandler" />
|
||||
</bean>
|
||||
<bean id="XACMLPolicyEnforcementPoint"
|
||||
class="com.raytheon.uf.edex.registry.acp.xacml.XACMLPolicyEnforcementPoint">
|
||||
<property name="xacmlContextHandler" ref="XACMLContextHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="XACMLContextHandler"
|
||||
class="com.raytheon.uf.edex.registry.acp.xacml.XACMLContextHandler">
|
||||
<property name="queryManager" ref="queryServiceImpl" />
|
||||
<property name="registryObjectDao" ref="registryObjectDao" />
|
||||
<property name="xacmlPolicyAdmin" ref="XACMLPolicyAdministrator" />
|
||||
</bean>
|
||||
<bean id="XACMLContextHandler"
|
||||
class="com.raytheon.uf.edex.registry.acp.xacml.XACMLContextHandler">
|
||||
<property name="queryManager" ref="queryServiceImpl" />
|
||||
<property name="registryObjectDao" ref="registryObjectDao" />
|
||||
<property name="xacmlPolicyAdmin" ref="XACMLPolicyAdministrator" />
|
||||
</bean>
|
||||
|
||||
<bean id="XACMLPolicyAdministrator"
|
||||
class="com.raytheon.uf.edex.registry.acp.xacml.XACMLPolicyAdministrator">
|
||||
<property name="extrinsicObjectDao" ref="extrinsicObjectDao" />
|
||||
<property name="lcm" ref="lcmServiceImpl" />
|
||||
</bean>
|
||||
<bean id="XACMLPolicyAdministrator"
|
||||
class="com.raytheon.uf.edex.registry.acp.xacml.XACMLPolicyAdministrator">
|
||||
<property name="extrinsicObjectDao" ref="extrinsicObjectDao" />
|
||||
<property name="lcm" ref="lcmServiceImpl" />
|
||||
</bean>
|
||||
|
||||
<!-- start service -->
|
||||
<bean id="queryServiceFactory" class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
|
||||
init-method="create">
|
||||
<property name="serviceClass"
|
||||
value="oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.QueryManager" />
|
||||
<property name="address">
|
||||
<bean factory-bean="ServiceUrlFactory" factory-method="getServiceAddress">
|
||||
<constructor-arg value="queryManager" />
|
||||
<constructor-arg value="${EBXML_QUERY_SERVICE_SOAP_PORT}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="serviceBean" ref="queryServiceSoapImpl" />
|
||||
<property name="inInterceptors">
|
||||
<list>
|
||||
<ref bean="XACMLPolicyEnforcementPoint" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- start service -->
|
||||
<bean id="notificationServiceFactory" class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
|
||||
init-method="create">
|
||||
<property name="serviceClass"
|
||||
value="oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.NotificationListener" />
|
||||
<property name="address">
|
||||
<bean factory-bean="ServiceUrlFactory" factory-method="getServiceAddress">
|
||||
<constructor-arg value="notificationListener" />
|
||||
<constructor-arg value="${EBXML_QUERY_SERVICE_SOAP_PORT}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="serviceBean" ref="notificationServiceImpl" />
|
||||
</bean>
|
||||
|
||||
<!-- start service -->
|
||||
<bean id="lcmServiceFactory" class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
|
||||
init-method="create">
|
||||
<property name="serviceClass"
|
||||
value="oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager" />
|
||||
<property name="address">
|
||||
<bean factory-bean="ServiceUrlFactory" factory-method="getServiceAddress">
|
||||
<constructor-arg value="lifecycleManager" />
|
||||
<constructor-arg value="${EBXML_QUERY_SERVICE_SOAP_PORT}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="serviceBean" ref="lcmServiceImpl" />
|
||||
<property name="inInterceptors">
|
||||
<list>
|
||||
<ref bean="XACMLPolicyEnforcementPoint" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- start service -->
|
||||
<bean id="validatorServiceFactory" class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
|
||||
init-method="create">
|
||||
<property name="serviceClass"
|
||||
value="oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.Validator" />
|
||||
<property name="address">
|
||||
<bean factory-bean="ServiceUrlFactory" factory-method="getServiceAddress">
|
||||
<constructor-arg value="validator" />
|
||||
<constructor-arg value="${EBXML_QUERY_SERVICE_SOAP_PORT}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="serviceBean" ref="validatorServiceImpl" />
|
||||
</bean>
|
||||
|
||||
<!-- start service -->
|
||||
<bean id="catalogerServiceFactory" class="org.apache.cxf.jaxws.JaxWsServerFactoryBean"
|
||||
init-method="create">
|
||||
<property name="serviceClass"
|
||||
value="oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.Cataloger" />
|
||||
<property name="address">
|
||||
<bean factory-bean="ServiceUrlFactory" factory-method="getServiceAddress">
|
||||
<constructor-arg value="cataloger" />
|
||||
<constructor-arg value="${EBXML_QUERY_SERVICE_SOAP_PORT}" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="serviceBean" ref="catalogerServiceImpl" />
|
||||
</bean>
|
||||
</beans>
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
@ -77,6 +76,7 @@ import com.raytheon.uf.edex.registry.ebxml.services.lifecycle.LifecycleManagerIm
|
|||
* 2/9/2012 184 bphillip Initial Coding
|
||||
* 3/18/2013 1082 bphillip Changed to use transactional boundaries and spring injection
|
||||
* 4/9/2013 1802 bphillip Changed submitObjects method call from submitObjectsInternal
|
||||
* Apr 15, 2013 1693 djohnson Use a strategy to verify the database is up to date.
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
|
@ -89,12 +89,9 @@ public class DbInit implements ApplicationListener {
|
|||
private static volatile boolean INITIALIZED = false;
|
||||
|
||||
/** The logger */
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(DbInit.class);
|
||||
|
||||
/** Query to check which tables exist in the ebxml database */
|
||||
private static final String TABLE_CHECK_QUERY = "SELECT tablename FROM pg_tables where schemaname = 'ebxml';";
|
||||
|
||||
/** Constant used for table regeneration */
|
||||
private static final String DROP_TABLE = "drop table ";
|
||||
|
||||
|
@ -113,8 +110,9 @@ public class DbInit implements ApplicationListener {
|
|||
|
||||
private XACMLPolicyAdministrator xacmlAdmin;
|
||||
|
||||
public DbInit() {
|
||||
private IEbxmlDatabaseValidationStrategy dbValidationStrategy;
|
||||
|
||||
public DbInit() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -290,39 +288,7 @@ public class DbInit implements ApplicationListener {
|
|||
*/
|
||||
private boolean isDbValid(AnnotationConfiguration aConfig)
|
||||
throws SQLException, EbxmlRegistryException {
|
||||
statusHandler.info("Verifying RegRep database...");
|
||||
final List<String> existingTables = new ArrayList<String>();
|
||||
List<String> definedTables = new ArrayList<String>();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> tables = (List<String>) sessionFactory.getCurrentSession()
|
||||
.createSQLQuery(TABLE_CHECK_QUERY).list();
|
||||
for (String table : tables) {
|
||||
existingTables.add("ebxml." + table);
|
||||
}
|
||||
|
||||
final String[] dropSqls = aConfig
|
||||
.generateDropSchemaScript(((SessionFactoryImpl) sessionFactory)
|
||||
.getDialect());
|
||||
for (String sql : dropSqls) {
|
||||
if (sql.startsWith(DROP_TABLE)) {
|
||||
// Drop the table names to all lower case since this is the form
|
||||
// the database expects
|
||||
definedTables.add(sql.replace(DROP_TABLE, "").toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the table set defined by Hibernate matches the table set
|
||||
// defined in the database already
|
||||
if (existingTables.size() <= definedTables.size()
|
||||
&& !existingTables.containsAll(definedTables)) {
|
||||
for (String defined : definedTables) {
|
||||
if (!existingTables.contains(defined)) {
|
||||
statusHandler.warn("MISSING TABLE: " + defined);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return dbValidationStrategy.isDbValid(aConfig, sessionFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -351,9 +317,8 @@ public class DbInit implements ApplicationListener {
|
|||
statusHandler.info("Populating RegRep database from file: "
|
||||
+ fileList[i].getName());
|
||||
|
||||
SubmitObjectsRequest obj = null;
|
||||
obj = (SubmitObjectsRequest) SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(fileList[i]);
|
||||
SubmitObjectsRequest obj = SerializationUtil
|
||||
.jaxbUnmarshalFromXmlFile(SubmitObjectsRequest.class, fileList[i]);
|
||||
|
||||
// Ensure an owner is assigned
|
||||
for (RegistryObjectType regObject : obj.getRegistryObjectList()
|
||||
|
@ -487,6 +452,7 @@ public class DbInit implements ApplicationListener {
|
|||
this.sessionFactory = sessionFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
if (!INITIALIZED) {
|
||||
|
@ -515,4 +481,20 @@ public class DbInit implements ApplicationListener {
|
|||
this.xacmlAdmin = xacmlAdmin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dbValidationStrategy
|
||||
*/
|
||||
public IEbxmlDatabaseValidationStrategy getDbValidationStrategy() {
|
||||
return dbValidationStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dbValidationStrategy
|
||||
* the dbValidationStrategy to set
|
||||
*/
|
||||
public void setDbValidationStrategy(
|
||||
IEbxmlDatabaseValidationStrategy dbValidationStrategy) {
|
||||
this.dbValidationStrategy = dbValidationStrategy;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.registry.ebxml.dao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.AnnotationConfiguration;
|
||||
import org.hibernate.impl.SessionFactoryImpl;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
|
||||
/**
|
||||
* Validates the Postgres instance of EBXML.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 15, 2013 1693 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class EbxmlPostgresValidationStrategy implements
|
||||
IEbxmlDatabaseValidationStrategy {
|
||||
|
||||
/** The logger */
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(EbxmlPostgresValidationStrategy.class);
|
||||
|
||||
/** Query to check which tables exist in the ebxml database */
|
||||
private static final String TABLE_CHECK_QUERY = "SELECT tablename FROM pg_tables where schemaname = 'ebxml';";
|
||||
|
||||
/** Constant used for table regeneration */
|
||||
private static final String DROP_TABLE = "drop table ";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isDbValid(AnnotationConfiguration aConfig,
|
||||
SessionFactory sessionFactory) {
|
||||
statusHandler.info("Verifying RegRep database...");
|
||||
final List<String> existingTables = new ArrayList<String>();
|
||||
List<String> definedTables = new ArrayList<String>();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> tables = sessionFactory.getCurrentSession()
|
||||
.createSQLQuery(TABLE_CHECK_QUERY).list();
|
||||
for (String table : tables) {
|
||||
existingTables.add("ebxml." + table);
|
||||
}
|
||||
|
||||
final String[] dropSqls = aConfig
|
||||
.generateDropSchemaScript(((SessionFactoryImpl) sessionFactory)
|
||||
.getDialect());
|
||||
for (String sql : dropSqls) {
|
||||
if (sql.startsWith(DROP_TABLE)) {
|
||||
// Drop the table names to all lower case since this is the form
|
||||
// the database expects
|
||||
definedTables.add(sql.replace(DROP_TABLE, "").toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the table set defined by Hibernate matches the table set
|
||||
// defined in the database already
|
||||
if (existingTables.size() <= definedTables.size()
|
||||
&& !existingTables.containsAll(definedTables)) {
|
||||
for (String defined : definedTables) {
|
||||
if (!existingTables.contains(defined)) {
|
||||
statusHandler.warn("MISSING TABLE: " + defined);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.registry.ebxml.dao;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.AnnotationConfiguration;
|
||||
|
||||
/**
|
||||
* Database validation strategy.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 15, 2013 1693 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IEbxmlDatabaseValidationStrategy {
|
||||
|
||||
/**
|
||||
* Check whether the database is valid compared to the annotation
|
||||
* configuration.
|
||||
*
|
||||
* @param aConfig
|
||||
* the configuration
|
||||
* @param sessionFactory
|
||||
* the session factory
|
||||
* @return true if valid
|
||||
*/
|
||||
boolean isDbValid(AnnotationConfiguration aConfig,
|
||||
SessionFactory sessionFactory);
|
||||
|
||||
}
|
|
@ -56,7 +56,7 @@
|
|||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/com.raytheon.uf.edex.event"/>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/javax.measure"/>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/javax.vecmath"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/hsqldb.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/h2-1.3.171.jar"/>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/com.raytheon.uf.common.gridcoverage"/>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/com.raytheon.uf.edex.datadelivery.service"/>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/com.raytheon.viz.ui"/>
|
||||
|
|
|
@ -0,0 +1,322 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.registry.ebxml.dao;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.LifecycleManager;
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.MsgRegistryException;
|
||||
import oasis.names.tc.ebxml.regrep.wsdl.registry.services.v4.QueryManager;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.Mode;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.lcm.v4.SubmitObjectsRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryRequest;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.QueryResponse;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.query.v4.ResponseOptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.QueryType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectListType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.RegistryObjectType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.SlotType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rim.v4.StringValueType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.ObjectExistsExceptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryExceptionType;
|
||||
import oasis.names.tc.ebxml.regrep.xsd.rs.v4.RegistryResponseType;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.raytheon.uf.common.registry.constants.RegistryResponseStatus;
|
||||
import com.raytheon.uf.edex.core.EDEXUtil;
|
||||
import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
||||
import com.raytheon.uf.edex.registry.ebxml.services.query.QueryConstants;
|
||||
import com.raytheon.uf.edex.registry.ebxml.services.query.QueryManagerImpl.RETURN_TYPE;
|
||||
import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
||||
|
||||
/**
|
||||
* Test {@link LifecycleManager} submit objects functionality.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 15, 2013 1693 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
"/spring/ebxml.xml", "/spring/ebxml-impl.xml",
|
||||
"/spring/ebxml-querytypes.xml", "/spring/ebxml-registry-dao.xml",
|
||||
"/ebxml/unit-test-ebxml-beans.xml" })
|
||||
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class LifecycleManagerSubmitObjectsTest {
|
||||
|
||||
private static final String MY_REGISTRY_OBJECT_ID = "myRegistryObjectId";
|
||||
|
||||
private static final String REGISTRY_OBJECT_TYPE = "myRegistryObjectType";
|
||||
|
||||
@Autowired
|
||||
private LifecycleManager lifecycleManager;
|
||||
|
||||
private QueryManager queryManager;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.queryManager = EDEXUtil.getESBComponent(QueryManager.class,
|
||||
"queryServiceImpl");
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateOnly - If an object does not exist, server MUST create it as a new
|
||||
* object. If an object already exists, the server MUST return an
|
||||
* ObjectExistsException fault message
|
||||
*
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
@Test
|
||||
public void createOnlySubmitObjectsWithNonExistantObjectSucceeds()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, Mode.CREATE_ONLY);
|
||||
|
||||
final RegistryResponseType response = lifecycleManager
|
||||
.submitObjects(submitObjectsRequest);
|
||||
|
||||
assertThat(response.getStatus(),
|
||||
is(equalTo(RegistryResponseStatus.SUCCESS)));
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateOnly - If an object does not exist, server MUST create it as a new
|
||||
* object. If an object already exists, the server MUST return an
|
||||
* ObjectExistsException fault message
|
||||
*
|
||||
* @throws MsgRegistryException
|
||||
*/
|
||||
@Test
|
||||
public void createOnlySubmitObjectsWithExistantObjectFails()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, Mode.CREATE_ONLY);
|
||||
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
|
||||
try {
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
|
||||
fail("Expected a MsgRegistryException to have been thrown!");
|
||||
} catch (MsgRegistryException exception) {
|
||||
final RegistryExceptionType faultInfo = exception.getFaultInfo();
|
||||
assertThat(faultInfo,
|
||||
is(instanceOf(ObjectExistsExceptionType.class)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateOrReplace (default) - If an object does not exist, server MUST
|
||||
* create it as a new object. If an object already exists, server MUST
|
||||
* replace the existing object with the submitted object
|
||||
*/
|
||||
@Test
|
||||
public void createOrReplaceSubmitObjectsWithNonExistantObjectSucceeds()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, Mode.CREATE_OR_REPLACE);
|
||||
|
||||
final RegistryResponseType response = lifecycleManager
|
||||
.submitObjects(submitObjectsRequest);
|
||||
|
||||
assertThat(response.getStatus(),
|
||||
is(equalTo(RegistryResponseStatus.SUCCESS)));
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateOrReplace (default) - If an object does not exist, server MUST
|
||||
* create it as a new object. If an object already exists, server MUST
|
||||
* replace the existing object with the submitted object
|
||||
*/
|
||||
@Test
|
||||
public void createOrReplaceSubmitObjectsWithExistantObjectSucceeds()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, Mode.CREATE_OR_REPLACE);
|
||||
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
|
||||
final RegistryResponseType response = lifecycleManager
|
||||
.submitObjects(submitObjectsRequest);
|
||||
|
||||
assertThat(response.getStatus(),
|
||||
is(equalTo(RegistryResponseStatus.SUCCESS)));
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateOrReplace (default) - If an object does not exist, server MUST
|
||||
* create it as a new object. If an object already exists, server MUST
|
||||
* replace the existing object with the submitted object
|
||||
*/
|
||||
@Test
|
||||
public void createOrReplaceSubmitObjectsWithExistantObjectReplacesExisting()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, Mode.CREATE_OR_REPLACE);
|
||||
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
|
||||
QueryRequest partQueryRequest = createQueryForRegistryObjectByLid(MY_REGISTRY_OBJECT_ID);
|
||||
|
||||
final QueryResponse queryResponse = queryManager
|
||||
.executeQuery(partQueryRequest);
|
||||
final List<RegistryObjectType> registryObjects = queryResponse
|
||||
.getRegistryObjectList().getRegistryObject();
|
||||
assertThat(registryObjects, hasSize(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateOrVersion - If an object does not exist, server MUST create it as a
|
||||
* new object. If an object already exists, server MUST not alter the
|
||||
* existing object and instead it MUST create a new version of the existing
|
||||
* object using the state of the submitted object
|
||||
*/
|
||||
@Test
|
||||
public void createOrVersionSubmitObjectsWithNonExistantObjectSucceeds()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, Mode.CREATE_OR_VERSION);
|
||||
|
||||
final RegistryResponseType response = lifecycleManager
|
||||
.submitObjects(submitObjectsRequest);
|
||||
|
||||
assertThat(response.getStatus(),
|
||||
is(equalTo(RegistryResponseStatus.SUCCESS)));
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateOrVersion - If an object does not exist, server MUST create it as a
|
||||
* new object. If an object already exists, server MUST not alter the
|
||||
* existing object and instead it MUST create a new version of the existing
|
||||
* object using the state of the submitted object
|
||||
*/
|
||||
@Test
|
||||
public void createOrVersionSubmitObjectsWithExistantObjectVersionsExisting()
|
||||
throws MsgRegistryException {
|
||||
|
||||
SubmitObjectsRequest submitObjectsRequest = createSubmitObjectsRequest(
|
||||
MY_REGISTRY_OBJECT_ID, Mode.CREATE_OR_VERSION);
|
||||
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
lifecycleManager.submitObjects(submitObjectsRequest);
|
||||
|
||||
QueryRequest partQueryRequest = createQueryForRegistryObjectByLid(MY_REGISTRY_OBJECT_ID);
|
||||
|
||||
final QueryResponse queryResponse = queryManager
|
||||
.executeQuery(partQueryRequest);
|
||||
final List<RegistryObjectType> registryObjects = queryResponse
|
||||
.getRegistryObjectList().getRegistryObject();
|
||||
assertThat(registryObjects, hasSize(2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the submit objects request.
|
||||
*
|
||||
* @param registryObjectId
|
||||
* the registry object id
|
||||
* @param mode
|
||||
* @return
|
||||
*/
|
||||
private SubmitObjectsRequest createSubmitObjectsRequest(
|
||||
String registryObjectId, Mode mode) {
|
||||
final RegistryObjectType registryObject = new RegistryObjectType();
|
||||
registryObject.setId(MY_REGISTRY_OBJECT_ID);
|
||||
registryObject.setLid(registryObject.getId());
|
||||
registryObject.setObjectType(REGISTRY_OBJECT_TYPE);
|
||||
|
||||
List<RegistryObjectType> registryObjects = Lists.newArrayList();
|
||||
registryObjects.add(registryObject);
|
||||
|
||||
RegistryObjectListType registryObjectList = new RegistryObjectListType();
|
||||
registryObjectList.setRegistryObject(registryObjects);
|
||||
SubmitObjectsRequest submitObjectsRequest = new SubmitObjectsRequest();
|
||||
submitObjectsRequest.setCheckReferences(false);
|
||||
submitObjectsRequest.setComment("This is a comment.");
|
||||
submitObjectsRequest.setId("someId");
|
||||
submitObjectsRequest.setMode(mode);
|
||||
submitObjectsRequest.setRegistryObjectList(registryObjectList);
|
||||
|
||||
return submitObjectsRequest;
|
||||
}
|
||||
|
||||
private QueryRequest createQueryForRegistryObjectByLid(
|
||||
String registryObjectId) {
|
||||
final ResponseOptionType responseOption = EbxmlObjectUtil.queryObjectFactory
|
||||
.createResponseOptionType();
|
||||
responseOption.setReturnType(RETURN_TYPE.RegistryObject.toString());
|
||||
responseOption.setReturnComposedObjects(false);
|
||||
|
||||
final QueryType queryType = new QueryType();
|
||||
queryType
|
||||
.setQueryDefinition("urn:oasis:names:tc:ebxml-regrep:query:GetObjectsByLid");
|
||||
Set<SlotType> slots = new HashSet<SlotType>();
|
||||
final SlotType slot = new SlotType();
|
||||
slot.setName(QueryConstants.LID);
|
||||
final StringValueType slotValue = new StringValueType();
|
||||
slotValue.setStringValue(registryObjectId);
|
||||
slot.setSlotValue(slotValue);
|
||||
slots.add(slot);
|
||||
queryType.setSlot(slots);
|
||||
|
||||
QueryRequest partQueryRequest = new QueryRequest();
|
||||
partQueryRequest.setResponseOption(responseOption);
|
||||
partQueryRequest.setFederated(false);
|
||||
partQueryRequest.setQuery(queryType);
|
||||
partQueryRequest.setMatchOlderVersions(true);
|
||||
partQueryRequest.setMaxResults(new BigInteger("9999"));
|
||||
return partQueryRequest;
|
||||
}
|
||||
|
||||
}
|
BIN
tests/lib/h2-1.3.171.jar
Normal file
BIN
tests/lib/h2-1.3.171.jar
Normal file
Binary file not shown.
Binary file not shown.
11
tests/resources/META-INF/jax-ws-catalog.xml
Normal file
11
tests/resources/META-INF/jax-ws-catalog.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE catalog
|
||||
PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"
|
||||
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
|
||||
|
||||
<!-- Required by JAX-WS used for EBXML, to find the correct schemas -->
|
||||
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
|
||||
prefer="system">
|
||||
<rewriteSystem systemIdStartString="http://www.w3.org/2006/03/addressing"
|
||||
rewritePrefix="classpath:/schemas/wsdl" />
|
||||
</catalog>
|
20
tests/resources/ebxml/unit-test-ebxml-beans.xml
Normal file
20
tests/resources/ebxml/unit-test-ebxml-beans.xml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
|
||||
|
||||
<bean id="ebxmlDbValidationStrategy"
|
||||
class="com.raytheon.uf.edex.registry.ebxml.dao.EbxmlHsqlValidationStrategy" />
|
||||
|
||||
<bean
|
||||
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="targetClass">
|
||||
<value>com.raytheon.uf.common.localization.PathManagerFactoryTest
|
||||
</value>
|
||||
</property>
|
||||
<property name="targetMethod">
|
||||
<value>initLocalization</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
|
||||
destroy-method="close">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbc.JDBCDriver" />
|
||||
<property name="url" value="jdbc:hsqldb:mem:unit-testing" />
|
||||
<property name="driverClassName" value="org.h2.Driver" />
|
||||
<property name="url" value="jdbc:h2:mem:unit-testing:;INIT=create schema IF NOT EXISTS ebxml" />
|
||||
<property name="username" value="sa" />
|
||||
<property name="password" value="" />
|
||||
<property name="defaultAutoCommit" value="false" />
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<list>
|
||||
<value>com.raytheon.uf.edex.datadelivery.bandwidth.dao</value>
|
||||
<value>com.raytheon.uf.edex.datadelivery.retrieval.db</value>
|
||||
<value>oasis.names.tc.ebxml.regrep.xsd.rim.v4</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="configLocation">
|
||||
|
@ -21,7 +22,7 @@
|
|||
</property>
|
||||
</bean>
|
||||
|
||||
<tx:annotation-driven transaction-manager="metadataTxManager" />
|
||||
<tx:annotation-driven transaction-manager="metadataTxManager" proxy-target-class="true" />
|
||||
|
||||
<bean id="metadataTxManager"
|
||||
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
|
||||
|
|
|
@ -17,5 +17,6 @@
|
|||
<property name="hibernate.jdbc.use_streams_for_binary">false</property>
|
||||
<property name="hibernate.hbm2ddl.auto">create</property>
|
||||
<property name="cache.use_query_cache">false</property>
|
||||
<property name="dialect">com.raytheon.uf.edex.database.hibernate.H2Dialect</property>
|
||||
</session-factory>
|
||||
</hibernate-configuration>
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.database.hibernate;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
|
||||
/**
|
||||
* Extend default H2Dialect to allow for a larger default column length, when
|
||||
* required.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 16, 2013 1693 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class H2Dialect extends org.hibernate.dialect.H2Dialect {
|
||||
private static final int LARGE_DEFAULT_LENGTH = 3000;
|
||||
|
||||
@Override
|
||||
public String getTypeName(int code, int length, int precision, int scale)
|
||||
throws HibernateException {
|
||||
// Overridden to return a larger column size for default length binary
|
||||
// columns, to emulate Postgres' column size growing ability
|
||||
if (code == Types.VARBINARY
|
||||
&& length == org.hibernate.mapping.Column.DEFAULT_LENGTH) {
|
||||
length = LARGE_DEFAULT_LENGTH;
|
||||
}
|
||||
return super.getTypeName(code, length, precision, scale);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.registry.ebxml.dao;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.AnnotationConfiguration;
|
||||
|
||||
/**
|
||||
* Validates the Ebxml database for HSQL.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 12, 2013 1693 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class EbxmlHsqlValidationStrategy implements
|
||||
IEbxmlDatabaseValidationStrategy {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isDbValid(AnnotationConfiguration aConfig,
|
||||
SessionFactory sessionFactory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue