diff options
author | Endi S. Dewata <edewata@redhat.com> | 2017-06-22 02:59:58 +0200 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2017-06-22 05:29:43 +0200 |
commit | 355dac82588ce83e84b7dc57b4f7dbf27c6ba9bd (patch) | |
tree | 1d8466942d568d85976e2505f80eb4e375acff0a | |
parent | 2326a4426218ac1db2885f349d0623490d49d69a (diff) | |
download | pki-355dac82588ce83e84b7dc57b4f7dbf27c6ba9bd.tar.gz pki-355dac82588ce83e84b7dc57b4f7dbf27c6ba9bd.tar.xz pki-355dac82588ce83e84b7dc57b4f7dbf27c6ba9bd.zip |
Refactored ILogEventFactory implementations.
A new LogFactory base class has been added to store the
common fields and methods of the classes implementing
ILogEventFactory interface.
https://pagure.io/dogtagpki/issue/2689
Change-Id: Ife683856e769bd95f22e0fc06e8b65853c3708a2
4 files changed, 65 insertions, 108 deletions
diff --git a/base/server/cmscore/src/com/netscape/cmscore/logging/AuditEventFactory.java b/base/server/cmscore/src/com/netscape/cmscore/logging/AuditEventFactory.java index bfab6bbbc..06230b14c 100644 --- a/base/server/cmscore/src/com/netscape/cmscore/logging/AuditEventFactory.java +++ b/base/server/cmscore/src/com/netscape/cmscore/logging/AuditEventFactory.java @@ -20,9 +20,7 @@ package com.netscape.cmscore.logging; import java.util.Properties; import com.netscape.certsrv.logging.AuditEvent; -import com.netscape.certsrv.logging.IBundleLogEvent; import com.netscape.certsrv.logging.ILogEvent; -import com.netscape.certsrv.logging.ILogEventFactory; import com.netscape.certsrv.logging.ILogger; import com.netscape.certsrv.logging.LogCategory; import com.netscape.certsrv.logging.LogSource; @@ -35,12 +33,7 @@ import com.netscape.certsrv.logging.LogSource; * @author mzhao * @version $Revision$, $Date$ */ -public class AuditEventFactory implements ILogEventFactory { - - /** - * List of supported properties. - */ - public static final String PROP_BUNDLE = "bundleName"; +public class AuditEventFactory extends LogFactory { /** * Constructs a audit event factory. @@ -71,31 +64,4 @@ public class AuditEventFactory implements ILogEventFactory { setProperties(prop, event); return event; } - - /** - * Set the resource bundle of the log event. - * - * @param prop the properties - * @param event the log event - */ - protected void setProperties(Properties prop, IBundleLogEvent event) { - if (prop == null) { - event.setBundleName(null); - } else { - String bundleName = (String) prop.get(PROP_BUNDLE); - - if (bundleName != null) { - event.setBundleName(bundleName); - } - } - } - - /** - * Releases an log event. - * - * @param e the log event - */ - public void release(ILogEvent e) { - // do nothing - } } diff --git a/base/server/cmscore/src/com/netscape/cmscore/logging/LogFactory.java b/base/server/cmscore/src/com/netscape/cmscore/logging/LogFactory.java new file mode 100644 index 000000000..3d76c74b8 --- /dev/null +++ b/base/server/cmscore/src/com/netscape/cmscore/logging/LogFactory.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) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.cmscore.logging; + +import java.util.Properties; + +import com.netscape.certsrv.logging.IBundleLogEvent; +import com.netscape.certsrv.logging.ILogEvent; +import com.netscape.certsrv.logging.ILogEventFactory; + +public abstract class LogFactory implements ILogEventFactory { + + public static final String PROP_BUNDLE = "bundleName"; + + public LogFactory() { + } + + /** + * Set the resource bundle of the log event. + * + * @param prop the properties + * @param event the log event + */ + protected void setProperties(Properties prop, IBundleLogEvent event) { + if (prop == null) { + event.setBundleName(null); + } else { + String bundleName = (String) prop.get(PROP_BUNDLE); + + if (bundleName != null) { + event.setBundleName(bundleName); + } + } + } + + /** + * Releases an log event. + * + * @param e the log event + */ + public void release(ILogEvent e) { + // do nothing + } +} diff --git a/base/server/cmscore/src/com/netscape/cmscore/logging/SignedAuditEventFactory.java b/base/server/cmscore/src/com/netscape/cmscore/logging/SignedAuditEventFactory.java index 3dc67b122..22400f5ea 100644 --- a/base/server/cmscore/src/com/netscape/cmscore/logging/SignedAuditEventFactory.java +++ b/base/server/cmscore/src/com/netscape/cmscore/logging/SignedAuditEventFactory.java @@ -19,14 +19,12 @@ package com.netscape.cmscore.logging; import java.util.Properties; -import com.netscape.certsrv.logging.IBundleLogEvent; +import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.logging.ILogEvent; -import com.netscape.certsrv.logging.ILogEventFactory; import com.netscape.certsrv.logging.ILogger; import com.netscape.certsrv.logging.LogCategory; import com.netscape.certsrv.logging.LogSource; import com.netscape.certsrv.logging.SignedAuditEvent; -import com.netscape.cmscore.util.Debug; /** * A log event object for handling system messages @@ -37,12 +35,7 @@ import com.netscape.cmscore.util.Debug; * @author cfu * @version $Revision$, $Date$ */ -public class SignedAuditEventFactory implements ILogEventFactory { - - /** - * List of supported properties. - */ - public static final String PROP_BUNDLE = "bundleName"; +public class SignedAuditEventFactory extends LogFactory { /** * Constructs a system event factory. @@ -78,8 +71,8 @@ public class SignedAuditEventFactory implements ILogEventFactory { eventType = typeMessage.substring(typeBegin + 6, colon); message = typeMessage.substring(colon + 2); - //Debug.trace("SignedAuditEventFactory: create() message=" + message + "\n"); - Debug.trace("SignedAuditEventFactory: create() message created for eventType=" + eventType + "\n"); + //CMS.debug("SignedAuditEventFactory: create() message=" + message + "\n"); + CMS.debug("SignedAuditEventFactory: create() message created for eventType=" + eventType + "\n"); } else { // no type specified @@ -98,31 +91,4 @@ public class SignedAuditEventFactory implements ILogEventFactory { return event; } - - /** - * Set the resource bundle of the log event. - * - * @param prop the properties - * @param event the log event - */ - protected void setProperties(Properties prop, IBundleLogEvent event) { - if (prop == null) { - event.setBundleName(null); - } else { - String bundleName = (String) prop.get(PROP_BUNDLE); - - if (bundleName != null) { - event.setBundleName(bundleName); - } - } - } - - /** - * Releases an log event. - * - * @param e the log event - */ - public void release(ILogEvent e) { - // do nothing - } } diff --git a/base/server/cmscore/src/com/netscape/cmscore/logging/SystemEventFactory.java b/base/server/cmscore/src/com/netscape/cmscore/logging/SystemEventFactory.java index f76c49d81..3a8cd8d5c 100644 --- a/base/server/cmscore/src/com/netscape/cmscore/logging/SystemEventFactory.java +++ b/base/server/cmscore/src/com/netscape/cmscore/logging/SystemEventFactory.java @@ -19,9 +19,7 @@ package com.netscape.cmscore.logging; import java.util.Properties; -import com.netscape.certsrv.logging.IBundleLogEvent; import com.netscape.certsrv.logging.ILogEvent; -import com.netscape.certsrv.logging.ILogEventFactory; import com.netscape.certsrv.logging.ILogger; import com.netscape.certsrv.logging.LogCategory; import com.netscape.certsrv.logging.LogSource; @@ -35,12 +33,7 @@ import com.netscape.certsrv.logging.SystemEvent; * @author mzhao * @version $Revision$, $Date$ */ -public class SystemEventFactory implements ILogEventFactory { - - /** - * List of supported properties. - */ - public static final String PROP_BUNDLE = "bundleName"; +public class SystemEventFactory extends LogFactory { /** * Constructs a system event factory. @@ -71,31 +64,4 @@ public class SystemEventFactory implements ILogEventFactory { setProperties(prop, event); return event; } - - /** - * Set the resource bundle of the log event. - * - * @param prop the properties - * @param event the log event - */ - protected void setProperties(Properties prop, IBundleLogEvent event) { - if (prop == null) { - event.setBundleName(null); - } else { - String bundleName = (String) prop.get(PROP_BUNDLE); - - if (bundleName != null) { - event.setBundleName(bundleName); - } - } - } - - /** - * Releases an log event. - * - * @param e the log event - */ - public void release(ILogEvent e) { - // do nothing - } } |