diff options
author | Brinda Santh <bs2796@att.com> | 2019-12-02 19:04:13 -0500 |
---|---|---|
committer | Brinda Santh Muthuramalingam <bs2796@att.com> | 2019-12-06 17:46:13 +0000 |
commit | 7466e4277c9fe098a61ae126d1892b3cd30d6f89 (patch) | |
tree | aee929bbb64db1d1b831cbe17551957c8916c3c2 /ms/controllerblueprints | |
parent | aa75fbae60835585b72195c581b88cacca511a5d (diff) |
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 <bs2796@att.com>
Change-Id: I41a429eb21a050e5ab512a7a73a394b975543f31
Diffstat (limited to 'ms/controllerblueprints')
2 files changed, 30 insertions, 3 deletions
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) } |