mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Optimize policy pick strategy for corrective action implementation
This commit is contained in:
parent
684ff5df7f
commit
2724d8ac03
@ -55,6 +55,8 @@ public class CorrectiveAction implements Serializable {
|
|||||||
)
|
)
|
||||||
private List<ProfileFeature> operations;
|
private List<ProfileFeature> operations;
|
||||||
|
|
||||||
|
private int featureId;
|
||||||
|
|
||||||
public String getActionType() {
|
public String getActionType() {
|
||||||
return actionType;
|
return actionType;
|
||||||
}
|
}
|
||||||
@ -78,4 +80,12 @@ public class CorrectiveAction implements Serializable {
|
|||||||
public void setOperations(List<ProfileFeature> operations) {
|
public void setOperations(List<ProfileFeature> operations) {
|
||||||
this.operations = operations;
|
this.operations = operations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFeatureId() {
|
||||||
|
return featureId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFeatureId(int featureId) {
|
||||||
|
this.featureId = featureId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ProfileOperation extends ConfigOperation implements Serializable {
|
public class ProfileOperation extends ConfigOperation implements Serializable {
|
||||||
private List<Integer> correctiveActionIds = new ArrayList<>();
|
private List<Integer> correctiveActionIds;
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return Type.PROFILE;
|
return Type.PROFILE;
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
<div class="wr-steps hidden">
|
<div class="wr-steps hidden">
|
||||||
<div class="col-md-2 col-xs-2 col-md-offset-1">
|
<div class="col-md-2 col-xs-2 col-md-offset-2">
|
||||||
<div class="itm-wiz itm-wiz-current" data-step="policy-platform">
|
<div class="itm-wiz itm-wiz-current" data-step="policy-platform">
|
||||||
<div class="wiz-no">1</div>
|
<div class="wiz-no">1</div>
|
||||||
<div class="wiz-lbl hidden-xs"><span>Select a platform</span></div>
|
<div class="wiz-lbl hidden-xs"><span>Select a platform</span></div>
|
||||||
@ -23,16 +23,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<br class="c-both"/>
|
<br class="c-both"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 col-xs-2">
|
|
||||||
<div class="itm-wiz" data-step="policy-type">
|
|
||||||
<div class="wiz-no">3</div>
|
|
||||||
<div class="wiz-lbl hidden-xs"><span>Select policy type</span></div>
|
|
||||||
</div>
|
|
||||||
<br class="c-both"/>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-2 col-xs-2">
|
<div class="col-md-2 col-xs-2">
|
||||||
<div class="itm-wiz" data-step="policy-criteria">
|
<div class="itm-wiz" data-step="policy-criteria">
|
||||||
<div class="wiz-no">4</div>
|
<div class="wiz-no">3</div>
|
||||||
<div class="wiz-lbl hidden-xs"><span>Assign to groups</span></div>
|
<div class="wiz-lbl hidden-xs"><span>Assign to groups</span></div>
|
||||||
</div>
|
</div>
|
||||||
<br class="c-both"/>
|
<br class="c-both"/>
|
||||||
@ -209,7 +202,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="wr-input-control wr-btn-grp">
|
<div class="wr-input-control wr-btn-grp">
|
||||||
<a href="javascript:void(0)" class="wr-btn wizard-stepper" data-is-back-btn="true"
|
<a href="javascript:void(0)" class="wr-btn wizard-stepper" data-is-back-btn="true"
|
||||||
data-current="policy-criteria" data-next="policy-type">Back</a>
|
data-current="policy-criteria" data-next="policy-profile">Back</a>
|
||||||
<a href="javascript:void(0)" class="wr-btn wizard-stepper"
|
<a href="javascript:void(0)" class="wr-btn wizard-stepper"
|
||||||
data-current="policy-criteria" data-next="policy-naming" data-validate="true">Continue</a>
|
data-current="policy-criteria" data-next="policy-naming" data-validate="true">Continue</a>
|
||||||
</div>
|
</div>
|
||||||
@ -217,45 +210,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-centered wr-content policy-type hidden">
|
|
||||||
<div class="wr-form">
|
|
||||||
<h1 id="policy-type-page-wizard-title" class="page-sub-title">ADD POLICY</h1>
|
|
||||||
<hr>
|
|
||||||
<div id="policy-type-wizard-steps" class="row wr-wizard"></div>
|
|
||||||
<hr>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<h4 class="hidden-xs"> Step 3: Select policy type</h4>
|
|
||||||
<br>
|
|
||||||
<div id="policy-type-main-error-msg" class="alert alert-danger hidden" role="alert">
|
|
||||||
<i class="icon fw fw-error"></i><span></span>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div class="wr-input-control">
|
|
||||||
<label class="wr-input-control radio light">
|
|
||||||
<input type="radio" id="policy-type-general" name="policy-type-radio-btn"
|
|
||||||
value="GENERAL" checked/>
|
|
||||||
<span class="helper">General Policy</span>
|
|
||||||
</label>
|
|
||||||
<label class="wr-input-control radio light">
|
|
||||||
<input type="radio" id="policy-type-corrective" name="policy-type-radio-btn"
|
|
||||||
value="CORRECTIVE"/>
|
|
||||||
<span class="helper">Corrective Policy</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="select-general-policy-type"></div>
|
|
||||||
<div class="wr-input-control wr-btn-grp">
|
|
||||||
<a href="javascript:void(0)" class="wr-btn wizard-stepper" data-is-back-btn="true"
|
|
||||||
data-current="policy-type" data-next="policy-profile">Back</a>
|
|
||||||
<a href="javascript:void(0)" class="wr-btn wizard-stepper"
|
|
||||||
data-current="policy-type"
|
|
||||||
data-next="policy-criteria" data-validate="false">Continue</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-centered wr-content policy-profile hidden">
|
<div class="col-centered wr-content policy-profile hidden">
|
||||||
<div class="wr-form">
|
<div class="wr-form">
|
||||||
<h1 id="policy-profile-page-wizard-title" class="page-sub-title">ADD POLICY</h1>
|
<h1 id="policy-profile-page-wizard-title" class="page-sub-title">ADD POLICY</h1>
|
||||||
@ -288,7 +242,7 @@
|
|||||||
data-current="policy-profile" data-next="policy-platform">Back</a>
|
data-current="policy-profile" data-next="policy-platform">Back</a>
|
||||||
<a href="javascript:void(0)" class="wr-btn wizard-stepper"
|
<a href="javascript:void(0)" class="wr-btn wizard-stepper"
|
||||||
data-current="policy-profile"
|
data-current="policy-profile"
|
||||||
data-next="policy-type" data-validate="true">Continue</a>
|
data-next="policy-criteria" data-validate="true">Continue</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -222,28 +222,6 @@ stepForwardFrom["policy-profile"] = function () {
|
|||||||
policy["profile"] = generatePolicyProfile();
|
policy["profile"] = generatePolicyProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// add policy correction action page
|
|
||||||
var policyCorrectiveActionTemplateSrc =
|
|
||||||
"/public/cdmf.unit.policy.corrective-action/templates/policy-corrective-action.hbs";
|
|
||||||
var policyCorrectiveActionScriptSrc =
|
|
||||||
"/public/cdmf.unit.policy.corrective-action/js/policy-corrective-action.js";
|
|
||||||
var policyCorrectiveActionTemplateCacheKey = "policy-corrective-action";
|
|
||||||
|
|
||||||
$.template(policyCorrectiveActionTemplateCacheKey, context + policyCorrectiveActionTemplateSrc,
|
|
||||||
function (template) {
|
|
||||||
var content = template(
|
|
||||||
{
|
|
||||||
"deviceType": policy["platform"],
|
|
||||||
"correctivePolicies": $("#logged-in-user").data("corrective-policies")
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$("#select-general-policy-type").html(content);
|
|
||||||
var script = document.createElement('script');
|
|
||||||
script.type = 'text/javascript';
|
|
||||||
script.src = context + policyCorrectiveActionScriptSrc;
|
|
||||||
document.head.append(script);
|
|
||||||
});
|
|
||||||
|
|
||||||
// updating next-page wizard title with selected platform
|
// updating next-page wizard title with selected platform
|
||||||
$("#policy-type-page-wizard-title").text("ADD " + policy["platform"] + " POLICY");
|
$("#policy-type-page-wizard-title").text("ADD " + policy["platform"] + " POLICY");
|
||||||
};
|
};
|
||||||
@ -261,28 +239,6 @@ stepBackFrom["policy-profile"] = function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Forward action of policy type page.
|
|
||||||
*/
|
|
||||||
stepForwardFrom["policy-type"] = function () {
|
|
||||||
policy["type"] = $("input[name=policy-type-radio-btn]:checked").val();
|
|
||||||
var correctiveActionList = [];
|
|
||||||
if (policy.type === "GENERAL") {
|
|
||||||
var selectedCorrectivePolicyId = $("#corrective-policy-input").val();
|
|
||||||
if (selectedCorrectivePolicyId && selectedCorrectivePolicyId !== "none") {
|
|
||||||
var correctiveAction = {
|
|
||||||
"actionType": "POLICY",
|
|
||||||
"policyId": selectedCorrectivePolicyId
|
|
||||||
};
|
|
||||||
correctiveActionList.push(correctiveAction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
policy["correctiveActionList"] = correctiveActionList;
|
|
||||||
//updating next-page wizard title with selected platform
|
|
||||||
$("#policy-criteria-page-wizard-title").text("ADD " + policy["platform"] + " POLICY");
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forward action of policy criteria page.
|
* Forward action of policy criteria page.
|
||||||
*/
|
*/
|
||||||
@ -483,8 +439,7 @@ var savePolicy = function (policy, isActive, serviceURL) {
|
|||||||
"compliance": policy["selectedNonCompliantAction"],
|
"compliance": policy["selectedNonCompliantAction"],
|
||||||
"ownershipType": null,
|
"ownershipType": null,
|
||||||
"active": isActive,
|
"active": isActive,
|
||||||
"policyType": policy["type"],
|
"policyType": "GENERAL",
|
||||||
"correctiveActions": policy["correctiveActionList"],
|
|
||||||
"profile": {
|
"profile": {
|
||||||
"profileName": policy["policyName"],
|
"profileName": policy["policyName"],
|
||||||
"deviceType": policy["platform"],
|
"deviceType": policy["platform"],
|
||||||
@ -639,6 +594,7 @@ $(document).ready(function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//todo
|
||||||
$('input[type=radio][name=policy-type-radio-btn]').change(function() {
|
$('input[type=radio][name=policy-type-radio-btn]').change(function() {
|
||||||
if ($(this).val() === "CORRECTIVE") {
|
if ($(this).val() === "CORRECTIVE") {
|
||||||
$("#select-general-policy-type").addClass("hidden");
|
$("#select-general-policy-type").addClass("hidden");
|
||||||
|
|||||||
@ -1,38 +1,30 @@
|
|||||||
{{#zone "content"}}
|
{{#zone "content"}}
|
||||||
{{#if isAuthorized }}
|
{{#if isAuthorized }}
|
||||||
<span id="logged-in-user" class="hidden" data-username="{{@user.username}}" data-domain="{{@user.domain}}"
|
<span id="logged-in-user" class="hidden" data-username="{{@user.username}}" data-domain="{{@user.domain}}"
|
||||||
data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}" data-storeapps="{{storeApps}}"
|
data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}" data-storeapps="{{storeApps}}"></span>
|
||||||
data-corrective-policies="{{correctivePolicies}}"></span>
|
|
||||||
<span id="policy-operations" class="hidden" data-template="{{policyOperations.template}}"
|
<span id="policy-operations" class="hidden" data-template="{{policyOperations.template}}"
|
||||||
data-script="{{policyOperations.script}}" data-style="{{policyOperations.style}}"></span>
|
data-script="{{policyOperations.script}}" data-style="{{policyOperations.style}}"></span>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
<div class="wr-steps hidden">
|
<div class="wr-steps hidden">
|
||||||
<div class="col-md-3 col-xs-3">
|
<div class="col-md-3 col-xs-3 col-md-offset-2">
|
||||||
<div class="itm-wiz itm-wiz-current" data-step="policy-profile">
|
<div class="itm-wiz itm-wiz-current" data-step="policy-profile">
|
||||||
<div class="wiz-no">1</div>
|
<div class="wiz-no">1</div>
|
||||||
<div class="wiz-lbl hidden-xs"><span>Edit current profile</span></div>
|
<div class="wiz-lbl hidden-xs"><span>Edit current profile</span></div>
|
||||||
</div>
|
</div>
|
||||||
<br class="c-both"/>
|
<br class="c-both"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 col-xs-3">
|
|
||||||
<div class="itm-wiz itm-wiz" data-step="policy-type">
|
|
||||||
<div class="wiz-no">2</div>
|
|
||||||
<div class="wiz-lbl hidden-xs"><span>Edit policy type</span></div>
|
|
||||||
</div>
|
|
||||||
<br class="c-both"/>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3 col-xs-3">
|
<div class="col-md-3 col-xs-3">
|
||||||
<div class="itm-wiz" data-step="policy-criteria">
|
<div class="itm-wiz" data-step="policy-criteria">
|
||||||
<div class="wiz-no">3</div>
|
<div class="wiz-no">2</div>
|
||||||
<div class="wiz-lbl hidden-xs"><span>Edit assignment groups</span></div>
|
<div class="wiz-lbl hidden-xs"><span>Edit assignment groups</span></div>
|
||||||
</div>
|
</div>
|
||||||
<br class="c-both"/>
|
<br class="c-both"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 col-xs-3">
|
<div class="col-md-3 col-xs-3">
|
||||||
<div class="itm-wiz" data-step="policy-naming">
|
<div class="itm-wiz" data-step="policy-naming">
|
||||||
<div class="wiz-no">4</div>
|
<div class="wiz-no">3</div>
|
||||||
<div class="wiz-lbl hidden-xs"><span>Republish to devices</span></div>
|
<div class="wiz-lbl hidden-xs"><span>Republish to devices</span></div>
|
||||||
</div>
|
</div>
|
||||||
<br class="c-both"/>
|
<br class="c-both"/>
|
||||||
@ -56,7 +48,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<h4 class="visible-xs">Step 4: Republish to devices</h4>
|
<h4 class="visible-xs">Step 3: Republish to devices</h4>
|
||||||
<br>
|
<br>
|
||||||
<div id="policy-naming-main-error-msg" class="alert alert-danger hidden" role="alert">
|
<div id="policy-naming-main-error-msg" class="alert alert-danger hidden" role="alert">
|
||||||
<i class="icon fw fw-error"></i><span></span>
|
<i class="icon fw fw-error"></i><span></span>
|
||||||
@ -204,7 +196,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="wr-input-control wr-btn-grp">
|
<div class="wr-input-control wr-btn-grp">
|
||||||
<a href="#" class="wr-btn wizard-stepper" data-is-back-btn="true"
|
<a href="#" class="wr-btn wizard-stepper" data-is-back-btn="true"
|
||||||
data-current="policy-criteria" data-next="policy-type">
|
data-current="policy-criteria" data-next="policy-profile">
|
||||||
Back
|
Back
|
||||||
</a>
|
</a>
|
||||||
<a href="#" class="wr-btn wizard-stepper" data-current="policy-criteria"
|
<a href="#" class="wr-btn wizard-stepper" data-current="policy-criteria"
|
||||||
@ -217,53 +209,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-centered wr-content policy-type hidden">
|
|
||||||
<div class="wr-form">
|
|
||||||
<h1 id="policy-type-page-wizard-title" class="page-sub-title">EDIT POLICY</h1>
|
|
||||||
<hr>
|
|
||||||
<div id="policy-type-wizard-steps" class="row wr-wizard"></div>
|
|
||||||
<hr>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<h4 class="visible-xs"> Step 2: Select policy type</h4>
|
|
||||||
<br>
|
|
||||||
<div id="policy-type-main-error-msg" class="alert alert-danger hidden" role="alert">
|
|
||||||
<i class="icon fw fw-error"></i><span></span>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div class="wr-input-control">
|
|
||||||
<label class="wr-input-control radio light">
|
|
||||||
<input type="radio" id="policy-type-general" name="policy-type-radio-btn"
|
|
||||||
value="GENERAL"/>
|
|
||||||
<span class="helper">General Policy</span>
|
|
||||||
</label>
|
|
||||||
<label class="wr-input-control radio light">
|
|
||||||
<input type="radio" id="policy-type-corrective" name="policy-type-radio-btn"
|
|
||||||
value="CORRECTIVE"/>
|
|
||||||
<span class="helper">Corrective Policy</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='policy-type-loading-corrective-actions'>
|
|
||||||
<br/>
|
|
||||||
<i class='fw fw-settings fw-spin fw-2x'></i>
|
|
||||||
Loading corrective actions . . .
|
|
||||||
<br/>
|
|
||||||
<br/>
|
|
||||||
</div>
|
|
||||||
<div id="select-general-policy-type"></div>
|
|
||||||
<div class="wr-input-control wr-btn-grp">
|
|
||||||
<a href="#" class="wr-btn wizard-stepper" data-is-back-btn="true"
|
|
||||||
data-current="policy-type" data-next="policy-profile">Back</a>
|
|
||||||
<a href="#" class="wr-btn wizard-stepper"
|
|
||||||
data-current="policy-type"
|
|
||||||
data-next="policy-criteria" data-validate="false">Continue</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-centered wr-content policy-profile">
|
<div class="col-centered wr-content policy-profile">
|
||||||
<div class="wr-form">
|
<div class="wr-form">
|
||||||
<h1 id="policy-profile-page-wizard-title" class="page-sub-title">EDIT POLICY</h1>
|
<h1 id="policy-profile-page-wizard-title" class="page-sub-title">EDIT POLICY</h1>
|
||||||
@ -293,7 +238,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="wr-input-control wr-btn-grp">
|
<div class="wr-input-control wr-btn-grp">
|
||||||
<a href="#" class="wr-btn wizard-stepper" data-current="policy-profile"
|
<a href="#" class="wr-btn wizard-stepper" data-current="policy-profile"
|
||||||
data-next="policy-type" data-validate="true">
|
data-next="policy-criteria" data-validate="true">
|
||||||
Continue
|
Continue
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -85,18 +85,5 @@ function onRequest(context) {
|
|||||||
var enrollmentApps = policyModule.getStoreAppsForPolicy();
|
var enrollmentApps = policyModule.getStoreAppsForPolicy();
|
||||||
context["storeApps"] = JSON.stringify(enrollmentApps["content"]);
|
context["storeApps"] = JSON.stringify(enrollmentApps["content"]);
|
||||||
|
|
||||||
var correctivePolicies = policyModule.getAllPoliciesByType("CORRECTIVE")["content"];
|
|
||||||
if (correctivePolicies) {
|
|
||||||
var i;
|
|
||||||
for (i = 0; i < correctivePolicies.length; i++) {
|
|
||||||
if (correctivePolicies[i].id.toString() === policyId) {
|
|
||||||
correctivePolicies.splice(i, 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
context["correctivePolicies"] = JSON.stringify(correctivePolicies);
|
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
@ -280,72 +280,10 @@ stepForwardFrom["policy-profile"] = function () {
|
|||||||
policy["profile"] = generatePolicyProfile();
|
policy["profile"] = generatePolicyProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
var policyType = currentlyEffected.policyType;
|
|
||||||
$("input[name=policy-type-radio-btn][value=" + policyType + "]").prop("checked", true).trigger('change');
|
|
||||||
|
|
||||||
// add policy correction action page
|
|
||||||
var policyCorrectiveActionTemplateSrc =
|
|
||||||
"/public/cdmf.unit.policy.corrective-action/templates/policy-corrective-action.hbs";
|
|
||||||
var policyCorrectiveActionScriptSrc =
|
|
||||||
"/public/cdmf.unit.policy.corrective-action/js/policy-corrective-action.js";
|
|
||||||
var policyCorrectiveActionTemplateCacheKey = "policy-corrective-action";
|
|
||||||
|
|
||||||
$.template(policyCorrectiveActionTemplateCacheKey, context + policyCorrectiveActionTemplateSrc,
|
|
||||||
function (template) {
|
|
||||||
var content = template(
|
|
||||||
{
|
|
||||||
"deviceType": policy["platform"],
|
|
||||||
"correctivePolicies": $("#logged-in-user").data("corrective-policies")
|
|
||||||
}
|
|
||||||
);
|
|
||||||
$("#select-general-policy-type").html(content);
|
|
||||||
if ("GENERAL" === policyType && currentlyEffected.correctiveActions &&
|
|
||||||
currentlyEffected.correctiveActions.length > 0) {
|
|
||||||
currentlyEffected.correctiveActions.forEach(function (correctiveAction) {
|
|
||||||
if ("POLICY" === correctiveAction.actionType) {
|
|
||||||
if ($("#corrective-policy-input option[value=" + correctiveAction.policyId + "]").length > 0) {
|
|
||||||
$("#corrective-policy-input").val(correctiveAction.policyId);
|
|
||||||
} else {
|
|
||||||
$("#corrective-action-policy-id-missing-msg").removeClass("hidden");
|
|
||||||
}
|
|
||||||
// returned from for each since currently only supported corrective action type is
|
|
||||||
// POLICY.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
var script = document.createElement('script');
|
|
||||||
script.type = 'text/javascript';
|
|
||||||
script.src = context + policyCorrectiveActionScriptSrc;
|
|
||||||
document.head.prepend(script);
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".policy-type-loading-corrective-actions").addClass("hidden");
|
|
||||||
|
|
||||||
// updating next-page wizard title with selected platform
|
// updating next-page wizard title with selected platform
|
||||||
$("#policy-type-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]);
|
$("#policy-type-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Forward action of policy type page.
|
|
||||||
*/
|
|
||||||
stepForwardFrom["policy-type"] = function () {
|
|
||||||
policy["type"] = $("input[name=policy-type-radio-btn]:checked").val();
|
|
||||||
var correctiveActionList = [];
|
|
||||||
if (policy.type === "GENERAL") {
|
|
||||||
var selectedCorrectivePolicyId = $("#corrective-policy-input").val();
|
|
||||||
if (selectedCorrectivePolicyId && selectedCorrectivePolicyId !== "none") {
|
|
||||||
var correctiveAction = {
|
|
||||||
"actionType": "POLICY",
|
|
||||||
"policyId": selectedCorrectivePolicyId
|
|
||||||
};
|
|
||||||
correctiveActionList.push(correctiveAction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
policy["correctiveActionList"] = correctiveActionList;
|
|
||||||
// updating next-page wizard title with selected platform
|
|
||||||
$("#policy-criteria-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forward action of policy criteria page.
|
* Forward action of policy criteria page.
|
||||||
@ -556,8 +494,7 @@ var updatePolicy = function (policy, state) {
|
|||||||
"description": policy["description"],
|
"description": policy["description"],
|
||||||
"compliance": policy["selectedNonCompliantAction"],
|
"compliance": policy["selectedNonCompliantAction"],
|
||||||
"ownershipType": null,
|
"ownershipType": null,
|
||||||
"policyType": policy["type"],
|
"policyType": "GENERAL",
|
||||||
"correctiveActions": policy["correctiveActionList"],
|
|
||||||
"profile": {
|
"profile": {
|
||||||
"profileName": policy["policyName"],
|
"profileName": policy["policyName"],
|
||||||
"deviceType": policy["platform"],
|
"deviceType": policy["platform"],
|
||||||
|
|||||||
@ -69,30 +69,6 @@ var displayPolicy = function (policyPayloadObj) {
|
|||||||
$("#policy-roles").text(policyPayloadObj.roles.toString().split(",").join(", "));
|
$("#policy-roles").text(policyPayloadObj.roles.toString().split(",").join(", "));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("GENERAL" === policyPayloadObj.policyType &&
|
|
||||||
policyPayloadObj.correctiveActions && policyPayloadObj.correctiveActions.length > 0) {
|
|
||||||
policyPayloadObj.correctiveActions.forEach(function (correctiveAction) {
|
|
||||||
if ("POLICY" === correctiveAction.actionType) {
|
|
||||||
$("#corrective-action-type-policy-id").html(correctiveAction.policyId);
|
|
||||||
var correctivePolicies = $("#logged-in-user").data("corrective-policies");
|
|
||||||
if (correctivePolicies) {
|
|
||||||
var i;
|
|
||||||
for (i = 0; i < correctivePolicies.length; i++) {
|
|
||||||
if (correctiveAction.policyId === correctivePolicies[i].id) {
|
|
||||||
$("#corrective-action-policy-id-missing-msg").addClass("hidden");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$("#policy-corrective-actions-list").removeClass("hidden");
|
|
||||||
} else {
|
|
||||||
$("#policy-corrective-actions-list").addClass("hidden");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var policyId = policyPayloadObj["id"];
|
var policyId = policyPayloadObj["id"];
|
||||||
var deviceType = policy["platform"];
|
var deviceType = policy["platform"];
|
||||||
var policyOperations = $("#policy-operations");
|
var policyOperations = $("#policy-operations");
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
{{#zone "content"}}
|
{{#zone "content"}}
|
||||||
{{#if isAuthorized}}
|
{{#if isAuthorized}}
|
||||||
<span id="logged-in-user" class="hidden" data-username="{{@user.username}}" data-domain="{{@user.domain}}"
|
<span id="logged-in-user" class="hidden" data-username="{{@user.username}}" data-domain="{{@user.domain}}"
|
||||||
data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}"
|
data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}"></span>
|
||||||
data-corrective-policies="{{correctivePolicies}}"></span>
|
|
||||||
{{#defineZone "policy-profile-top"}}
|
{{#defineZone "policy-profile-top"}}
|
||||||
<div class="row wr-device-board">
|
<div class="row wr-device-board">
|
||||||
<div class="col-lg-12 wr-secondary-bar">
|
<div class="col-lg-12 wr-secondary-bar">
|
||||||
@ -47,42 +46,9 @@
|
|||||||
<td class="sorting_1" style="padding:10px 15px;">Assigned Roles</td>
|
<td class="sorting_1" style="padding:10px 15px;">Assigned Roles</td>
|
||||||
<td id="policy-roles" style="padding:10px 15px;"></td>
|
<td id="policy-roles" style="padding:10px 15px;"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr role="row" id="roles-row" class="even">
|
|
||||||
<td class="sorting_1" style="padding:10px 15px;">Policy Type</td>
|
|
||||||
<td id="policy-type" style="padding:10px 15px;"></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{/defineZone}}
|
{{/defineZone}}
|
||||||
<div id="policy-corrective-actions-list" class="hidden">
|
|
||||||
<div style="background: #008cc4; color: #fff; padding: 10px; margin-bottom: 5px">
|
|
||||||
Corrective Actions
|
|
||||||
</div>
|
|
||||||
<div class="add-margin-top-4x">
|
|
||||||
<div id="policy-corrective-actions">
|
|
||||||
<table class="table table-responsive table-striped">
|
|
||||||
<tbody>
|
|
||||||
<tr role="row">
|
|
||||||
<td class="sorting_1" style="padding:10px 15px; width: 14%;">Action Type</td>
|
|
||||||
<td style="padding:10px 15px;">POLICY</td>
|
|
||||||
<td class="sorting_1" style="padding:10px 15px; width: 14%;">Policy ID</td>
|
|
||||||
<td id="corrective-action-type-policy-id" style="padding:10px 15px;"></td>
|
|
||||||
</tr>
|
|
||||||
<tr id="corrective-action-policy-id-missing-msg">
|
|
||||||
<td class="alert alert-danger" colspan="4" style="padding:10px 15px;">
|
|
||||||
<strong>
|
|
||||||
<i class="icon fw fw-error"></i>
|
|
||||||
Corrective policy having the above Policy ID has been updated to
|
|
||||||
a GENERAL policy or it has been deleted. Hence this policy will
|
|
||||||
not be applied till modified correctly.
|
|
||||||
</strong>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div style="background: #008cc4; color: #fff; padding: 10px; margin-bottom: 5px">Description
|
<div style="background: #008cc4; color: #fff; padding: 10px; margin-bottom: 5px">Description
|
||||||
</div>
|
</div>
|
||||||
<div class="add-margin-top-4x">
|
<div class="add-margin-top-4x">
|
||||||
|
|||||||
@ -45,7 +45,7 @@ function onRequest(context) {
|
|||||||
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
|
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
|
||||||
page["isCloud"] = devicemgtProps.isCloud;
|
page["isCloud"] = devicemgtProps.isCloud;
|
||||||
|
|
||||||
page["correctivePolicies"] = JSON.stringify(policyModule.getAllPoliciesByType("CORRECTIVE")["content"]);
|
/*page["correctivePolicies"] = JSON.stringify(policyModule.getAllPoliciesByType("CORRECTIVE")["content"]);*/
|
||||||
|
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ public interface PolicyDAO {
|
|||||||
* @return list of retrieved {@link CorrectiveAction}
|
* @return list of retrieved {@link CorrectiveAction}
|
||||||
* @throws PolicyManagerDAOException is thrown when there is an error in retrieving corrective actions to database
|
* @throws PolicyManagerDAOException is thrown when there is an error in retrieving corrective actions to database
|
||||||
*/
|
*/
|
||||||
List<CorrectiveAction> getCorrectiveActionsOfPolicy(int policyId, int featureId) throws PolicyManagerDAOException;
|
List<CorrectiveAction> getCorrectiveActionsOfPolicy(int policyId) throws PolicyManagerDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to update corrective actions of policy in the database based on the policy ID
|
* This method is used to update corrective actions of policy in the database based on the policy ID
|
||||||
|
|||||||
@ -290,24 +290,25 @@ public class PolicyDAOImpl implements PolicyDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CorrectiveAction> getCorrectiveActionsOfPolicy(int policyId, int featureId) throws PolicyManagerDAOException {
|
public List<CorrectiveAction> getCorrectiveActionsOfPolicy(int policyId) throws PolicyManagerDAOException {
|
||||||
try {
|
try {
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
String query = "SELECT " +
|
String query = "SELECT " +
|
||||||
"ACTION_TYPE, " +
|
"ACTION_TYPE, " +
|
||||||
"CORRECTIVE_POLICY_ID " +
|
"CORRECTIVE_POLICY_ID, " +
|
||||||
|
"FEATURE_ID "+
|
||||||
"FROM DM_POLICY_CORRECTIVE_ACTION " +
|
"FROM DM_POLICY_CORRECTIVE_ACTION " +
|
||||||
"WHERE POLICY_ID = ? AND FEATURE_ID = ?";
|
"WHERE POLICY_ID = ?";
|
||||||
try (PreparedStatement selectStmt = conn.prepareStatement(query)) {
|
try (PreparedStatement selectStmt = conn.prepareStatement(query)) {
|
||||||
List<CorrectiveAction> correctiveActions = new ArrayList<>();
|
List<CorrectiveAction> correctiveActions = new ArrayList<>();
|
||||||
selectStmt.setInt(1, policyId);
|
selectStmt.setInt(1, policyId);
|
||||||
selectStmt.setInt(2, featureId);
|
|
||||||
try (ResultSet rs = selectStmt.executeQuery()) {
|
try (ResultSet rs = selectStmt.executeQuery()) {
|
||||||
CorrectiveAction correctiveAction;
|
CorrectiveAction correctiveAction;
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
correctiveAction = new CorrectiveAction();
|
correctiveAction = new CorrectiveAction();
|
||||||
correctiveAction.setActionType(rs.getString("ACTION_TYPE"));
|
correctiveAction.setActionType(rs.getString("ACTION_TYPE"));
|
||||||
correctiveAction.setPolicyId(rs.getInt("CORRECTIVE_POLICY_ID"));
|
correctiveAction.setPolicyId(rs.getInt("CORRECTIVE_POLICY_ID"));
|
||||||
|
correctiveAction.setFeatureId(rs.getInt("FEATURE_ID"));
|
||||||
correctiveActions.add(correctiveAction);
|
correctiveActions.add(correctiveAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -90,7 +90,6 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Policy addPolicy(Policy policy) throws PolicyManagementException {
|
public Policy addPolicy(Policy policy) throws PolicyManagementException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PolicyManagementDAOFactory.beginTransaction();
|
PolicyManagementDAOFactory.beginTransaction();
|
||||||
if (policy.getProfile() != null && policy.getProfile().getProfileId() == 0) {
|
if (policy.getProfile() != null && policy.getProfile().getProfileId() == 0) {
|
||||||
@ -102,6 +101,10 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
|
|
||||||
profileDAO.addProfile(profile);
|
profileDAO.addProfile(profile);
|
||||||
featureDAO.addProfileFeatures(profile.getProfileFeaturesList(), profile.getProfileId());
|
featureDAO.addProfileFeatures(profile.getProfileFeaturesList(), profile.getProfileId());
|
||||||
|
}
|
||||||
|
policy = policyDAO.addPolicy(policy);
|
||||||
|
if (policy.getProfile() != null) {
|
||||||
|
Profile profile = policy.getProfile();
|
||||||
List<ProfileFeature> profileFeaturesList = profile.getProfileFeaturesList();
|
List<ProfileFeature> profileFeaturesList = profile.getProfileFeaturesList();
|
||||||
for (ProfileFeature profileFeature : profileFeaturesList) {
|
for (ProfileFeature profileFeature : profileFeaturesList) {
|
||||||
if (profileFeature.getCorrectiveActions() != null &&
|
if (profileFeature.getCorrectiveActions() != null &&
|
||||||
@ -115,7 +118,6 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
policy = policyDAO.addPolicy(policy);
|
|
||||||
|
|
||||||
if (policy.getUsers() != null) {
|
if (policy.getUsers() != null) {
|
||||||
policyDAO.addPolicyToUser(policy.getUsers(), policy);
|
policyDAO.addPolicyToUser(policy.getUsers(), policy);
|
||||||
@ -728,14 +730,17 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
try {
|
try {
|
||||||
Profile profile = profileManager.getProfile(policy.getProfileId());
|
Profile profile = profileManager.getProfile(policy.getProfileId());
|
||||||
policy.setProfile(profile);
|
policy.setProfile(profile);
|
||||||
|
|
||||||
PolicyManagementDAOFactory.openConnection();
|
PolicyManagementDAOFactory.openConnection();
|
||||||
|
List<CorrectiveAction> correctiveActionsOfPolicy = policyDAO
|
||||||
|
.getCorrectiveActionsOfPolicy(policyId);
|
||||||
for (ProfileFeature profileFeature : policy.getProfile().getProfileFeaturesList()) {
|
for (ProfileFeature profileFeature : policy.getProfile().getProfileFeaturesList()) {
|
||||||
List<CorrectiveAction> correctiveActionsOfPolicy = policyDAO
|
List<CorrectiveAction> correctiveActions = new ArrayList<>();
|
||||||
.getCorrectiveActionsOfPolicy(policyId, profileFeature.getId());
|
for (CorrectiveAction correctiveAction : correctiveActionsOfPolicy) {
|
||||||
if (correctiveActionsOfPolicy != null) {
|
if (correctiveAction.getFeatureId() == profileFeature.getId()) {
|
||||||
profileFeature.setCorrectiveActions(correctiveActionsOfPolicy);
|
correctiveActions.add(correctiveAction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
profileFeature.setCorrectiveActions(correctiveActions);
|
||||||
}
|
}
|
||||||
} catch (ProfileManagementException e) {
|
} catch (ProfileManagementException e) {
|
||||||
throw new PolicyManagementException("Error occurred while getting the profile related to policy ID (" +
|
throw new PolicyManagementException("Error occurred while getting the profile related to policy ID (" +
|
||||||
@ -1339,12 +1344,19 @@ public class PolicyManagerImpl implements PolicyManager {
|
|||||||
private void buildPolicyList(List<Policy> policyList, List<Profile> profileList)
|
private void buildPolicyList(List<Policy> policyList, List<Profile> profileList)
|
||||||
throws PolicyManagerDAOException, GroupManagementException {
|
throws PolicyManagerDAOException, GroupManagementException {
|
||||||
for (Policy policy : policyList) {
|
for (Policy policy : policyList) {
|
||||||
|
List<CorrectiveAction> correctiveActionsOfPolicy = policyDAO
|
||||||
|
.getCorrectiveActionsOfPolicy(policy.getId());
|
||||||
for (Profile profile : profileList) {
|
for (Profile profile : profileList) {
|
||||||
if (policy.getProfileId() == profile.getProfileId()) {
|
if (policy.getProfileId() == profile.getProfileId()) {
|
||||||
policy.setProfile(profile);
|
policy.setProfile(profile);
|
||||||
for (ProfileFeature profileFeature : profile.getProfileFeaturesList()) {
|
for (ProfileFeature profileFeature : profile.getProfileFeaturesList()) {
|
||||||
profileFeature.setCorrectiveActions(policyDAO
|
List<CorrectiveAction> correctiveActionList = new ArrayList<>();
|
||||||
.getCorrectiveActionsOfPolicy(policy.getId(), profileFeature.getId()));
|
for (CorrectiveAction correctiveAction : correctiveActionsOfPolicy) {
|
||||||
|
if (profileFeature.getId() == correctiveAction.getFeatureId()) {
|
||||||
|
correctiveActionList.add(correctiveAction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
profileFeature.setCorrectiveActions(correctiveActionList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,8 +65,8 @@ public final class PolicyManagementConstants {
|
|||||||
public static final String GENERAL_POLICY_TYPE = "GENERAL";
|
public static final String GENERAL_POLICY_TYPE = "GENERAL";
|
||||||
public static final String CORRECTIVE_POLICY_TYPE = "CORRECTIVE";
|
public static final String CORRECTIVE_POLICY_TYPE = "CORRECTIVE";
|
||||||
public static final String POLICY_CORRECTIVE_ACTION_TYPE = "POLICY";
|
public static final String POLICY_CORRECTIVE_ACTION_TYPE = "POLICY";
|
||||||
public static final String CORRECTIVE_POLICY_FEATURE_CODE = "CORRECTIVE_POLICY";
|
public static final String POLICY_FEATURE_CODE = "POLICY_ACTION";
|
||||||
public static final String CORRECTIVE_POLICY_LIST = "CORRECTIVE_ACTIONS";
|
public static final String POLICY_ACTIONS = "POLICY_ACTIONS";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Caller would reference the constants using PolicyManagementConstants.DEVICE_CONFIG_XML_NAME,
|
Caller would reference the constants using PolicyManagementConstants.DEVICE_CONFIG_XML_NAME,
|
||||||
|
|||||||
@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.util;
|
package org.wso2.carbon.policy.mgt.core.util;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
@ -140,51 +139,10 @@ public class PolicyManagerUtil {
|
|||||||
|
|
||||||
public static Operation transformPolicy(Policy policy) throws PolicyTransformException {
|
public static Operation transformPolicy(Policy policy) throws PolicyTransformException {
|
||||||
List<ProfileFeature> effectiveFeatures = policy.getProfile().getProfileFeaturesList();
|
List<ProfileFeature> effectiveFeatures = policy.getProfile().getProfileFeaturesList();
|
||||||
|
|
||||||
PolicyOperation policyOperation = new PolicyOperation();
|
PolicyOperation policyOperation = new PolicyOperation();
|
||||||
policyOperation.setEnabled(true);
|
policyOperation.setEnabled(true);
|
||||||
policyOperation.setType(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.POLICY);
|
policyOperation.setType(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.POLICY);
|
||||||
policyOperation.setCode(PolicyOperation.POLICY_OPERATION_CODE);
|
policyOperation.setCode(PolicyOperation.POLICY_OPERATION_CODE);
|
||||||
/*if (policy.getPolicyType() != null &&
|
|
||||||
PolicyManagementConstants.GENERAL_POLICY_TYPE.equals(policy.getPolicyType()) &&
|
|
||||||
policy.getCorrectiveActions() != null) {
|
|
||||||
for (CorrectiveAction correctiveAction : policy.getCorrectiveActions()) {
|
|
||||||
if (PolicyManagementConstants.POLICY_CORRECTIVE_ACTION_TYPE
|
|
||||||
.equalsIgnoreCase(correctiveAction.getActionType())) {
|
|
||||||
PolicyAdministratorPoint pap = new PolicyAdministratorPointImpl();
|
|
||||||
try {
|
|
||||||
Policy correctivePolicy = pap.getPolicy(correctiveAction.getPolicyId());
|
|
||||||
if (correctivePolicy == null || !PolicyManagementConstants.CORRECTIVE_POLICY_TYPE
|
|
||||||
.equalsIgnoreCase(correctivePolicy.getPolicyType() )) {
|
|
||||||
String msg = "No corrective policy was found for the policy " + policy.getPolicyName() +
|
|
||||||
" and policy ID " + policy.getId();
|
|
||||||
log.error(msg);
|
|
||||||
throw new PolicyTransformException(msg);
|
|
||||||
} else {
|
|
||||||
List<ProfileOperation> correctiveProfileOperations = createProfileOperations(
|
|
||||||
correctivePolicy.getProfile().getProfileFeaturesList());
|
|
||||||
ProfileFeature correctivePolicyFeature = new ProfileFeature();
|
|
||||||
correctivePolicyFeature.setProfileId(correctivePolicy.getProfileId());
|
|
||||||
correctivePolicyFeature.setContent(new Gson().toJson(correctiveProfileOperations));
|
|
||||||
correctivePolicyFeature.setDeviceType(correctivePolicy.getProfile().getDeviceType());
|
|
||||||
correctivePolicyFeature.setFeatureCode(
|
|
||||||
PolicyManagementConstants.CORRECTIVE_POLICY_FEATURE_CODE);
|
|
||||||
correctivePolicyFeature.setId(correctivePolicy.getId());
|
|
||||||
effectiveFeatures.add(correctivePolicyFeature);
|
|
||||||
}
|
|
||||||
} catch (PolicyManagementException e) {
|
|
||||||
String msg = "Error occurred while retrieving corrective policy for policy " +
|
|
||||||
policy.getPolicyName() + " and policy ID " + policy.getId();
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new PolicyTransformException(msg, e);
|
|
||||||
}
|
|
||||||
// Currently only supported POLICY corrective action type so the break is added. This should be
|
|
||||||
// removed when we start supporting other corrective action types
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
policyOperation.setProfileOperations(createProfileOperations(effectiveFeatures));
|
policyOperation.setProfileOperations(createProfileOperations(effectiveFeatures));
|
||||||
if (policy.getPolicyType() != null &&
|
if (policy.getPolicyType() != null &&
|
||||||
PolicyManagementConstants.GENERAL_POLICY_TYPE.equals(policy.getPolicyType())) {
|
PolicyManagementConstants.GENERAL_POLICY_TYPE.equals(policy.getPolicyType())) {
|
||||||
@ -197,88 +155,38 @@ public class PolicyManagerUtil {
|
|||||||
private static void setCorrectiveActions(List<ProfileFeature> features,
|
private static void setCorrectiveActions(List<ProfileFeature> features,
|
||||||
PolicyOperation policyOperation, Policy policy)
|
PolicyOperation policyOperation, Policy policy)
|
||||||
throws PolicyTransformException {
|
throws PolicyTransformException {
|
||||||
ProfileOperation correctiveOperations = new ProfileOperation();
|
ProfileOperation correctiveProfileOperation = new ProfileOperation();
|
||||||
correctiveOperations.setCode(PolicyManagementConstants.CORRECTIVE_POLICY_LIST);
|
correctiveProfileOperation.setCode(PolicyManagementConstants.POLICY_ACTIONS);
|
||||||
for (ProfileFeature effectiveFeature : features) {
|
Set<Integer> correctivePolicyIdSet = new HashSet<>();
|
||||||
if (effectiveFeature.getCorrectiveActions() != null) {
|
try {
|
||||||
for (CorrectiveAction correctiveAction : effectiveFeature.getCorrectiveActions()) {
|
for (ProfileFeature feature : features) {
|
||||||
|
List<CorrectiveAction> correctiveActions = feature.getCorrectiveActions();
|
||||||
|
for (CorrectiveAction correctiveAction : correctiveActions) {
|
||||||
if (PolicyManagementConstants.POLICY_CORRECTIVE_ACTION_TYPE
|
if (PolicyManagementConstants.POLICY_CORRECTIVE_ACTION_TYPE
|
||||||
.equalsIgnoreCase(correctiveAction.getActionType())) {
|
.equals(correctiveAction.getActionType())) {
|
||||||
|
correctivePolicyIdSet.add(correctiveAction.getPolicyId());
|
||||||
PolicyAdministratorPoint pap = new PolicyAdministratorPointImpl();
|
}
|
||||||
try {
|
//Add check for another action type in future implementation
|
||||||
Policy correctivePolicy = pap.getPolicy(correctiveAction.getPolicyId());
|
}
|
||||||
if (correctivePolicy == null || !PolicyManagementConstants
|
}
|
||||||
.CORRECTIVE_POLICY_TYPE.equalsIgnoreCase(correctivePolicy
|
PolicyAdministratorPoint pap = new PolicyAdministratorPointImpl();
|
||||||
.getPolicyType())) {
|
List<Policy> allCorrectivePolicies = pap
|
||||||
String msg = "No corrective policy was found for the policy " +
|
.getPolicies(PolicyManagementConstants.CORRECTIVE_POLICY_TYPE);
|
||||||
policy.getPolicyName() + " and policy ID " + policy.getId();
|
idLoop:
|
||||||
log.error(msg);
|
for (Integer policyId : correctivePolicyIdSet) {
|
||||||
throw new PolicyTransformException(msg);
|
for (Policy correctivePolicy : allCorrectivePolicies) {
|
||||||
} else {
|
if (policyId == correctivePolicy.getId()) {
|
||||||
createCorrectiveProfileOperations(correctivePolicy, correctiveOperations);
|
createCorrectiveProfileOperations(correctivePolicy, correctiveProfileOperation);
|
||||||
policyOperation.getProfileOperations().add(correctiveOperations);
|
policyOperation.getProfileOperations().add(correctiveProfileOperation);
|
||||||
}
|
continue idLoop;
|
||||||
} catch (PolicyManagementException e) {
|
|
||||||
String msg = "Error occurred while retrieving corrective policy for policy " +
|
|
||||||
policy.getPolicyName() + " and policy ID " + policy.getId();
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new PolicyTransformException(msg, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*for (CorrectiveAction correctiveAction : effectiveFeature.getCorrectiveActions()) {
|
|
||||||
if (PolicyManagementConstants.POLICY_CORRECTIVE_ACTION_TYPE
|
|
||||||
.equalsIgnoreCase(correctiveAction.getActionType())) {
|
|
||||||
PolicyAdministratorPoint pap = new PolicyAdministratorPointImpl();
|
|
||||||
try {
|
|
||||||
Policy correctivePolicy = pap.getPolicy(correctiveAction.getPolicyId());
|
|
||||||
if (correctivePolicy == null || !PolicyManagementConstants
|
|
||||||
.CORRECTIVE_POLICY_TYPE.equalsIgnoreCase(correctivePolicy
|
|
||||||
.getPolicyType() )) {
|
|
||||||
String msg = "No corrective policy was found for the policy " +
|
|
||||||
policy.getPolicyName() + " and policy ID " + policy.getId();
|
|
||||||
log.error(msg);
|
|
||||||
throw new PolicyTransformException(msg);
|
|
||||||
} else {
|
|
||||||
*//*List<ProfileOperation> correctiveProfileOperations =
|
|
||||||
createProfileOperations();*//*
|
|
||||||
createCorrectiveProfileOperations(correctivePolicy.getProfile()
|
|
||||||
.getProfileFeaturesList());
|
|
||||||
|
|
||||||
|
|
||||||
ProfileFeature correctivePolicyFeature = new ProfileFeature();
|
|
||||||
correctivePolicyFeature.setProfileId(correctivePolicy.getProfileId());
|
|
||||||
correctivePolicyFeature.setContent(new Gson()
|
|
||||||
.toJson(correctiveProfileOperations));
|
|
||||||
correctivePolicyFeature.setDeviceType(correctivePolicy
|
|
||||||
.getProfile().getDeviceType());
|
|
||||||
correctivePolicyFeature.setFeatureCode(
|
|
||||||
PolicyManagementConstants.CORRECTIVE_POLICY_FEATURE_CODE);
|
|
||||||
correctivePolicyFeature.setId(correctivePolicy.getId());
|
|
||||||
effectiveFeatures.add(correctivePolicyFeature);
|
|
||||||
}
|
|
||||||
} catch (PolicyManagementException e) {
|
|
||||||
String msg = "Error occurred while retrieving corrective policy for policy " +
|
|
||||||
policy.getPolicyName() + " and policy ID " + policy.getId();
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new PolicyTransformException(msg, e);
|
|
||||||
}
|
|
||||||
// Currently only supported POLICY corrective action type so the break
|
|
||||||
// is added. This should be removed when we start supporting other
|
|
||||||
// corrective action types
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} catch (PolicyManagementException e) {
|
||||||
|
String msg = "Error occurred while retrieving corrective policy for policy " +
|
||||||
|
policy.getPolicyName() + " and policy ID " + policy.getId();
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new PolicyTransformException(msg, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,18 +194,21 @@ public class PolicyManagerUtil {
|
|||||||
ProfileOperation correctiveOperationList) {
|
ProfileOperation correctiveOperationList) {
|
||||||
ProfileOperation profileOperation = new ProfileOperation();
|
ProfileOperation profileOperation = new ProfileOperation();
|
||||||
profileOperation.setId(correctivePolicy.getId());
|
profileOperation.setId(correctivePolicy.getId());
|
||||||
profileOperation.setCode(PolicyManagementConstants.CORRECTIVE_POLICY_FEATURE_CODE);
|
profileOperation.setCode(PolicyManagementConstants.POLICY_FEATURE_CODE);
|
||||||
profileOperation.setEnabled(true);
|
profileOperation.setEnabled(true);
|
||||||
profileOperation.setStatus(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Status.PENDING);
|
profileOperation.setStatus(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Status.PENDING);
|
||||||
profileOperation.setType(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.PROFILE);
|
profileOperation.setType(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.PROFILE);
|
||||||
String correctivePayload =(String) correctiveOperationList.getPayLoad();
|
|
||||||
if (correctivePayload == null) {
|
|
||||||
correctivePayload = "";
|
|
||||||
}
|
|
||||||
List<ProfileOperation> profileOperations = createProfileOperations(correctivePolicy
|
List<ProfileOperation> profileOperations = createProfileOperations(correctivePolicy
|
||||||
.getProfile().getProfileFeaturesList());
|
.getProfile().getProfileFeaturesList());
|
||||||
String payload = new Gson().toJson(profileOperations);
|
profileOperation.setPayLoad(profileOperations);
|
||||||
correctiveOperationList.setPayLoad(correctivePayload.concat(payload));
|
List<ProfileOperation> payLoad;
|
||||||
|
if (correctiveOperationList.getPayLoad() != null) {
|
||||||
|
payLoad = (List<ProfileOperation>) correctiveOperationList.getPayLoad();
|
||||||
|
} else {
|
||||||
|
payLoad = new ArrayList<>();
|
||||||
|
}
|
||||||
|
payLoad.add(profileOperation);
|
||||||
|
correctiveOperationList.setPayLoad(payLoad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -307,10 +218,14 @@ public class PolicyManagerUtil {
|
|||||||
ProfileOperation profileOperation = new ProfileOperation();
|
ProfileOperation profileOperation = new ProfileOperation();
|
||||||
profileOperation.setCode(feature.getFeatureCode());
|
profileOperation.setCode(feature.getFeatureCode());
|
||||||
profileOperation.setEnabled(true);
|
profileOperation.setEnabled(true);
|
||||||
|
profileOperation.setId(feature.getId());
|
||||||
profileOperation.setStatus(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Status.PENDING);
|
profileOperation.setStatus(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Status.PENDING);
|
||||||
profileOperation.setType(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.PROFILE);
|
profileOperation.setType(org.wso2.carbon.device.mgt.common.operation.mgt.Operation.Type.PROFILE);
|
||||||
profileOperation.setPayLoad(feature.getContent());
|
profileOperation.setPayLoad(feature.getContent());
|
||||||
for (CorrectiveAction correctiveAction : feature.getCorrectiveActions()) {
|
for (CorrectiveAction correctiveAction : feature.getCorrectiveActions()) {
|
||||||
|
if (profileOperation.getCorrectiveActionIds() == null) {
|
||||||
|
profileOperation.setCorrectiveActionIds(new ArrayList<>());
|
||||||
|
}
|
||||||
profileOperation.getCorrectiveActionIds().add(correctiveAction.getPolicyId());
|
profileOperation.getCorrectiveActionIds().add(correctiveAction.getPolicyId());
|
||||||
}
|
}
|
||||||
profileOperations.add(profileOperation);
|
profileOperations.add(profileOperation);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user