openBackhaul / MicroWaveDeviceInventory

Physical and logical inventory of the MW SDN Domain
Apache License 2.0
5 stars 1 forks source link

To make register-yourself work with no request-body #879

Closed PrathibaJee closed 6 months ago

PrathibaJee commented 6 months ago

As of now , performing a register-yourself without a request-body is not triggering RO://register-application. This is because, in the server/controllers/BasicServices.js , a handling is missing to make this service work for both with or without request-body ,

Copy pasting this code from other applications for your reference

module.exports.registerYourself = async function registerYourself(req, res, next, body, user, originator, xCorrelator, traceIndicator, customerJourney) {
let startTime = process.hrtime();
let responseCode = responseCodeEnum.code.NO_CONTENT;
let responseBodyToDocument;
if (Object.keys(req.body).length === 0) {
body = req.body;
user = req.headers["user"];
originator = req.headers["originator"];
xCorrelator = req.headers["x-correlator"];
traceIndicator = req.headers["trace-indicator"];
customerJourney = req.headers["customer-journey"];
}
await BasicServices.registerYourself(body, user, xCorrelator, traceIndicator, customerJourney, req.url)
.then(async function (responseBody) {
responseBodyToDocument = responseBody;
let responseHeader = await restResponseHeader.createResponseHeader(xCorrelator, startTime, req.url);
restResponseBuilder.buildResponse(res, responseCode, responseBody, responseHeader);
})
.catch(async function (responseBody) {
let responseHeader = await restResponseHeader.createResponseHeader(xCorrelator, startTime, req.url);
let sentResp = restResponseBuilder.buildResponse(res, undefined, responseBody, responseHeader);
responseCode = sentResp.code;
responseBodyToDocument = sentResp.body;
});
executionAndTraceService.recordServiceRequest(xCorrelator, traceIndicator, user, originator, req.url, responseCode, req.body, responseBodyToDocument);
};
PrathibaJee commented 6 months ago

Issue is fixed in the tag test_v1.1.4. Following scenarios are verified ,

  1. Performing register-yourself manually with request-body
  2. Performing register-yourself manually without request-body
  3. Automatic initiation of register-yourself during the application startup

@IswaryaaS , thank you for your support in verification.