You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2013/09/18 14:11:04 UTC
svn commit: r1524383 - in /syncope/branches/1_1_X/core: ./
src/main/java/org/apache/syncope/core/audit/
src/main/java/org/apache/syncope/core/persistence/dao/impl/
src/main/resources/ src/main/resources/logback/
Author: ilgrosso
Date: Wed Sep 18 12:11:04 2013
New Revision: 1524383
URL: http://svn.apache.org/r1524383
Log:
[SYNCOPE-412] Backporting to 1_1_X part of audit SQL management from SYNCOPE-405
Removed:
syncope/branches/1_1_X/core/src/main/resources/logback/hsqldb.sql
Modified:
syncope/branches/1_1_X/core/pom.xml
syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/audit/JNDIFallbackConnectionSource.java
syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AbstractContentDealer.java
syncope/branches/1_1_X/core/src/main/resources/audit.xml
syncope/branches/1_1_X/core/src/main/resources/logback/h2.sql
syncope/branches/1_1_X/core/src/main/resources/logback/mysql.sql
syncope/branches/1_1_X/core/src/main/resources/logback/oracle.sql
syncope/branches/1_1_X/core/src/main/resources/logback/postgresql.sql
syncope/branches/1_1_X/core/src/main/resources/logback/sqlserver.sql
syncope/branches/1_1_X/core/src/main/resources/syncopeContext.xml
Modified: syncope/branches/1_1_X/core/pom.xml
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/pom.xml?rev=1524383&r1=1524382&r2=1524383&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/pom.xml (original)
+++ syncope/branches/1_1_X/core/pom.xml Wed Sep 18 12:11:04 2013
@@ -1027,7 +1027,7 @@ under the License.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
- <version>5.1.24</version>
+ <version>5.1.26</version>
<scope>test</scope>
</dependency>
</dependencies>
Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/audit/JNDIFallbackConnectionSource.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/audit/JNDIFallbackConnectionSource.java?rev=1524383&r1=1524382&r2=1524383&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/audit/JNDIFallbackConnectionSource.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/audit/JNDIFallbackConnectionSource.java Wed Sep 18 12:11:04 2013
@@ -18,138 +18,108 @@
*/
package org.apache.syncope.core.audit;
-import ch.qos.logback.core.db.ConnectionSource;
-import ch.qos.logback.core.db.ConnectionSourceBase;
import ch.qos.logback.core.db.DataSourceConnectionSource;
-import ch.qos.logback.core.db.JNDIConnectionSource;
-import ch.qos.logback.core.db.dialect.SQLDialectCode;
-import ch.qos.logback.core.spi.ContextAwareBase;
+import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
+import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
-import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import javax.sql.DataSource;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.commons.io.IOUtils;
+import org.apache.syncope.core.persistence.dao.impl.AbstractContentDealer;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PropertiesLoaderUtils;
+import org.springframework.jdbc.datasource.DataSourceUtils;
+import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSParser;
/**
- * Implementation of {@link ConnectionSource} that attempts at first to obtain a {@link javax.sql.DataSource} from a
- * JNDI provider and, if not found, from a provided {@link javax.sql.DataSource DataSource}.
+ * Specialization of {@link DataSourceConnectionSource} that first attempts to obtain a {@link javax.sql.DataSource}
+ * from the JNDI name configured in Spring or, when not found, builds a new {@link javax.sql.DataSource DataSource} via
+ * Commons DBCP; if any datasource if found, the SQL init script is used to populate the database.
*/
-public class JNDIFallbackConnectionSource extends ContextAwareBase implements ConnectionSource {
+public class JNDIFallbackConnectionSource extends DataSourceConnectionSource {
- private String jndiLocation;
+ private static final String PERSISTENCE_CONTEXT = "/persistenceContext.xml";
- private DataSource dataSource;
+ private static DataSource datasource;
- private ConnectionSourceBase delegate;
-
- public String getJndiLocation() {
- return jndiLocation;
- }
-
- public void setJndiLocation(final String jndiLocation) {
- this.jndiLocation = jndiLocation;
- }
-
- public DataSource getDataSource() {
- return dataSource;
- }
+ static {
+ // 1. Attempts to lookup for configured JNDI datasource (if present and available)
+ InputStream springConf = JNDIFallbackConnectionSource.class.getResourceAsStream(PERSISTENCE_CONTEXT);
+ try {
+ DOMImplementationRegistry reg = DOMImplementationRegistry.newInstance();
+ DOMImplementationLS impl = (DOMImplementationLS) reg.getDOMImplementation("LS");
+ LSParser parser = impl.createLSParser(DOMImplementationLS.MODE_SYNCHRONOUS, null);
+ LSInput lsinput = impl.createLSInput();
+ lsinput.setByteStream(springConf);
+
+ XPathFactory xPathfactory = XPathFactory.newInstance();
+ XPath xpath = xPathfactory.newXPath();
+ XPathExpression expr = xpath.compile("//*[local-name()='property' and @name='jndiName']/@value");
+ String jndiName = (String) expr.evaluate(parser.parse(lsinput), XPathConstants.STRING);
- public void setDataSource(final DataSource dataSource) {
- this.dataSource = dataSource;
- }
+ Context ctx = new InitialContext();
+ Object obj = ctx.lookup(jndiName);
- private void chooseDelegate() {
- if (delegate != null) {
- return;
+ datasource = (DataSource) PortableRemoteObject.narrow(obj, DataSource.class);
+ } catch (Exception e) {
+ // ignore
+ } finally {
+ IOUtils.closeQuietly(springConf);
}
- JNDIConnectionSource jndiCS = new JNDIConnectionSource();
- jndiCS.setJndiLocation(jndiLocation);
+ // 2. Creates Commons DBCP datasource
+ String initSQLScript = null;
try {
- Context ctx = new InitialContext();
- Object obj = ctx.lookup(jndiCS.getJndiLocation());
+ Properties persistence = PropertiesLoaderUtils.loadProperties(
+ new ClassPathResource(AbstractContentDealer.PERSISTENCE_PROPERTIES));
- PortableRemoteObject.narrow(obj, DataSource.class);
+ initSQLScript = persistence.getProperty("logback.sql");
- delegate = jndiCS;
- addInfo("DataSource obtained from " + jndiLocation);
- } catch (NamingException e) {
- addError("During lookup of " + jndiLocation);
- } catch (ClassCastException e) {
- addError("Object at " + jndiLocation + " does not seem to be a DataSource instance", e);
- }
+ if (datasource == null) {
+ BasicDataSource bds = new BasicDataSource();
+ bds.setDriverClassName(persistence.getProperty("jpa.driverClassName"));
+ bds.setUrl(persistence.getProperty("jpa.url"));
+ bds.setUsername(persistence.getProperty("jpa.username"));
+ bds.setPassword(persistence.getProperty("jpa.password"));
- if (delegate == null) {
- addInfo("Could not obtain DataSource via JNDI");
+ bds.setLogAbandoned(true);
+ bds.setRemoveAbandoned(true);
- DataSourceConnectionSource dataSourceCS = new DataSourceConnectionSource();
- dataSourceCS.setDataSource(dataSource);
- Connection conn = null;
- try {
- conn = dataSourceCS.getConnection();
-
- delegate = dataSourceCS;
- addInfo("Provided DataSource successfully reported");
- } catch (SQLException e) {
- addError("While trying to get connection from DataSource " + dataSource, e);
- } finally {
- if (conn != null) {
- try {
- conn.close();
- } catch (SQLException sqle) {
- addError("Could not close connection", sqle);
- }
- }
+ datasource = bds;
}
+ } catch (Exception e) {
+ throw new IllegalStateException("Audit datasource configuration failed", e);
}
- if (delegate != null) {
- delegate.setContext(context);
+ // 3. Initializes the chosen datasource
+ ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
+ populator.setScripts(new Resource[] {new ClassPathResource("/logback/" + initSQLScript)});
+ // forces statement separation via ;; in order to support stored procedures
+ populator.setSeparator(";;");
+ Connection conn = DataSourceUtils.getConnection(datasource);
+ try {
+ populator.populate(conn);
+ } catch (SQLException e) {
+ throw new IllegalStateException("Could not init the Audit datasource", e);
+ } finally {
+ DataSourceUtils.releaseConnection(conn, datasource);
}
}
- @Override
- public boolean isStarted() {
- chooseDelegate();
- return delegate.isStarted();
- }
-
- @Override
- public void start() {
- chooseDelegate();
- delegate.start();
- }
-
- @Override
- public void stop() {
- chooseDelegate();
- delegate.stop();
- }
-
- @Override
- public Connection getConnection() throws SQLException {
-
- chooseDelegate();
- return delegate.getConnection();
- }
-
- @Override
- public SQLDialectCode getSQLDialectCode() {
- chooseDelegate();
- return delegate.getSQLDialectCode();
- }
-
- @Override
- public boolean supportsGetGeneratedKeys() {
- chooseDelegate();
- return delegate.supportsGetGeneratedKeys();
- }
-
- @Override
- public boolean supportsBatchUpdates() {
- chooseDelegate();
- return delegate.supportsBatchUpdates();
+ public JNDIFallbackConnectionSource() {
+ super.setDataSource(datasource);
}
}
Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AbstractContentDealer.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AbstractContentDealer.java?rev=1524383&r1=1524382&r2=1524383&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AbstractContentDealer.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AbstractContentDealer.java Wed Sep 18 12:11:04 2013
@@ -35,7 +35,7 @@ public abstract class AbstractContentDea
protected static final String ROOT_ELEMENT = "dataset";
- private static final String PERSISTENCE_PROPERTIES = "/persistence.properties";
+ public static final String PERSISTENCE_PROPERTIES = "/persistence.properties";
private static final String VIEWS_XML = "/views.xml";
Modified: syncope/branches/1_1_X/core/src/main/resources/audit.xml
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/resources/audit.xml?rev=1524383&r1=1524382&r2=1524383&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/resources/audit.xml (original)
+++ syncope/branches/1_1_X/core/src/main/resources/audit.xml Wed Sep 18 12:11:04 2013
@@ -18,18 +18,8 @@ specific language governing permissions
under the License.
-->
<included>
- <property resource="persistence.properties"/>
-
<appender name="audit" class="ch.qos.logback.classic.db.DBAppender">
- <connectionSource class="org.apache.syncope.core.audit.JNDIFallbackConnectionSource">
- <param name="jndiLocation" value="java:comp/env/jdbc/syncopeDataSource"/>
- <dataSource class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <param name="driverClassName" value="${jpa.driverClassName}"/>
- <param name="url" value="${jpa.url}"/>
- <param name="username" value="${jpa.username}"/>
- <param name="password" value="${jpa.password}"/>
- </dataSource>
- </connectionSource>
+ <connectionSource class="org.apache.syncope.core.audit.JNDIFallbackConnectionSource"/>
</appender>
<logger name="syncope.audit" additivity="false">
Modified: syncope/branches/1_1_X/core/src/main/resources/logback/h2.sql
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/resources/logback/h2.sql?rev=1524383&r1=1524382&r2=1524383&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/resources/logback/h2.sql (original)
+++ syncope/branches/1_1_X/core/src/main/resources/logback/h2.sql Wed Sep 18 12:11:04 2013
@@ -15,15 +15,11 @@
-- specific language governing permissions and limitations
-- under the License.
-# This SQL script creates the required tables by ch.qos.logback.classic.db.DBAppender.
-#
-# It is intended for H2 databases.
+-- This SQL script creates the required tables by ch.qos.logback.classic.db.DBAppender.
+--
+-- It is intended for H2 databases.
-DROP TABLE logging_event_exception IF EXISTS;
-DROP TABLE logging_event_property IF EXISTS;
-DROP TABLE logging_event IF EXISTS;
-
-CREATE TABLE logging_event (
+CREATE TABLE IF NOT EXISTS logging_event (
timestmp BIGINT NOT NULL,
formatted_message LONGVARCHAR NOT NULL,
logger_name VARCHAR(256) NOT NULL,
@@ -38,19 +34,18 @@ CREATE TABLE logging_event (
caller_class VARCHAR(256),
caller_method VARCHAR(256),
caller_line CHAR(4),
- event_id IDENTITY NOT NULL);
-
+ event_id IDENTITY NOT NULL);;
-CREATE TABLE logging_event_property (
+CREATE TABLE IF NOT EXISTS logging_event_property (
event_id BIGINT NOT NULL,
mapped_key VARCHAR(254) NOT NULL,
mapped_value LONGVARCHAR,
PRIMARY KEY(event_id, mapped_key),
- FOREIGN KEY (event_id) REFERENCES logging_event(event_id));
+ FOREIGN KEY (event_id) REFERENCES logging_event(event_id));;
-CREATE TABLE logging_event_exception (
+CREATE TABLE IF NOT EXISTS logging_event_exception (
event_id BIGINT NOT NULL,
i SMALLINT NOT NULL,
trace_line VARCHAR(256) NOT NULL,
PRIMARY KEY(event_id, i),
- FOREIGN KEY (event_id) REFERENCES logging_event(event_id));
+ FOREIGN KEY (event_id) REFERENCES logging_event(event_id));;
Modified: syncope/branches/1_1_X/core/src/main/resources/logback/mysql.sql
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/resources/logback/mysql.sql?rev=1524383&r1=1524382&r2=1524383&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/resources/logback/mysql.sql (original)
+++ syncope/branches/1_1_X/core/src/main/resources/logback/mysql.sql Wed Sep 18 12:11:04 2013
@@ -15,20 +15,12 @@
-- specific language governing permissions and limitations
-- under the License.
-# This SQL script creates the required tables by ch.qos.logback.classic.db.DBAppender.
-#
-# It is intended for MySQL databases. It has been tested on MySQL 5.1.37
-# on Linux
+-- This SQL script creates the required tables by ch.qos.logback.classic.db.DBAppender.
+--
+-- It is intended for MySQL databases. It has been tested on MySQL 5.1.37
+-- on Linux
-BEGIN;
-DROP TABLE IF EXISTS logging_event_property;
-DROP TABLE IF EXISTS logging_event_exception;
-DROP TABLE IF EXISTS logging_event;
-COMMIT;
-
-
-BEGIN;
-CREATE TABLE logging_event
+CREATE TABLE IF NOT EXISTS logging_event
(
timestmp BIGINT NOT NULL,
formatted_message TEXT NOT NULL,
@@ -45,27 +37,22 @@ CREATE TABLE logging_event
caller_method VARCHAR(254) NOT NULL,
caller_line CHAR(4) NOT NULL,
event_id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY
- );
-COMMIT;
+ );;
-BEGIN;
-CREATE TABLE logging_event_property
+CREATE TABLE IF NOT EXISTS logging_event_property
(
event_id BIGINT NOT NULL,
mapped_key VARCHAR(254) NOT NULL,
mapped_value TEXT,
PRIMARY KEY(event_id, mapped_key),
FOREIGN KEY (event_id) REFERENCES logging_event(event_id)
- );
-COMMIT;
+ );;
-BEGIN;
-CREATE TABLE logging_event_exception
+CREATE TABLE IF NOT EXISTS logging_event_exception
(
event_id BIGINT NOT NULL,
i SMALLINT NOT NULL,
trace_line VARCHAR(254) NOT NULL,
PRIMARY KEY(event_id, i),
FOREIGN KEY (event_id) REFERENCES logging_event(event_id)
- );
-COMMIT;
\ No newline at end of file
+ );;
Modified: syncope/branches/1_1_X/core/src/main/resources/logback/oracle.sql
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/resources/logback/oracle.sql?rev=1524383&r1=1524382&r2=1524383&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/resources/logback/oracle.sql (original)
+++ syncope/branches/1_1_X/core/src/main/resources/logback/oracle.sql Wed Sep 18 12:11:04 2013
@@ -20,17 +20,17 @@
-- It is intended for Oracle 9i, 10g and 11g databases. Tested on version 9.2,
-- 10g and 11g.
--- The following lines are useful in cleaning any previously existing tables
-
---drop TRIGGER logging_event_id_seq_trig;
---drop SEQUENCE logging_event_id_seq;
---drop table logging_event_property;
---drop table logging_event_exception;
---drop table logging_event;
-
-
-CREATE SEQUENCE logging_event_id_seq MINVALUE 1 START WITH 1;
+BEGIN
+ BEGIN
+ EXECUTE IMMEDIATE 'DROP TABLE logging_event CASCADE CONSTRAINTS';
+ EXCEPTION
+ WHEN OTHERS THEN
+ IF SQLCODE != -942 THEN
+ RAISE;
+ END IF;
+ END;
+ EXECUTE IMMEDIATE '
CREATE TABLE logging_event
(
timestmp NUMBER(20) NOT NULL,
@@ -48,25 +48,22 @@ CREATE TABLE logging_event
caller_method VARCHAR(254) NOT NULL,
caller_line CHAR(4) NOT NULL,
event_id NUMBER(10) PRIMARY KEY
- );
+ )';
+END;
+;;
--- the / suffix may or may not be needed depending on your SQL Client
--- Some SQL Clients, e.g. SQuirrel SQL has trouble with the following
--- trigger creation command, while SQLPlus (the basic SQL Client which
--- ships with Oracle) has no trouble at all.
-
-CREATE TRIGGER logging_event_id_seq_trig
- BEFORE INSERT ON logging_event
- FOR EACH ROW
- BEGIN
- SELECT logging_event_id_seq.NEXTVAL
- INTO :NEW.event_id
- FROM DUAL;
- END;
-/
-
+BEGIN
+ BEGIN
+ EXECUTE IMMEDIATE 'DROP TABLE logging_event_property CASCADE CONSTRAINTS';
+ EXCEPTION
+ WHEN OTHERS THEN
+ IF SQLCODE != -942 THEN
+ RAISE;
+ END IF;
+ END;
+ EXECUTE IMMEDIATE '
CREATE TABLE logging_event_property
(
event_id NUMBER(10) NOT NULL,
@@ -74,8 +71,23 @@ CREATE TABLE logging_event_property
mapped_value VARCHAR2(1024),
PRIMARY KEY(event_id, mapped_key),
FOREIGN KEY (event_id) REFERENCES logging_event(event_id)
- );
-
+ )
+';
+
+END;
+;;
+
+BEGIN
+ BEGIN
+ EXECUTE IMMEDIATE 'DROP TABLE logging_event_exception CASCADE CONSTRAINTS';
+ EXCEPTION
+ WHEN OTHERS THEN
+ IF SQLCODE != -942 THEN
+ RAISE;
+ END IF;
+ END;
+
+ EXECUTE IMMEDIATE '
CREATE TABLE logging_event_exception
(
event_id NUMBER(10) NOT NULL,
@@ -83,8 +95,32 @@ CREATE TABLE logging_event_exception
trace_line VARCHAR2(254) NOT NULL,
PRIMARY KEY(event_id, i),
FOREIGN KEY (event_id) REFERENCES logging_event(event_id)
- );
-
+ )
+';
+END;
+;;
+DECLARE
+ t_count INTEGER;
+BEGIN
+ SELECT COUNT(*)
+ INTO t_count
+ FROM user_sequences
+ WHERE sequence_name = 'LOGGING_EVENT_ID_SEQ';
+
+ IF t_count = 0 THEN
+ EXECUTE IMMEDIATE 'CREATE SEQUENCE LOGGING_EVENT_ID_SEQ MINVALUE 1 START WITH 1';
+ END IF;
+END;
+;;
+CREATE OR REPLACE TRIGGER logging_event_id_seq_trig
+ BEFORE INSERT ON logging_event
+ FOR EACH ROW
+ BEGIN
+ SELECT logging_event_id_seq.NEXTVAL
+ INTO :NEW.event_id
+ FROM DUAL;
+ END;
+;;
Modified: syncope/branches/1_1_X/core/src/main/resources/logback/postgresql.sql
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/resources/logback/postgresql.sql?rev=1524383&r1=1524382&r2=1524383&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/resources/logback/postgresql.sql (original)
+++ syncope/branches/1_1_X/core/src/main/resources/logback/postgresql.sql Wed Sep 18 12:11:04 2013
@@ -19,16 +19,26 @@
--
-- It is intended for PostgreSQL databases.
-DROP TABLE logging_event_property;
-DROP TABLE logging_event_exception;
-DROP TABLE logging_event;
-DROP SEQUENCE logging_event_id_seq;
+DO
+$do$
+DECLARE
+ _kind "char";
+BEGIN
+
+SELECT INTO _kind c.relkind
+FROM pg_class c
+JOIN pg_namespace n ON n.oid = c.relnamespace
+WHERE c.relname = 'logging_event_id_seq'
+AND c.relkind = ANY('{r,i,S,v,f}');
+
+IF NOT FOUND THEN
+ CREATE SEQUENCE logging_event_id_seq MINVALUE 1 START 1;
+END IF;
+END
+$do$;;
-CREATE SEQUENCE logging_event_id_seq MINVALUE 1 START 1;
-
-
-CREATE TABLE logging_event
+CREATE TABLE IF NOT EXISTS logging_event
(
timestmp BIGINT NOT NULL,
formatted_message TEXT NOT NULL,
@@ -45,22 +55,22 @@ CREATE TABLE logging_event
caller_method VARCHAR(254) NOT NULL,
caller_line CHAR(4) NOT NULL,
event_id BIGINT DEFAULT nextval('logging_event_id_seq') PRIMARY KEY
- );
+ );;
-CREATE TABLE logging_event_property
+CREATE TABLE IF NOT EXISTS logging_event_property
(
event_id BIGINT NOT NULL,
mapped_key VARCHAR(254) NOT NULL,
mapped_value VARCHAR(1024),
PRIMARY KEY(event_id, mapped_key),
FOREIGN KEY (event_id) REFERENCES logging_event(event_id)
- );
+ );;
-CREATE TABLE logging_event_exception
+CREATE TABLE IF NOT EXISTS logging_event_exception
(
event_id BIGINT NOT NULL,
i SMALLINT NOT NULL,
trace_line VARCHAR(254) NOT NULL,
PRIMARY KEY(event_id, i),
FOREIGN KEY (event_id) REFERENCES logging_event(event_id)
- );
+ );;
Modified: syncope/branches/1_1_X/core/src/main/resources/logback/sqlserver.sql
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/resources/logback/sqlserver.sql?rev=1524383&r1=1524382&r2=1524383&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/resources/logback/sqlserver.sql (original)
+++ syncope/branches/1_1_X/core/src/main/resources/logback/sqlserver.sql Wed Sep 18 12:11:04 2013
@@ -15,12 +15,20 @@
-- specific language governing permissions and limitations
-- under the License.
-DROP TABLE logging_event_property
-DROP TABLE logging_event_exception
-DROP TABLE logging_event
-
+IF NOT EXISTS
+(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[logging_event]') AND type in (N'U'))
+BEGIN
CREATE TABLE logging_event ( timestmp DECIMAL(20) NOT NULL, formatted_message VARCHAR(4000) NOT NULL, logger_name VARCHAR(254) NOT NULL, level_string VARCHAR(254) NOT NULL, thread_name VARCHAR(254), reference_flag SMALLINT, arg0 VARCHAR(254), arg1 VARCHAR(254), arg2 VARCHAR(254), arg3 VARCHAR(254), caller_filename VARCHAR(254) NOT NULL, caller_class VARCHAR(254) NOT NULL, caller_method VARCHAR(254) NOT NULL, caller_line CHAR(4) NOT NULL, event_id DECIMAL(38) NOT NULL identity, PRIMARY KEY(event_id))
+END;;
+IF NOT EXISTS
+(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[logging_event_property]') AND type in (N'U'))
+BEGIN
CREATE TABLE logging_event_property ( event_id DECIMAL(38) NOT NULL, mapped_key VARCHAR(254) NOT NULL, mapped_value VARCHAR(1024), PRIMARY KEY(event_id, mapped_key), FOREIGN KEY (event_id) REFERENCES logging_event(event_id))
+END;;
+IF NOT EXISTS
+(SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[logging_event_exception]') AND type in (N'U'))
+BEGIN
CREATE TABLE logging_event_exception ( event_id DECIMAL(38) NOT NULL, i SMALLINT NOT NULL, trace_line VARCHAR(254) NOT NULL, PRIMARY KEY(event_id, i), FOREIGN KEY (event_id) REFERENCES logging_event(event_id) )
+END;;
Modified: syncope/branches/1_1_X/core/src/main/resources/syncopeContext.xml
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/resources/syncopeContext.xml?rev=1524383&r1=1524382&r2=1524383&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/resources/syncopeContext.xml (original)
+++ syncope/branches/1_1_X/core/src/main/resources/syncopeContext.xml Wed Sep 18 12:11:04 2013
@@ -65,9 +65,6 @@ under the License.
<value type="org.springframework.core.io.Resource">
classpath:/quartz/${quartz.sql}
</value>
- <value type="org.springframework.core.io.Resource">
- classpath:/logback/${logback.sql}
- </value>
</array>
</property>
</bean>