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>
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 ;
return dbresposne;
}
+
+ private String getAppcTimestampResponse(String dbresposne) {
+ log.info("getAppcTimestampResponse:[" + dbresposne +"]" );
+ return dbresposne;
+ }
}
case DesignServiceConstants.GETDESIGNS:
response = getDesigns(payload, requestID);
break;
+ case DesignServiceConstants.GETAPPCTIMESTAMPUTC:
+ response = getAppcTimestampUTC( requestID );
+ break;
case DesignServiceConstants.ADDINCART:
response = setInCart(payload, requestID);
break;
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();
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;
}
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;
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";