adding policy owner parameter

application-manager-new
Rasika Perera 9 years ago
parent 74958fd4bc
commit 864ee109a5

@ -38,7 +38,8 @@ policyModule = function () {
name: policyName, name: policyName,
mediaType: 'text/plain', mediaType: 'text/plain',
content: policyDefinition, content: policyDefinition,
description: policyDescription description: policyDescription,
properties:{owner: carbonUser.username}
}; };
if (carbonUser) { if (carbonUser) {
@ -54,7 +55,7 @@ policyModule = function () {
var mqttsenderClass = Packages.org.wso2.device.mgt.mqtt.policy.push.MqttPush; var mqttsenderClass = Packages.org.wso2.device.mgt.mqtt.policy.push.MqttPush;
var mqttsender = new mqttsenderClass(); var mqttsender = new mqttsenderClass();
var result = mqttsender.pushToMQTT("/iot/policymgt/govern", policyDefinition, "tcp://localhost:1883", "Raspberry-Policy-sender"); var result = mqttsender.pushToMQTT("/iot/policymgt/govern/" + deviceType + "/" + carbonUser.username, policyDefinition, "tcp://localhost:1883", "Raspberry-Policy-sender");
mqttsender = null; mqttsender = null;
@ -88,6 +89,12 @@ policyModule = function () {
//loop through policies //loop through policies
for (var j = 0; j < deviceTypePolicies.content.length; j++) { for (var j = 0; j < deviceTypePolicies.content.length; j++) {
var deviceTypePolicy = registry.get(deviceTypePolicies.content[j]); var deviceTypePolicy = registry.get(deviceTypePolicies.content[j]);
if(stringify(registry.properties(deviceTypePolicies.content[j]).owner) != '["'+carbonUser.username+'"]'){
//not owned by current user, skip it
continue;
}
var policyObj = { var policyObj = {
"id": deviceTypePolicy.uuid, // Identifier of the policy. "id": deviceTypePolicy.uuid, // Identifier of the policy.
//"priorityId": 1, // Priority of the policies. This will be used only for simple evaluation. //"priorityId": 1, // Priority of the policies. This will be used only for simple evaluation.
@ -136,7 +143,7 @@ policyModule = function () {
registry.remove(constants.POLICY_REGISTRY_PATH + deviceType + "/" + name); registry.remove(constants.POLICY_REGISTRY_PATH + deviceType + "/" + name);
bool = true; bool = true;
} catch (err) { } catch (err) {
log.error("Error while trying to remove policy :" + name); log.error("Error while trying to remove policy :" + name, err);
} }
} }

@ -3,8 +3,6 @@
<div class="col-md-12"> <div class="col-md-12">
<!-- content --> <!-- content -->
<div class="wr-content"> <div class="wr-content">
<p class="page-sub-title">Policies</p>
<p>{{listPolicyStatus}}</p> <p>{{listPolicyStatus}}</p>
<div class="wr-list-group wr-sortable"> <div class="wr-list-group wr-sortable">

@ -5,7 +5,7 @@ function onRequest(context) {
//log.info((allPolicies)); //log.info((allPolicies));
if (!allPolicies || allPolicies.length == 0) { if (!allPolicies || allPolicies.length == 0) {
context.policies = []; context.policies = [];
context.listPolicyStatus = "Oops, Sorry, No other Policies found."; context.listPolicyStatus = "";
} else { } else {
var i, filteredPoliciesList = []; var i, filteredPoliciesList = [];
for (i = 0; i < allPolicies.length; i++) { for (i = 0; i < allPolicies.length; i++) {

Loading…
Cancel
Save