Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ const ACTION_PROFILE_CONSEQUENT_OPERATION_REFERENCE = ACTION_PROFILE_CONFIGURATI

const FILE_PROFILE_PAC = PROFILE + "={profileUuid}/file-profile-1-0:file-profile-pac";
const FILE_PROFILE_CONFIGURATION = FILE_PROFILE_PAC + "/file-profile-configuration";
const FILE_PROFILE_FILE_PATH = FILE_PROFILE_CONFIGURATION + "/file-path";
const FILE_PROFILE_USER_NAME = FILE_PROFILE_CONFIGURATION + "/user-name";
const FILE_PROFILE_PASSWORD = FILE_PROFILE_CONFIGURATION + "/password";
const FILE_PROFILE_FILE_NAME = FILE_PROFILE_CONFIGURATION + "/file-name";
const FILE_PROFILE_OPERATION = FILE_PROFILE_CONFIGURATION + "/operation";


Expand Down Expand Up @@ -96,9 +94,7 @@ module.exports = {
ACTION_PROFILE_CONSEQUENT_OPERATION_REFERENCE,
FILE_PROFILE_PAC,
FILE_PROFILE_CONFIGURATION,
FILE_PROFILE_FILE_PATH,
FILE_PROFILE_USER_NAME,
FILE_PROFILE_PASSWORD,
FILE_PROFILE_FILE_NAME,
FILE_PROFILE_OPERATION,
LOGICAL_TERMINATION_POINT,
LOGICAL_TERMINATION_POINT_UUID,
Expand Down Expand Up @@ -134,4 +130,4 @@ module.exports = {
FORWARDING_CONSTRUCT,
FC_PORT,
FC_PORT_LOGICAL_TERMINATION_POINT
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ForwardingDomain {
* and fcPortDirection.
* @param {String} ltpUuid uuid of a logical-termination-point instance. It should be a valid string in the
* pattern '-\d+-\d+-\d+-op-(s|c)-\d{4}$'.
* @param {Enumerator} fcPortDirection the value can be any one of the ForwardingConstruct.FcPort.portDirectionEnum
* @param {String} fcPortDirection the value can be any one of the ForwardingConstruct.FcPort.portDirectionEnum
* @returns {Promise<Array>} filtered ForwardingConstructList
**/
static async getForwardingConstructListForTheFcPortAsync(ltpUuid, fcPortDirection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const profile = require('../../../onfModel/models/Profile');
const onfPaths = require('../../../onfModel/constants/OnfPaths');
const onfAttributes = require('../../../onfModel/constants/OnfAttributes');
const fileOperation = require('../../../databaseDriver/JSONDriver');

global.applicationDataPath;
/**
* @extends profile
*/
class FileProfile extends profile {
/**
* FileProfilePac class holds the following properties,
* 1.fileProfileCapability - class that holds the fileIdentifier, fileProfileConfiguration.
* 2.fileProfileConfiguration - class that holds the filePath, username, password, operation.
* 2.fileProfileConfiguration - class that holds the fileName, operation.
*/
static FileProfilePac = class FileProfilePac {
static profileName = profile.profileNameEnum.FILE_PROFILE;
Expand All @@ -43,9 +43,7 @@ class FileProfile extends profile {
};

static FileProfileConfiguration = class FileProfileConfiguration {
filePath;
userName;
password;
fileName;
operation;

static operationEnum = {
Expand All @@ -57,16 +55,12 @@ class FileProfile extends profile {

/**
* constructor
* @param {string} filePath path for the file.
* @param {string} userName user name to access the file.
* @param {string} password password name to access the file.
* @param {string} fileName name for the file.
* @param {string} operation operation.
* This constructor will instantiate the fileProfileConfiguration class
*/
constructor(filePath, userName, password, operation) {
this.filePath = filePath;
this.userName = userName;
this.password = password;
constructor(fileName, operation) {
this.fileName = fileName;
this.operation = operation;
}
};
Expand All @@ -75,19 +69,17 @@ class FileProfile extends profile {
* constructor
* @param {string} fileIdentifier Identifier for the file.
* @param {string} fileDescription Description for the file.
* @param {string} filePath path for the file.
* @param {string} userName user name to access the file.
* @param {string} password password to access the file..
* @param {string} fileName path for the file.
* @param {string} operation operation.
* This constructor will instantiate the FileProfilePac class
*/
constructor(fileIdentifier, fileDescription, filePath, userName, password, operation) {
constructor(fileIdentifier, fileDescription, fileName, operation) {
this.fileProfileCapability = new FileProfilePac.
FileProfileCapability(
fileIdentifier, fileDescription);
this.FileProfileConfiguration = new FileProfilePac.
FileProfileConfiguration(
filePath, userName, password, operation);
fileName, operation);
}
}

Expand All @@ -96,23 +88,19 @@ class FileProfile extends profile {
* @param {string} uuid : the value should be a valid string in the pattern '-\d+-\d+-\d+-file-p-\d+$'
* @param {string} fileIdentifier Identifier for the file.
* @param {string} fileDescription Description for the file.
* @param {string} filePath path for the file.
* @param {string} userName user name to access the file.
* @param {string} password password to access the file..
* @param {string} fileName path for the file.
* @param {string} operation operation.
* This constructor will instantiate the FileProfile class
*/
constructor(uuid, fileIdentifier, fileDescription, filePath, userName, password, operation) {
constructor(uuid, fileIdentifier, fileDescription, fileName, operation) {
super(
uuid,
FileProfile.FileProfilePac.profileName
);
this[onfAttributes.FILE_PROFILE.PAC] = new FileProfile.FileProfilePac(
fileIdentifier,
fileDescription,
filePath,
userName,
password,
fileName,
operation
);
}
Expand Down Expand Up @@ -178,8 +166,8 @@ class FileProfile extends profile {
let profileUuid = profiles.flatMap(profile => profile[onfAttributes.GLOBAL_CLASS.UUID]);
for (let profileUuidIndex = 0; profileUuidIndex < profileUuid.length; profileUuidIndex++) {
let uuid = profileUuid[profileUuidIndex];
let value = await FileProfile.getFilePath(uuid)
let completeFilePath = "./application-data/" + value;
let value = await FileProfile.getFileName(uuid)
let completeFilePath = global.applicationDataPath + value;
if (fileSystem.existsSync(completeFilePath)) {
applicationDataFile = completeFilePath;
}
Expand All @@ -197,77 +185,24 @@ class FileProfile extends profile {
}

/**
* @description This function returns the file path for the provided file profile uuid.
* @description This function returns the file name for the provided file profile uuid.
* @param {String} profileUuid : the value should be a valid string in the pattern '-\d+-\d+-\d+-file-p-\d+$'
* @returns {promise} string {filePath}
* @returns {promise} string {fileName}
**/
static async getFilePath(profileUuid) {
static async getFileName(profileUuid) {
return new Promise(async function (resolve, reject) {
try {
let filePath;
let fileName;
let profileList = await profileCollection.getProfileListForProfileNameAsync(FileProfile.FileProfilePac.profileName);
for (let profile of profileList) {
let uuidOfProfile = profile[onfAttributes.GLOBAL_CLASS.UUID];
if (uuidOfProfile === profileUuid) {
let fileProfilePac = profile[onfAttributes.FILE_PROFILE.PAC];
let fileProfileConfiguration = fileProfilePac[onfAttributes.FILE_PROFILE.CONFIGURATION];
filePath = fileProfileConfiguration[onfAttributes.FILE_PROFILE.FILE_NAME];
fileName = fileProfileConfiguration[onfAttributes.FILE_PROFILE.FILE_NAME];
}
}
resolve(filePath);
} catch (error) {
reject(error);
}
});
}



/**
* @description This function returns the user name for the provided file profile uuid.
* @param {String} profileUuid : the value should be a valid string in the pattern '-\d+-\d+-\d+-file-p-\d+$'
* @returns {promise} string {userName}
**/
static async getUserName(profileUuid) {
return new Promise(async function (resolve, reject) {
try {
let userName;
let profileList = await profileCollection.getProfileListForProfileNameAsync(FileProfile.FileProfilePac.profileName);
for (let profile of profileList) {
let uuidOfProfile = profile[onfAttributes.GLOBAL_CLASS.UUID];
if (uuidOfProfile === profileUuid) {
let fileProfilePac = profile[onfAttributes.FILE_PROFILE.PAC];
let fileProfileConfiguration = fileProfilePac[onfAttributes.FILE_PROFILE.CONFIGURATION];
userName = fileProfileConfiguration[onfAttributes.FILE_PROFILE.USER_NAME];
}
}
resolve(userName);
} catch (error) {
reject(error);
}
});
}


/**
* @description This function returns the password for the provided file profile uuid.
* @param {String} profileUuid : the value should be a valid string in the pattern '-\d+-\d+-\d+-file-p-\d+$'
* @returns {promise} string {password}
**/
static async getPassword(profileUuid) {
return new Promise(async function (resolve, reject) {
try {
let password;
let profileList = await profileCollection.getProfileListForProfileNameAsync(FileProfile.FileProfilePac.profileName);
for (let profile of profileList) {
let uuidOfProfile = profile[onfAttributes.GLOBAL_CLASS.UUID];
if (uuidOfProfile === profileUuid) {
let fileProfilePac = profile[onfAttributes.FILE_PROFILE.PAC];
let fileProfileConfiguration = fileProfilePac[onfAttributes.FILE_PROFILE.CONFIGURATION];
password = fileProfileConfiguration[onfAttributes.FILE_PROFILE.PASSWORD];
}
}
resolve(password);
resolve(fileName);
} catch (error) {
reject(error);
}
Expand Down Expand Up @@ -300,78 +235,22 @@ class FileProfile extends profile {
}

/**
* @description This function sets the file path for the provided file profile uuid.
* @param {String} profileUuid : the value should be a valid string in the pattern '-\d+-\d+-\d+-file-p-\d+$'
* @param {String} filePathValueToBeUpdated : Value of file path that needs to be updated.
* @returns {promise} boolean {true|false}
**/
static async setFilePath(profileUuid, filePathValueToBeUpdated) {
return new Promise(async function (resolve, reject) {
try {
let isUpdated = false;
try {
let filePath = onfPaths.FILE_PROFILE_FILE_PATH
.replace(
"{profileUuid}", profileUuid);
isUpdated = await fileOperation.writeToDatabaseAsync(
filePath,
filePathValueToBeUpdated,
false);
resolve(isUpdated);
} catch (error) {
reject(error);
}
} catch (error) {
reject(error);
}
});
}

/**
* @description This function sets the user name for the provided file profile uuid.
* @param {String} profileUuid : the value should be a valid string in the pattern '-\d+-\d+-\d+-file-p-\d+$'
* @param {String} userName : the value of user name
* @returns {promise} boolean {true|false}
**/
static async setUserName(profileUuid, userName) {
return new Promise(async function (resolve, reject) {
try {
let isUpdated = false;
try {
let userNamePath = onfPaths.FILE_PROFILE_USER_NAME
.replace(
"{profileUuid}", profileUuid);
isUpdated = await fileOperation.writeToDatabaseAsync(
userNamePath,
userName,
false);
resolve(isUpdated);
} catch (error) {
reject(error);
}
} catch (error) {
reject(error);
}
});
}

/**
* @description This function sets the password for the provided file profile uuid.
* @description This function sets the file name for the provided file profile uuid.
* @param {String} profileUuid : the value should be a valid string in the pattern '-\d+-\d+-\d+-file-p-\d+$'
* @param {String} password : the value of password
* @param {String} fileNameValueToBeUpdated : Value of file name that needs to be updated.
* @returns {promise} boolean {true|false}
**/
static async setPassword(profileUuid, password) {
static async setFileName(profileUuid, fileNameValueToBeUpdated) {
return new Promise(async function (resolve, reject) {
try {
let isUpdated = false;
try {
let passwordPath = onfPaths.FILE_PROFILE_PASSWORD
let fileName = onfPaths.FILE_PROFILE_FILE_NAME
.replace(
"{profileUuid}", profileUuid);
isUpdated = await fileOperation.writeToDatabaseAsync(
passwordPath,
password,
fileName,
fileNameValueToBeUpdated,
false);
resolve(isUpdated);
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* @file This class provides a stub for onf core-model.
* This class consolidates the technology specific extensions.
* @author prathiba.jeevan.external@telefonica.com
* @since 23.05.2024
* @version 1.0
* @copyright Telefónica Germany GmbH & Co. OHG*
**/

'use strict';

const ForwardingDomain = require('../models/ForwardingDomain');
const eventDispatcher = require('../../rest/client/eventDispatcher');
const FcPort = require('../models/FcPort');
// eslint-disable-next-line no-unused-vars
const ForwardingProcessingInput = require('./models/forwardingConstruct/ForwardingProcessingInput');

/**
* @description This function process a forwarding construct by calling the appropriate call back operations based on the fcPort input and output directions.
* @param {ForwardingProcessingInput} forwardingInputList list of attributes required for processing the RESTCALL
* @param {String} user user who initiates this request
* @param {String} xCorrelator flow id of this request
* @param {String} traceIndicator trace indicator of the request
* @param {String} customerJourney customer journey of the request
* @returns {Promise<String>} response
**/
exports.processForwardingConstructAsync = async function (forwardingProcessingInput, user,
xCorrelator, traceIndicator, customerJourney) {
let response;
let forwardingName = forwardingProcessingInput.forwardingName;
let attributeList = forwardingProcessingInput.attributeList;
let forwardingConstruct = await ForwardingDomain.getForwardingConstructForTheForwardingNameAsync(
forwardingName);
let fcPortList = forwardingConstruct["fc-port"];
for (let fcPort of fcPortList) {
let fcPortDirection = fcPort["port-direction"];
if (fcPortDirection == FcPort.portDirectionEnum.OUTPUT) {
let fcPortLogicalTerminationPoint = fcPort["logical-termination-point"];
response = await eventDispatcher.dispatchEvent(
fcPortLogicalTerminationPoint,
attributeList,
user,
xCorrelator,
traceIndicator,
customerJourney,
undefined,
undefined,
true
);
}
}
return response;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* @deprecated please use LogicalTerminationPointServicesV2.js
* This module provides functionalities to
* - manipulate the /core-model-1-4:control-construct/logical-termination-point
* - create tcp, http, operation client instance groups for new applications
Expand Down
Loading