Skip to content

Commit 007f26d

Browse files
committed
fixed defects
1 parent 72ceb59 commit 007f26d

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,16 @@ public static void troubleshootEvent(AuditEvent event) {
5353
throw new TroubleshootException(
5454
"Invalid Audit event type,\n Audit4j: Audit Event should not null, This event will not be logged by the Audit4j.");
5555
} else if (event.getActor() == null) {
56-
event.setActor(CoreConstants.DEFAULT_ACTOR);
57-
Log.warn("Audit4j:WARN If you are not parsing the actor to the AuditEvent,\n"
58-
+ "Audit4j:WARN you should make a your own AuditMetaData implementation. \n"
59-
+ "Audit4j:WARN otherwise actor will be hard coded as \"" + CoreConstants.DEFAULT_ACTOR
60-
+ "\" in the audit log. " + "\nAudit4j: See " + ErrorURL.NULL_ACTOR + " for further details.");
56+
if (Context.getConfig().getMetaData().getClass().equals(DummyMetaData.class)) {
57+
event.setActor(CoreConstants.DEFAULT_ACTOR);
58+
Log.warn("Audit4j:WARN If you are not parsing the actor to the AuditEvent,\n"
59+
+ "Audit4j:WARN you should make a your own AuditMetaData implementation. \n"
60+
+ "Audit4j:WARN otherwise actor will be hard coded as \"" + CoreConstants.DEFAULT_ACTOR
61+
+ "\" in the audit log. " + "\nAudit4j: See " + ErrorURL.NULL_ACTOR + " for further details.");
62+
63+
} else {
64+
event.setActor(Context.getConfig().getMetaData().getActor());
65+
}
6166
} else if (event.getOrigin() == null) {
6267
throw new TroubleshootException(
6368
"Invalid Audit event type,\n Audit4j: origin should not null, This event will not be logged by the Audit4j.");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private ValidationManager() {
5252
* the validation exception
5353
*/
5454
public static void validateEvent(AuditEvent event) throws ValidationException {
55-
if (event == null || event.getActor() == null || event.getOrigin() == null) {
55+
if (event == null || event.getActor() == null ) {
5656
throw new ValidationException("Invalid Input", ValidationException.VALIDATION_LEVEL_WARN);
5757
}
5858
}

0 commit comments

Comments
 (0)