>From ed68e77505b58a72c98de3ada7ea69aa003c877a Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Tue, 10 May 2016 05:30:34 +0200
Subject: [PATCH] Renamed token status READY to FORMATTED.

The token status READY has been renamed to FORMATTED for clarity.

https://fedorahosted.org/pki/ticket/2288
---
 .../netscape/certsrv/tps/token/TokenStatus.java    | 10 +++++-----
 base/tps-client/doc/CS.cfg                         |  4 ++--
 base/tps/shared/conf/CS.cfg                        |  4 ++--
 base/tps/shared/conf/token-states.properties       | 22 +++++++++++-----------
 base/tps/shared/webapps/tps/js/token.js            |  4 ++--
 .../src/org/dogtagpki/server/tps/TPSSubsystem.java |  8 ++++----
 .../src/org/dogtagpki/server/tps/TPSTokendb.java   |  2 +-
 .../server/tps/processor/TPSEnrollProcessor.java   |  6 +++---
 .../server/tps/processor/TPSProcessor.java         |  6 +++---
 .../dogtagpki/server/tps/rest/TokenService.java    |  8 ++++----
 10 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/base/common/src/com/netscape/certsrv/tps/token/TokenStatus.java b/base/common/src/com/netscape/certsrv/tps/token/TokenStatus.java
