Thursday, October 17, 2024

OIC - Convert DateTime from one timezone to another with Daylight saving in OIC

Usecase: 

Here, we will demonstrate how to convert one timezone to another considering the daylight saving time.

Here, we will see UTC to Australia timezone change.

Implementation steps:

  1. Create 2 javascript functions
    1. 1st one will determine whether the datetime under DST or not. Response will be in True or False.
    2. 2nd one will add UTC +11.00  or UTC+10.00 depends on the daylight saving.
  2. Import it to OIC library
  3. Create an integration and feed a datetime
  4. Feed the input date time to javascript and get the the converted timezone from the integration.

Javascript code used: (save .js extension)

function isDaylightSavingsInEffect(dateTimeInput) {

    var dateTime = new Date(dateTimeInput);

    var month = dateTime.getMonth();

    month = month + 1;

    var year = dateTime.getFullYear();

    var day = dateTime.getDate();

    var hours = dateTime.getHours();

    var firstDateofSunday = 0;

    var flag = false;

   // get first Sunday of any Month

    var firstSunday = new Date(year, month - 1, 1);

    var dayOfWeek = firstSunday.getDay();

    if (dayOfWeek == 0) {

        firstDateofSunday = 1;

    } else {

        firstDateofSunday = 7 - (dayOfWeek - 1);

    }

    // return for DST Eligibility

    if (month < 4 || month > 10 || (month == 10 && day >= firstDateofSunday) || (month == 4 && day <= firstDateofSunday)) {

        flag = true;

    } else {

        flag = false;

    }

    return flag;

}

// returns date and time YYYY-MM-DD HH:MM:SS 
function sc_convertUTC2AEST (utcDate) {
var inDate = new Date(utcDate);
var offset = 0;
var response = '';
if (!isNaN(inDate)) {
offset = isDaylightSavingsInEffect(inDate) ? 11 : 10; // Using your function to decide offset
inDate.setHours(inDate.getHours() + offset);
string ='';
response= string.concat(inDate.getUTCFullYear(), '-', (('0' + (inDate.getUTCMonth() + 1)).slice(-2)),'-', ('0' + inDate.getUTCDate()).slice(-2),' ', ('0' +
inDate.getUTCHours()).slice(-2), ('0' + inDate.getUTCMinutes()).slice(-2), ('0' + inDate.getUTCSeconds()).slice(-2))
}
return response;
}

Detailed screenshots:

Js Codes:



Testing:



Import .js file to libraries and save.


Create a integration and take js action and choose the javascript 2nd function >> feed the input UTC date time.



Map the js action response.


Note: Instead of using Javascript action, we can also call the function from xslt mapper.


Monday, October 14, 2024

OIC - How to convert from one timezone to another timezone

Usecase: Here we will demonstrate how to convert from UTC to IST timezone. We can convert to any other timezones.

Currently my oic instance timezone is in UTC and I have one requitement to convert it to IST timezone.

We have to use below functions:

  • Adjust-dateTime-to-timeZone() 
  • dayTimeDurarion()

Solution code:

fn:string(fn:adjust-dateTime-to-timezone(fn:current-dateTime(), ns0:dayTimeDuration('PT5H30M')))

Screenshots:



Notes:

How to get the duration:

From https://www.worldtimebuddy.com >> add place or timezone and can see the time difference with the UTC. Like for IST, its showing +5.5 hrs difference.


Duration syntax:

Now question is how to get the PT5H30M value and what syntax it follows:

  • P is the duration designator (for period) placed at the start of the duration representation.
  • Y is the year designator that follows the value for the number of years.
  • M is the month designator that follows the value for the number of months.
  • W is the week designator that follows the value for the number of weeks.
  • D is the day designator that follows the value for the number of days.
  • T is the time designator that precedes the time components of the representation.

So P means 'Period' and because there are no date-components it only has a 'Time'. You could interpret this as 'Period of Time'

The details for the time component are:

  • H is the hour designator that follows the value for the number of hours.
  • M is the minute designator that follows the value for the number of minutes.
  • S is the second designator that follows the value for the number of seconds.

Example

durarion("P1Y2M3DT10H30M") : represents a duration of 1 year, 2 months, 3 days, 10 hours and 30 minutes.

Duration("PT2000H") : represents a duration of 2000 hours.

We not only convert from date time, we can also convert from date to timezone or time to timezone. To achieve this, OIC has OOTB below functions:

  • adjust-dateTime-to-timeZone()
  • adjust-date-to-timeZone()
  • adjust-time-to-timeZone()

Example of fomatting after the timezone change.
xp20:format-dateTime (fn:adjust-dateTime-to-timezone (fn:current-dateTime(), xsd:dayTimeDuration ("PT8H") ), "[D01][M01][Y0001][H01][m01][s01]" )

Thursday, October 10, 2024

OIC - How to rename a connection name in oracle Integration

Usecase: simply, we see how to rename an existing connection.

Steps:

