diff --git a/audit-client/pom.xml b/audit-client/pom.xml
index 23a2dba..8af79f1 100644
--- a/audit-client/pom.xml
+++ b/audit-client/pom.xml
@@ -1,66 +1,64 @@
+
+ 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">
+
+ ch.qos.logback
+ audit-parent
+ 0.7-SNAPSHOT
+
-
- ch.qos.logback
- audit-parent
- 0.6
-
+ 4.0.0
- 4.0.0
+ audit-client
+ jar
+ Logback Audit Client
- ch.qos.logback
- audit-client
- jar
- Logback Audit Client
+
+
+ ch.qos.logback
+ audit-common
+
-
-
- ch.qos.logback
- audit-common
-
+
+ ch.qos.logback
+ logback-core
+
-
- ch.qos.logback
- logback-core
-
+
+ org.slf4j
+ slf4j-api
+
-
- org.slf4j
- slf4j-api
-
+
+ org.slf4j
+ slf4j-simple
+ test
+
-
- org.slf4j
- slf4j-simple
- test
-
+
-
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ once
+ plain
+ false
+
+ **/*AllTest.java
+ **/PackageTest.java
+ **/SizeBasedRollingTest.java
+
+
+
+
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- once
- plain
- false
-
- **/*AllTest.java
- **/PackageTest.java
- **/SizeBasedRollingTest.java
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/audit-client/src/main/java/ch/qos/logback/audit/client/AuditAppender.java b/audit-client/src/main/java/ch/qos/logback/audit/client/AuditAppender.java
index 3bbc414..08fe0dc 100644
--- a/audit-client/src/main/java/ch/qos/logback/audit/client/AuditAppender.java
+++ b/audit-client/src/main/java/ch/qos/logback/audit/client/AuditAppender.java
@@ -1,13 +1,13 @@
/**
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 2006-2011, QOS.ch. All rights reserved.
- *
+ *
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
- *
+ *
* or (per the licensee's choosing)
- *
+ *
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
@@ -21,24 +21,24 @@
public interface AuditAppender extends ContextAware, LifeCycle {
- /**
- * Get the name of this appender. The name uniquely identifies the appender.
- */
- public String getName();
+ /**
+ * Get the name of this appender. The name uniquely identifies the appender.
+ */
+ String getName();
- /**
- * Set the name of this appender. The name is used by other components to
- * identify this appender.
- *
- */
- public void setName(String name);
-
- /**
- * This is where an appender accomplishes its work. Note that the argument
- * is of type Object.
- * @param event
- */
- void doAppend(AuditEvent event) throws AuditException;
+ /**
+ * Set the name of this appender. The name is used by other components to
+ * identify this appender.
+ *
+ */
+ void setName(String name);
+
+ /**
+ * This is where an appender accomplishes its work. Note that the argument is of
+ * type Object.
+ *
+ * @param event
+ */
+ void doAppend(AuditEvent event) throws AuditException;
-
}
diff --git a/audit-client/src/main/java/ch/qos/logback/audit/client/AuditAppenderBase.java b/audit-client/src/main/java/ch/qos/logback/audit/client/AuditAppenderBase.java
index 6db9587..b20eed7 100644
--- a/audit-client/src/main/java/ch/qos/logback/audit/client/AuditAppenderBase.java
+++ b/audit-client/src/main/java/ch/qos/logback/audit/client/AuditAppenderBase.java
@@ -1,13 +1,13 @@
/**
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 2006-2011, QOS.ch. All rights reserved.
- *
+ *
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
- *
+ *
* or (per the licensee's choosing)
- *
+ *
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
@@ -18,61 +18,62 @@
import ch.qos.logback.audit.AuditException;
import ch.qos.logback.core.spi.ContextAwareBase;
-abstract public class AuditAppenderBase extends ContextAwareBase implements
- AuditAppender {
-
- protected boolean started = false;
-
- //static final int NOT_STARTED_ERROR_COUNT_LIMIT = 5;
- //int notStartedErrorCount = 0;
-
-
- /**
- * Appenders are named.
- */
- protected String name;
-
- public synchronized void doAppend(AuditEvent auditEvent)
- throws AuditException {
-
- try {
-
- if (!this.started) {
- throw new AuditException(
- "Attempted to append to non started appender [" + name + "].");
- }
-
- // ok, we now invoke derived class' implementation of append
- this.append(auditEvent);
-
- } catch (Exception e) {
- if (e instanceof AuditException) {
- throw (AuditException) e;
- } else {
- throw new AuditException("Failed to audit an event", e);
- }
- }
- }
-
- abstract protected void append(AuditEvent auditEvent) throws AuditException;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void start() {
- started = true;
- }
-
- public void stop() {
- started = false;
- }
-
- public boolean isStarted() {
- return started;
- }
+abstract public class AuditAppenderBase extends ContextAwareBase implements AuditAppender {
+
+ protected boolean started = false;
+
+ // static final int NOT_STARTED_ERROR_COUNT_LIMIT = 5;
+ // int notStartedErrorCount = 0;
+
+ /**
+ * Appenders are named.
+ */
+ protected String name;
+
+ @Override
+ public synchronized void doAppend(final AuditEvent auditEvent) throws AuditException {
+
+ try {
+
+ if (!started) {
+ throw new AuditException("Attempted to append to non started appender [" + name + "].");
+ }
+
+ // ok, we now invoke derived class' implementation of append
+ append(auditEvent);
+
+ } catch (final Exception e) {
+ if (e instanceof AuditException) {
+ throw (AuditException) e;
+ }
+ throw new AuditException("Failed to audit an event", e);
+ }
+ }
+
+ abstract protected void append(AuditEvent auditEvent) throws AuditException;
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ @Override
+ public void start() {
+ started = true;
+ }
+
+ @Override
+ public void stop() {
+ started = false;
+ }
+
+ @Override
+ public boolean isStarted() {
+ return started;
+ }
}
diff --git a/audit-client/src/main/java/ch/qos/logback/audit/client/AuditConstants.java b/audit-client/src/main/java/ch/qos/logback/audit/client/AuditConstants.java
index b37b6da..392cd94 100644
--- a/audit-client/src/main/java/ch/qos/logback/audit/client/AuditConstants.java
+++ b/audit-client/src/main/java/ch/qos/logback/audit/client/AuditConstants.java
@@ -1,13 +1,13 @@
/**
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 2006-2011, QOS.ch. All rights reserved.
- *
+ *
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
- *
+ *
* or (per the licensee's choosing)
- *
+ *
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
@@ -15,13 +15,13 @@
package ch.qos.logback.audit.client;
public interface AuditConstants {
- // TYPES
- static final String SUBJECT_TYPE = "SUBJECT_TYPE";
- static final String CRUD_TYPE = "CRUD_TYPE";
-
- // CRUD_TYPES
- static final String CREATE = "CREATE";
- static final String READ = "READ";
- static final String UPDATE = "UPDATE";
- static final String DELETE = "DELETE";
+ // TYPES
+ String SUBJECT_TYPE = "SUBJECT_TYPE";
+ String CRUD_TYPE = "CRUD_TYPE";
+
+ // CRUD_TYPES
+ String CREATE = "CREATE";
+ String READ = "READ";
+ String UPDATE = "UPDATE";
+ String DELETE = "DELETE";
}
diff --git a/audit-client/src/main/java/ch/qos/logback/audit/client/Auditor.java b/audit-client/src/main/java/ch/qos/logback/audit/client/Auditor.java
index 8b1f006..9c36fa9 100644
--- a/audit-client/src/main/java/ch/qos/logback/audit/client/Auditor.java
+++ b/audit-client/src/main/java/ch/qos/logback/audit/client/Auditor.java
@@ -1,19 +1,21 @@
/**
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 2006-2011, QOS.ch. All rights reserved.
- *
+ *
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
- *
+ *
* or (per the licensee's choosing)
- *
+ *
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
package ch.qos.logback.audit.client;
+import java.util.Objects;
+
import ch.qos.logback.audit.Application;
import ch.qos.logback.audit.AuditEvent;
import ch.qos.logback.audit.AuditEventBuilder;
@@ -23,48 +25,48 @@
public class Auditor extends ContextBase {
- AuditAppender auditAppender;
- Application clientApplication;
+ AuditAppender auditAppender;
+ Application clientApplication;
+
+ public AuditEventBuilder newAuditEventBuilder() {
+ final AuditEventBuilder ab = new AuditEventBuilderImpl();
+ ab.setClientApplication(clientApplication);
+ return ab;
+ }
- public AuditEventBuilder newAuditEventBuilder() {
- AuditEventBuilderImpl ab = new AuditEventBuilderImpl();
- ab.setClientApplication(clientApplication);
- return ab;
- }
+ public void log(final AuditEvent auditEvent) throws AuditException {
+ auditAppender.doAppend(auditEvent);
+ }
- public void log(AuditEvent auditEvent) throws AuditException {
- auditAppender.doAppend(auditEvent);
- }
+ public void log(final AuditEventBuilder builder) throws AuditException {
+ final AuditEvent auditEvent = builder.build();
+ auditAppender.doAppend(auditEvent);
+ }
- public void log(AuditEventBuilder builder) throws AuditException {
- AuditEvent auditEvent = builder.build();
- auditAppender.doAppend(auditEvent);
- }
-
- public AuditAppender getAuditAppender() {
- return auditAppender;
- }
+ public AuditAppender getAuditAppender() {
+ return auditAppender;
+ }
- public void setAuditAppender(AuditAppender auditAppender) {
- this.auditAppender = auditAppender;
- }
+ public void setAuditAppender(final AuditAppender auditAppender) {
+ this.auditAppender = auditAppender;
+ }
- public void shutdown() {
- if (auditAppender != null) {
- auditAppender.stop();
- }
- auditAppender = null;
- }
+ public void shutdown() {
+ if (Objects.nonNull(auditAppender)) {
+ auditAppender.stop();
+ }
+ auditAppender = null;
+ }
- public Application getClientApplication() {
- return clientApplication;
- }
+ public Application getClientApplication() {
+ return clientApplication;
+ }
- public void setClientApplication(Application capp) {
- if(this.clientApplication != null) {
- throw new IllegalStateException("Client application has been set already.");
- }
- this.clientApplication = capp;
- }
+ public void setClientApplication(final Application capp) {
+ if (Objects.nonNull(clientApplication)) {
+ throw new IllegalStateException("Client application has been set already.");
+ }
+ clientApplication = capp;
+ }
}
diff --git a/audit-client/src/main/java/ch/qos/logback/audit/client/AuditorFacade.java b/audit-client/src/main/java/ch/qos/logback/audit/client/AuditorFacade.java
index 4372fe5..e387845 100644
--- a/audit-client/src/main/java/ch/qos/logback/audit/client/AuditorFacade.java
+++ b/audit-client/src/main/java/ch/qos/logback/audit/client/AuditorFacade.java
@@ -1,13 +1,13 @@
/**
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 2006-2011, QOS.ch. All rights reserved.
- *
+ *
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
- *
+ *
* or (per the licensee's choosing)
- *
+ *
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/
@@ -16,6 +16,7 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -26,78 +27,74 @@
import ch.qos.logback.audit.Predicate;
public class AuditorFacade {
- final Logger logger = LoggerFactory.getLogger(AuditorFacade.class);
-
- final String object;
- final String verb;
- final String subject;
- Application originatingApplication;
- Map predicateMap;
+ final Logger logger = LoggerFactory.getLogger(AuditorFacade.class);
- public AuditorFacade(String subject, String verb, String object) {
- this.subject = subject;
- this.verb = verb;
- this.object = object;
- }
+ final String object;
+ final String verb;
+ final String subject;
+ Application originatingApplication;
+ Map predicateMap;
- public void audit() throws AuditException {
- Auditor auditor = AuditorFactory.getAuditor();
+ public AuditorFacade(final String subject, final String verb, final String object) {
+ this.subject = subject;
+ this.verb = verb;
+ this.object = object;
+ }
- AuditEventBuilder builder = auditor.newAuditEventBuilder();
- builder.setObject(object);
- builder.setVerb(verb);
- builder.setSubject(subject);
- if (predicateMap != null) {
- builder.setPredicateMap(predicateMap);
- }
- if (originatingApplication != null) {
- builder.setOriginatingApplication(originatingApplication);
- }
- auditor.log(builder);
- }
+ public void audit() throws AuditException {
+ final Auditor auditor = AuditorFactory.getAuditor();
- public AuditorFacade setPredicateMap(Map predicateMap) {
- this.predicateMap = predicateMap;
- return this;
- }
+ final AuditEventBuilder builder = auditor.newAuditEventBuilder();
+ builder.setObject(object);
+ builder.setVerb(verb);
+ builder.setSubject(subject);
+ if (Objects.nonNull(predicateMap)) {
+ builder.setPredicateMap(predicateMap);
+ }
+ if (Objects.nonNull(originatingApplication)) {
+ builder.setOriginatingApplication(originatingApplication);
+ }
+ auditor.log(builder);
+ }
- /**
- * Add a predicate.
- *
- * @param predicate
- * @return
- */
- public AuditorFacade add(Predicate predicate) {
- if (predicate == null) {
- throw new IllegalArgumentException(
- "The predicate parameter cannot be null");
- }
- return add(predicate.getName(), predicate.getValue());
- }
+ public AuditorFacade setPredicateMap(final Map predicateMap) {
+ this.predicateMap = predicateMap;
+ return this;
+ }
- /**
- * Add a predicate through two parameters, key and value.
- *
- * @param key
- * @param value
- * @return
- */
- public AuditorFacade add(String key, String value) {
- if (predicateMap == null) {
- predicateMap = new HashMap();
- }
- predicateMap.put(key, value);
- return this;
- }
+ /**
+ * Add a predicate.
+ *
+ * @param predicate
+ * @return
+ */
+ public AuditorFacade add(final Predicate predicate) {
+ if (Objects.isNull(predicate)) {
+ throw new IllegalArgumentException("The predicate parameter cannot be null");
+ }
+ return add(predicate.getName(), predicate.getValue());
+ }
- /**
- * Set the originating application name.
- *
- * @param originatingApplication
- * @return
- */
- public AuditorFacade originating(Application originatingApplication) {
- this.originatingApplication = originatingApplication;
- return this;
- }
+ /**
+ * Add a predicate through two parameters, key and value.
+ *
+ * @param key
+ * @param value
+ * @return
+ */
+ public AuditorFacade add(final String key, final String value) {
+ Objects.