diff options
author | Endi S. Dewata <edewata@redhat.com> | 2017-06-21 22:34:45 +0200 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2017-06-22 04:00:51 +0200 |
commit | 2326a4426218ac1db2885f349d0623490d49d69a (patch) | |
tree | c4458ea07528986c160dbd0607d41818881fe933 /base/common | |
parent | d884229da2673703777d474fddd8c3c61eba9308 (diff) | |
download | pki-2326a4426218ac1db2885f349d0623490d49d69a.tar.gz pki-2326a4426218ac1db2885f349d0623490d49d69a.tar.xz pki-2326a4426218ac1db2885f349d0623490d49d69a.zip |
Added LogSource enumeration.
A LogSource enumeration has been added to replace the integer
log source in the Logger class.
https://pagure.io/dogtagpki/issue/2689
Change-Id: I6f69219fbbfa00d83f26a32174c75ff2782eb6af
Diffstat (limited to 'base/common')
7 files changed, 118 insertions, 59 deletions
diff --git a/base/common/src/com/netscape/certsrv/logging/AuditEvent.java b/base/common/src/com/netscape/certsrv/logging/AuditEvent.java index 1d94dad16..0a42343c6 100644 --- a/base/common/src/com/netscape/certsrv/logging/AuditEvent.java +++ b/base/common/src/com/netscape/certsrv/logging/AuditEvent.java @@ -228,7 +228,7 @@ public class AuditEvent implements IBundleLogEvent { private String mMessage = null; private int mLevel = -1; private int mNTEventType = -1; - private int mSource = -1; + private LogSource mSource; private boolean mMultiline = false; private long mTimeStamp = System.currentTimeMillis(); @@ -399,20 +399,20 @@ public class AuditEvent implements IBundleLogEvent { /** * Retrieves log source. * - * @return an integer that indicates the component source + * @return the component source * where this message event was triggered */ - public int getSource() { + public LogSource getSource() { return mSource; } /** * Sets log source. * - * @param source an integer that represents the component source + * @param source the component source * where this message event was triggered */ - public void setSource(int source) { + public void setSource(LogSource source) { mSource = source; } diff --git a/base/common/src/com/netscape/certsrv/logging/ILogEvent.java b/base/common/src/com/netscape/certsrv/logging/ILogEvent.java index 865d3dc9a..a0e641564 100644 --- a/base/common/src/com/netscape/certsrv/logging/ILogEvent.java +++ b/base/common/src/com/netscape/certsrv/logging/ILogEvent.java @@ -41,12 +41,12 @@ public interface ILogEvent extends Serializable { /** * Retrieves log source. - * This is an id of the subsystem responsible + * This is the subsystem responsible * for creating the log event. * - * @return Integer source id. + * @return log source. */ - public int getSource(); + public LogSource getSource(); /** * Retrieves log level. diff --git a/base/common/src/com/netscape/certsrv/logging/ILogEventFactory.java b/base/common/src/com/netscape/certsrv/logging/ILogEventFactory.java index 1cc48a502..e61abba1b 100644 --- a/base/common/src/com/netscape/certsrv/logging/ILogEventFactory.java +++ b/base/common/src/com/netscape/certsrv/logging/ILogEventFactory.java @@ -33,14 +33,14 @@ public interface ILogEventFactory { * * @param evtClass The event type. * @param prop The resource bundle. - * @param source The subsystem ID who creates the log event. + * @param source The subsystem who creates the log event. * @param level The severity of the log event. * @param multiline The log message has more than one line or not. * @param msg The detail message of the log. * @param params The parameters in the detail log message. * @return The created ILogEvent object. */ - public ILogEvent create(LogCategory evtClass, Properties prop, int source, + public ILogEvent create(LogCategory evtClass, Properties prop, LogSource source, int level, boolean multiline, String msg, Object params[]); /** diff --git a/base/common/src/com/netscape/certsrv/logging/ILogger.java b/base/common/src/com/netscape/certsrv/logging/ILogger.java index 633f668b8..f3e365f95 100644 --- a/base/common/src/com/netscape/certsrv/logging/ILogger.java +++ b/base/common/src/com/netscape/certsrv/logging/ILogger.java @@ -56,91 +56,91 @@ public interface ILogger { /** * log source: used by servlet to retrieve all logs */ - public static final int S_ALL = 0; //used by servlet only + public static final LogSource S_ALL = LogSource.ALL; //used by servlet only /** * log source: identify the log entry is from KRA */ - public static final int S_KRA = 1; + public static final LogSource S_KRA = LogSource.KRA; /** * log source: identify the log entry is from RA */ - public static final int S_RA = 2; + public static final LogSource S_RA = LogSource.RA; /** * log source: identify the log entry is from CA */ - public static final int S_CA = 3; + public static final LogSource S_CA = LogSource.CA; /** * log source: identify the log entry is from http subsystem */ - public static final int S_HTTP = 4; + public static final LogSource S_HTTP = LogSource.HTTP; /** * log source: identify the log entry is from database subsystem */ - public static final int S_DB = 5; + public static final LogSource S_DB = LogSource.DB; /** * log source: identify the log entry is from authentication subsystem */ - public static final int S_AUTHENTICATION = 6; + public static final LogSource S_AUTHENTICATION = LogSource.AUTHENTICATION; /** * log source: identify the log entry is from admin subsystem */ - public static final int S_ADMIN = 7; + public static final LogSource S_ADMIN = LogSource.ADMIN; /** * log source: identify the log entry is from ldap subsystem */ - public static final int S_LDAP = 8; + public static final LogSource S_LDAP = LogSource.LDAP; /** * log source: identify the log entry is from request queue subsystem */ - public static final int S_REQQUEUE = 9; + public static final LogSource S_REQQUEUE = LogSource.REQQUEUE; /** * log source: identify the log entry is from acl subsystem */ - public static final int S_ACLS = 10; + public static final LogSource S_ACLS = LogSource.ACLS; /** * log source: identify the log entry is from usergrp subsystem */ - public static final int S_USRGRP = 11; - public static final int S_OCSP = 12; + public static final LogSource S_USRGRP = LogSource.USRGRP; + public static final LogSource S_OCSP = LogSource.OCSP; /** * log source: identify the log entry is from authorization subsystem */ - public static final int S_AUTHORIZATION = 13; + public static final LogSource S_AUTHORIZATION = LogSource.AUTHORIZATION; /** * log source: identify the log entry is from signed audit */ - public static final int S_SIGNED_AUDIT = 14; + public static final LogSource S_SIGNED_AUDIT = LogSource.SIGNED_AUDIT; /** * log source: identify the log entry is from CrossCertPair subsystem */ - public static final int S_XCERT = 15; + public static final LogSource S_XCERT = LogSource.XCERT; /** * log source: identify the log entry is from CrossCertPair subsystem */ - public static final int S_TKS = 16; - public static final int S_TPS = 17; + public static final LogSource S_TKS = LogSource.TKS; + public static final LogSource S_TPS = LogSource.TPS; /** * log source: identify the log entry is from other subsystem * eg. policy, security, connector,registration */ - public static final int S_OTHER = 20; + public static final LogSource S_OTHER = LogSource.OTHER; // List of defined log levels. /** @@ -275,7 +275,7 @@ public interface ILogger { * @param source The source of the log event. * @param msg The detail message to be logged. */ - public void log(LogCategory evtClass, int source, String msg); + public void log(LogCategory evtClass, LogSource source, String msg); /** * Logs an event to the log queue. @@ -285,7 +285,7 @@ public interface ILogger { * @param source The source of the log event. * @param msg The detail message to be logged. */ - public void log(LogCategory evtClass, Properties props, int source, String msg); + public void log(LogCategory evtClass, Properties props, LogSource source, String msg); /** * Logs an event to the log queue. @@ -295,7 +295,7 @@ public interface ILogger { * @param level The level of the log event. * @param msg The detail message to be logged. */ - public void log(LogCategory evtClass, int source, int level, String msg); + public void log(LogCategory evtClass, LogSource source, int level, String msg); /** * Logs an event to the log queue. @@ -306,7 +306,7 @@ public interface ILogger { * @param level The level of the log event. * @param msg The detail message to be logged. */ - public void log(LogCategory evtClass, Properties props, int source, int level, String msg); + public void log(LogCategory evtClass, Properties props, LogSource source, int level, String msg); /** * Logs an event to the log queue. @@ -317,7 +317,7 @@ public interface ILogger { * @param msg The detail message to be logged. * @param param The parameter in the detail message. */ - public void log(LogCategory evtClass, int source, int level, String msg, Object param); + public void log(LogCategory evtClass, LogSource source, int level, String msg, Object param); /** * Logs an event to the log queue. @@ -328,7 +328,7 @@ public interface ILogger { * @param msg The detail message to be logged. * @param params The parameters in the detail message. */ - public void log(LogCategory evtClass, int source, int level, String msg, Object params[]); + public void log(LogCategory evtClass, LogSource source, int level, String msg, Object params[]); /** * Logs an event to the log queue. @@ -339,7 +339,7 @@ public interface ILogger { * @param msg The detail message to be logged. * @param param The parameters in the detail message. */ - public void log(LogCategory evtClass, Properties props, int source, String msg, Object param); + public void log(LogCategory evtClass, Properties props, LogSource source, String msg, Object param); /** * Logs an event to the log queue. @@ -351,7 +351,7 @@ public interface ILogger { * @param msg The detail message to be logged. * @param param The parameter in the detail message. */ - public void log(LogCategory evtClass, Properties props, int source, int level, String msg, + public void log(LogCategory evtClass, Properties props, LogSource source, int level, String msg, Object param); /** @@ -364,7 +364,7 @@ public interface ILogger { * @param msg The detail message to be logged. * @param params The parameters in the detail message. */ - public void log(LogCategory evtClass, Properties prop, int source, int level, String msg, + public void log(LogCategory evtClass, Properties prop, LogSource source, int level, String msg, Object params[]); //multiline log @@ -377,7 +377,7 @@ public interface ILogger { * @param msg The detail message to be logged. * @param multiline true If the message has more than one line, otherwise false. */ - public void log(LogCategory evtClass, int source, String msg, boolean multiline); + public void log(LogCategory evtClass, LogSource source, String msg, boolean multiline); /** * Logs an event to the log queue. @@ -388,7 +388,7 @@ public interface ILogger { * @param msg The detail message to be logged. * @param multiline True if the message has more than one line, otherwise false. */ - public void log(LogCategory evtClass, Properties props, int source, String msg, boolean multiline); + public void log(LogCategory evtClass, Properties props, LogSource source, String msg, boolean multiline); /** * Logs an event to the log queue. @@ -399,7 +399,7 @@ public interface ILogger { * @param msg The detail message to be logged. * @param multiline True if the message has more than one line, otherwise false. */ - public void log(LogCategory evtClass, int source, int level, String msg, boolean multiline); + public void log(LogCategory evtClass, LogSource source, int level, String msg, boolean multiline); /** * Logs an event to the log queue. @@ -411,7 +411,7 @@ public interface ILogger { * @param msg The detail message to be logged. * @param multiline True if the message has more than one line, otherwise false. */ - public void log(LogCategory evtClass, Properties props, int source, int level, String msg, boolean multiline); + public void log(LogCategory evtClass, Properties props, LogSource source, int level, String msg, boolean multiline); /** * Logs an event to the log queue. @@ -423,7 +423,7 @@ public interface ILogger { * @param param The parameter in the detail message. * @param multiline True if the message has more than one line, otherwise false. */ - public void log(LogCategory evtClass, int source, int level, String msg, Object param, boolean multiline); + public void log(LogCategory evtClass, LogSource source, int level, String msg, Object param, boolean multiline); /** * Logs an event to the log queue. @@ -435,7 +435,7 @@ public interface ILogger { * @param param The parameter in the detail message. * @param multiline True if the message has more than one line, otherwise false. */ - public void log(LogCategory evtClass, Properties props, int source, String msg, Object param, boolean multiline); + public void log(LogCategory evtClass, Properties props, LogSource source, String msg, Object param, boolean multiline); /** * Logs an event to the log queue. @@ -448,7 +448,7 @@ public interface ILogger { * @param param The parameter in the detail message. * @param multiline True if the message has more than one line, otherwise false. */ - public void log(LogCategory evtClass, Properties props, int source, int level, String msg, + public void log(LogCategory evtClass, Properties props, LogSource source, int level, String msg, Object param, boolean multiline); /** @@ -462,7 +462,7 @@ public interface ILogger { * @param params The parameters in the detail message. * @param multiline True if the message has more than one line, otherwise false. */ - public void log(LogCategory evtClass, Properties prop, int source, int level, String msg, + public void log(LogCategory evtClass, Properties prop, LogSource source, int level, String msg, Object params[], boolean multiline); /* @@ -476,7 +476,7 @@ public interface ILogger { * @param multiline True if the message has more than one line, otherwise false. * @return ILogEvent, a log event. */ - public ILogEvent create(LogCategory evtClass, Properties prop, int source, int level, + public ILogEvent create(LogCategory evtClass, Properties prop, LogSource source, int level, String msg, Object params[], boolean multiline); /** diff --git a/base/common/src/com/netscape/certsrv/logging/LogSource.java b/base/common/src/com/netscape/certsrv/logging/LogSource.java new file mode 100644 index 000000000..a7efeb1ea --- /dev/null +++ b/base/common/src/com/netscape/certsrv/logging/LogSource.java @@ -0,0 +1,59 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2017 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.certsrv.logging; + +public enum LogSource { + ALL (0), + KRA (1), + RA (2), + CA (3), + HTTP (4), + DB (5), + AUTHENTICATION (6), + ADMIN (7), + LDAP (8), + REQQUEUE (9), + ACLS (10), + USRGRP (11), + OCSP (12), + AUTHORIZATION (13), + SIGNED_AUDIT (14), + XCERT (15), + TKS (16), + TPS (17), + OTHER (20); + + private final int value; + + private LogSource(int value) { + this.value = value; + } + + public int value() { + return value; + } + + public static LogSource valueOf(int value) { + for (LogSource s : LogSource.values()) { + if (s.value == value) { + return s; + } + } + return null; + } +} diff --git a/base/common/src/com/netscape/certsrv/logging/SignedAuditEvent.java b/base/common/src/com/netscape/certsrv/logging/SignedAuditEvent.java index b5483eb9f..c9adb3f85 100644 --- a/base/common/src/com/netscape/certsrv/logging/SignedAuditEvent.java +++ b/base/common/src/com/netscape/certsrv/logging/SignedAuditEvent.java @@ -46,7 +46,7 @@ public class SignedAuditEvent implements IBundleLogEvent { private String mMessage = null; private int mLevel = -1; private int mNTEventType = -1; - private int mSource = -1; + private LogSource mSource; private boolean mMultiline = false; private long mTimeStamp = System.currentTimeMillis(); @@ -213,21 +213,21 @@ public class SignedAuditEvent implements IBundleLogEvent { /** * Retrieves log source. - * This is an id of the subsystem responsible + * This is the subsystem responsible * for creating the log event. * - * @return Integer source id. + * @return LogSource log source. */ - public int getSource() { + public LogSource getSource() { return mSource; } /** * Sets log source. * - * @param source Integer id of log source. + * @param source log source. */ - public void setSource(int source) { + public void setSource(LogSource source) { mSource = source; } diff --git a/base/common/src/com/netscape/certsrv/logging/SystemEvent.java b/base/common/src/com/netscape/certsrv/logging/SystemEvent.java index 3704e60ca..96f944c38 100644 --- a/base/common/src/com/netscape/certsrv/logging/SystemEvent.java +++ b/base/common/src/com/netscape/certsrv/logging/SystemEvent.java @@ -45,7 +45,7 @@ public class SystemEvent implements IBundleLogEvent { private String mMessage = null; private int mLevel = -1; private int mNTEventType = -1; - private int mSource = -1; + private LogSource mSource; private boolean mMultiline = false; private long mTimeStamp = System.currentTimeMillis(); @@ -211,12 +211,12 @@ public class SystemEvent implements IBundleLogEvent { /** * Retrieves log source. - * This is an id of the subsystem responsible + * This is the subsystem responsible * for creating the log event. * - * @return Integer source id. + * @return log source. */ - public int getSource() { + public LogSource getSource() { return mSource; } @@ -224,9 +224,9 @@ public class SystemEvent implements IBundleLogEvent { * Sets log source. * Sets the id of the subsystem issuing the event. * - * @param source Integer source id. + * @param source log source. */ - public void setSource(int source) { + public void setSource(LogSource source) { mSource = source; } |