fixing adding new policy not shown error

application-manager-new
Rasika Perera 9 years ago
parent dadf913a83
commit 6ea6551ada

@ -32,7 +32,7 @@ if (uriMatcher.match("/{context}/api/policies/update")) {
policyModule.updatePolicyPriorities(payload);
} else if (uriMatcher.match("/{context}/api/policies/add")) {
var content = request.getContent();
var id = content.policyName;
var policyName = content.policyName;
var policyDefinition = content.profile.policyDefinition;
var policyDescription = content.profile.policyDescription;
var deviceType = content.profile.deviceType.name;
@ -40,7 +40,7 @@ if (uriMatcher.match("/{context}/api/policies/update")) {
log.info("@@@@@ Policy Declaration : " + stringify(content));
try {
result = policyModule.addPolicy(id, deviceType, policyDefinition, policyDescription);
result = policyModule.addPolicy(policyName, deviceType, policyDefinition, policyDescription);
} catch (e) {
log.error("Exception occurred while trying to add new policy under name:" + id, e);
// http status code 500 refers to - Internal Server Error.

@ -28,8 +28,6 @@ policyModule = function () {
publicMethods.addPolicy = function (policyName, deviceType, policyDefinition, policyDescription) {
if (policyName && deviceType) {
return false;
}
var carbonModule = require("carbon");
var carbonServer = application.get("carbonServer");
@ -59,7 +57,12 @@ policyModule = function () {
var result = mqttsender.pushToMQTT("/iot/policymgt/govern", policyDefinition, "tcp://10.100.0.104:1883", "Raspberry-Policy-sender");
mqttsender = null;
return true;
} else {
return false;
}
};
publicMethods.getPolicies = function () {

Loading…
Cancel
Save