Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 3bab4bda authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Merge pull request #105 in EDELIVERY/smp from...

Merge pull request #105 in EDELIVERY/smp from bugfix/EDELIVERY-3712-error-when-concurrently-calling to development

* commit '5f470ee68f8234ef51491488f180bab5f19d3140':
  update h2 database configuration for unit and integrational tests
  Wrap javax.xml.validation.Validator into ThreadLocal
parents 6a998465 de28d789
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ import eu.europa.ec.smp.api.exceptions.XmlInvalidAgainstSchemaException;
import org.xml.sax.SAXException;
import javax.xml.XMLConstants;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
......@@ -30,24 +31,37 @@ import java.net.URL;
*/
public class BdxSmpOasisValidator {
private static final Validator validator;
/**
* Class has only static members.
*/
private BdxSmpOasisValidator() {
static {
}
/**
* thread safe validator
*/
private static final ThreadLocal<Validator> validator = ThreadLocal.withInitial( () -> {
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
URL xsdFilePath = BdxSmpOasisValidator.class.getResource("/bdx-smp-201605.xsd");
try {
Schema schema = schemaFactory.newSchema(xsdFilePath);
validator = schema.newValidator();
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
validator.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
Validator vaInstance = schema.newValidator();
vaInstance.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
vaInstance.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
return vaInstance;
} catch (SAXException e) {
throw new IllegalStateException("Unable to initialize BDX SMP OASIS XSD schema validator.", e);
}
} );
private static Validator getValidator() {
return validator.get();
}
public static void validateXSD(String xmlBody) throws XmlInvalidAgainstSchemaException {
try {
validator.validate(new StreamSource(new StringReader(xmlBody)));
getValidator().validate(new StreamSource(new StringReader(xmlBody)));
} catch (SAXException | IOException e) {
throw new XmlInvalidAgainstSchemaException(e.getMessage(), e);
}
......
......@@ -6,9 +6,7 @@ import eu.europa.ec.edelivery.smp.services.ServiceUIData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.*;
import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.hibernate5.HibernateTransactionManager;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
......@@ -17,12 +15,10 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Configuration
//@PropertySource("persistence-test-h2.properties")
@EnableTransactionManagement
public class H2JPATestConfiguration {
@Autowired
......@@ -31,19 +27,10 @@ public class H2JPATestConfiguration {
@Bean(name = "h2DataSource")
public DataSource h2DataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
/*
dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName"));
dataSource.setUrl(env.getProperty("jdbc.url"));
dataSource.setUsername(env.getProperty("jdbc.user"));
dataSource.setPassword(env.getProperty("jdbc.pass"));*/
dataSource.setDriverClassName("org.h2.Driver");
dataSource.setUrl("jdbc:h2:file:./target/myDb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=TRUE;AUTO_SERVER=TRUE");
dataSource.setUrl("jdbc:h2:file:./target/h2TestDb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=TRUE;AUTO_SERVER=TRUE");
dataSource.setUsername("smp-dev");
dataSource.setPassword("smp-dev");
return dataSource;
}
......@@ -52,7 +39,8 @@ public class H2JPATestConfiguration {
LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
lef.setDataSource(h2DataSource);
lef.setJpaVendorAdapter(jpaVendorAdapter);
lef.setPackagesToScan("eu.europa.ec.edelivery.smp.data.ui");
lef.getJpaPropertyMap().put("org.hibernate.envers.store_data_at_delete", true);
lef.setPackagesToScan("eu.europa.ec.edelivery.smp.data.ui", "eu.europa.ec.edelivery.smp.data.model");
return lef;
}
......@@ -63,8 +51,6 @@ public class H2JPATestConfiguration {
hibernateJpaVendorAdapter.setShowSql(false);
hibernateJpaVendorAdapter.setGenerateDdl(true);
hibernateJpaVendorAdapter.setDatabase(Database.H2);
return hibernateJpaVendorAdapter;
}
......@@ -80,13 +66,11 @@ public class H2JPATestConfiguration {
public ServiceUIData serviceUIData(){
ServiceUIData serviceMetadat = new ServiceUIData();
return serviceMetadat;
}
@Bean
public UiDaoService uiDaoService(){
UiDaoService uiDaoService = new UiDaoService();
return uiDaoService;
}
}
......@@ -13,8 +13,7 @@
package eu.europa.ec.edelivery.smp.services;
import eu.europa.ec.edelivery.smp.config.PropertiesSingleDomainTestConfig;
import eu.europa.ec.edelivery.smp.config.SmpServicesTestConfig;
import eu.europa.ec.edelivery.smp.config.H2JPATestConfiguration;
import eu.europa.ec.edelivery.smp.data.model.*;
import org.hibernate.envers.AuditReader;
import org.hibernate.envers.AuditReaderFactory;
......@@ -24,15 +23,10 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.persistence.*;
import javax.xml.bind.JAXBException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
;
import java.util.Map;
import java.util.UUID;
......@@ -44,17 +38,14 @@ import static eu.europa.ec.edelivery.smp.testutil.AuditUtils.*;
* Created by rihtajo
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {SmpServicesTestConfig.class, PropertiesSingleDomainTestConfig.class})
@ContextConfiguration(classes = {H2JPATestConfiguration.class})
public class AuditIntegrationTest {
// because envers creates audit on commit we user PersistenceUnit to control commit...
// (instead of PersistenceContext and transaction annotations... )
@PersistenceUnit
EntityManagerFactory emf;
@Before
public void before() throws IOException {
clearDatabase();
......@@ -92,6 +83,7 @@ public class AuditIntegrationTest {
}
public void clearTable(EntityManager em, String tableName, String condition){
System.out.printf(String.format("DELETE FROM %s WHERE %s", tableName, condition));
System.out.printf(String.format("DELETE FROM %s_AUD WHERE %s", tableName, condition));
Query qTable = em.createNativeQuery(String.format("DELETE FROM %s WHERE %s", tableName, condition));
......
......@@ -2,12 +2,11 @@ package eu.europa.ec.edelivery.smp.services;
import eu.europa.ec.edelivery.smp.config.H2JPATestConfiguration;
import eu.europa.ec.edelivery.smp.data.ui.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
......@@ -16,46 +15,67 @@ import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {
H2JPATestConfiguration.class})
@ActiveProfiles("db-h2-integration-test")
@Transactional
public class ServiceUIDataIntegrationTest {
@Autowired
private ServiceUIData serviceUIData;
private DomainRO testDomain = null;
private ServiceGroupRO testSG = null;
@Before
public void initDatabase() {
testDomain = new DomainRO();
testDomain.setDomainId("test");
testDomain.setBdmslSmpId("test");
serviceUIData.persistDomain(testDomain);
testSG = new ServiceGroupRO();
testSG.setServiceGroupROId(new ServiceGroupRO.ServiceGroupROId());
testSG.getServiceGroupROId().setParticipantId("testParticipantId");
testSG.getServiceGroupROId().setParticipantSchema("testParticipantSchema");
testSG.setDomain(testDomain.getDomainId());
serviceUIData.persistServiceGroup(testSG);
}
@Test
public void getServiceGroupList() {
for (int i=0;i<20; i++) {
for (int i = 0; i < 20; i++) {
ServiceGroupRO sg = new ServiceGroupRO();
sg.setServiceGroupROId(new ServiceGroupRO.ServiceGroupROId());
sg.getServiceGroupROId().setParticipantId("ParticipantId" + i);
sg.getServiceGroupROId().setParticipantSchema("ParticipantId");
sg.setDomain("test");
sg.setDomain(testDomain.getDomainId());
serviceUIData.persistServiceGroup(sg);
}
ServiceResult<ServiceGroupRO> lst = serviceUIData.getServiceGroupList(0,10,null,null);
ServiceResult<ServiceGroupRO> lst = serviceUIData.getServiceGroupList(0, 10, null, null);
assertEquals(10, lst.getServiceEntities().size());
}
@Test
public void getUserList() {
for (int i=0;i<20; i++) {
for (int i = 0; i < 20; i++) {
UserRO ent = new UserRO();
ent.setAdmin(false);
ent.setUsername("Username" +i);
ent.setUsername("Username" + i);
ent.setPassword("Password");
serviceUIData.persistUser(ent);
}
ServiceResult<UserRO> lst = serviceUIData.getUserList(0,10,null,null);
ServiceResult<UserRO> lst = serviceUIData.getUserList(0, 10, null, null);
assertEquals(10, lst.getServiceEntities().size());
}
@Test
public void getDomainList() {
for (int i=0;i<20; i++) {
for (int i = 0; i < 20; i++) {
DomainRO ent = new DomainRO();
ent.setDomainId("DomainId" + i);
ent.setBdmslClientCertAlias("dmslClientCertAlias");
......@@ -65,30 +85,28 @@ public class ServiceUIDataIntegrationTest {
serviceUIData.persistDomain(ent);
}
ServiceResult<DomainRO> lst = serviceUIData.getDomainList(0,10,null,null);
ServiceResult<DomainRO> lst = serviceUIData.getDomainList(0, 10, null, null);
assertEquals(10, lst.getServiceEntities().size());
}
@Test
public void getServiceMetadataList() {
for (int i=0;i<20; i++) {
for (int i = 0; i < 20; i++) {
ServiceMetadataRO ent = new ServiceMetadataRO();
ent.setServiceMetadataROId(new ServiceMetadataRO.ServiceMetadataROId());
ent.getServiceMetadataROId().setDocumentIdScheme("DocumentIdScheme");
ent.getServiceMetadataROId().setDocumentIdValue("DocumentIdValue");
ent.getServiceMetadataROId().setParticipantId("ParticipantId" +i);
ent.getServiceMetadataROId().setParticipantSchema("ParticipantSchema");
ent.getServiceMetadataROId().setDocumentIdValue("DocumentIdValue" +i);
ent.getServiceMetadataROId().setParticipantId(testSG.getServiceGroupROId().getParticipantId());
ent.getServiceMetadataROId().setParticipantSchema(testSG.getServiceGroupROId().getParticipantSchema());
long cnt = serviceUIData.getServiceMetadataList(0, 10, null, null).getCount();
serviceUIData.persistMetaData(ent);
}
ServiceResult<ServiceMetadataRO> lst = serviceUIData.getServiceMetadataList(0,10,null,null);
ServiceResult<ServiceMetadataRO> lst = serviceUIData.getServiceMetadataList(0, 10, null, null);
assertEquals(10, lst.getServiceEntities().size());
}
@Test
public void persistServiceGroup() {
......@@ -96,29 +114,28 @@ public class ServiceUIDataIntegrationTest {
sg.setServiceGroupROId(new ServiceGroupRO.ServiceGroupROId());
sg.getServiceGroupROId().setParticipantId("ParticipantId");
sg.getServiceGroupROId().setParticipantSchema("ParticipantId");
sg.setDomain("test");
long cnt = serviceUIData.getServiceGroupList(0,10,null,null).getCount();
sg.setDomain(testDomain.getDomainId());
long cnt = serviceUIData.getServiceGroupList(0, 10, null, null).getCount();
serviceUIData.persistServiceGroup(sg);
ServiceResult<ServiceGroupRO> lst = serviceUIData.getServiceGroupList(0,10,null,null);
ServiceResult<ServiceGroupRO> lst = serviceUIData.getServiceGroupList(0, 10, null, null);
assertEquals(cnt + 1, lst.getCount().longValue());
}
@Test
public void persistUser() {
UserRO ent = new UserRO();
ent.setAdmin(false);
ent.setUsername("Username");
ent.setPassword("Password");
long cnt = serviceUIData.getUserList(0,10,null,null).getCount();
long cnt = serviceUIData.getUserList(0, 10, null, null).getCount();
serviceUIData.persistUser(ent);
ServiceResult<UserRO> lst = serviceUIData.getUserList(0,10,null,null);
assertEquals(cnt+1, lst.getCount().longValue());
ServiceResult<UserRO> lst = serviceUIData.getUserList(0, 10, null, null);
assertEquals(cnt + 1, lst.getCount().longValue());
}
@Test
......@@ -130,12 +147,12 @@ public class ServiceUIDataIntegrationTest {
ent.setBdmslClientCertHeader("dmslClientCertHeader");
ent.setBdmslSmpId("BdmslSmpId");
ent.setSignatureCertAlias("SignatureCertAlias");
long cnt = serviceUIData.getDomainList(0,10,null,null).getCount();
long cnt = serviceUIData.getDomainList(0, 10, null, null).getCount();
serviceUIData.persistDomain(ent);
ServiceResult<DomainRO> lst = serviceUIData.getDomainList(0,10,null,null);
assertEquals(cnt+1, lst.getCount().longValue());
ServiceResult<DomainRO> lst = serviceUIData.getDomainList(0, 10, null, null);
assertEquals(cnt + 1, lst.getCount().longValue());
}
@Test
......@@ -144,16 +161,14 @@ public class ServiceUIDataIntegrationTest {
ent.setServiceMetadataROId(new ServiceMetadataRO.ServiceMetadataROId());
ent.getServiceMetadataROId().setDocumentIdScheme("DocumentIdScheme");
ent.getServiceMetadataROId().setDocumentIdValue("DocumentIdValue");
ent.getServiceMetadataROId().setParticipantId("ParticipantId");
ent.getServiceMetadataROId().setParticipantSchema("ParticipantSchema");
long cnt = serviceUIData.getServiceMetadataList(0,10,null,null).getCount();
ent.getServiceMetadataROId().setParticipantId(testSG.getServiceGroupROId().getParticipantId());
ent.getServiceMetadataROId().setParticipantSchema(testSG.getServiceGroupROId().getParticipantSchema());
long cnt = serviceUIData.getServiceMetadataList(0, 10, null, null).getCount();
serviceUIData.persistMetaData(ent);
ServiceResult<ServiceMetadataRO> lst = serviceUIData.getServiceMetadataList(0,10,null,null);
assertEquals(cnt+1, lst.getCount().longValue());
ServiceResult<ServiceMetadataRO> lst = serviceUIData.getServiceMetadataList(0, 10, null, null);
assertEquals(cnt + 1, lst.getCount().longValue());
}
}
\ No newline at end of file
......@@ -10,133 +10,70 @@
-- See the Licence for the specific language governing permissions and limitations under the Licence.
CREATE TABLE smp_domain (
domainId VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
bdmslClientCertHeader VARCHAR(4000)
CHARACTER SET utf8
COLLATE utf8_bin NULL,
bdmslClientCertAlias VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NULL,
bdmslSmpId VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
signatureCertAlias VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NULL,
domainId VARCHAR(50) NOT NULL,
bdmslClientCertHeader VARCHAR(4000) ,
bdmslClientCertAlias VARCHAR(50) ,
bdmslSmpId VARCHAR(50) NOT NULL,
signatureCertAlias VARCHAR(50) ,
PRIMARY KEY(domainId)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
);
CREATE TABLE smp_domain_AUD (
domainId VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
bdmslClientCertHeader VARCHAR(4000)
CHARACTER SET utf8
COLLATE utf8_bin NULL,
bdmslClientCertAlias VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NULL,
bdmslSmpId VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
signatureCertAlias VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NULL,
domainId VARCHAR(50) NOT NULL,
bdmslClientCertHeader VARCHAR(4000),
bdmslClientCertAlias VARCHAR(50),
bdmslSmpId VARCHAR(50) NOT NULL,
signatureCertAlias VARCHAR(50) NULL,
REV integer not null,
REVTYPE tinyint,
PRIMARY KEY(domainId, REV)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
);
CREATE TABLE smp_service_group (
businessIdentifier VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
businessIdentifierScheme VARCHAR(100)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
domainId VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL
DEFAULT 'domain1',
businessIdentifier VARCHAR(50) NOT NULL,
businessIdentifierScheme VARCHAR(100) NOT NULL,
domainId VARCHAR(50) DEFAULT 'domain1' NOT NULL ,
extension TEXT NULL DEFAULT NULL,
PRIMARY KEY (businessIdentifier, businessIdentifierScheme),
CONSTRAINT FK_srv_group_domain FOREIGN KEY (domainId)
REFERENCES smp_domain (domainId)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
);
CREATE TABLE smp_service_group_AUD (
businessIdentifier VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
businessIdentifierScheme VARCHAR(100)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
domainId VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL
DEFAULT 'domain1',
businessIdentifier VARCHAR(50) NOT NULL,
businessIdentifierScheme VARCHAR(100) NOT NULL,
domainId VARCHAR(50) NOT NULL,
extension TEXT NULL DEFAULT NULL,
REV integer not null,
REVTYPE tinyint,
PRIMARY KEY (businessIdentifier, businessIdentifierScheme, REV)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
);
CREATE TABLE smp_service_metadata (
documentIdentifier VARCHAR(500)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
documentIdentifierScheme VARCHAR(100)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
businessIdentifier VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
businessIdentifierScheme VARCHAR(100)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
documentIdentifier VARCHAR(500) NOT NULL,
documentIdentifierScheme VARCHAR(100) NOT NULL,
businessIdentifier VARCHAR(50) NOT NULL,
businessIdentifierScheme VARCHAR(100) NOT NULL,
xmlcontent TEXT,
PRIMARY KEY (documentIdentifier, documentIdentifierScheme, businessIdentifier, businessIdentifierScheme),
KEY FK_service_metadata_service_group (businessIdentifier, businessIdentifierScheme),
CONSTRAINT FK_service_metadata_service_group FOREIGN KEY (businessIdentifier, businessIdentifierScheme) REFERENCES smp_service_group (businessIdentifier, businessIdentifierScheme)
FOREIGN KEY (businessIdentifier, businessIdentifierScheme) REFERENCES smp_service_group (businessIdentifier, businessIdentifierScheme)
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
);
CREATE TABLE smp_service_metadata_AUD (
documentIdentifier VARCHAR(500)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
documentIdentifierScheme VARCHAR(100)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
businessIdentifier VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
businessIdentifierScheme VARCHAR(100)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
documentIdentifier VARCHAR(500) NOT NULL,
documentIdentifierScheme VARCHAR(100) NOT NULL,
businessIdentifier VARCHAR(50) NOT NULL,
businessIdentifierScheme VARCHAR(100) NOT NULL,
xmlcontent TEXT,
REV integer not null,
REVTYPE tinyint,
PRIMARY KEY (documentIdentifier, documentIdentifierScheme, businessIdentifier, businessIdentifierScheme, REV)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
);
CREATE TABLE smp_user (
......@@ -144,9 +81,7 @@ CREATE TABLE smp_user (
password VARCHAR(256),
isadmin TINYINT(1) DEFAULT 0 NOT NULL,
PRIMARY KEY (username)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
);
CREATE TABLE smp_user_AUD (
username VARCHAR(256) NOT NULL,
......@@ -155,46 +90,31 @@ CREATE TABLE smp_user_AUD (
REV integer not null,
REVTYPE tinyint,
PRIMARY KEY (username, REV)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
);
CREATE TABLE smp_ownership (
username VARCHAR(256) NOT NULL,
businessIdentifier VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
businessIdentifierScheme VARCHAR(100)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
KEY FK_ownership_service_group (businessIdentifier, businessIdentifierScheme),
KEY FK_ownership_user (username),
CONSTRAINT FK_ownership_service_group FOREIGN KEY (businessIdentifier, businessIdentifierScheme) REFERENCES smp_service_group (businessIdentifier, businessIdentifierScheme)
businessIdentifier VARCHAR(50) NOT NULL,
businessIdentifierScheme VARCHAR(100),
PRIMARY KEY (businessIdentifier, businessIdentifierScheme, username),
FOREIGN KEY (businessIdentifier, businessIdentifierScheme) REFERENCES smp_service_group (businessIdentifier, businessIdentifierScheme)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT FK_ownership_user FOREIGN KEY (username) REFERENCES smp_user (username)
FOREIGN KEY (username) REFERENCES smp_user (username)
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
);
CREATE TABLE smp_ownership_AUD (
username VARCHAR(256) NOT NULL,
businessIdentifier VARCHAR(50)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
businessIdentifierScheme VARCHAR(100)
CHARACTER SET utf8
COLLATE utf8_bin NOT NULL,
businessIdentifier VARCHAR(50) NOT NULL,
businessIdentifierScheme VARCHAR(100) NOT NULL,
REV integer not null,
REVTYPE tinyint,
PRIMARY KEY (username, businessIdentifier, businessIdentifierScheme, REV)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8;
);
CREATE TABLE SMP_REV_INFO (
......@@ -203,67 +123,10 @@ CREATE TABLE SMP_REV_INFO (
REVISION_DATE timestamp NULL,
username VARCHAR(255) NULL,
CONSTRAINT PK_SMP_REV_INFO PRIMARY KEY (ID)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
DELIMITER //
DROP PROCEDURE IF EXISTS validate_new_user //
CREATE PROCEDURE validate_new_user (IN new_user_is_admin TINYINT(1))
BEGIN
IF new_user_is_admin <> 0 AND new_user_is_admin <> 1
THEN
SIGNAL SQLSTATE '99999'
SET MESSAGE_TEXT = '0 or 1 are the only allowed values for ISADMIN column';
END IF;
END //
DROP PROCEDURE IF EXISTS validate_new_domain //
CREATE PROCEDURE validate_new_domain (IN new_bdmsl_client_cert_alias varchar(50), IN new_bdmsl_client_cert_header varchar(4000))
BEGIN
IF ((new_bdmsl_client_cert_alias > '' OR new_bdmsl_client_cert_alias = null) AND (new_bdmsl_client_cert_header > '' OR new_bdmsl_client_cert_header = null))
THEN
SIGNAL SQLSTATE '99999'
SET MESSAGE_TEXT = 'Both BDMSL authentication ways cannot be switched ON at the same time: bdmslClientCertAlias and bdmslClientCertHeader';
END IF;
END //
DROP TRIGGER IF EXISTS smp_domain_check_bdmsl_auth_before_insert //
DROP TRIGGER IF EXISTS smp_domain_check_bdmsl_auth_before_update //
CREATE TRIGGER smp_domain_check_bdmsl_auth_before_update
BEFORE UPDATE ON smp_domain
FOR EACH ROW
BEGIN
call validate_new_domain(NEW.bdmslClientCertAlias, NEW.bdmslClientCertHeader);
END //
CREATE TRIGGER smp_domain_check_bdmsl_auth_before_insert
BEFORE INSERT ON smp_domain
FOR EACH ROW
BEGIN
call validate_new_domain(NEW.bdmslClientCertAlias, NEW.bdmslClientCertHeader);
END //
);
DROP TRIGGER IF EXISTS smp_user_check_is_admin_value_before_insert //
DROP TRIGGER IF EXISTS smp_user_check_is_admin_value_before_update //
CREATE TRIGGER smp_user_check_is_admin_value_before_insert
BEFORE INSERT ON smp_user
FOR EACH ROW
BEGIN
call validate_new_user(NEW.ISADMIN);
END //
CREATE TRIGGER smp_user_check_is_admin_value_before_update
BEFORE UPDATE ON smp_user
FOR EACH ROW
BEGIN
call validate_new_user(NEW.ISADMIN);
END //
DELIMITER ;
create table hibernate_sequence(
next_val BIGINT NOT NULL
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment