From 7466e4277c9fe098a61ae126d1892b3cd30d6f89 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Mon, 2 Dec 2019 19:04:13 -0500 Subject: Remote Script Executor Component Define and Implement component-remote-script-executor component and DSL. Get the timeout from model definitions fix the dat pattern issues Define API data extension functions. Issue-ID: CCSDK-1975 Signed-off-by: Brinda Santh Change-Id: I41a429eb21a050e5ab512a7a73a394b975543f31 --- .../core/BluePrintConstants.kt | 7 ++++++ .../controllerblueprints/core/utils/DateUtils.kt | 26 +++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'ms/controllerblueprints/modules') diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt index b97cb026a..669299534 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/BluePrintConstants.kt @@ -24,6 +24,13 @@ package org.onap.ccsdk.cds.controllerblueprints.core */ object BluePrintConstants { + var APP_NAME = System.getProperty("APPNAME") + ?: System.getProperty("APP_NAME") + ?: System.getProperty("APPLICATION_NAME") + ?: "cds-controller-default" + + const val DATE_TIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" + const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion" const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion" const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt index e01ba805d..4fd907a5a 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/DateUtils.kt @@ -16,12 +16,32 @@ package org.onap.ccsdk.cds.controllerblueprints.core.utils +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants +import java.text.SimpleDateFormat import java.time.LocalDateTime import java.time.ZoneId import java.time.format.DateTimeFormatter +import java.util.Date + +fun controllerDate(): Date { + val localDateTime = LocalDateTime.now(ZoneId.systemDefault()) + return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()) +} fun currentTimestamp(): String { - val now = LocalDateTime.now(ZoneId.systemDefault()) - val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - return formatter.format(now) + val localDateTime = LocalDateTime.now(ZoneId.systemDefault()) + val formatter = DateTimeFormatter.ofPattern(BluePrintConstants.DATE_TIME_PATTERN) + return formatter.format(localDateTime) +} + +/** Parse string date in CDS string format */ +fun String.toControllerDate(): Date { + val formatter = SimpleDateFormat(BluePrintConstants.DATE_TIME_PATTERN) + return formatter.parse(this) +} + +/** Return date to CDS string format */ +fun Date.currentTimestamp(): String { + val formatter = SimpleDateFormat(BluePrintConstants.DATE_TIME_PATTERN) + return formatter.format(this) } -- cgit 1.2.3-korg