fixing policy errors

application-manager-new
Rasika Perera 9 years ago
parent 43a756d851
commit d6abb3fdd7

@ -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 () {

@ -173,7 +173,6 @@
<!--Later add the navigation menu from here-->
{{/zone}}
{{#zone "action-bar"}}
{{#if permissions.ADD_POLICY}}
<a href="/iotserver/policies/add-policy" class="cu-btn">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
@ -181,7 +180,6 @@
</span>
Add Policy
</a>
{{/if}}
{{/zone}}
{{#zone "bottomJs"}}
<script src="{{self.publicURL}}/js/policy-listing.js"></script>

Loading…
Cancel
Save