Skip to content

Commit a81f1eb

Browse files
committed
refactored the codebase for release 2.0.0
1 parent 0280606 commit a81f1eb

File tree

66 files changed

+1307
-473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1307
-473
lines changed

src/main/java/org/audit4j/core/AnnotationAuditProcessor.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
2-
* Copyright 2014 Janith Bandara, This source is a part of Audit4j -
3-
* An open-source audit platform for Enterprise java platform.
4-
* http://mechanizedspace.com/audit4j
2+
* Copyright 2014 Janith Bandara, This source is a part of
3+
* Audit4j - An open source auditing framework.
54
* http://audit4j.org
65
*
76
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,7 +27,10 @@
2827
* @param <T>
2928
* the generic type
3029
* @author <a href="mailto:[email protected]">Janith Bandara</a>
30+
*
31+
* @since 1.0.0
3132
*/
33+
@Deprecated
3234
public abstract class AnnotationAuditProcessor<T extends AuditBase> extends AuditProcessor<T> {
3335

3436
/** The audit event. */
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright 2014 Janith Bandara, This source is a part of
3+
* Audit4j - An open source auditing framework.
4+
* http://audit4j.org
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.audit4j.core;
20+
21+
import java.util.List;
22+
23+
import org.audit4j.core.annotation.AuditAnnotationAttributes;
24+
import org.audit4j.core.annotation.AuditFieldAnnotationAttribute;
25+
import org.audit4j.core.annotation.SelectionType;
26+
import org.audit4j.core.dto.AnnotationAuditEvent;
27+
import org.audit4j.core.dto.AuditEvent;
28+
import org.audit4j.core.dto.Field;
29+
30+
/**
31+
* The Class AnnotationTransformer.
32+
*
33+
* @author <a href="mailto:[email protected]">Janith Bandara</a>
34+
*
35+
* @since 2.0.0
36+
*/
37+
public class AnnotationTransformer {
38+
39+
/**
40+
* Transform to event.
41+
*
42+
* @param annotationEvent the annotation event
43+
* @return the audit event
44+
* @since 2.0.0
45+
*/
46+
public AuditEvent transformToEvent(AnnotationAuditEvent annotationEvent) {
47+
final AuditAnnotationAttributes attributes = new AuditAnnotationAttributes();
48+
final AuditFieldAnnotationAttribute fieldAttributes = new AuditFieldAnnotationAttribute();
49+
List<Field> fields = null;
50+
AuditEvent event = new AuditEvent();
51+
String action = "";
52+
53+
if (attributes.hasAnnotation(annotationEvent.getClass())) {
54+
final SelectionType selection = attributes.getSelection(annotationEvent.getClass());
55+
if (selection.equals(SelectionType.ALL)) {
56+
fields = fieldAttributes.getAllFields(annotationEvent.getMethod(), annotationEvent.getArgs());
57+
} else if (selection.equals(SelectionType.MARKED)) {
58+
fields = fieldAttributes.getMarkedFields(annotationEvent.getMethod(), annotationEvent.getArgs());
59+
}
60+
action = attributes.getAction(annotationEvent.getMethod().getClass(), annotationEvent.getMethod());
61+
} else if (attributes.hasAnnotation(annotationEvent.getMethod())) {
62+
final SelectionType selection = attributes.getSelection(annotationEvent.getMethod());
63+
if (selection.equals(SelectionType.ALL)) {
64+
fields = fieldAttributes.getAllFields(annotationEvent.getMethod(), annotationEvent.getArgs());
65+
} else if (selection.equals(SelectionType.MARKED)) {
66+
fields = fieldAttributes.getMarkedFields(annotationEvent.getMethod(), annotationEvent.getArgs());
67+
}
68+
action = attributes.getAction(annotationEvent.getMethod());
69+
}
70+
71+
if (action.equals(CoreConstants.ACTION.equals(action))) {
72+
action = annotationEvent.getMethod().getName();
73+
}
74+
event.setAction(action);
75+
event.setFields(fields);
76+
return event;
77+
}
78+
}

src/main/java/org/audit4j/core/AsyncAuditEngine.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
2-
* Copyright 2014 Janith Bandara, This source is a part of Audit4j -
3-
* An open-source audit platform for Enterprise java platform.
4-
* http://mechanizedspace.com/audit4j
2+
* Copyright 2014 Janith Bandara, This source is a part of
3+
* Audit4j - An open source auditing framework.
54
* http://audit4j.org
65
*
76
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -42,10 +41,14 @@
4241
import org.audit4j.core.dto.AuditBase;
4342

4443
/**
44+
* @deprecated due to new Streaming api. no longer using.
4545
* The Class AsyncAuditEngine.
4646
*
4747
* @author Janith Bandara
48+
*
49+
* @since 1.0
4850
*/
51+
@Deprecated
4952
public class AsyncAuditEngine implements ExceptionListener {
5053

5154
/** The queue name. */

src/main/java/org/audit4j/core/AsynchronousAnnotationProcessor.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
2-
* Copyright 2014 Janith Bandara, This source is a part of Audit4j -
3-
* An open-source audit platform for Enterprise java platform.
4-
* http://mechanizedspace.com/audit4j
2+
* Copyright 2014 Janith Bandara, This source is a part of
3+
* Audit4j - An open source auditing framework.
54
* http://audit4j.org
65
*
76
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,12 +28,14 @@
2928
import org.audit4j.core.dto.Field;
3029
import org.audit4j.core.handler.Handler;
3130

32-
3331
/**
3432
* The Class AsynchronousAuditProcessor.
3533
*
3634
* @author Janith Bandara
35+
*
36+
* @since 1.0.0
3737
*/
38+
@Deprecated
3839
public class AsynchronousAnnotationProcessor extends AnnotationAuditProcessor<AnnotationAuditEvent> {
3940

4041
/**
@@ -61,7 +62,7 @@ public void process(AnnotationAuditEvent auditDto) {
6162
AuditEvent event = new AuditEvent();
6263
String action = "";
6364
if (attributes.hasAnnotation(auditDto.getClass())) {
64-
handlers = Context.getHandlers();
65+
handlers = Context.getConfig().getHandlers();
6566

6667
final SelectionType selection = attributes.getSelection(auditDto.getClass());
6768
if (selection.equals(SelectionType.ALL)) {
@@ -71,7 +72,7 @@ public void process(AnnotationAuditEvent auditDto) {
7172
}
7273
action = attributes.getAction(auditDto.getMethod().getClass(), auditDto.getMethod());
7374
} else if (attributes.hasAnnotation(auditDto.getMethod())) {
74-
handlers = Context.getHandlers();
75+
handlers = Context.getConfig().getHandlers();
7576
final SelectionType selection = attributes.getSelection(auditDto.getMethod());
7677
if (selection.equals(SelectionType.ALL)) {
7778
fields = fieldAttributes.getAllFields(auditDto.getMethod(), auditDto.getArgs());

src/main/java/org/audit4j/core/AsynchronousCallAuditProcessor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
2-
* Copyright 2014 Janith Bandara, This source is a part of Audit4j -
3-
* An open-source audit platform for Enterprise java platform.
4-
* http://mechanizedspace.com/audit4j
2+
* Copyright 2014 Janith Bandara, This source is a part of
3+
* Audit4j - An open source auditing framework.
54
* http://audit4j.org
65
*
76
* Licensed under the Apache License, Version 2.0 (the "License");

src/main/java/org/audit4j/core/AuditEventProcessor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
2-
* Copyright 2014 Janith Bandara, This source is a part of Audit4j -
3-
* An open-source audit platform for Enterprise java platform.
4-
* http://mechanizedspace.com/audit4j
2+
* Copyright 2014 Janith Bandara, This source is a part of
3+
* Audit4j - An open source auditing framework.
54
* http://audit4j.org
65
*
76
* Licensed under the Apache License, Version 2.0 (the "License");

0 commit comments

Comments
 (0)