Edit >> 3 dots action top right corner >> edit info >> update connection name and >> save.

Screenshots:






OIC - Comparison of OIC Stage Action and FTP Connection Capabilities referring digital signature.

Overview: This document outlines the key differences between the OIC Stage action and FTP connection functionalities, focusing on their support for cryptographic operations, including encryption, decryption, and signing keys.

OIC Stage Action:

  1. Does not support signing keys or digital signature.
  2. Limited to data processing without cryptographic signing capabilities.

FTP Connection:

  1. Supports both encryption and decryption.
  2. Capable of signing data, ensuring integrity and authenticity through the use of signing keys.

Conclusion: Understanding these differences is crucial for selecting the appropriate method for secure data transmission and processing in integration scenarios.



OIC - "Using local-name() in XPath to Retrieve XML Data Without Namespace Prefix"

Use case: 

In this scenario, we will demonstrate how to retrieve the value of the ErrMsg field in XML using the local-name() XPath function, bypassing the need for a namespace prefix.

The following response was received from an endpoint where the namespace prefix is missing. Our objective is to retrieve the value of the ErrMsg field for further post processing logic:

<enb:ImportDataResponse xmlns:enb="enablon">

    <Response>

        <RowCount>2</RowCount>

        <RowSuc>2</RowSuc>

        <ErrMsg />

    </Response>

</enb:ImportDataResponse>


Solution:

We need to use xslt xpath function: local-name() as below:

$Invoke_SkillsAssessment_ImportData_Enablon//*[local-name()='Response']/*[local-name()='ErrMsg']


Saturday, October 5, 2024

OIC - How to get the outbound ip address of your oracle integration 3 instance

In previous versions of Oracle Integration Cloud (OIC), obtaining the outbound IP address of your OIC instance required raising a service request with Oracle support. Once received, this IP address could be shared with third-party applications or service providers to whitelist your instance, ensuring seamless communication.

However, starting with version 3, the outbound IP address is readily available directly on the OIC instance's home page. This eliminates the need to raise a support request and simplifies the process of whitelisting, streamlining communication with third-party applications.

Navigation:

Go to Home page >> click user name profile >> about >> outbound ip.




Friday, October 4, 2024

OIC - Create Secret in OCI Vault to store your keys and access from OIC

Use Case:

In this section, we will demonstrate how to create a secret in Oracle Cloud Infrastructure (OCI) Vault for securely storing your keys. Additionally, we will outline the process for retrieving secret keys using the Secret OCI ID from the OCI Vault through Oracle Integration Cloud.

  • In Oracle Cloud Infrastructure (OCI) Vault, a "secret" refers to confidential and sensitive information securely stored within the vault. This can include database passwords, SSH keys, SSL certificates, API keys, and other credentials that require protection from unauthorized access.
  • OCI Vault enables effective management and control over these secrets within your Oracle Cloud environment. The service provides robust security features such as encryption at rest and in transit, access controls, auditing capabilities, and seamless integration with other OCI services.

Part1: Create secret in OCI Vault to store your keys.

Implementation steps:

  1. Create vault
  2. Create key
  3. Create secret
Detailed screenshots:












Part2: Get the keys from vault using OIC integrations.

Implementation steps:

  1. Create a Rest connection for the OCI vault using vault secret retrieval API, tenancy OCID, User OCID, Private Key with finger print and optional passphrase. Security policy as OCI Signature Version 1. Check this blog- how to get all the details: https://soalicious.blogspot.com/2022/09/oci-how-to-get-tenancy-ocid-user-ocid.html
  2. Create a rest trigger to get the secret key
    1. Resource url: /mydata/{secretId}
    2. Get method
    3. Query param: versionNumber
    4. Json response as {"Name":"","Value":""}
  3. Configure vault rest api invoke as below
    1. Resource uri: /20190301/secretbundles/{secretId}
    2. GET method
    3. Add versionNumber Query param
    4. Add json as response
    5. Map the trigger secrect id and version number.
  4. Map the content response to integration response. Use decodeBase64() function to decode the content.
Json response for oci vault api:

{
  "secretId": "",
  "timeCreated": "2021-08-30T05:33:13.530Z",
  "versionNumber": 1,
  "versionName": null,
  "secretBundleContent": {
    "contentType": "BASE64",
    "content": ""
  },
  "timeOfDeletion": null,
  "timeOfExpiry": null,
  "stages": ["CURRENT", "LATEST"],
  "metadata": null
}

Base URI Vault rest api formation:
https://secrets.vaults.<region>.oci.oraclecloud.com

Detailed steps with screenshots:

Step1: create a Vault Rest connection:


Step2: Create application integration to configure trigger







Step3: configure Rest vault api invoke





Step4: map the request payload of the invoke rest vault api.

Step5: map the vault response content(decoded) to integration response.


Reference:

https://medium.com/@bimands/create-secret-to-store-your-keys-and-access-from-oic-e23bf2613792

Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...