APPC CDT Future timestamp issue fix -new HTTP req 95/55595/4
authorod7427 <od7427@att.com>
Fri, 29 Jun 2018 17:33:47 +0000 (13:33 -0400)
committerTakamune Cho <tc012c@att.com>
Fri, 6 Jul 2018 18:19:10 +0000 (18:19 +0000)
APPC CDT GUI generated timestamp in user browser in request data.
Sometimes the timestamp appeared in future compared to APPC server time.
To fix the APPC CDT Future timestamp issue adding a new HTTP request to
 DesignDBService to get UTC Timestamp from the APPC server.
Also adding this request to DbResponseProcessor, RequestValidator
 to avoid validation failures.
Modified DesignDBService.java to satisfy review comments.
Made additional corrections after failed build.

Change-Id: Ic9d3f1ebb42143e497e21520843a78ecb882d0fc
Issue-ID: APPC-1026
Signed-off-by: od7427 <od7427@att.com>
appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbResponseProcessor.java
appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java
appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/RequestValidator.java
appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java

index a2a9226..229e61c 100644 (file)
@@ -33,12 +33,15 @@ public class DbResponseProcessor {
     private static final EELFLogger log = EELFManager.getInstance().getLogger(DbResponseProcessor.class);
     public String parseResponse(String dbresposne, String action) throws Exception {
         
-        log.info("Starting Parsing the response for action : " + action +  "\n data "  + dbresposne );
+        log.info("Starting Parsing the response for action :[" + action +  "]\n data:[" + dbresposne +"]" );
         String response ;         
         switch (action) {
         case DesignServiceConstants.GETDESIGNS:
             response =  getDesignsResponse(dbresposne);
             break;
+        case DesignServiceConstants.GETAPPCTIMESTAMPUTC:
+            response = getAppcTimestampResponse(dbresposne);
+            break;
         case DesignServiceConstants.ADDINCART:
             response =  getAddInCartResponse(dbresposne);
             break ;
@@ -106,4 +109,9 @@ public class DbResponseProcessor {
         return dbresposne;
         
     }
+
+    private String getAppcTimestampResponse(String dbresposne) {
+        log.info("getAppcTimestampResponse:["  + dbresposne +"]" );
+        return dbresposne;
+    }
 }
index 83ef0f9..f897125 100644 (file)
@@ -79,6 +79,9 @@ public class DesignDBService {
             case DesignServiceConstants.GETDESIGNS:
                 response = getDesigns(payload, requestID);
                 break;
+            case DesignServiceConstants.GETAPPCTIMESTAMPUTC:
+                response =  getAppcTimestampUTC( requestID );
+                break;
             case DesignServiceConstants.ADDINCART:
                 response = setInCart(payload, requestID);
                 break;
@@ -110,6 +113,20 @@ public class DesignDBService {
         return response;
     }
 
+    private String getAppcTimestampUTC( String requestID) throws Exception
+    {
+      log.info("Starting getAppcTimestampUTC: requestID:"+ requestID );
+      java.util.TimeZone gmtTZ= java.util.TimeZone.getTimeZone("GMT");
+      java.text.SimpleDateFormat formatter =
+        new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );
+      formatter.setTimeZone( gmtTZ );
+      java.util.Date dateVal= new java.util.Date();
+      log.info("getAppcTimestampUTC: current local Date:["+ dateVal+"]");
+      String timeStr= formatter.format( dateVal );
+      log.info("getAppcTimestampUTC: returning:["+timeStr+"]");
+      return timeStr;
+    }
+
     private String setInCart(String payload, String requestID) throws Exception {
 
         ObjectMapper objectMapper = new ObjectMapper();
index 8bf063d..5278cc7 100644 (file)
@@ -30,6 +30,7 @@ import static org.onap.appc.design.services.util.DesignServiceConstants.ARTIFACT
 import static org.onap.appc.design.services.util.DesignServiceConstants.ARTIFACT_TYPE;
 import static org.onap.appc.design.services.util.DesignServiceConstants.ARTIFACT_VERSOIN;
 import static org.onap.appc.design.services.util.DesignServiceConstants.GETARTIFACT;
+import static org.onap.appc.design.services.util.DesignServiceConstants.GETAPPCTIMESTAMPUTC;
 import static org.onap.appc.design.services.util.DesignServiceConstants.GETDESIGNS;
 import static org.onap.appc.design.services.util.DesignServiceConstants.GETSTATUS;
 import static org.onap.appc.design.services.util.DesignServiceConstants.PROTOCOL;
@@ -55,16 +56,20 @@ public class RequestValidator {
     }
 
     public static void validate(String action, String payload) throws RequestValidationException, IOException {
-        log.info("payload" + payload);
+        log.info("validate: action:"  +  action );
+        log.info("validate: payload:" + payload);
         ObjectMapper objectMapper = new ObjectMapper();
         JsonNode payloadObject = objectMapper.readTree(payload);
-        log.info("payloadObject" + payloadObject.get(ARTIFACT_CONTENTS));
+        log.info("payloadObject:" + payloadObject.get(ARTIFACT_CONTENTS));
 
-        String errorString;
+        String errorString= null;
         switch (action) {
             case GETDESIGNS:
                 errorString = resolveGetDesignsErrorString(payloadObject);
                 break;
+            case GETAPPCTIMESTAMPUTC:
+                log.info("validate: No payload validation needed for Timestamp.");
+                break;
             case GETARTIFACT:
                 errorString = resolveGetArtifactErrorString(payloadObject);
                 break;
index 9f311d9..f7208bf 100644 (file)
@@ -36,6 +36,7 @@ public class DesignServiceConstants {
         public static final String DATA_TYPE_SQL = "SQL";
             
         public static final String GETDESIGNS = "getDesigns";
+        public static final String GETAPPCTIMESTAMPUTC = "getAppcTimestampUTC";
         public static final String UPLOADARTIFACTS =  "uploadArtifacts";
         public static final String  VALIDATETEMPLATE =  "validateTemplate";
         public static final String GETSTATUS =  "getStatus";