index f570c125d81b0729f17287f3635b8976d4f34436..ada2729b735fc03b1039da59f6e96c0983290bf5 100644
--- a/base/common/src/com/netscape/certsrv/tps/token/TokenStatus.java
+++ b/base/common/src/com/netscape/certsrv/tps/token/TokenStatus.java
@@ -48,7 +48,7 @@ public class TokenStatus {
     static Map<String, TokenStatus> instancesByName = new HashMap<String, TokenStatus>();
     static Map<Integer, TokenStatus> instancesByValue = new HashMap<Integer, TokenStatus>();
 
-    public final static int TOKEN_READY               = 0;
+    public final static int TOKEN_FORMATTED           = 0;
     public final static int TOKEN_DAMAGED             = 1;
     public final static int TOKEN_PERM_LOST           = 2;
     public final static int TOKEN_SUSPENDED           = 3;
@@ -56,7 +56,7 @@ public class TokenStatus {
     public final static int TOKEN_TEMP_LOST_PERM_LOST = 5;
     public final static int TOKEN_TERMINATED          = 6;
 
-    public final static TokenStatus READY               = new TokenStatus("READY", TOKEN_READY);
+    public final static TokenStatus FORMATTED           = new TokenStatus("FORMATTED", TOKEN_FORMATTED);
     public final static TokenStatus DAMAGED             = new TokenStatus("DAMAGED", TOKEN_DAMAGED);
     public final static TokenStatus PERM_LOST           = new TokenStatus("PERM_LOST", TOKEN_PERM_LOST);
     public final static TokenStatus SUSPENDED           = new TokenStatus("SUSPENDED", TOKEN_SUSPENDED);
@@ -137,12 +137,12 @@ public class TokenStatus {
     public static TokenStatus valueOf(String name) {
 
         if ("UNINITIALIZED".equals(name)) {
-            System.err.println("WARNING: The token status " + name + " has been deprecated. Please use READY instead.");
-            return READY;
+            System.err.println("WARNING: The token status " + name + " has been deprecated. Please use " + FORMATTED + " instead.");
+            return FORMATTED;
         }
 
         if ("TEMP_LOST".equals(name)) {
-            System.err.println("WARNING: The token status " + name + " has been deprecated. Please use SUSPENDED instead.");
+            System.err.println("WARNING: The token status " + name + " has been deprecated. Please use " + SUSPENDED + " instead.");
             return SUSPENDED;
         }
 
diff --git a/base/tps-client/doc/CS.cfg b/base/tps-client/doc/CS.cfg
index f4bed51cb548f4d2db980c1325160a8ffaca7ede..c3f44e35014b5570a58ceddb3861dea3010824a7 100644
--- a/base/tps-client/doc/CS.cfg
+++ b/base/tps-client/doc/CS.cfg
@@ -1482,7 +1482,7 @@ tokendb._064=#     is set to YES. Otherwise, re-enrollment is not
 tokendb._065=#     allowed.
 tokendb._066=# tokendb.allowedTransitions:
 tokendb._067=#   - has transitions between the following states
-tokendb._068=#     READY = 0,
+tokendb._068=#     FORMATTED = 0,
 tokendb._069=#     DAMAGED = 1,
 tokendb._070=#     PERM_LOST = 2,
 tokendb._071=#     SUSPENDED = 3,
@@ -1593,7 +1593,7 @@ tps._005=# tps.cert.subsystem.nickname=xxx
 tps._007=# tps.cert.audit_signing.nickname=xxx
 tps._008=# tps.operations.allowedTransitions:
 tps._009=#   - token operations, like formatting and enrollment have transitions between the following states
-tps._010=#     READY = 0,
+tps._010=#     FORMATTED = 0,
 tps._011=#     ACTIVE = 4
 tps._012=# Note: Default transitions can be removed from the list if necessary.
 tps._013=# Do not add other transitions since they may not be supported.
diff --git a/base/tps/shared/conf/CS.cfg b/base/tps/shared/conf/CS.cfg
index c2b5265047ce225e23f9090706b1725dd2902f2b..fef2e55f444a6d3f9c076977ae82cb43197150cb 100644
--- a/base/tps/shared/conf/CS.cfg
+++ b/base/tps/shared/conf/CS.cfg
@@ -1954,7 +1954,7 @@ tokendb._064=#     is set to YES. Otherwise, re-enrollment is not
 tokendb._065=#     allowed.
 tokendb._066=# tokendb.allowedTransitions:
 tokendb._067=#   - has transitions between the following states
-tokendb._068=#     READY = 0,
+tokendb._068=#     FORMATTED = 0,
 tokendb._069=#     DAMAGED = 1,
 tokendb._070=#     PERM_LOST = 2,
 tokendb._071=#     SUSPENDED = 3,
@@ -2024,7 +2024,7 @@ tps._005=# tps.cert.subsystem.nickname=xxx
 tps._007=# tps.cert.audit_signing.nickname=xxx
 tps._008=# tps.operations.allowedTransitions:
 tps._009=#   - token operations, like formatting and enrollment have transitions between the following states
-tps._010=#     READY = 0,
+tps._010=#     FORMATTED = 0,
 tps._011=#     ACTIVE = 4
 tps._012=# Note: Default transitions can be removed from the list if necessary.
 tps._013=# Do not add other transitions since they may not be supported.
diff --git a/base/tps/shared/conf/token-states.properties b/base/tps/shared/conf/token-states.properties
index e6366286ff551425d91a49c4221284dfb303dc06..c4bdb56e70abc7cde410a9688d7bc9a03367414c 100644
--- a/base/tps/shared/conf/token-states.properties
+++ b/base/tps/shared/conf/token-states.properties
@@ -1,22 +1,22 @@
 # Token states
-READY               = Uninitialized/ready
+FORMATTED           = Formatted (uninitialized)
 ACTIVE              = Active
-SUSPENDED           = Temporarily lost/suspended
+SUSPENDED           = Suspended (temporarily lost)
 PERM_LOST           = Permanently lost
 DAMAGED             = Physically damaged
 TEMP_LOST_PERM_LOST = Temporarily lost then permanently lost
 TERMINATED          = Terminated
 
 # Token state transitions
-READY.DAMAGED            = This token has been physically damaged.
-READY.PERM_LOST          = This token has been permanently lost.
-READY.SUSPENDED          = This token has been temporarily lost/suspended.
-READY.TERMINATED         = This token has been terminated.
-SUSPENDED.ACTIVE         = This temporarily lost/suspended token has been found.
-SUSPENDED.PERM_LOST      = This temporarily lost/suspended token has become permanently lost.
-SUSPENDED.TERMINATED     = This temporarily lost/suspended token has been terminated.
-SUSPENDED.READY          = This temporarily lost/suspended token has been found.
+FORMATTED.DAMAGED        = This token has been physically damaged.
+FORMATTED.PERM_LOST      = This token has been permanently lost.
+FORMATTED.SUSPENDED      = This token has been suspended (temporarily lost).
+FORMATTED.TERMINATED     = This token has been terminated.
+SUSPENDED.ACTIVE         = This suspended (temporarily lost) token has been found.
+SUSPENDED.PERM_LOST      = This suspended (temporarily lost) token has become permanently lost.
+SUSPENDED.TERMINATED     = This suspended (temporarily lost) token has been terminated.
+SUSPENDED.FORMATTED      = This suspended (temporarily lost) token has been found.
 ACTIVE.DAMAGED           = This token has been physically damaged.
 ACTIVE.PERM_LOST         = This token has been permanently lost.
-ACTIVE.SUSPENDED         = This token has been temporarily lost/suspended.
+ACTIVE.SUSPENDED         = This token has been suspended (temporarily lost).
 ACTIVE.TERMINATED        = This token has been terminated.
diff --git a/base/tps/shared/webapps/tps/js/token.js b/base/tps/shared/webapps/tps/js/token.js
index 2bcf9e11ef0f533347768feba55a310cc844af85..be5ef7bdfdcf2e4e046fbbc7f84e989ab50df1b3 100644
--- a/base/tps/shared/webapps/tps/js/token.js
+++ b/base/tps/shared/webapps/tps/js/token.js
@@ -21,9 +21,9 @@
 
 // TODO: load labels from server
 var TokenStatus = {
-    READY               : "Uninitialized/ready",
+    FORMATTED           : "Formatted (uninitialized)",
     ACTIVE              : "Active",
-    SUSPENDED           : "Temporarily lost/suspended",
+    SUSPENDED           : "Suspended (temporarily lost)",
     PERM_LOST           : "Permanently lost",
     DAMAGED             : "Physically damaged",
     TEMP_LOST_PERM_LOST : "Temporarily lost then permanently lost",
diff --git a/base/tps/src/org/dogtagpki/server/tps/TPSSubsystem.java b/base/tps/src/org/dogtagpki/server/tps/TPSSubsystem.java
index 7e4a92be005c2f22d425bd761ea616248dbf1902..2d415c16c7da0b4ad19ecc7d4b2ac3e2d329aa70 100644
--- a/base/tps/src/org/dogtagpki/server/tps/TPSSubsystem.java
+++ b/base/tps/src/org/dogtagpki/server/tps/TPSSubsystem.java
@@ -146,7 +146,7 @@ public class TPSSubsystem implements IAuthority, ISubsystem {
      * Return the allowed next states for a given token based on TPS configuration.
      *
      * If the current state is SUSPENDED, token will be allowed transition to either
-     * READY or ACTIVE depending on whether the token has certificates.
+     * FORMATTED or ACTIVE depending on whether the token has certificates.
      *
      * @param tokenRecord
      * @return A non-null collection of allowed next token states.
@@ -163,11 +163,11 @@ public class TPSSubsystem implements IAuthority, ISubsystem {
             // check token certificates
             Collection<TPSCertRecord> certRecords = tdb.tdbGetCertRecordsByCUID(tokenRecord.getId());
 
-            // if token has no certificates, allow token to become ready again
+            // if token has no certificates, allow token to become FORMATTED again
             if (certRecords.isEmpty()) {
-                ns.add(TokenStatus.READY);
+                ns.add(TokenStatus.FORMATTED);
 
-            } else { // otherwise, allow token to become active again
+            } else { // otherwise, allow token to become ACTIVE again
                 ns.add(TokenStatus.ACTIVE);
             }
 
diff --git a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
index 523ac2f56888402511e7893dd5cf3c788bc300ee..52eadd35f4fb4829c9c3e1889516e813647d38e7 100644
--- a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
+++ b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
@@ -186,7 +186,7 @@ public class TPSTokendb {
         } catch (Exception e) {
             CMS.debug("TPSTokendb.tdbUpdateTokenEntry: token entry not found; Adding");
             // add and exit
-            tdbAddTokenEntry(tokenRecord, TokenStatus.READY);
+            tdbAddTokenEntry(tokenRecord, TokenStatus.FORMATTED);
             return;
         }
         // token found; modify
diff --git a/base/tps/src/org/dogtagpki/server/tps/processor/TPSEnrollProcessor.java b/base/tps/src/org/dogtagpki/server/tps/processor/TPSEnrollProcessor.java
index 25e016b6400f3667cfc6eb22b04666a4f5af05c6..bbdc15b86456077a5ff7c64c0b8d79b281fa098c 100644
--- a/base/tps/src/org/dogtagpki/server/tps/processor/TPSEnrollProcessor.java
+++ b/base/tps/src/org/dogtagpki/server/tps/processor/TPSEnrollProcessor.java
@@ -319,7 +319,7 @@ public class TPSEnrollProcessor extends TPSProcessor {
             }
         } else {
             CMS.debug(method + " token does not exist");
-            tokenRecord.setTokenStatus(TokenStatus.READY);
+            tokenRecord.setTokenStatus(TokenStatus.FORMATTED);
 
             checkAllowUnknownToken(TPSEngine.OP_FORMAT_PREFIX);
         }
@@ -368,7 +368,7 @@ public class TPSEnrollProcessor extends TPSProcessor {
 
         if (!isTokenPresent) {
             try {
-                tps.tdb.tdbAddTokenEntry(tokenRecord, TokenStatus.READY);
+                tps.tdb.tdbAddTokenEntry(tokenRecord, TokenStatus.FORMATTED);
             } catch (Exception e) {
                 String failMsg = "add token failure";
                 logMsg = failMsg + ":" + e.toString();
@@ -1032,7 +1032,7 @@ public class TPSEnrollProcessor extends TPSProcessor {
                 logMsg = "found current token entry";
                 CMS.debug(method + ":" + logMsg);
 
-                if (tokenRecord.getTokenStatus() == TokenStatus.READY) {
+                if (tokenRecord.getTokenStatus() == TokenStatus.FORMATTED) {
                     // this is the current token
                     if (tokenRecords.size() == 1) {
                         // the current token is the only token owned by the user
diff --git a/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java b/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java
index 023f75479b3a36b1e30fff2d04613384a40fb901..334a31bde68d2d3f14498580864f89c1e7c9b4c8 100644
--- a/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java
+++ b/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java
@@ -2055,8 +2055,8 @@ public class TPSProcessor {
 
         if (isTokenPresent) {
             CMS.debug("TPSProcessor.format: token exists");
-            TokenStatus newState = TokenStatus.READY;
-            // Check for transition to 0/READY status.
+            TokenStatus newState = TokenStatus.FORMATTED;
+            // Check for transition to FORMATTED status.
 
             if (!tps.engine.isOperationTransitionAllowed(tokenRecord.getTokenStatus(), newState)) {
                 String info = " illegal transition attempted: " + tokenRecord.getTokenStatus() +
@@ -2151,7 +2151,7 @@ public class TPSProcessor {
         }
 
         // Update Token DB
-        tokenRecord.setTokenStatus(TokenStatus.READY);
+        tokenRecord.setTokenStatus(TokenStatus.FORMATTED);
         try {
             tps.tdb.tdbUpdateTokenEntry(tokenRecord);
         } catch (Exception e) {
diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
index fd897ccfbd437dc2221961fdce62cde045cfefc9..7d78b7166af53592756c190877bcaf8db22f283a 100644
--- a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
+++ b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
@@ -91,7 +91,7 @@ public class TokenService extends PKIService implements TokenResource {
         auditModParams.put("UserID", tokenRecord.getUserID());
 
         switch (tokenState.getValue()) {
-        case TokenStatus.TOKEN_READY:
+        case TokenStatus.TOKEN_FORMATTED:
             tokenRecord.setTokenStatus(tokenState);
             tokenRecord.setReason(null);
             break;
@@ -368,9 +368,9 @@ public class TokenService extends PKIService implements TokenResource {
                 auditModParams.put("Policy", policy);
             }
 
-            // new tokens are ready when created
-            tokenRecord.setTokenStatus(TokenStatus.READY);
-            auditModParams.put("Status", TokenStatus.READY.toString());
+            // new tokens are FORMATTED when added via UI/CLI
+            tokenRecord.setTokenStatus(TokenStatus.FORMATTED);
+            auditModParams.put("Status", TokenStatus.FORMATTED.toString());
 
             database.addRecord(tokenID, tokenRecord);
             subsystem.tdb.tdbActivity(ActivityDatabase.OP_ADD, tokenRecord,
-- 
2.4.11

