From 43a2c0b834b711a7cec2c43121c441e162919804 Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edewata@redhat.com>
Date: Thu, 5 Jul 2012 14:32:27 -0500
Subject: [PATCH] Refactored RequestStatus.

The RequestStatus has been modified to use a map to convert string
into RequestStatus instance. The string constants in RequestStatus
are no longer needed because instances can be compared using
equal sign directly or equals().

Ticket #161
---
 base/common/src/CMakeLists.txt                     |    1 +
 .../netscape/certsrv/request/RequestStatus.java    |  115 +++++++++-----------
 .../certsrv/request/RequestStatusAdapter.java      |   38 +++++++
 .../cms/servlet/cert/CMCRevReqServlet.java         |   44 ++++----
 .../com/netscape/cms/servlet/cert/DoRevoke.java    |   56 ++++------
 .../com/netscape/cms/servlet/cert/DoRevokeTPS.java |   45 +++-----
 .../com/netscape/cms/servlet/cert/DoUnrevoke.java  |   23 ++---
 .../netscape/cms/servlet/cert/DoUnrevokeTPS.java   |   23 ++---
 .../cms/servlet/cert/scep/CRSEnrollment.java       |    4 +-
 .../cms/servlet/request/CertReqParser.java         |    4 +-
 10 files changed, 179 insertions(+), 174 deletions(-)
 create mode 100644 base/common/src/com/netscape/certsrv/request/RequestStatusAdapter.java

