Skip to content

Commit

Permalink
Merge pull request #994 from openBackhaul/v2.1.1_impl
Browse files Browse the repository at this point in the history
V2.1.1 impl
  • Loading branch information
IswaryaaS authored Jul 31, 2024
2 parents eafd3de + 6b0fe82 commit 1ae5293
Show file tree
Hide file tree
Showing 35 changed files with 2,315 additions and 1,110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ async function validateOperationKey(request, scopes, schema) {
*/
// eslint-disable-next-line no-unused-vars
async function validateBasicAuth(request, scopes, schema) {
const authStatus = await authorizingService.isAuthorized(request.headers.authorization, request.method);
let pathDefinedInOpenApi = request.openapi.openApiRoute;
const authStatus = await authorizingService.isAuthorized(request.headers.authorization, request.method, pathDefinedInOpenApi);
if (authStatus.isAuthorized == true) {
return true;
} else {
Expand All @@ -89,7 +90,7 @@ async function validateBasicAuth(request, scopes, schema) {
function loggingErrorHandler(err, req, res, next) {
const statusCode = err.status || 500;
const errorBody = {
code : statusCode,
code: statusCode,
message: err.message,
errors: err.errors,
}
Expand All @@ -101,7 +102,9 @@ function loggingErrorHandler(err, req, res, next) {
const traceIndicator = req.headers['trace-indicator'];
const user = req.headers.user;
const originator = req.headers.originator;
executionAndTraceService.recordServiceRequest(xCorrelator, traceIndicator, user, originator, req.url, statusCode, req.body, errorBody);
if (!(originator == "ExecutionAndTraceLog" && req.url == "/v1/record-service-request")) {
executionAndTraceService.recordServiceRequest(xCorrelator, traceIndicator, user, originator, req.url, statusCode, req.body, errorBody);
}
}
}
console.log(`loggingErrorHandler - caught error, returning response with status code "${statusCode}" and body ${JSON.stringify(errorBody)}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ const FILE_PROFILE = {
CONFIGURATION: "file-profile-configuration",
FILE_IDENTIFIER: "file-identifier",
FILE_DESCRIPTION: "file-description",
FILE_PATH: "file-path",
USER_NAME: "user-name",
PASSWORD: "password",
FILE_NAME: "file-name",
OPERATION: "operation"
};

Expand Down
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 @@ -17,7 +17,6 @@ const Profile = require('./Profile');
class ProfileCollection {

/**
* @deprecated use getProfileListForProfileNameAsync
* @description This function returns the profile list from /core-model-1-4:control-construct/profile-collection/profile.
* @returns {promise} list {profile list}
**/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const tcpClientInterface = require('./TcpClientInterface');
const onfPaths = require('../../constants/OnfPaths');
const onfAttributes = require('../../constants/OnfAttributes');
const fileOperation = require('../../../databaseDriver/JSONDriver');

const operationKeyUpdateNotificationService = require('../../services/OperationKeyUpdateNotificationService');
/**
* @extends LayerProtocol
*/
Expand Down Expand Up @@ -121,7 +121,7 @@ class OperationClientInterface extends LayerProtocol {
}
return undefined;
}

/**
* @description This function returns the detailedLoggingIsOn attribute of the operation client.
* @param {String} operationClientUuid : uuid of the operation client ,the value should be a valid string
Expand Down Expand Up @@ -201,15 +201,23 @@ class OperationClientInterface extends LayerProtocol {
* @param {String} operationClientUuid : uuid of the http client ,the value should be a valid string
* in the pattern '-\d+-\d+-\d+-op-client-\d+$'
* @param {String} operationKey : key that needs to be updated.
* @returns {Promise<boolean>} true|false
* @returns {Promise<boolean>} isOperationKeySet
**/
static async setOperationKeyAsync(operationClientUuid, operationKey) {
let operationKeyPath = onfPaths.OPERATION_CLIENT_OPERATION_KEY.replace(
"{uuid}", operationClientUuid);
return await fileOperation.writeToDatabaseAsync(
operationKeyPath,
operationKey,
false);
let isOperationKeySet = false
let oldoperationKey = await this.getOperationKeyAsync(operationClientUuid);
if (oldoperationKey != operationKey) {
let operationKeyPath = onfPaths.OPERATION_CLIENT_OPERATION_KEY.replace(
"{uuid}", operationClientUuid);
isOperationKeySet = await fileOperation.writeToDatabaseAsync(
operationKeyPath,
operationKey,
false);
}
if (isOperationKeySet == true || oldoperationKey == operationKey) {
operationKeyUpdateNotificationService.addOperationKeyUpdateToNotificationChannel(operationClientUuid);
}
return isOperationKeySet;
}

/**
Expand Down Expand Up @@ -288,7 +296,7 @@ class OperationClientInterface extends LayerProtocol {
const layerProtocol = ltp[onfAttributes.LOGICAL_TERMINATION_POINT.LAYER_PROTOCOL][0];
const layerProtocolName = layerProtocol[onfAttributes.LAYER_PROTOCOL.LAYER_PROTOCOL_NAME];
return LayerProtocol.layerProtocolNameEnum.OPERATION_CLIENT === layerProtocolName;
}
}
}

/**
Expand All @@ -309,4 +317,5 @@ function getConfiguredRemoteAddress(remoteAddress) {
return remoteAddress;
}

module.exports = OperationClientInterface;

module.exports = OperationClientInterface;
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const LayerProtocol = require('../LayerProtocol');
const onfPaths = require('../../constants/OnfPaths');
const onfAttributes = require('../../constants/OnfAttributes');
const fileOperation = require('../../../databaseDriver/JSONDriver');
const ForwardingDomain = require('../../models/ForwardingDomain');
const FcPort = require('../FcPort');
const operationKeyUpdateNotificationService = require('../../services/OperationKeyUpdateNotificationService');
/**
* @extends LayerProtocol
*/
Expand Down Expand Up @@ -62,9 +65,9 @@ class OperationServerInterface extends LayerProtocol {
*/
constructor(operationName) {
this.operationServerInterfaceCapability = new OperationServerInterfacePac.
OperationServerInterfaceCapability(operationName);
OperationServerInterfaceCapability(operationName);
this.operationServerInterfaceConfiguration = new OperationServerInterfacePac.
OperationServerInterfaceConfiguration();
OperationServerInterfaceConfiguration();
}
}

Expand All @@ -76,7 +79,7 @@ class OperationServerInterface extends LayerProtocol {
super(0,
OperationServerInterface.OperationServerInterfacePac.layerProtocolName);
this[onfAttributes.LAYER_PROTOCOL.OPERATION_SERVER_INTERFACE_PAC] = new
OperationServerInterface.OperationServerInterfacePac(operationName);
OperationServerInterface.OperationServerInterfacePac(operationName);
}

/**
Expand Down Expand Up @@ -160,12 +163,20 @@ class OperationServerInterface extends LayerProtocol {
* @returns {Promise<boolean>} true | false
**/
static async setOperationKeyAsync(operationServerUuid, operationKey) {
let operationKeyPath = onfPaths.OPERATION_SERVER_OPERATION_KEY.replace(
"{uuid}", operationServerUuid);
return await fileOperation.writeToDatabaseAsync(
operationKeyPath,
operationKey,
false);
let isOperationKeySet = false
let oldoperationKey = await this.getOperationKeyAsync(operationServerUuid);
if (oldoperationKey != operationKey) {
let operationKeyPath = onfPaths.OPERATION_SERVER_OPERATION_KEY.replace(
"{uuid}", operationServerUuid);
isOperationKeySet = await fileOperation.writeToDatabaseAsync(
operationKeyPath,
operationKey,
false);
}
if (isOperationKeySet == true || oldoperationKey == operationKey) {
operationKeyUpdateNotificationService.addOperationKeyUpdateToNotificationChannel(operationServerUuid);
}
return isOperationKeySet;
}

/**
Expand Down Expand Up @@ -194,7 +205,7 @@ class OperationServerInterface extends LayerProtocol {
**/
static async getOperationServerUuidAsync(operationName) {
let logicalTerminationPointList = await controlConstruct.
getLogicalTerminationPointListAsync(LayerProtocol.layerProtocolNameEnum.OPERATION_SERVER);
getLogicalTerminationPointListAsync(LayerProtocol.layerProtocolNameEnum.OPERATION_SERVER);
if (logicalTerminationPointList != undefined) {
for (let i = 0; i < logicalTerminationPointList.length; i++) {
let logicalTerminationPoint = logicalTerminationPointList[i];
Expand All @@ -209,6 +220,26 @@ class OperationServerInterface extends LayerProtocol {
}
}

/**
* @description This function returns the input operationServer operationName of the fowarding.
* @param {String} forwardingName: the value should be a valid forwardingName
* @returns {Promise<String|undefined>} operationServerName
**/

static async getInputOperationServerNameFromForwarding(forwardingName) {
let forwardConstruct = await ForwardingDomain.getForwardingConstructForTheForwardingNameAsync(forwardingName)
if (forwardConstruct === undefined) {
return undefined;
}
let fcPorts = forwardConstruct[onfAttributes.FORWARDING_CONSTRUCT.FC_PORT];
let fcPortOutput = fcPorts.filter(
fcPort => fcPort[onfAttributes.FC_PORT.PORT_DIRECTION] === FcPort.portDirectionEnum.INPUT
)[0];
let operationServerUuid = fcPortOutput[onfAttributes.FC_PORT.LOGICAL_TERMINATION_POINT];
let operationServerName = await this.getOperationNameAsync(operationServerUuid);
return operationServerName;
}

/**
* @description Determines if given UUID belongs to a server operation.
* @param {String} operationUuid UUID to be checked
Expand All @@ -235,4 +266,4 @@ class OperationServerInterface extends LayerProtocol {
return "s" === splitted[5];
}
}
module.exports = OperationServerInterface;
module.exports = OperationServerInterface;
Loading

0 comments on commit 1ae5293

Please sign in to comment.