Revision: 8db25c3ed6f6
Branch: default
Author: gm2552
Date: Mon Dec 15 17:46:15 2014 UTC
Log: Adding tag for direct-common-audit-1.0
https://code.google.com/p/nhin-d/source/detail?r=8db25c3ed6f6
Added:
/java/tags/direct-common-audit-1.0/pom.xml
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/RDBMSAuditor.java
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/RDBMSDao.java
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/RDBMSDaoImpl.java
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/entity/AuditContext.java
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/entity/AuditEvent.java
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/entity/package-info.java
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/package-info.java
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/provider/AggregateClassLoader.java
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/provider/RDBMSAuditorProvider.java
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/provider/package-info.java
/java/tags/direct-common-audit-1.0/src/main/resources/META-INF/persistence.xml
/java/tags/direct-common-audit-1.0/src/main/resources/auditStore.xml
/java/tags/direct-common-audit-1.0/src/report/findbugs-exclude.xml
/java/tags/direct-common-audit-1.0/src/site/resources/css/site.css
/java/tags/direct-common-audit-1.0/src/site/resources/images/logo.png
/java/tags/direct-common-audit-1.0/src/site/site.xml
/java/tags/direct-common-audit-1.0/src/site/xdoc/index.xml
/java/tags/direct-common-audit-1.0/src/test/java/org/nhindirect/common/audit/RDBMSAuditorProviderTest.java
/java/tags/direct-common-audit-1.0/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditorBaseTest.java
/java/tags/direct-common-audit-1.0/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_getEventsTest.java
/java/tags/direct-common-audit-1.0/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_getLastEventTest.java
/java/tags/direct-common-audit-1.0/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_writeEventTest.java
/java/tags/direct-common-audit-1.0/src/test/resources/auditStore-test.xml
/java/tags/direct-common-audit-1.0/src/test/resources/properties/auditStore.properties
Modified:
/java/direct-common-audit/pom.xml
=======================================
--- /dev/null
+++ /java/tags/direct-common-audit-1.0/pom.xml Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,560 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="
http://maven.apache.org/POM/4.0.0"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd ">
+ <groupId>org.nhind</groupId>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>direct-common-audit</artifactId>
+ <name>Direct Project additional auditing implementations</name>
+ <version>1.0</version>
+ <description>Direct Project additional implementation for auditing
interface</description>
+ <inceptionYear>2010</inceptionYear>
+
<url>
http://api.nhindirect.org/x/www/api.nhindirect.org/java/site/direct-common-audit/${project.version}</url>
+ <developers>
+ <developer>
+ <name>Greg Meyer</name>
+ <id>GM2552</id>
+ <email>
gm2...@cerner.com</email>
+ <roles>
+ <role>owner</role>
+ </roles>
+ </developer>
+ </developers>
+ <organization>
+ <name>The Direct Project</name>
+ <url>
http://nhindirect.org</url>
+ </organization>
+ <prerequisites>
+ <maven>2.0.4</maven>
+ </prerequisites>
+ <scm>
+
<url>
http://code.google.com/p/nhin-d/source/browse/#hg/java/direct-common-audit</url>
+
<connection>scm:hg:
https://nhin-d.googlecode.com/hg/nhin-d/java/direct-common-audit</connection>
+ </scm>
+ <issueManagement>
+ <system>Google Code</system>
+ <url>
http://code.google.com/p/nhin-d/issues/list</url>
+ </issueManagement>
+ <licenses>
+ <license>
+ <name>New BSD License</name>
+ <url>
http://nhindirect.org/BSDLicense</url>
+ </license>
+ </licenses>
+ <repositories>
+ <repository>
+ <id>REPO2</id>
+ <name>Maven2 Central Repo2</name>
+ <url>
http://repo2.maven.org/maven2/</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.nhind</groupId>
+ <artifactId>direct-common</artifactId>
+ <version>1.4.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.5</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate</artifactId>
+ <version>
3.2.7.ga</version>
+ <type>pom</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>
3.3.2.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>
3.3.2.GA</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>ejb3-persistence</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>geronimo-spec</groupId>
+ <artifactId>geronimo-spec-jta</artifactId>
+ <version>1.0.1B-rc4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <version>
3.3.1.GA</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>ejb3-persistence</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>3.0.4.RELEASE</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>3.0.4.RELEASE</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ <version>3.0.4.RELEASE</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-tx</artifactId>
+ <version>3.0.4.RELEASE</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ <version>3.0.4.RELEASE</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.4</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.1</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.2.0</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.1</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <version>1.6.1</version>
+ <type>jar</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.4.1.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>3.0.4.RELEASE</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.8.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav</artifactId>
+ <version>RELEASE</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh-external</artifactId>
+ <version>1.0-beta-6</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh</artifactId>
+ <version>1.0-beta-6</version>
+ </extension>
+ </extensions>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <targetPath>lib</targetPath>
+ <directory>${project.basedir}/lib</directory>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ </testResource>
+ <testResource>
+ <targetPath>lib</targetPath>
+ <directory>${project.basedir}/lib</directory>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>testCompile</goal>
+ </goals>
+ <phase>compile</phase>
+ </execution>
+ </executions>
+ <configuration>
+ <fork>true</fork>
+ <optimize>true</optimize>
+ <showDeprecation>true</showDeprecation>
+ <encoding>UTF-8</encoding>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.0.3</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.atlassian.maven.plugins</groupId>
+ <artifactId>maven-clover2-plugin</artifactId>
+ <version>3.1.0</version>
+ <configuration>
+ <jdk>1.6</jdk>
+ <licenseLocation>
+ ${project.basedir}/../licenses/clover.license
+ </licenseLocation>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>pre-site</phase>
+ <goals>
+ <goal>instrument</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <index>true</index>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+<!--
+ <plugin>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>2.2.0</version>
+ <configuration>
+ <includes>**/entity/*.class</includes>
+ <addDefaultConstructor>true</addDefaultConstructor>
+ <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+ </configuration>
+ <executions>
+ <execution>
+ <id>enhancer</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>enhance</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.2.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ -->
+ <!-- for releases only
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.6.1</version>
+ <configuration>
+ <charset>UTF-8</charset>
+ <docencoding>UTF-8</docencoding>
+ <docfilessubdirs>true</docfilessubdirs>
+ <detectJavaApiLink>true</detectJavaApiLink>
+ <detectLinks>true</detectLinks>
+ <source>1.6</source>
+ <show>public</show>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>sign-artifacts</id>
+ <phase>package</phase>
+ <goals>
+ <goal>sign</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ -->
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+
<tagBase>scm:hg:
https://nhin-d.googlecode.com/hg/nhin-d/java/tags</tagBase>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>2.1.1</version>
+ <dependencies>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>2.1.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.6.1</version>
+ <configuration>
+ <charset>UTF-8</charset>
+ <docencoding>UTF-8</docencoding>
+ <docfilessubdirs>true</docfilessubdirs>
+ <detectJavaApiLink>true</detectJavaApiLink>
+ <detectLinks>true</detectLinks>
+ <source>1.6</source>
+ <show>public</show>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <targetJdk>1.6</targetJdk>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changelog-plugin</artifactId>
+ <configuration>
+ <dates>
+ <!-- Insert the date of the most recent release -->
+ <date>2011-01-15</date>
+ </dates>
+ <outputEncoding>UTF-8</outputEncoding>
+ <type>date</type>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>clirr-maven-plugin</artifactId>
+ <configuration>
+ <minSeverity>info</minSeverity>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <effort>Max</effort>
+
<excludeFilterFile>${project.basedir}/src/report/findbugs-exclude.xml</excludeFilterFile>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ <configuration>
+ <tags>
+ <tag>FIXME</tag>
+ <tag>TODO</tag>
+ <tag>WARN</tag>
+ <tag>@deprecated</tag>
+ </tags>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.atlassian.maven.plugins</groupId>
+ <artifactId>maven-clover2-plugin</artifactId>
+ <version>3.1.0</version>
+ <configuration>
+ <licenseLocation>
+ ${project.basedir}/../licenses/clover.license
+ </licenseLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+ <distributionManagement>
+ <site>
+ <id>nhind-site</id>
+ <name>NHIN Direct API publication site</name>
+
<url>sftp://
api.nhindirect.org/x/www/api.nhindirect.org/java/site/direct-common-audit/${project.version}</url>
+ </site>
+ <snapshotRepository>
+ <id>sonatype-snapshot</id>
+ <name>Sonatype OSS Maven SNAPSHOT Repository</name>
+ <url>
https://oss.sonatype.org/content/repositories/snapshots/</url>
+ <uniqueVersion>false</uniqueVersion>
+ </snapshotRepository>
+ <repository>
+ <id>sonatype-release</id>
+ <name>Sonatype OSS Maven Release Repositor</name>
+
<url>
https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
+ <uniqueVersion>false</uniqueVersion>
+ </repository>
+ </distributionManagement>
+</project>
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/RDBMSAuditor.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,227 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer
gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(
nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.common.audit.impl;
+
+import java.lang.management.ManagementFactory;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.UUID;
+import java.util.Vector;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nhindirect.common.audit.AbstractAuditor;
+import org.nhindirect.common.audit.AuditContext;
+import org.nhindirect.common.audit.AuditEvent;
+import org.nhindirect.common.audit.AuditorMBean;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * Implementation of the DirectProject RI auditor that writes records to a
configurable database.
+ * Also implements the AuditorMBean interface for management access to
audit events.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public class RDBMSAuditor extends AbstractAuditor implements AuditorMBean
+{
+ private final Log LOGGER =
LogFactory.getFactory().getInstance(RDBMSAuditor.class);
+
+ private String[] itemNames;
+ private CompositeType eventType;
+
+ @Autowired
+ protected RDBMSDao dao;
+
+ /**
+ * Constructor
+ */
+ public RDBMSAuditor()
+ {
+ super();
+ // register the auditor as an MBean
+
+ registerMBean();
+ }
+
+ /**
+ * Constructor
+ */
+ public RDBMSAuditor(RDBMSDao dao)
+ {
+ this();
+ // register the auditor as an MBean
+
+ setDao(dao);
+ }
+
+
+ public void setDao(RDBMSDao dao)
+ {
+ this.dao = dao;
+ }
+
+ /*
+ * Register the MBean
+ */
+ private void registerMBean()
+ {
+
+ LOGGER.info("Registering RDBMSAuditor MBean");
+
+ try
+ {
+ itemNames = new String[] {"Event Id", "Event Time", "Event
Principal", "Event Name", "Event Type", "Contexts"};
+
+ OpenType<?>[] types = {SimpleType.STRING, SimpleType.STRING,
SimpleType.STRING, SimpleType.STRING,
+ SimpleType.STRING, ArrayType.getArrayType(SimpleType.STRING)};
+
+ eventType = new CompositeType("AuditEvent", "Direct Auditable Event",
itemNames, itemNames, types);
+ }
+ catch (OpenDataException e)
+ {
+ LOGGER.error("Failed to create settings composite type: " +
e.getLocalizedMessage(), e);
+ return;
+ }
+
+ final Class<?> clazz = this.getClass();
+ final StringBuilder objectNameBuilder = new
StringBuilder(clazz.getPackage().getName());
+ objectNameBuilder.append(":type=").append(clazz.getSimpleName());
+ objectNameBuilder.append(",name=").append(UUID.randomUUID());
+
+ try
+ {
+ final StandardMBean mbean = new StandardMBean(this, AuditorMBean.class);
+
+ final MBeanServer mbeanServer =
ManagementFactory.getPlatformMBeanServer();
+ mbeanServer.registerMBean(mbean, new
ObjectName(objectNameBuilder.toString()));
+ }
+ catch (JMException e)
+ {
+ LOGGER.error("Unable to register the RDBMSAuditors MBean", e);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void writeEvent(UUID eventId, Calendar eventTimeStamp,
+ String principal, AuditEvent event, Collection<? extends AuditContext>
contexts)
+ {
+ this.dao.writeRDBMSEvent(eventId, eventTimeStamp, principal, event,
contexts);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Integer getEventCount()
+ {
+ return this.dao.getRDBMSEventCount();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public CompositeData[] getEvents(Integer eventCount)
+ {
+ if (eventType == null || eventCount == 0)
+ return null;
+
+ final Vector<CompositeData> retVal = new Vector<CompositeData>();
+
+ final
Collection<org.nhindirect.common.audit.impl.entity.AuditEvent> rs =
this.dao.getRDBMSEvents(eventCount);
+ if (rs.size() == 0)
+ return null;
+
+ for (org.nhindirect.common.audit.impl.entity.AuditEvent event : rs)
+ {
+ String[] contexts = null;
+
+ if (event.getAuditContexts() != null
&& !event.getAuditContexts().isEmpty())
+ {
+ contexts = new String[event.getAuditContexts().size()];
+ int idx = 0;
+ for (org.nhindirect.common.audit.impl.entity.AuditContext ctx :
event.getAuditContexts())
+ {
+ contexts[idx++] = ctx.getContextName() + ":" + ctx.getContextValue();
+ }
+ }
+
+ if (contexts == null)
+ contexts = new String[] {" "};
+
+ try
+ {
+
+ final Object[] eventValues = {event.getUUID(),
event.getEventTime().toString(), event.getPrincipal(),
+ event.getEventName(), event.getEventType(), contexts};
+
+ retVal.add(new CompositeDataSupport(eventType, itemNames,
eventValues));
+ }
+ catch (OpenDataException e)
+ {
+ LOGGER.error("Error create composit data for audit event.", e);
+ }
+ }
+
+ return retVal.toArray(new CompositeData[retVal.size()]);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public CompositeData getLastEvent()
+ {
+ final CompositeData[] events = getEvents(1);
+
+ if (events == null)
+ return null;
+
+ return events[0];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void clear()
+ {
+ this.dao.rDBMSclear();
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/RDBMSDao.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,46 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer
gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(
nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.common.audit.impl;
+
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.UUID;
+
+import org.nhindirect.common.audit.AuditContext;
+import org.nhindirect.common.audit.AuditEvent;
+
+/**
+ * DAO interface for reading and writing audit info to the RDBMS.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public interface RDBMSDao
+{
+ public void writeRDBMSEvent(UUID eventId, Calendar eventTimeStamp,
+ String principal, AuditEvent event, Collection<? extends AuditContext>
contexts);
+
+ public Integer getRDBMSEventCount();
+
+ public Collection<org.nhindirect.common.audit.impl.entity.AuditEvent>
getRDBMSEvents(Integer eventCount);
+
+ public void rDBMSclear();
+}
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/RDBMSDaoImpl.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,184 @@
+package org.nhindirect.common.audit.impl;
+
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Locale;
+import java.util.UUID;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nhindirect.common.audit.AuditContext;
+import org.nhindirect.common.audit.AuditEvent;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * DOA implementation for audit events.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+@Repository
+public class RDBMSDaoImpl implements RDBMSDao
+{
+ private final Log LOGGER =
LogFactory.getFactory().getInstance(RDBMSDaoImpl.class);
+
+ @PersistenceContext
+ @Autowired
+ private EntityManager entityManager;
+
+ public RDBMSDaoImpl()
+ {
+
+ }
+
+ ///CLOVER:OFF
+ public RDBMSDaoImpl(EntityManager entityManager)
+ {
+ this();
+
+ setEntityManager(entityManager);
+ }
+ ///CLOVER:ON
+
+ /**
+ * Sets the entity manager for access to the underlying data store medium.
+ * @param entityManager The entity manager.
+ */
+ ///CLOVER:OFF
+ public void setEntityManager(EntityManager entityManager)
+ {
+ this.entityManager = entityManager;
+ }
+ ///CLOVER:ON
+
+ /**
+ * Validate that we have a connection to the DAO
+ */
+ protected void validateState()
+ {
+ if (entityManager == null)
+ throw new IllegalStateException("entityManger has not been
initialized");
+ }
+
+ @Override
+ @Transactional(readOnly = false)
+ public void writeRDBMSEvent(UUID eventId, Calendar eventTimeStamp,
+ String principal, AuditEvent event,
+ Collection<? extends AuditContext> contexts)
+ {
+ try
+ {
+ validateState();
+
+ final org.nhindirect.common.audit.impl.entity.AuditEvent newEvent =
+ new org.nhindirect.common.audit.impl.entity.AuditEvent();
+
+ newEvent.setEventName(event.getName());
+ newEvent.setEventType(event.getType());
+
+ newEvent.setEventTime(Calendar.getInstance(Locale.getDefault()));
+ newEvent.setPrincipal(principal);
+ newEvent.setUUID(eventId.toString());
+
+ if (contexts != null)
+ {
+ final Collection<org.nhindirect.common.audit.impl.entity.AuditContext>
entityContexts = newEvent.getAuditContexts();
+ for (AuditContext context : contexts)
+ {
+ final org.nhindirect.common.audit.impl.entity.AuditContext newContext
=
+ new org.nhindirect.common.audit.impl.entity.AuditContext();
+
+ newContext.setContextName(context.getContextName());
+ newContext.setContextValue(context.getContextValue());
+ newContext.setAuditEvent(newEvent);
+ entityContexts.add(newContext);
+ }
+ }
+ entityManager.persist(newEvent);
+ entityManager.flush();
+ }
+ catch (Throwable e)
+ {
+ LOGGER.error("Failed to write audit event to RDBMS store: " +
e.getMessage(), e);
+ }
+
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public Integer getRDBMSEventCount()
+ {
+ try
+ {
+ validateState();
+
+ final Query select = entityManager.createQuery("SELECT count(ae)
from AuditEvent ae");
+
+ return new Integer(((Long)select.getSingleResult()).intValue());
+ }
+ catch (Throwable e)
+ {
+ LOGGER.error("Failed to write audit event count: " + e.getMessage(), e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public Collection<org.nhindirect.common.audit.impl.entity.AuditEvent>
getRDBMSEvents(Integer eventCount)
+ {
+ try
+ {
+ final Query select =
+ entityManager.createQuery("SELECT ae from AuditEvent ae ORDER BY
ae.eventTime desc").setMaxResults(eventCount);
+
+ @SuppressWarnings("unchecked")
+ final Collection<org.nhindirect.common.audit.impl.entity.AuditEvent> rs
= select.getResultList();
+
+ // lazy fetching
+ for (org.nhindirect.common.audit.impl.entity.AuditEvent event :
rs)
+ event.getAuditContexts().size();
+
+ return rs;
+ }
+ catch (Throwable e)
+ {
+ LOGGER.error("Failed get audit events: " + e.getMessage(), e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ @Transactional(readOnly = false)
+ public void rDBMSclear()
+ {
+ // truncating the tables
+
+ try
+ {
+ Query delete =
+ entityManager.createQuery("delete from AuditContext");
+
+ delete.executeUpdate();
+
+ delete =
+ entityManager.createQuery("delete from AuditEvent");
+
+ delete.executeUpdate();
+
+ entityManager.flush();
+ }
+ catch (Throwable e)
+ {
+ LOGGER.error("Failed clear audit events: " + e.getMessage(), e);
+ throw new RuntimeException(e);
+ }
+ }
+
+
+}
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/entity/AuditContext.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,143 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer
gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(
nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.common.audit.impl.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import
javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * Audit context data entity.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+@Entity
+@Table(name = "auditcontext")
+public class AuditContext
+{
+ private long id;
+ private String contextName;
+ private String contextValue;
+ private AuditEvent auditEvent;
+
+ public AuditContext()
+ {
+
+ }
+
+ /**
+ * Get the value of id.
+ *
+ * @return the value of id.
+ */
+ @Id
+ @Column(name = "id", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ public long getId()
+ {
+ return id;
+ }
+
+ /**
+ * Set the value of id.
+ *
+ * @param id
+ * The value of id.
+ */
+ public void setId(long id)
+ {
+
this.id = id;
+ }
+
+ /**
+ * Get the value of contextName.
+ *
+ * @return the value of contextName.
+ */
+ @Column(name = "contextName", unique = false)
+ public String getContextName()
+ {
+ return contextName;
+ }
+
+
+ /**
+ * Gets the value of contextName.
+ * @param contextName Get the value of contextName.
+ */
+ public void setContextName(String contextName)
+ {
+ this.contextName = contextName;
+ }
+
+ /**
+ * Get the value of contextValue.
+ *
+ * @return the value of contextValue.
+ */
+ @Column(name = "contextValue", unique = false)
+ public String getContextValue()
+ {
+ return contextValue;
+ }
+
+
+ /**
+ * Gets the value of contextValue.
+ * @param contextValue Get the value of contextValue.
+ */
+ public void setContextValue(String contextValue)
+ {
+ this.contextValue = contextValue;
+ }
+
+ /**
+ * Get the value of the audit event.
+ *
+ * @return the value of audit event.
+ */
+ @ManyToOne(optional = false, fetch = FetchType.EAGER)
+ @JoinColumn(name = "auditEventId")
+ public AuditEvent getAuditEvent()
+ {
+ return auditEvent;
+ }
+
+ /**
+ * Set the value of the audit event.
+ *
+ * @param trustBundle
+ * The value of the audit event.
+ */
+ public void setAuditEvent(AuditEvent auditEvent)
+ {
+ this.auditEvent = auditEvent;
+
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/entity/AuditEvent.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,220 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer
gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(
nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.common.audit.impl.entity;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import
javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+/**
+ * Audit event data entity.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+@Entity
+@Table(name = "auditevent")
+public class AuditEvent
+{
+ private long id;
+ private String UUID;
+ private String principal;
+ private String eventName;
+ private String eventType;
+ private Calendar eventTime;
+ private Collection<AuditContext> auditContexts;
+
+
+ public AuditEvent()
+ {
+
+ }
+
+ /**
+ * Get the value of id.
+ *
+ * @return the value of id.
+ */
+ @Id
+ @Column(name = "id", nullable = false)
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ public long getId()
+ {
+ return id;
+ }
+
+ /**
+ * Set the value of id.
+ *
+ * @param id
+ * The value of id.
+ */
+ public void setId(long id)
+ {
+
this.id = id;
+ }
+
+ /**
+ * Get the value of UUID.
+ *
+ * @return the value of UUID.
+ */
+ @Column(name = "uuid", unique = false)
+ public String getUUID()
+ {
+ return UUID;
+ }
+
+
+ /**
+ * Gets the value of UUID.
+ * @param UUID Get the value of UUID.
+ */
+ public void setUUID(String UUID)
+ {
+ this.UUID = UUID;
+ }
+
+ /**
+ * Get the value of principal.
+ *
+ * @return the value of principal.
+ */
+ @Column(name = "principal")
+ public String getPrincipal()
+ {
+ return principal;
+ }
+
+
+ /**
+ * Gets the value of principal.
+ * @param principal Get the value of principal.
+ */
+ public void setPrincipal(String principal)
+ {
+ this.principal = principal;
+ }
+
+
+ /**
+ * Get the value of eventName.
+ *
+ * @return the value of eventName.
+ */
+ @Column(name = "eventName", unique = false)
+ public String getEventName()
+ {
+ return eventName;
+ }
+
+
+ /**
+ * Gets the value of eventName.
+ * @param eventName Get the value of eventName.
+ */
+ public void setEventName(String eventName)
+ {
+ this.eventName = eventName;
+ }
+
+ /**
+ * Get the value of eventType.
+ *
+ * @return the value of eventType.
+ */
+ @Column(name = "eventType", unique = false)
+ public String getEventType()
+ {
+ return eventType;
+ }
+
+
+ /**
+ * Gets the value of eventType.
+ * @param eventType Get the value of eventType.
+ */
+ public void setEventType(String eventType)
+ {
+ this.eventType = eventType;
+ }
+
+ /**
+ * Get the value of createTime.
+ *
+ * @return the value of createTime.
+ */
+ @Column(name = "eventTime", nullable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ public Calendar getEventTime()
+ {
+ return eventTime;
+ }
+
+ /**
+ * Set the value of eventTime.
+ *
+ * @param eventTime
+ * The value of eventTime.
+ */
+ public void setEventTime(Calendar eventTime)
+ {
+ this.eventTime = eventTime;
+ }
+
+ /**
+ * Get a collection of AuditContexts.
+ *
+ * @return a collection of AuditContexts.
+ */
+ @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch =
FetchType.LAZY, mappedBy = "auditEvent")
+ public Collection<AuditContext> getAuditContexts()
+ {
+ if (auditContexts == null)
+ {
+ auditContexts = new ArrayList<AuditContext>();
+ }
+ return auditContexts;
+ }
+
+ /**
+ * Set the collection of AuditContexts.
+ *
+ * @param contexts
+ * the value of AuditContexts
+ */
+ public void setAuditContexts(Collection<AuditContext> contexts)
+ {
+ this.auditContexts = contexts;
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/entity/package-info.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,26 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer
gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(
nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * Entity classes for auditing data structures and storage.
+ */
+
+package org.nhindirect.common.audit.impl.entity;
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/impl/package-info.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,26 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer
gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(
nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * Database backed auditing implementation
+ */
+
+package org.nhindirect.common.audit.impl;
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/provider/AggregateClassLoader.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,184 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer
gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(
nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.common.audit.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Enumeration;
+
+/**
+ * Class loader that aggregates a list class loaders and searches each on
iteratively for classes resources.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public class AggregateClassLoader extends ClassLoader
+{
+
+ protected final Collection<ClassLoader> classLoaders;
+ protected final Collection<ClassLoader> resourceLoaders;
+
+ /**
+ * Constructor
+ * @param classLoaders Collection of class loaders used for loading
class objects.
+ * @param resourceLoaders Collection of class loaders used for loading
resources.
+ */
+ public AggregateClassLoader(Collection<ClassLoader> classLoaders,
Collection<ClassLoader> resourceLoaders)
+ {
+ this.classLoaders = classLoaders;
+ this.resourceLoaders = resourceLoaders;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public synchronized void clearAssertionStatus()
+ {
+ for(ClassLoader loader : classLoaders)
+ loader.clearAssertionStatus();
+
+ for(ClassLoader loader : resourceLoaders)
+ loader.clearAssertionStatus();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public URL getResource(String arg0)
+ {
+ for(ClassLoader loader : resourceLoaders)
+ {
+ final URL url = loader.getResource(arg0);
+ if (url != null)
+ return url;
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public InputStream getResourceAsStream(String arg0)
+ {
+ for(ClassLoader loader : resourceLoaders)
+ {
+ final InputStream stream = loader.getResourceAsStream(arg0);
+ if (stream != null)
+ return stream;
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Enumeration<URL> getResources(String arg0) throws IOException
+ {
+ Enumeration<URL> urls = null;
+ for(ClassLoader loader : resourceLoaders)
+ {
+ try
+ {
+ urls= loader.getResources(arg0);
+
+ }
+ catch (IOException e)
+ {
+
+ }
+ }
+
+ return urls;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Class<?> loadClass(String arg0) throws ClassNotFoundException
+ {
+ Class<?> clazz = null;
+ for(ClassLoader loader : classLoaders)
+ {
+ try
+ {
+ clazz = loader.loadClass(arg0);
+ if (clazz != null)
+ return clazz;
+ }
+ catch (ClassNotFoundException e)
+ {
+
+ }
+ }
+
+ throw new ClassNotFoundException("Class " + arg0 + " not found");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public synchronized void setClassAssertionStatus(String arg0, boolean
arg1)
+ {
+ for(ClassLoader loader : classLoaders)
+ loader.setClassAssertionStatus(arg0, arg1);
+
+ for(ClassLoader loader : resourceLoaders)
+ loader.setClassAssertionStatus(arg0, arg1);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public synchronized void setDefaultAssertionStatus(boolean arg0)
+ {
+ for(ClassLoader loader : classLoaders)
+ loader.setDefaultAssertionStatus(arg0);
+
+ for(ClassLoader loader : resourceLoaders)
+ loader.setDefaultAssertionStatus(arg0);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public synchronized void setPackageAssertionStatus(String arg0, boolean
arg1)
+ {
+ for(ClassLoader loader : classLoaders)
+ loader.setPackageAssertionStatus(arg0, arg1);
+
+ for(ClassLoader loader : resourceLoaders)
+ loader.setPackageAssertionStatus(arg0, arg1);
+ }
+
+}
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/provider/RDBMSAuditorProvider.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,104 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer
gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(
nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package org.nhindirect.common.audit.provider;
+
+
+import java.util.Arrays;
+
+import org.nhindirect.common.audit.Auditor;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import com.google.inject.Provider;
+
+/**
+ * Google Guice provider for the RDBMSAuditor.
+ * @author Greg Meyer
+ * @since 1.0
+ */
+public class RDBMSAuditorProvider implements Provider<Auditor>
+{
+ private static final String DEFAULT_APPLICATION_CONTEXT_FILE
= "auditStore.xml";
+
+ private final String springConfigLocation;
+ protected Auditor auditor = null;
+
+ /**
+ * Default constructor. Uses the default file auditStore.xml to pull the
Sring configuration.
+ */
+ public RDBMSAuditorProvider()
+ {
+ this((String)null);
+ }
+
+ /**
+ * Constructor with the spring file location for the entity manager.
+ * @param fileLoc The location of the spring file location for the entity
manager.
+ */
+ public RDBMSAuditorProvider(String springConfigLocation)
+ {
+ this.springConfigLocation = springConfigLocation;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public synchronized Auditor get()
+ {
+ if (auditor == null)
+ auditor = createAuditor();
+
+ return auditor;
+ }
+
+ protected Auditor createAuditor()
+ {
+ final String fileLoc = (springConfigLocation == null ||
springConfigLocation.isEmpty()) ? DEFAULT_APPLICATION_CONTEXT_FILE :
springConfigLocation;
+
+ final ClassLoader loader = new
AggregateClassLoader(Arrays.asList(Thread.currentThread().getContextClassLoader()),
+ Arrays.asList(ClassLoader.getSystemClassLoader(),
+ Thread.currentThread().getContextClassLoader(),
RDBMSAuditorProvider.class.getClassLoader()));
+
+ try
+ {
+
+ final ClassPathXmlApplicationContext ctx = new
ClassPathXmlApplicationContext(fileLoc)
+ {
+ protected void initBeanDefinitionReader(XmlBeanDefinitionReader
reader)
+ {
+ super.initBeanDefinitionReader(reader);
+
+ reader.setBeanClassLoader(loader);
+ setClassLoader(loader);
+ }
+
+ };
+
+ return (Auditor)ctx.getBean("auditor");
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Auditor could not be found in Spring
configuration.", e);
+ }
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/main/java/org/nhindirect/common/audit/provider/package-info.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,26 @@
+/*
+Copyright (c) 2010, NHIN Direct Project
+All rights reserved.
+
+Authors:
+ Greg Meyer
gm2...@cerner.com
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
distribution. Neither the name of the The NHIN Direct Project
(
nhindirect.org).
+nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/**
+ * Google Guide providers and supporting class loaders.
+ */
+
+package org.nhindirect.common.audit.provider;
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/main/resources/META-INF/persistence.xml
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="
http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
+
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="audit-store" transaction-type="RESOURCE_LOCAL">
+ <properties>
+ <property name="hibernate.hbm2ddl.auto" value="validate" />
+ <!--
+ <property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
+ -->
+ </properties>
+ </persistence-unit>
+</persistence>
=======================================
--- /dev/null
+++ /java/tags/direct-common-audit-1.0/src/main/resources/auditStore.xml
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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"
+ xmlns:context="
http://www.springframework.org/schema/context"
+ xsi:schemaLocation="
+
http://www.springframework.org/schema/beans
+
http://www.springframework.org/schema/beans/spring-beans.xsd
+
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
+
http://www.springframework.org/schema/tx
+
http://www.springframework.org/schema/tx/spring-tx.xsd"
+ default-autowire="byName">
+
+ <tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true"/>
+ <context:component-scan base-package="org.nhindirect.common.audit.impl" />
+ <context:property-placeholder
location="classpath:properties/auditStore.properties"/>
+
+
+ <!-- Exception translation bean post processor -->
+ <bean
+
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"
/>
+
+ <bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
+
+ <bean id="entityManagerFactory"
+
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
+ <property name="jpaVendorAdapter">
+ <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
+ <property name="showSql" value="false" />
+ <property name="generateDdl" value="true" />
+ <property name="databasePlatform"
value='${auditStore.db.databasePlatform}' />
+
+ </bean>
+ </property>
+ <property name="dataSource" ref="dataSource"/>
+ <property name="persistenceUnitName" value="audit-store" />
+ </bean>
+
+
+ <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
+ destroy-method="close">
+ <property name="driverClassName" value='${auditStore.db.databaseDriver}'
/>
+ <property name="url" value='${auditStore.db.databaseURL}' />
+ <property name="username" value='${auditStore.db.username}' />
+ <property name="password" value='${auditStore.db.password}' />
+ </bean>
+ <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
+ <property name="entityManagerFactory" ref="entityManagerFactory"/>
+ </bean>
+
+ <bean id="auditor" class="org.nhindirect.common.audit.impl.RDBMSAuditor"
/>
+</beans>
=======================================
--- /dev/null
+++ /java/tags/direct-common-audit-1.0/src/report/findbugs-exclude.xml Mon
Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<FindBugsFilter>
+ <Match>
+ <Class name="~.*Test.*" />
+ </Match>
+ <Match>
+ <Bug pattern="DLS_DEAD_LOCAL_STORE" />
+ </Match>
+</FindBugsFilter>
=======================================
--- /dev/null
+++ /java/tags/direct-common-audit-1.0/src/site/resources/css/site.css Mon
Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,17 @@
+.source {
+ background-color: #fff;
+ color: #000;
+ border-right: 1px solid #888;
+ border-left: 1px solid #888;
+ border-top: 1px solid #888;
+ border-bottom: 1px solid #888;
+ margin-right: 7px;
+ margin-left: 7px;
+ margin-top: 1em;
+ overflow: auto;
+ }
+
+.source pre {
+ margin-right: 7px;
+ margin-left: 7px;
+ }
=======================================
--- /dev/null
+++ /java/tags/direct-common-audit-1.0/src/site/resources/images/logo.png
Mon Dec 15 17:46:15 2014 UTC
Binary file, no diff available.
=======================================
--- /dev/null
+++ /java/tags/direct-common-audit-1.0/src/site/site.xml Mon Dec 15
17:46:15 2014 UTC
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <bannerLeft>
+ <name>The Direct Project: Common Auditing Implementations</name>
+ <src>images/logo.png</src>
+ <href>
http://nhindirect.org/</href>
+ </bannerLeft>
+ <version position="left" />
+ <publishDate position="right" format="E M-dd-yyyy HH:mm" />
+ <body>
+ <menu name="Documents">
+ <item name="Release Notes" href="releaseNotes.html" />
+ </menu>
+ <menu name="External Links">
+ <item name="The Direct Project Wiki" href="
http://nhindirect.org"
/>
+ </menu>
+ ${reports}
+ </body>
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-classic-skin</artifactId>
+ <version>1.0</version>
+ </skin>
+</project>
=======================================
--- /dev/null
+++ /java/tags/direct-common-audit-1.0/src/site/xdoc/index.xml Mon Dec 15
17:46:15 2014 UTC
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document xmlns="
http://maven.apache.org/XDOC/2.0"
+ xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
http://maven.apache.org/XDOC/2.0
http://maven.apache.org/xsd/xdoc-2.0.xsd">
+ <properties>
+ <title>The Direct Project: Common Auditing Implementations</title>
+ <author>Greg Meyer</author>
+ </properties>
+ <head>
+ <title>The Direct Project: Common Auditing Implementations</title>
+ </head>
+ <body>
+ <section name="Overview">
+ <p>
+ This module includes additional auditing implementations include RDBMS
based storage.
+ </p>
+ </section>
+ </body>
+</document>
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/test/java/org/nhindirect/common/audit/RDBMSAuditorProviderTest.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,57 @@
+package org.nhindirect.common.audit;
+
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+import org.junit.Test;
+import org.nhindirect.common.audit.provider.RDBMSAuditorProvider;
+
+public class RDBMSAuditorProviderTest
+{
+ @Test
+ public void testCreateWithDefaultConfigFile_assertCreated() throws
Exception
+ {
+ final RDBMSAuditorProvider provider = new RDBMSAuditorProvider();
+
+ assertNotNull(provider.get());
+ }
+
+ @Test
+ public void testCreateWithSpecificFile_assertCreated() throws Exception
+ {
+ final RDBMSAuditorProvider provider = new
RDBMSAuditorProvider("auditStore.xml");
+
+ assertNotNull(provider.get());
+ }
+
+ @Test
+ public void testCreateWithUnknownFile_assertException() throws Exception
+ {
+ boolean exceptionOccured = false;
+ try
+ {
+ final RDBMSAuditorProvider provider = new
RDBMSAuditorProvider("auditStoreBogus.xml");
+ provider.get();
+ }
+ catch (IllegalStateException e)
+ {
+ exceptionOccured = true;
+ }
+
+ assertTrue(exceptionOccured);
+ }
+
+
+ @Test
+ public void testCreateWithSpecificFile_assertCreatedAndWriteEvent()
throws Exception
+ {
+ final RDBMSAuditorProvider provider = new
RDBMSAuditorProvider("auditStore.xml");
+
+ final Auditor auditor = provider.get();
+ assertNotNull(auditor);
+ final AuditEvent auditEvent = new AuditEvent("name1", "value1");
+
+ auditor.audit("testPin", auditEvent, null);
+
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditorBaseTest.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,63 @@
+package org.nhindirect.common.audit.impl;
+
+import static org.junit.Assert.assertEquals;
+
+
+import java.io.File;
+
+import org.junit.Before;
+import org.junit.runner.RunWith;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import
org.springframework.test.context.transaction.TransactionConfiguration;
+import org.springframework.transaction.annotation.Transactional;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations =
{ "file:src/main/resources/auditStore.xml" })
+@TransactionConfiguration(transactionManager = "transactionManager",
defaultRollback = true)
+@Transactional
+public abstract class RDBMSAuditorBaseTest
+{
+ @Autowired
+ protected RDBMSDao auditor;
+
+
+ protected RDBMSAuditor auditorImpl;
+
+ private static final String derbyHomeLoc = "/target/data";
+
+ static
+ {
+ try
+ {
+ final File baseLocation = new File("dummy.txt");
+ String fullDerbyHome = baseLocation.getAbsolutePath().substring(0,
baseLocation.getAbsolutePath().lastIndexOf(File.separator)) + derbyHomeLoc;
+ System.setProperty("derby.system.home", fullDerbyHome);
+
+ }
+ catch (Exception e)
+ {
+
+ }
+ }
+
+
+ @Before
+ public void setUp()
+ {
+ clearAuditEvent();
+
+ auditorImpl = new RDBMSAuditor();
+ auditorImpl.setDao(auditor);
+ }
+
+ protected void clearAuditEvent()
+ {
+ auditor.rDBMSclear();
+
+ assertEquals((Integer)0, auditor.getRDBMSEventCount());
+ }
+
+}
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_getEventsTest.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,141 @@
+package org.nhindirect.common.audit.impl;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.UUID;
+
+import javax.management.openmbean.CompositeData;
+
+import org.junit.Test;
+import org.nhindirect.common.audit.AuditEvent;
+import org.nhindirect.common.audit.DefaultAuditContext;
+
+public class RDBMSAuditor_getEventsTest extends RDBMSAuditorBaseTest
+{
+ private static final String PRINCIPAL = "JUNITTEST";
+
+ @Test
+ public void testGetEvents_AssertGotAllRecordsRequested()
+ {
+
+ AuditEvent event1 = new AuditEvent("Category" +
UUID.randomUUID(), "type");
+ AuditEvent event2 = new AuditEvent("Category" +
UUID.randomUUID(), "type");
+
+ DefaultAuditContext context1 = new
DefaultAuditContext("name1", "value1");
+ DefaultAuditContext context2 = new
DefaultAuditContext("name2", "value2");
+
+ auditorImpl.audit(PRINCIPAL, event1);
+ auditorImpl.audit(PRINCIPAL, event2, Arrays.asList(context1, context2));
+
+ CompositeData[] events = auditorImpl.getEvents(2);
+
+ assertNotNull(events);
+ assertEquals(2, events.length);
+
+ CompositeData lastMessage = events[0];
+ assertEquals(event2.getName(), lastMessage.get("Event Name"));
+ assertEquals(event2.getType(), lastMessage.get("Event Type"));
+ assertTrue(lastMessage.get("Event Id").toString().length() > 0);
+ assertTrue(lastMessage.get("Event Time").toString().length() > 0);
+ assertNotNull(lastMessage.get("Contexts"));
+ String[] contexts = (String[])lastMessage.get("Contexts");
+ assertEquals(2, contexts.length);
+
+ assertEquals("name1:value1", contexts[0]);
+ assertEquals("name2:value2", contexts[1]);
+ }
+
+ @Test
+ public void
testGetEvents_RequestMoreThanAvailable_AssertGotAllAvailableRecords()
+ {
+
+
+ AuditEvent event1 = new AuditEvent("Category" +
UUID.randomUUID(), "type");
+ AuditEvent event2 = new AuditEvent("Category" +
UUID.randomUUID(), "type");
+
+ DefaultAuditContext context1 = new
DefaultAuditContext("name1", "value1");
+ DefaultAuditContext context2 = new
DefaultAuditContext("name2", "value2");
+
+ auditorImpl.audit(PRINCIPAL, event1);
+ auditorImpl.audit(PRINCIPAL, event2, Arrays.asList(context1, context2));
+
+ CompositeData[] events = auditorImpl.getEvents(5);
+
+ assertNotNull(events);
+ assertEquals(2, events.length);
+
+ CompositeData lastMessage = events[0];
+ assertEquals(event2.getName(), lastMessage.get("Event Name"));
+ assertEquals(event2.getType(), lastMessage.get("Event Type"));
+ assertTrue(lastMessage.get("Event Id").toString().length() > 0);
+ assertTrue(lastMessage.get("Event Time").toString().length() > 0);
+ assertNotNull(lastMessage.get("Contexts"));
+ String[] contexts = (String[])lastMessage.get("Contexts");
+ assertEquals(2, contexts.length);
+
+ assertEquals("name1:value1", contexts[0]);
+ assertEquals("name2:value2", contexts[1]);
+ }
+
+ @Test
+ public void testGetEvents_RequestLessThanAvailable_AssertGotOnlyRecords()
+ {
+
+ AuditEvent event1 = new AuditEvent("Category" +
UUID.randomUUID(), "type");
+ AuditEvent event2 = new AuditEvent("Category" +
UUID.randomUUID(), "type");
+
+ DefaultAuditContext context1 = new
DefaultAuditContext("name1", "value1");
+ DefaultAuditContext context2 = new
DefaultAuditContext("name2", "value2");
+
+ auditorImpl.audit(PRINCIPAL, event1);
+ auditorImpl.audit(PRINCIPAL, event2, Arrays.asList(context1, context2));
+
+ CompositeData[] events = auditorImpl.getEvents(1);
+
+ assertNotNull(events);
+ assertEquals(1, events.length);
+
+ CompositeData lastMessage = events[0];
+ assertEquals(event2.getName(), lastMessage.get("Event Name"));
+ assertEquals(event2.getType(), lastMessage.get("Event Type"));
+ assertTrue(lastMessage.get("Event Id").toString().length() > 0);
+ assertTrue(lastMessage.get("Event Time").toString().length() > 0);
+ assertNotNull(lastMessage.get("Contexts"));
+ String[] contexts = (String[])lastMessage.get("Contexts");
+ assertEquals(2, contexts.length);
+
+ assertEquals("name1:value1", contexts[0]);
+ assertEquals("name2:value2", contexts[1]);
+ }
+
+ @Test
+ public void testGetEvents_NoRecordsAvailable_NoRecordsFound()
+ {
+
+ CompositeData[] events = auditorImpl.getEvents(1);
+
+ assertNull(events);
+ }
+
+ @Test
+ public void testGetEvents_NoRecordsRequested_ReturnedRecords()
+ {
+ AuditEvent event1 = new AuditEvent("Category" +
UUID.randomUUID(), "type");
+ AuditEvent event2 = new AuditEvent("Category" +
UUID.randomUUID(), "type");
+
+ DefaultAuditContext context1 = new
DefaultAuditContext("name1", "value1");
+ DefaultAuditContext context2 = new
DefaultAuditContext("name2", "value2");
+
+ auditorImpl.audit(PRINCIPAL, event1);
+ auditorImpl.audit(PRINCIPAL, event2, Arrays.asList(context1, context2));
+
+ CompositeData[] events = auditorImpl.getEvents(0);
+
+ assertNull(events);
+
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_getLastEventTest.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,77 @@
+package org.nhindirect.common.audit.impl;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+
+import java.util.Arrays;
+
+import javax.management.openmbean.CompositeData;
+
+import org.junit.Test;
+import org.nhindirect.common.audit.AuditEvent;
+import org.nhindirect.common.audit.DefaultAuditContext;
+
+public class RDBMSAuditor_getLastEventTest extends RDBMSAuditorBaseTest
+{
+ @Test
+ public void testGetLastEventTest_noContexts_lastEventRetrieved() throws
Exception
+ {
+
+ final AuditEvent auditEvent = new AuditEvent("name1", "value1");
+
+ this.auditorImpl.audit("testPin", auditEvent, null);
+
+ final CompositeData lastMessage = auditorImpl.getLastEvent();
+
+ assertNotNull(lastMessage);
+
+ assertEquals(auditEvent.getName(), lastMessage.get("Event Name"));
+ assertEquals(auditEvent.getType(), lastMessage.get("Event Type"));
+ assertTrue(lastMessage.get("Event Id").toString().length() > 0);
+ assertTrue(lastMessage.get("Event Time").toString().length() > 0);
+ assertNotNull(lastMessage.get("Contexts"));
+ String[] contexts = (String[])lastMessage.get("Contexts");
+ assertEquals(1, contexts.length);
+
+ }
+
+ @Test
+ public void testGetLastEventTest_withContexts_lastEventRetrieved()
throws Exception
+ {
+
+ final AuditEvent auditEvent = new AuditEvent("name1", "value1");
+
+ final DefaultAuditContext context1 = new
DefaultAuditContext("name1", "value1");
+ final DefaultAuditContext context2 = new
DefaultAuditContext("name2", "value2");
+
+ this.auditorImpl.audit("testPin", auditEvent,
Arrays.asList(context1, context2));
+
+ final CompositeData lastMessage = auditorImpl.getLastEvent();
+
+ assertNotNull(lastMessage);
+
+ assertEquals(auditEvent.getName(), lastMessage.get("Event Name"));
+ assertEquals(auditEvent.getType(), lastMessage.get("Event Type"));
+ assertTrue(lastMessage.get("Event Id").toString().length() > 0);
+ assertTrue(lastMessage.get("Event Time").toString().length() > 0);
+ assertNotNull(lastMessage.get("Contexts"));
+ String[] contexts = (String[])lastMessage.get("Contexts");
+ assertEquals(2, contexts.length);
+
+ assertEquals("name1:value1", contexts[0]);
+ assertEquals("name2:value2", contexts[1]);
+
+ }
+
+ @Test
+ public void testGetLastEventTest_noEntries_assertNull() throws Exception
+ {
+
+ final CompositeData lastMessage = auditorImpl.getLastEvent();
+
+ assertNull(lastMessage);
+
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/test/java/org/nhindirect/common/audit/impl/RDBMSAuditor_writeEventTest.java
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,66 @@
+package org.nhindirect.common.audit.impl;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+
+import java.util.Arrays;
+
+import javax.management.openmbean.CompositeData;
+
+import org.junit.Test;
+import org.nhindirect.common.audit.AuditEvent;
+import org.nhindirect.common.audit.DefaultAuditContext;
+
+public class RDBMSAuditor_writeEventTest extends RDBMSAuditorBaseTest
+{
+ @Test
+ public void testWriteEvent_noContexts_assertWritten() throws Exception
+ {
+
+ final AuditEvent auditEvent = new AuditEvent("name1", "value1");
+
+ this.auditorImpl.audit("testPin", auditEvent, null);
+
+ final CompositeData lastMessage = auditorImpl.getLastEvent();
+
+ assertNotNull(lastMessage);
+
+ assertEquals(auditEvent.getName(), lastMessage.get("Event Name"));
+ assertEquals(auditEvent.getType(), lastMessage.get("Event Type"));
+ assertTrue(lastMessage.get("Event Id").toString().length() > 0);
+ assertTrue(lastMessage.get("Event Time").toString().length() > 0);
+ assertNotNull(lastMessage.get("Contexts"));
+ String[] contexts = (String[])lastMessage.get("Contexts");
+ assertEquals(1, contexts.length);
+
+ }
+
+ @Test
+ public void testWriteEvent_withContexts_assertWritten() throws Exception
+ {
+
+ final AuditEvent auditEvent = new AuditEvent("name1", "value1");
+
+ final DefaultAuditContext context1 = new
DefaultAuditContext("name1", "value1");
+ final DefaultAuditContext context2 = new
DefaultAuditContext("name2", "value2");
+
+ this.auditorImpl.audit("testPin", auditEvent, Arrays.asList(context1,
context2));
+
+ final CompositeData lastMessage = auditorImpl.getLastEvent();
+
+ assertNotNull(lastMessage);
+
+ assertEquals(auditEvent.getName(), lastMessage.get("Event Name"));
+ assertEquals(auditEvent.getType(), lastMessage.get("Event Type"));
+ assertTrue(lastMessage.get("Event Id").toString().length() > 0);
+ assertTrue(lastMessage.get("Event Time").toString().length() > 0);
+ assertNotNull(lastMessage.get("Contexts"));
+ String[] contexts = (String[])lastMessage.get("Contexts");
+ assertEquals(2, contexts.length);
+
+ assertEquals("name1:value1", contexts[0]);
+ assertEquals("name2:value2", contexts[1]);
+
+ }
+}
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/test/resources/auditStore-test.xml
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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"
+ xmlns:context="
http://www.springframework.org/schema/context"
+ xsi:schemaLocation="
+
http://www.springframework.org/schema/beans
+
http://www.springframework.org/schema/beans/spring-beans.xsd
+
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
+
http://www.springframework.org/schema/tx
+
http://www.springframework.org/schema/tx/spring-tx.xsd"
+ default-autowire="byName">
+
+ <context:annotation-config />
+ <context:component-scan base-package="org.nhindirect.common.audit.impl" />
+ <tx:annotation-driven transaction-manager="transactionManager" />
+
+<!--
+ <context:property-placeholder ignore-resource-not-found="true"
location="classpath*:properties/auditStore.properties"/>
+-->
+ <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="location">
+ <value>classpath:properties/auditStore.properties</value>
+ </property>
+ </bean>
+
+ <!-- Exception translation bean post processor -->
+ <bean
+
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"
/>
+
+ <bean id="entityManagerFactory"
+
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
+ <property name="jpaVendorAdapter">
+ <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
+ <property name="showSql" value="true" />
+ <property name="generateDdl" value="true" />
+ <!-- <property name="databasePlatform"
value="org.hibernate.dialect.PostgreSQLDialect" /> -->
+ <property name="databasePlatform"
value='${auditStore.db.databasePlatform}' />
+ </bean>
+ </property>
+ <property name="dataSource" ref="dataSource"/>
+ <property name="persistenceUnitName" value="audit-store" />
+ </bean>
+
+
+ <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
+ destroy-method="close">
+ <property name="driverClassName" value='${auditStore.db.databaseDriver}'
/>
+ <property name="url" value='${auditStore.db.databaseURL}' />
+ <property name="username" value='${auditStore.db.username}' />
+ <property name="password" value='${auditStore.db.password}' />
+ </bean>
+ <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager" />
+</beans>
=======================================
--- /dev/null
+++
/java/tags/direct-common-audit-1.0/src/test/resources/properties/auditStore.properties
Mon Dec 15 17:46:15 2014 UTC
@@ -0,0 +1,5 @@
+auditStore.db.databasePlatform=org.hibernate.dialect.DerbyDialect
+auditStore.db.databaseDriver=org.apache.derby.jdbc.EmbeddedDriver
+auditStore.db.databaseURL=jdbc:derby:nhindconfig;create=true
+auditStore.db.username=nhind
+auditStore.db.password=nhind
=======================================
--- /java/direct-common-audit/pom.xml Fri Dec 12 20:31:58 2014 UTC
+++ /java/direct-common-audit/pom.xml Mon Dec 15 17:46:15 2014 UTC
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>direct-common-audit</artifactId>
<name>Direct Project additional auditing implementations</name>
- <version>1.0-SNAPSHOT</version>
+ <version>1.1-SNAPSHOT</version>
<description>Direct Project additional implementation for auditing
interface</description>
<inceptionYear>2010</inceptionYear>
<url>
http://api.nhindirect.org/x/www/api.nhindirect.org/java/site/direct-common-audit/${project.version}</url>