diff --git a/base/common/src/CMakeLists.txt b/base/common/src/CMakeLists.txt
index 6d8386faf2f1aedd0bb4fecead3a4aa124be8307..55720ab143102f4dbed3f5290f2d5b4d6e9ad886 100644
--- a/base/common/src/CMakeLists.txt
+++ b/base/common/src/CMakeLists.txt
@@ -366,6 +366,7 @@ set(pki-certsrv_java_SRCS
     com/netscape/certsrv/request/IRequestListener.java
     com/netscape/certsrv/request/AgentApproval.java
     com/netscape/certsrv/request/RequestStatus.java
+    com/netscape/certsrv/request/RequestStatusAdapter.java
     com/netscape/certsrv/request/IRequestScheduler.java
     com/netscape/certsrv/request/IRequest.java
     com/netscape/certsrv/request/IRequestQueue.java
diff --git a/base/common/src/com/netscape/certsrv/request/RequestStatus.java b/base/common/src/com/netscape/certsrv/request/RequestStatus.java
index fd501ef0f5a4a241db9a3347339d49cef043b8e1..22878e867522e9daf68137b23f24b38627f33a53 100644
--- a/base/common/src/com/netscape/certsrv/request/RequestStatus.java
+++ b/base/common/src/com/netscape/certsrv/request/RequestStatus.java
@@ -17,6 +17,11 @@
 // --- END COPYRIGHT BLOCK ---
 package com.netscape.certsrv.request;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
 /**
  * The RequestStatus class represents the current state of a request
  * in a request queue. The state of the request changes as actions
@@ -34,13 +39,9 @@ package com.netscape.certsrv.request;
  * @version $Revision$ $Date$
  */
 public final class RequestStatus {
-    public static String BEGIN_STRING = "begin";
-    public static String PENDING_STRING = "pending";
-    public static String APPROVED_STRING = "approved";
-    public static String SVC_PENDING_STRING = "svc_pending";
-    public static String CANCELED_STRING = "canceled";
-    public static String REJECTED_STRING = "rejected";
-    public static String COMPLETE_STRING = "complete";
+
+    public static final Collection<RequestStatus> INSTANCES = new ArrayList<RequestStatus>();
+    public static final Map<String, RequestStatus> LABELS = new LinkedHashMap<String, RequestStatus>();
 
     /**
      * The initial state of a request. Requests in this state have not
@@ -50,7 +51,7 @@ public final class RequestStatus {
      * but it could be some other protocol module, such as email)
      * should populate the request with data need to service it.
      */
-    public static RequestStatus BEGIN = new RequestStatus(BEGIN_STRING);
+    public static RequestStatus BEGIN = new RequestStatus("begin");
 
     /**
      * The state of a request that is waiting for action by an agent.
@@ -60,7 +61,7 @@ public final class RequestStatus {
      * In this state there may be PolicyMessages present that indicate
      * the reason for the pending status.
      */
-    public static RequestStatus PENDING = new RequestStatus(PENDING_STRING);
+    public static RequestStatus PENDING = new RequestStatus("pending");
 
     /**
      * The state of a request that has been approved by an agent, or
@@ -70,22 +71,21 @@ public final class RequestStatus {
      * These requests are resent to the service during the recovery
      * process that runs at server startup.
      */
-    public static RequestStatus APPROVED = new RequestStatus(APPROVED_STRING);
+    public static RequestStatus APPROVED = new RequestStatus("approved");
 
     /**
      * The state of a request that has been sent to the service, but
      * has not been fully processed. The service will invoke the
      * serviceComplete() method to cause processing to continue.
      */
-    public static RequestStatus SVC_PENDING =
-            new RequestStatus(SVC_PENDING_STRING);
+    public static RequestStatus SVC_PENDING = new RequestStatus("svc_pending");
 
     /**
      * Not implemented. This is intended to be a final state that is
      * reached when a request is removed from the processing queue without
      * normal notification occurring. (see REJECTED)
      */
-    public static RequestStatus CANCELED = new RequestStatus(CANCELED_STRING);
+    public static RequestStatus CANCELED = new RequestStatus("canceled");
 
     /**
      * The state of a request after it is rejected. When a request is
@@ -96,7 +96,7 @@ public final class RequestStatus {
      * the rejection, or AgentMessages, which allow the agent to give
      * reasons for the action.
      */
-    public static RequestStatus REJECTED = new RequestStatus(REJECTED_STRING);
+    public static RequestStatus REJECTED = new RequestStatus("rejected");
 
     /**
      * The normal final state of a request. The completion status attribute
@@ -104,35 +104,38 @@ public final class RequestStatus {
      * necessarily successful, but may indicated that service processing
      * did not succeed.
      */
-    public static RequestStatus COMPLETE = new RequestStatus(COMPLETE_STRING);
+    public static RequestStatus COMPLETE = new RequestStatus("complete");
+
+    private String label;
+
+    /**
+     * Class constructor. Creates request status from the string.
+     *
+     * @param label string describing request status
+     */
+    private RequestStatus(String label) {
+        this.label = label;
+
+        INSTANCES.add(this);
+        LABELS.put(label.toLowerCase(), this);
+    }
 
     /**
      * Converts a string name for a request status into the
      * request status enum object.
      * <p>
      *
-     * @param s
+     * @param label
      *            The string representation of the state.
      * @return
      *         request status
      */
-    public static RequestStatus fromString(String s) {
-        if (s.equals(BEGIN_STRING))
-            return BEGIN;
-        if (s.equals(PENDING_STRING))
-            return PENDING;
-        if (s.equals(APPROVED_STRING))
-            return APPROVED;
-        if (s.equals(SVC_PENDING_STRING))
-            return SVC_PENDING;
-        if (s.equals(CANCELED_STRING))
-            return CANCELED;
-        if (s.equals(REJECTED_STRING))
-            return REJECTED;
-        if (s.equals(COMPLETE_STRING))
-            return COMPLETE;
+    public static RequestStatus fromString(String label) {
+        return valueOf(label);
+    }
 
-        return null;
+    public static RequestStatus valueOf(String label) {
+        return LABELS.get(label.toLowerCase());
     }
 
     /**
@@ -142,41 +145,31 @@ public final class RequestStatus {
      * @return request status
      */
     public String toString() {
-        return mString;
+        return label;
     }
 
-    /**
-     * Class constructor. Creates request status from the string.
-     *
-     * @param string string describing request status
-     */
-    private RequestStatus(String string) {
-        mString = string;
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((label == null) ? 0 : label.hashCode());
+        return result;
     }
 
-    private String mString;
-
-    /**
-     * Compares request status with specified string.
-     *
-     * @param string string describing request status
-     */
-    public boolean equals(String string) {
-        if (string.equals(mString))
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
             return true;
-        else
+        if (obj == null)
             return false;
-    }
-
-    /**
-     * Compares current request status with request status.
-     *
-     * @param rs request status
-     */
-    public boolean equals(RequestStatus rs) {
-        if (mString.equals(rs.mString))
-            return true;
-        else
+        if (getClass() != obj.getClass())
+            return false;
+        RequestStatus other = (RequestStatus) obj;
+        if (label == null) {
+            if (other.label != null)
+                return false;
+        } else if (!label.equals(other.label))
             return false;
+        return true;
     }
 }
diff --git a/base/common/src/com/netscape/certsrv/request/RequestStatusAdapter.java b/base/common/src/com/netscape/certsrv/request/RequestStatusAdapter.java
new file mode 100644
index 0000000000000000000000000000000000000000..06b3605bbf5c630cd2d2c321543a0cd4aa6c2e80
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/request/RequestStatusAdapter.java
@@ -0,0 +1,38 @@
+// --- 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) 2012 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.request;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * The RevocationReasonAdapter class provides custom marshaling for RevocationReason.
+ *
+ * @author Endi S. Dewata
+ */
+public class RequestStatusAdapter extends XmlAdapter<String, RequestStatus> {
+
+    public RequestStatus unmarshal(String value) throws Exception {
+        return StringUtils.isEmpty(value) ? null : RequestStatus.valueOf(value);
+    }
+
+    public String marshal(RequestStatus value) throws Exception {
+        return value == null ? null : value.toString();
+    }
+}
\ No newline at end of file
diff --git a/base/common/src/com/netscape/cms/servlet/cert/CMCRevReqServlet.java b/base/common/src/com/netscape/cms/servlet/cert/CMCRevReqServlet.java
index ad818d89b7e90ff34ed25530cc72440dccd49321..48f04c8cdc041173b4534529a52b99a8c7450945 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/CMCRevReqServlet.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/CMCRevReqServlet.java
@@ -374,7 +374,7 @@ public class CMCRevReqServlet extends CMSServlet {
         String auditRequesterID = auditRequesterID(req);
         String auditSerialNumber = auditSerialNumber(eeSerialNumber);
         String auditRequestType = auditRequestType(reason);
-        String auditApprovalStatus = ILogger.SIGNED_AUDIT_EMPTY_VALUE;
+        RequestStatus auditApprovalStatus = null;
         String auditReasonNum = String.valueOf(reason);
 
         try {
@@ -558,7 +558,7 @@ public class CMCRevReqServlet extends CMSServlet {
             mQueue.processRequest(revReq);
 
             // retrieve the request status
-            auditApprovalStatus = revReq.getRequestStatus().toString();
+            auditApprovalStatus = revReq.getRequestStatus();
 
             RequestStatus stat = revReq.getRequestStatus();
 
@@ -792,9 +792,9 @@ public class CMCRevReqServlet extends CMSServlet {
             // store a message in the signed audit log file
             // if and only if "auditApprovalStatus" is
             // "complete", "revoked", or "canceled"
-            if ((auditApprovalStatus.equals(RequestStatus.COMPLETE_STRING))
-                    || (auditApprovalStatus.equals(RequestStatus.REJECTED_STRING))
-                    || (auditApprovalStatus.equals(RequestStatus.CANCELED_STRING))) {
+            if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                    auditApprovalStatus == RequestStatus.REJECTED ||
+                    auditApprovalStatus == RequestStatus.CANCELED) {
                 auditMessage = CMS.getLogMessage(
                         LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                         auditSubjectID,
@@ -803,7 +803,7 @@ public class CMCRevReqServlet extends CMSServlet {
                         auditSerialNumber,
                         auditRequestType,
                         auditReasonNum,
-                        auditApprovalStatus);
+                        auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                 audit(auditMessage);
             }
@@ -826,9 +826,9 @@ public class CMCRevReqServlet extends CMSServlet {
                 // message in the signed audit log file
                 // if and only if "auditApprovalStatus" is
                 // "complete", "revoked", or "canceled"
-                if ((auditApprovalStatus.equals(RequestStatus.COMPLETE_STRING))
-                        || (auditApprovalStatus.equals(RequestStatus.REJECTED_STRING))
-                        || (auditApprovalStatus.equals(RequestStatus.CANCELED_STRING))) {
+                if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                        auditApprovalStatus == RequestStatus.REJECTED ||
+                        auditApprovalStatus == RequestStatus.CANCELED) {
                     auditMessage = CMS.getLogMessage(
                             LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                             auditSubjectID,
@@ -837,7 +837,7 @@ public class CMCRevReqServlet extends CMSServlet {
                             auditSerialNumber,
                             auditRequestType,
                             auditReasonNum,
-                            auditApprovalStatus);
+                            auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                     audit(auditMessage);
                 }
@@ -864,9 +864,9 @@ public class CMCRevReqServlet extends CMSServlet {
                 // message in the signed audit log file
                 // if and only if "auditApprovalStatus" is
                 // "complete", "revoked", or "canceled"
-                if ((auditApprovalStatus.equals(RequestStatus.COMPLETE_STRING))
-                        || (auditApprovalStatus.equals(RequestStatus.REJECTED_STRING))
-                        || (auditApprovalStatus.equals(RequestStatus.CANCELED_STRING))) {
+                if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                        auditApprovalStatus == RequestStatus.REJECTED ||
+                        auditApprovalStatus == RequestStatus.CANCELED) {
                     auditMessage = CMS.getLogMessage(
                             LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                             auditSubjectID,
@@ -875,7 +875,7 @@ public class CMCRevReqServlet extends CMSServlet {
                             auditSerialNumber,
                             auditRequestType,
                             auditReasonNum,
-                            auditApprovalStatus);
+                            auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                     audit(auditMessage);
                 }
@@ -903,9 +903,9 @@ public class CMCRevReqServlet extends CMSServlet {
                 // message in the signed audit log file
                 // if and only if "auditApprovalStatus" is
                 // "complete", "revoked", or "canceled"
-                if ((auditApprovalStatus.equals(RequestStatus.COMPLETE_STRING))
-                        || (auditApprovalStatus.equals(RequestStatus.REJECTED_STRING))
-                        || (auditApprovalStatus.equals(RequestStatus.CANCELED_STRING))) {
+                if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                        auditApprovalStatus == RequestStatus.REJECTED ||
+                        auditApprovalStatus == RequestStatus.CANCELED) {
                     auditMessage = CMS.getLogMessage(
                             LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                             auditSubjectID,
@@ -914,7 +914,7 @@ public class CMCRevReqServlet extends CMSServlet {
                             auditSerialNumber,
                             auditRequestType,
                             auditReasonNum,
-                            auditApprovalStatus);
+                            auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                     audit(auditMessage);
                 }
@@ -939,9 +939,9 @@ public class CMCRevReqServlet extends CMSServlet {
                 // message in the signed audit log file
                 // if and only if "auditApprovalStatus" is
                 // "complete", "revoked", or "canceled"
-                if ((auditApprovalStatus.equals(RequestStatus.COMPLETE_STRING))
-                        || (auditApprovalStatus.equals(RequestStatus.REJECTED_STRING))
-                        || (auditApprovalStatus.equals(RequestStatus.CANCELED_STRING))) {
+                if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                        auditApprovalStatus == RequestStatus.REJECTED ||
+                        auditApprovalStatus == RequestStatus.CANCELED) {
                     auditMessage = CMS.getLogMessage(
                             LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                             auditSubjectID,
@@ -950,7 +950,7 @@ public class CMCRevReqServlet extends CMSServlet {
                             auditSerialNumber,
                             auditRequestType,
                             auditReasonNum,
-                            auditApprovalStatus);
+                            auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                     audit(auditMessage);
                 }
diff --git a/base/common/src/com/netscape/cms/servlet/cert/DoRevoke.java b/base/common/src/com/netscape/cms/servlet/cert/DoRevoke.java
index aac4315e720696ebddc5c886f7e863eb663a927f..be17272ec183c210a4fe189e9fadebf6443fa3c3 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/DoRevoke.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/DoRevoke.java
@@ -430,7 +430,7 @@ public class DoRevoke extends CMSServlet {
         String auditRequesterID = auditRequesterID(req);
         String auditSerialNumber = auditSerialNumber(eeSerialNumber);
         String auditRequestType = auditRequestType(reason);
-        String auditApprovalStatus = ILogger.SIGNED_AUDIT_EMPTY_VALUE;
+        RequestStatus auditApprovalStatus = null;
         String auditReasonNum = String.valueOf(reason);
 
         CMS.debug("DoRevoke: eeSerialNumber: " + eeSerialNumber + " auditSerialNumber: " + auditSerialNumber);
@@ -696,7 +696,7 @@ public class DoRevoke extends CMSServlet {
             mQueue.processRequest(revReq);
 
             // retrieve the request status
-            auditApprovalStatus = revReq.getRequestStatus().toString();
+            auditApprovalStatus = revReq.getRequestStatus();
 
             RequestStatus stat = revReq.getRequestStatus();
             String type = revReq.getRequestType();
@@ -747,12 +747,9 @@ public class DoRevoke extends CMSServlet {
                     // store a message in the signed audit log file
                     // if and only if "auditApprovalStatus" is
                     // "complete", "revoked", or "canceled"
-                    if ((auditApprovalStatus.equals(
-                                RequestStatus.COMPLETE_STRING)) ||
-                            (auditApprovalStatus.equals(
-                                    RequestStatus.REJECTED_STRING)) ||
-                            (auditApprovalStatus.equals(
-                                    RequestStatus.CANCELED_STRING))) {
+                    if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                            auditApprovalStatus == RequestStatus.REJECTED ||
+                            auditApprovalStatus == RequestStatus.CANCELED) {
                         auditMessage = CMS.getLogMessage(
                                     LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                                     auditSubjectID,
@@ -761,7 +758,7 @@ public class DoRevoke extends CMSServlet {
                                     auditSerialNumber,
                                     auditRequestType,
                                     auditReasonNum,
-                                    auditApprovalStatus);
+                                    auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                         audit(auditMessage);
                     }
@@ -963,9 +960,9 @@ public class DoRevoke extends CMSServlet {
             // store a message in the signed audit log file
             // if and only if "auditApprovalStatus" is
             // "complete", "revoked", or "canceled"
-            if ((auditApprovalStatus.equals(RequestStatus.COMPLETE_STRING))
-                    || (auditApprovalStatus.equals(RequestStatus.REJECTED_STRING))
-                    || (auditApprovalStatus.equals(RequestStatus.CANCELED_STRING))) {
+            if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                    auditApprovalStatus == RequestStatus.REJECTED ||
+                    auditApprovalStatus == RequestStatus.CANCELED) {
                 auditMessage = CMS.getLogMessage(
                             LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                             auditSubjectID,
@@ -974,7 +971,7 @@ public class DoRevoke extends CMSServlet {
                             auditSerialNumber,
                             auditRequestType,
                             auditReasonNum,
-                            auditApprovalStatus);
+                            auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                 audit(auditMessage);
             }
@@ -997,12 +994,9 @@ public class DoRevoke extends CMSServlet {
                 // message in the signed audit log file
                 // if and only if "auditApprovalStatus" is
                 // "complete", "revoked", or "canceled"
-                if ((auditApprovalStatus.equals(
-                            RequestStatus.COMPLETE_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.REJECTED_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.CANCELED_STRING))) {
+                if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                        auditApprovalStatus == RequestStatus.REJECTED ||
+                        auditApprovalStatus == RequestStatus.CANCELED) {
                     auditMessage = CMS.getLogMessage(
                                 LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                                 auditSubjectID,
@@ -1011,7 +1005,7 @@ public class DoRevoke extends CMSServlet {
                                 auditSerialNumber,
                                 auditRequestType,
                                 auditReasonNum,
-                                auditApprovalStatus);
+                                auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                     audit(auditMessage);
                 }
@@ -1038,12 +1032,9 @@ public class DoRevoke extends CMSServlet {
                 // message in the signed audit log file
                 // if and only if "auditApprovalStatus" is
                 // "complete", "revoked", or "canceled"
-                if ((auditApprovalStatus.equals(
-                            RequestStatus.COMPLETE_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.REJECTED_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.CANCELED_STRING))) {
+                if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                        auditApprovalStatus == RequestStatus.REJECTED ||
+                        auditApprovalStatus == RequestStatus.CANCELED) {
                     auditMessage = CMS.getLogMessage(
                                 LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                                 auditSubjectID,
@@ -1052,7 +1043,7 @@ public class DoRevoke extends CMSServlet {
                                 auditSerialNumber,
                                 auditRequestType,
                                 auditReasonNum,
-                                auditApprovalStatus);
+                                auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                     audit(auditMessage);
                 }
@@ -1080,12 +1071,9 @@ public class DoRevoke extends CMSServlet {
                 // message in the signed audit log file
                 // if and only if "auditApprovalStatus" is
                 // "complete", "revoked", or "canceled"
-                if ((auditApprovalStatus.equals(
-                            RequestStatus.COMPLETE_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.REJECTED_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.CANCELED_STRING))) {
+                if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                        auditApprovalStatus == RequestStatus.REJECTED ||
+                        auditApprovalStatus == RequestStatus.CANCELED) {
                     auditMessage = CMS.getLogMessage(
                                 LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                                 auditSubjectID,
@@ -1094,7 +1082,7 @@ public class DoRevoke extends CMSServlet {
                                 auditSerialNumber,
                                 auditRequestType,
                                 auditReasonNum,
-                                auditApprovalStatus);
+                                auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                     audit(auditMessage);
                 }
diff --git a/base/common/src/com/netscape/cms/servlet/cert/DoRevokeTPS.java b/base/common/src/com/netscape/cms/servlet/cert/DoRevokeTPS.java
index 35bdd5c8cddba895c11ce2449dae05fefbe719d2..65abd8a2283215171484a39a3536f2070a620cd2 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/DoRevokeTPS.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/DoRevokeTPS.java
@@ -325,7 +325,7 @@ public class DoRevokeTPS extends CMSServlet {
         String auditRequesterID = auditRequesterID(req);
         String auditSerialNumber = auditSerialNumber(null);
         String auditRequestType = auditRequestType(reason);
-        String auditApprovalStatus = ILogger.SIGNED_AUDIT_EMPTY_VALUE;
+        RequestStatus auditApprovalStatus = null;
         String auditReasonNum = String.valueOf(reason);
 
         if (revokeAll != null) {
@@ -499,7 +499,7 @@ public class DoRevokeTPS extends CMSServlet {
             mQueue.processRequest(revReq);
 
             // retrieve the request status
-            auditApprovalStatus = revReq.getRequestStatus().toString();
+            auditApprovalStatus = revReq.getRequestStatus();
 
             RequestStatus stat = revReq.getRequestStatus();
             String type = revReq.getRequestType();
@@ -550,12 +550,9 @@ public class DoRevokeTPS extends CMSServlet {
                     // store a message in the signed audit log file
                     // if and only if "auditApprovalStatus" is
                     // "complete", "revoked", or "canceled"
-                    if ((auditApprovalStatus.equals(
-                                RequestStatus.COMPLETE_STRING)) ||
-                            (auditApprovalStatus.equals(
-                                    RequestStatus.REJECTED_STRING)) ||
-                            (auditApprovalStatus.equals(
-                                    RequestStatus.CANCELED_STRING))) {
+                    if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                            auditApprovalStatus == RequestStatus.REJECTED ||
+                            auditApprovalStatus == RequestStatus.CANCELED) {
                         auditMessage = CMS.getLogMessage(
                                     LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                                     auditSubjectID,
@@ -564,7 +561,7 @@ public class DoRevokeTPS extends CMSServlet {
                                     auditSerialNumber,
                                     auditRequestType,
                                     auditReasonNum,
-                                    auditApprovalStatus);
+                                    auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                         audit(auditMessage);
                     }
@@ -744,9 +741,9 @@ public class DoRevokeTPS extends CMSServlet {
             // store a message in the signed audit log file
             // if and only if "auditApprovalStatus" is
             // "complete", "revoked", or "canceled"
-            if ((auditApprovalStatus.equals(RequestStatus.COMPLETE_STRING))
-                    || (auditApprovalStatus.equals(RequestStatus.REJECTED_STRING))
-                    || (auditApprovalStatus.equals(RequestStatus.CANCELED_STRING))) {
+            if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                    auditApprovalStatus == RequestStatus.REJECTED ||
+                    auditApprovalStatus == RequestStatus.CANCELED) {
                 auditMessage = CMS.getLogMessage(
                             LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                             auditSubjectID,
@@ -755,7 +752,7 @@ public class DoRevokeTPS extends CMSServlet {
                             auditSerialNumber,
                             auditRequestType,
                             auditReasonNum,
-                            auditApprovalStatus);
+                            auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                 audit(auditMessage);
             }
@@ -779,12 +776,9 @@ public class DoRevokeTPS extends CMSServlet {
                 // message in the signed audit log file
                 // if and only if "auditApprovalStatus" is
                 // "complete", "revoked", or "canceled"
-                if ((auditApprovalStatus.equals(
-                            RequestStatus.COMPLETE_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.REJECTED_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.CANCELED_STRING))) {
+                if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                        auditApprovalStatus == RequestStatus.REJECTED ||
+                        auditApprovalStatus == RequestStatus.CANCELED) {
                     auditMessage = CMS.getLogMessage(
                                 LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                                 auditSubjectID,
@@ -793,7 +787,7 @@ public class DoRevokeTPS extends CMSServlet {
                                 auditSerialNumber,
                                 auditRequestType,
                                 auditReasonNum,
-                                auditApprovalStatus);
+                                auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                     audit(auditMessage);
                 }
@@ -821,12 +815,9 @@ public class DoRevokeTPS extends CMSServlet {
                 // message in the signed audit log file
                 // if and only if "auditApprovalStatus" is
                 // "complete", "revoked", or "canceled"
-                if ((auditApprovalStatus.equals(
-                            RequestStatus.COMPLETE_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.REJECTED_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.CANCELED_STRING))) {
+                if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                        auditApprovalStatus == RequestStatus.REJECTED ||
+                        auditApprovalStatus == RequestStatus.CANCELED) {
                     auditMessage = CMS.getLogMessage(
                                 LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                                 auditSubjectID,
@@ -835,7 +826,7 @@ public class DoRevokeTPS extends CMSServlet {
                                 auditSerialNumber,
                                 auditRequestType,
                                 auditReasonNum,
-                                auditApprovalStatus);
+                                auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                     audit(auditMessage);
                 }
diff --git a/base/common/src/com/netscape/cms/servlet/cert/DoUnrevoke.java b/base/common/src/com/netscape/cms/servlet/cert/DoUnrevoke.java
index 5605acf6d7cdea26b7ea22fd7e9a8c94556f1129..1f018261bea1191ad4fc96720d6000ae5c35b019 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/DoUnrevoke.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/DoUnrevoke.java
@@ -249,7 +249,7 @@ public class DoUnrevoke extends CMSServlet {
         String auditRequesterID = auditRequesterID(req);
         String auditSerialNumber = auditSerialNumber(serialNumbers[0].toString());
         String auditRequestType = OFF_HOLD;
-        String auditApprovalStatus = ILogger.SIGNED_AUDIT_EMPTY_VALUE;
+        RequestStatus auditApprovalStatus = null;
         String auditReasonNum = String.valueOf(OFF_HOLD_REASON);
 
         try {
@@ -291,7 +291,7 @@ public class DoUnrevoke extends CMSServlet {
             mQueue.processRequest(unrevReq);
 
             // retrieve the request status
-            auditApprovalStatus = unrevReq.getRequestStatus().toString();
+            auditApprovalStatus = unrevReq.getRequestStatus();
 
             RequestStatus status = unrevReq.getRequestStatus();
             String type = unrevReq.getRequestType();
@@ -514,9 +514,9 @@ public class DoUnrevoke extends CMSServlet {
             // store a message in the signed audit log file
             // if and only if "auditApprovalStatus" is
             // "complete", "revoked", or "canceled"
-            if ((auditApprovalStatus.equals(RequestStatus.COMPLETE_STRING))
-                    || (auditApprovalStatus.equals(RequestStatus.REJECTED_STRING))
-                    || (auditApprovalStatus.equals(RequestStatus.CANCELED_STRING))) {
+            if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                    auditApprovalStatus == RequestStatus.REJECTED ||
+                    auditApprovalStatus == RequestStatus.CANCELED) {
                 auditMessage = CMS.getLogMessage(
                             LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                             auditSubjectID,
@@ -525,7 +525,7 @@ public class DoUnrevoke extends CMSServlet {
                             auditSerialNumber,
                             auditRequestType,
                             auditReasonNum,
-                            auditApprovalStatus);
+                            auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                 audit(auditMessage);
             }
@@ -548,12 +548,9 @@ public class DoUnrevoke extends CMSServlet {
                 // message in the signed audit log file
                 // if and only if "auditApprovalStatus" is
                 // "complete", "revoked", or "canceled"
-                if ((auditApprovalStatus.equals(
-                            RequestStatus.COMPLETE_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.REJECTED_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.CANCELED_STRING))) {
+                if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                        auditApprovalStatus == RequestStatus.REJECTED ||
+                        auditApprovalStatus == RequestStatus.CANCELED) {
                     auditMessage = CMS.getLogMessage(
                                 LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                                 auditSubjectID,
@@ -562,7 +559,7 @@ public class DoUnrevoke extends CMSServlet {
                                 auditSerialNumber,
                                 auditRequestType,
                                 auditReasonNum,
-                                auditApprovalStatus);
+                                auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                     audit(auditMessage);
                 }
diff --git a/base/common/src/com/netscape/cms/servlet/cert/DoUnrevokeTPS.java b/base/common/src/com/netscape/cms/servlet/cert/DoUnrevokeTPS.java
index 7916887f8ebbb8c49a90598c4581c60e77532451..ff383bbb4cd4ad396e01620479a786553171ce29 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/DoUnrevokeTPS.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/DoUnrevokeTPS.java
@@ -246,7 +246,7 @@ public class DoUnrevokeTPS extends CMSServlet {
         String auditRequesterID = auditRequesterID(req);
         String auditSerialNumber = auditSerialNumber(serialNumbers[0].toString());
         String auditRequestType = OFF_HOLD;
-        String auditApprovalStatus = ILogger.SIGNED_AUDIT_EMPTY_VALUE;
+        RequestStatus auditApprovalStatus = null;
         String auditReasonNum = String.valueOf(OFF_HOLD_REASON);
 
         try {
@@ -286,7 +286,7 @@ public class DoUnrevokeTPS extends CMSServlet {
             mQueue.processRequest(unrevReq);
 
             // retrieve the request status
-            auditApprovalStatus = unrevReq.getRequestStatus().toString();
+            auditApprovalStatus = unrevReq.getRequestStatus();
 
             RequestStatus status = unrevReq.getRequestStatus();
             String type = unrevReq.getRequestType();
@@ -458,9 +458,9 @@ public class DoUnrevokeTPS extends CMSServlet {
             // store a message in the signed audit log file
             // if and only if "auditApprovalStatus" is
             // "complete", "revoked", or "canceled"
-            if ((auditApprovalStatus.equals(RequestStatus.COMPLETE_STRING))
-                    || (auditApprovalStatus.equals(RequestStatus.REJECTED_STRING))
-                    || (auditApprovalStatus.equals(RequestStatus.CANCELED_STRING))) {
+            if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                    auditApprovalStatus == RequestStatus.REJECTED ||
+                    auditApprovalStatus == RequestStatus.CANCELED) {
                 auditMessage = CMS.getLogMessage(
                             LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                             auditSubjectID,
@@ -469,7 +469,7 @@ public class DoUnrevokeTPS extends CMSServlet {
                             auditSerialNumber,
                             auditRequestType,
                             auditReasonNum,
-                            auditApprovalStatus);
+                            auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                 audit(auditMessage);
             }
@@ -492,12 +492,9 @@ public class DoUnrevokeTPS extends CMSServlet {
                 // message in the signed audit log file
                 // if and only if "auditApprovalStatus" is
                 // "complete", "revoked", or "canceled"
-                if ((auditApprovalStatus.equals(
-                            RequestStatus.COMPLETE_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.REJECTED_STRING)) ||
-                        (auditApprovalStatus.equals(
-                                RequestStatus.CANCELED_STRING))) {
+                if (auditApprovalStatus == RequestStatus.COMPLETE ||
+                        auditApprovalStatus == RequestStatus.REJECTED ||
+                        auditApprovalStatus == RequestStatus.CANCELED) {
                     auditMessage = CMS.getLogMessage(
                                 LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
                                 auditSubjectID,
@@ -506,7 +503,7 @@ public class DoUnrevokeTPS extends CMSServlet {
                                 auditSerialNumber,
                                 auditRequestType,
                                 auditReasonNum,
-                                auditApprovalStatus);
+                                auditApprovalStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : auditApprovalStatus.toString());
 
                     audit(auditMessage);
                 }
diff --git a/base/common/src/com/netscape/cms/servlet/cert/scep/CRSEnrollment.java b/base/common/src/com/netscape/cms/servlet/cert/scep/CRSEnrollment.java
index dc0b0c4741254ecd1710b907eb49f46e63899471..c3d36561dc46cac062e0d79834fa4ee2ad635e50 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/scep/CRSEnrollment.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/scep/CRSEnrollment.java
@@ -1770,8 +1770,8 @@ public class CRSEnrollment extends HttpServlet {
                 crsResp.setPKIStatus(CRSPKIMessage.mStatus_FAILURE);
                 crsResp.setFailInfo(CRSPKIMessage.mFailInfo_badAlg);
             }
-        } else if (status.equals(RequestStatus.REJECTED_STRING) ||
-                 status.equals(RequestStatus.CANCELED_STRING)) {
+        } else if (status == RequestStatus.REJECTED ||
+                 status == RequestStatus.CANCELED) {
             crsResp.setPKIStatus(CRSPKIMessage.mStatus_FAILURE);
             crsResp.setFailInfo(CRSPKIMessage.mFailInfo_badRequest);
         } else { // not complete
diff --git a/base/common/src/com/netscape/cms/servlet/request/CertReqParser.java b/base/common/src/com/netscape/cms/servlet/request/CertReqParser.java
index 11716115f6e47eea5b82562ccc0f1bd072fa10ba..fd45894378f9ca61256ed2d05bd553c7fdd619fb 100644
--- a/base/common/src/com/netscape/cms/servlet/request/CertReqParser.java
+++ b/base/common/src/com/netscape/cms/servlet/request/CertReqParser.java
@@ -225,7 +225,7 @@ public class CertReqParser extends ReqParser {
                             IRequest.SERVER_ATTRS + LB + String.valueOf(saCounter++) + RB;
 
                     if (name.equalsIgnoreCase(IRequest.ISSUED_CERTS) && mDetails &&
-                            (req.getRequestStatus().toString().equals(RequestStatus.COMPLETE_STRING) ||
+                            (req.getRequestStatus() == RequestStatus.COMPLETE ||
                             req.getRequestType().equals(IRequest.GETREVOCATIONINFO_REQUEST))) {
                         X509CertImpl issuedCert[] =
                                 req.getExtDataInCertArray(IRequest.ISSUED_CERTS);
@@ -468,7 +468,7 @@ public class CertReqParser extends ReqParser {
             }
 
             if (name.equalsIgnoreCase(IRequest.ISSUED_CERTS) && mDetails &&
-                    (req.getRequestStatus().toString().equals(RequestStatus.COMPLETE_STRING) ||
+                    (req.getRequestStatus() == RequestStatus.COMPLETE ||
                     req.getRequestType().equals(IRequest.GETREVOCATIONINFO_REQUEST))) {
                 X509CertImpl issuedCert[] =
                         req.getExtDataInCertArray(IRequest.ISSUED_CERTS);
-- 
1.7.7.6

