diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js
index e828e070..3470266b 100755
--- a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js
+++ b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js
@@ -26,14 +26,18 @@ policyModule = function () {
var publicMethods = {};
var privateMethods = {};
- publicMethods.addPolicy = function (name, deviceType, policyDefinition, policyDescription) {
+ publicMethods.addPolicy = function (policyName, deviceType, policyDefinition, policyDescription) {
+ if(policyName && deviceType){
+ return false;
+ }
+
var carbonModule = require("carbon");
var carbonServer = application.get("carbonServer");
var options = {system: true};
var carbonUser = session.get(constants.USER_SESSION_KEY);
- resource = {
- name: name,
+ var resource = {
+ name: policyName,
mediaType: 'text/plain',
content: policyDefinition,
description: policyDescription
@@ -42,11 +46,11 @@ policyModule = function () {
if (carbonUser) {
options.tenantId = carbonUser.tenantId;
var registry = new carbonModule.registry.Registry(carbonServer, options);
- log.info("########### Policy name : " + name);
+ log.info("########### Policy name : " + policyName);
log.info("########### Policy type : " + deviceType);
log.info("########### Policy Declaration : " + policyDefinition);
log.info("########### Policy policyDescription: " + policyDescription);
- registry.put(constants.POLICY_REGISTRY_PATH + deviceType + "/" + name, resource);
+ registry.put(constants.POLICY_REGISTRY_PATH + deviceType + "/" + policyName, resource);
}
var mqttsenderClass = Packages.org.wso2.device.mgt.mqtt.policy.push.MqttPush;
@@ -55,6 +59,7 @@ policyModule = function () {
var result = mqttsender.pushToMQTT("/iot/policymgt/govern", policyDefinition, "tcp://10.100.0.104:1883", "Raspberry-Policy-sender");
mqttsender = null;
+ return true;
};
publicMethods.getPolicies = function () {
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-listing/policy-listing.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-listing/policy-listing.hbs
index c59bf826..3484060b 100644
--- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-listing/policy-listing.hbs
+++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-listing/policy-listing.hbs
@@ -173,7 +173,6 @@
{{/zone}}
{{#zone "action-bar"}}
- {{#if permissions.ADD_POLICY}}
@@ -181,7 +180,6 @@
Add Policy
- {{/if}}
{{/zone}}
{{#zone "bottomJs"}}