summaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-design-services
diff options
context:
space:
mode:
authorod7427 <od7427@att.com>2018-06-29 13:33:47 -0400
committerTakamune Cho <tc012c@att.com>2018-07-06 18:19:10 +0000
commitf5d3fa206b636a7e235b57b43a7812c92258208a (patch)
tree5d04eef93283148e5ea61fd93d980d31c2ef613e /appc-inbound/appc-design-services
parent9fec029349301e7bc54033a08270ca8707f4b9bd (diff)
APPC CDT Future timestamp issue fix -new HTTP req
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>
Diffstat (limited to 'appc-inbound/appc-design-services')
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbResponseProcessor.java10
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java17
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/RequestValidator.java11
-rw-r--r--appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java1
4 files changed, 35 insertions, 4 deletions
diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbResponseProcessor.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbResponseProcessor.java
index a2a9226d1..229e61cb3 100644
--- a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbResponseProcessor.java
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DbResponseProcessor.java
@@ -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;
+ }
}
diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java
index 83ef0f914..f8971255e 100644
--- a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/DesignDBService.java
@@ -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();
diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/RequestValidator.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/RequestValidator.java
index 8bf063dd8..5278cc7b3 100644
--- a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/RequestValidator.java
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/dbervices/RequestValidator.java
@@ -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;
diff --git a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java
index 9f311d934..f7208bf03 100644
--- a/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java
+++ b/appc-inbound/appc-design-services/provider/src/main/java/org/onap/appc/design/services/util/DesignServiceConstants.java
@@ -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";