diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java
index ee4f6071b7..163ac64711 100644
--- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java
+++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/dao/DeviceTypePluginDAO.java
@@ -67,6 +67,7 @@ public class DeviceTypePluginDAO {
if (resultSet.next()) {
device = new Device();
+ device.setDeviceIdentifier(deviceId);
if (log.isDebugEnabled()) {
log.debug(deviceId + " data has been fetched from " + deviceDAODefinition.getDeviceTableName() +
" database.");
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
index 317f875b1c..626203c304 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
@@ -220,6 +220,12 @@ public interface DeviceManagementProviderService {
boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException;
+ /**
+ * Returns the device of specified id.
+ * @param deviceId device Id
+ * @return Device returns null when device is not avaialble.
+ * @throws DeviceManagementException
+ */
Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException;
Device getDevice(DeviceIdentifier deviceId, Date since) throws DeviceManagementException;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
index 3f60cc89e0..b183ada935 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
@@ -825,9 +825,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
DeviceManagementDAOFactory.openConnection();
device = deviceDAO.getDevice(deviceId, this.getTenantId());
if (device == null) {
+ String msg = "No device is found upon the type '" + deviceId.getType() + "' and id '" +
+ deviceId.getId() + "'";
if (log.isDebugEnabled()) {
- log.debug("No device is found upon the type '" + deviceId.getType() + "' and id '" +
- deviceId.getId() + "'");
+ log.debug(msg);
}
return null;
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.hbs
index 09e414aa7b..eb97eb8623 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.hbs
@@ -299,6 +299,9 @@
data-current="policy-platform"
data-next="policy-profile"
data-platform="{{name}}"
+ data-template="{{template}}"
+ data-script="{{script}}"
+ data-style="{{style}}"
data-validate="false">
{{label}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
index f467aa9222..1b945e5e7c 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
@@ -43,10 +43,25 @@ function onRequest(context) {
if (configs && configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]) {
deviceTypeLabel = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY];
}
- var policyWizard = new File("/app/units/" + utility.getTenantedDeviceUnitName(deviceType, "policy-wizard"));
- if(policyWizard.isExists()){
+ var policyWizardSrc = "/app/units/" + utility.getTenantedDeviceUnitName(deviceType, "policy-wizard");
+ if (new File(policyWizardSrc).isExists()) {
content["icon"] = utility.getDeviceThumb(deviceType);
content["label"] = deviceTypeLabel;
+ var policyOperationsTemplateSrc = policyWizardSrc + "/public/templates/" + deviceType + "-policy-operations.hbs";
+ if (new File(policyOperationsTemplateSrc).isExists()) {
+ content["template"] = "/public/cdmf.unit.device.type." + deviceType +
+ ".policy-wizard/templates/" + deviceType + "-policy-operations.hbs";
+ }
+ var policyOperationsScriptSrc = policyWizardSrc + "/public/js/" + deviceType + "-policy-operations.js";
+ if (new File(policyOperationsScriptSrc).isExists()) {
+ content["script"] = "/public/cdmf.unit.device.type." + deviceType +
+ ".policy-wizard/js/" + deviceType + "-policy-operations.js";;
+ }
+ var policyOperationsStylesSrc = policyWizardSrc + "/public/css/" + deviceType + "-policy-operations.css";
+ if (new File(policyOperationsStylesSrc).isExists()) {
+ content["style"] = "/public/cdmf.unit.device.type." + deviceType +
+ ".policy-wizard/css/" + deviceType + "-policy-operations.css";;
+ }
types["types"].push(content);
}
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js
index d7d7b99f14..63807df7d9 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js
@@ -18,7 +18,6 @@
var stepForwardFrom = {};
var stepBackFrom = {};
var policy = {};
-var configuredOperations = [];
var validateInline = {};
var clearInline = {};
var validateStep = {};
@@ -139,52 +138,45 @@ stepForwardFrom["policy-platform"] = function (actionButton) {
$("#policy-profile-page-wizard-title").text("ADD " + policy["platform"] + " POLICY");
var deviceType = policy["platform"];
- var policyOperationsTemplateSrc = context + '/public/cdmf.unit.device.type.' + deviceType +
- '.policy-wizard/templates/' + deviceType + '-policy-operations.hbs';
- var policyOperationsScriptSrc = context + '/public/cdmf.unit.device.type.' + deviceType +
- '.policy-wizard/js/' + deviceType + '-policy-operations.js';
- var policyOperationsStylesSrc = context + '/public/cdmf.unit.device.type.' + deviceType +
- '.policy-wizard/css/' + deviceType + '-policy-operations.css';
+ var policyOperationsTemplateSrc = $(actionButton).data("template");
+ var policyOperationsScriptSrc = $(actionButton).data("script");
+ var policyOperationsStylesSrc = $(actionButton).data("style");
var policyOperationsTemplateCacheKey = deviceType + '-policy-operations';
- $.isResourceExists(policyOperationsTemplateSrc, function (status) {
- if (status) {
- $.template(policyOperationsTemplateCacheKey, policyOperationsTemplateSrc, function (template) {
- var content = template();
- $("#device-type-policy-operations").html(content).removeClass("hidden");
- $(".policy-platform").addClass("hidden");
- });
-
- $.isResourceExists(policyOperationsScriptSrc, function (status) {
- if (status) {
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.src = policyOperationsScriptSrc;
- $(".wr-advance-operations").prepend(script);
- }
- });
-
- $.isResourceExists(policyOperationsStylesSrc, function (status) {
- if (status) {
- var style = document.createElement('link');
- style.type = 'text/css';
- style.rel = 'stylesheet';
- style.href = policyOperationsStylesSrc;
- $(".wr-advance-operations").prepend(style);
- }
- });
- } else {
- $("#generic-policy-operations").removeClass("hidden");
- }
- $(".wr-advance-operations-init").addClass("hidden");
- });
+ if (policyOperationsTemplateSrc) {
+ $.template(policyOperationsTemplateCacheKey, context + policyOperationsTemplateSrc, function (template) {
+ var content = template();
+ $("#device-type-policy-operations").html(content).removeClass("hidden");
+ $(".policy-platform").addClass("hidden");
+ });
+ } else {
+ $("#generic-policy-operations").removeClass("hidden");
+ }
+ if (policyOperationsScriptSrc) {
+ var script = document.createElement('script');
+ script.type = 'text/javascript';
+ script.src = context + policyOperationsScriptSrc;
+ $(".wr-advance-operations").prepend(script);
+ }
+ if (policyOperationsStylesSrc) {
+ var style = document.createElement('link');
+ style.type = 'text/css';
+ style.rel = 'stylesheet';
+ style.href = context + policyOperationsStylesSrc;
+ $(".wr-advance-operations").prepend(style);
+ }
+ $(".wr-advance-operations-init").addClass("hidden");
};
/**
* Forward action of policy profile page. Generates policy profile payload.
*/
stepForwardFrom["policy-profile"] = function () {
- policy["profile"] = operationModule.generateProfile(policy["platform"], configuredOperations);
+ /*
+ generatePolicyProfile() function should be implemented in plugin side and should include the logic to build the
+ policy profile object.
+ */
+ policy["profile"] = generatePolicyProfile();
// updating next-page wizard title with selected platform
$("#policy-criteria-page-wizard-title").text("ADD " + policy["platform"] + " POLICY");
};
@@ -193,8 +185,11 @@ stepForwardFrom["policy-profile"] = function () {
* Backward action of policy profile page. Moves back to platform selection step.
*/
stepBackFrom["policy-profile"] = function () {
- // reinitialize configuredOperations
- configuredOperations = [];
+ /*
+ resetPolicyProfile() function should be implemented in plugin side and should include the logic to reset the policy
+ profile object.
+ */
+ resetPolicyProfile();
};
/**
@@ -370,18 +365,12 @@ stepForwardFrom["policy-naming"] = function () {
};
var savePolicy = function (policy, isActive, serviceURL) {
- var profilePayloads = [];
- // traverses key by key in policy["profile"]
- var key;
- for (key in policy["profile"]) {
- if (policy["profile"].hasOwnProperty(key)) {
- profilePayloads.push({
- "featureCode": key,
- "deviceType": policy["platform"],
- "content": policy["profile"][key]
- });
- }
- }
+ /*
+ generateProfileFeaturesList() should be implemented in the plugin side and should include logic to build the
+ profilePayloads array which contains objects, {featureCode:"value", deviceType:"value", content:"value"}.
+ policy["profile"] object will be available for the method which returns from the generatePolicyProfile() function.
+ */
+ var profilePayloads = generateProfileFeaturesList();
$.each(profilePayloads, function (i, item) {
$.each(item.content, function (key, value) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/public/js/policy-edit.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/public/js/policy-edit.js
index ce37d8d6a9..f06ae43796 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/public/js/policy-edit.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.edit/public/js/policy-edit.js
@@ -20,7 +20,6 @@ var validateStep = {};
var skipStep = {};
var stepForwardFrom = {};
var stepBackFrom = {};
-var configuredOperations = [];
var policy = {};
var currentlyEffected = {};
@@ -200,9 +199,11 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
script.type = 'text/javascript';
script.src = policyOperationsScriptSrc;
$(".wr-advance-operations").prepend(script);
- var configuredOperations = operationModule.populateProfile(policy["platform"],
- policyPayloadObj["profile"]["profileFeaturesList"]);
- polulateProfileOperations(configuredOperations);
+ /*
+ This method should be implemented in the relevant plugin side and should include the logic to
+ populate the policy profile in the plugin specific UI.
+ */
+ polulateProfileOperations(policyPayloadObj["profile"]["profileFeaturesList"]);
}
});
});
@@ -227,7 +228,11 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
* Forward action of policy profile page. Generates policy profile payload.
*/
stepForwardFrom["policy-profile"] = function () {
- policy["profile"] = operationModule.generateProfile(policy["platform"], configuredOperations);
+ /*
+ generatePolicyProfile() function should be implemented in plugin side and should include the logic to build the
+ policy profile object.
+ */
+ policy["profile"] = generatePolicyProfile();
// updating next-page wizard title with selected platform
$("#policy-criteria-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]);
};
@@ -415,19 +420,12 @@ var getParameterByName = function (name) {
};
var updatePolicy = function (policy, state) {
- var profilePayloads = [];
- // traverses key by key in policy["profile"]
- var key;
- for (key in policy["profile"]) {
-
- if (policy["profile"].hasOwnProperty(key)) {
- profilePayloads.push({
- "featureCode": key,
- "deviceType": policy["platform"],
- "content": policy["profile"][key]
- });
- }
- }
+ /*
+ generateProfileFeaturesList() should be implemented in the plugin side and should include logic to build the
+ profilePayloads array which contains objects, {featureCode:"value", deviceType:"value", content:"value"}.
+ policy["profile"] object will be available for the method which returns from the generatePolicyProfile() function.
+ */
+ var profilePayloads = generateProfileFeaturesList();
$.each(profilePayloads, function (i, item) {
$.each(item.content, function (key, value) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js
index b7bea7684f..2d045b864f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js
@@ -86,9 +86,11 @@ var displayPolicy = function (policyPayloadObj) {
script.type = 'text/javascript';
script.src = policyOperationsScriptSrc;
$(".wr-advance-operations").prepend(script);
- var previouslyConfiguredOperations = operationModule.populateProfile(policy["platform"],
- policyPayloadObj["profile"]["profileFeaturesList"]);
- polulateProfileOperations(previouslyConfiguredOperations);
+ /*
+ This method should be implemented in the relevant plugin side and should include the logic to
+ populate the policy profile in the plugin specific UI.
+ */
+ polulateProfileOperations(policyPayloadObj["profile"]["profileFeaturesList"]);
}
});
});
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.wizard/public/js/policy-create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.wizard/public/js/policy-create.js
deleted file mode 100644
index fd2bf3ff4f..0000000000
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.wizard/public/js/policy-create.js
+++ /dev/null
@@ -1,534 +0,0 @@
-/*
- *
- * WSO2 Inc. licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-var validateStep = {};
-var stepForwardFrom = {};
-var stepBackFrom = {};
-var policy = {};
-var configuredOperations = [];
-var validateInline = {};
-var clearInline = {};
-
-var enableInlineError = function (inputField, errorMsg, errorSign) {
- var fieldIdentifier = "#" + inputField;
- var errorMsgIdentifier = "#" + inputField + " ." + errorMsg;
- var errorSignIdentifier = "#" + inputField + " ." + errorSign;
-
- if (inputField) {
- $(fieldIdentifier).addClass(" has-error has-feedback");
- }
-
- if (errorMsg) {
- $(errorMsgIdentifier).removeClass(" hidden");
- }
-
- if (errorSign) {
- $(errorSignIdentifier).removeClass(" hidden");
- }
-};
-
-var disableInlineError = function (inputField, errorMsg, errorSign) {
- var fieldIdentifier = "#" + inputField;
- var errorMsgIdentifier = "#" + inputField + " ." + errorMsg;
- var errorSignIdentifier = "#" + inputField + " ." + errorSign;
-
- if (inputField) {
- $(fieldIdentifier).removeClass(" has-error has-feedback");
- }
-
- if (errorMsg) {
- $(errorMsgIdentifier).addClass(" hidden");
- }
-
- if (errorSign) {
- $(errorSignIdentifier).addClass(" hidden");
- }
-};
-
-/**
- *clear inline validation messages.
- */
-clearInline["policy-name"] = function () {
- disableInlineError("policyNameField", "nameEmpty", "nameError");
-};
-
-
-/**
- * Validate if provided policy name is valid against RegEx configures.
- */
-validateInline["policy-name"] = function () {
- var policyName = $("input#policy-name-input").val();
- if (policyName && inputIsValidAgainstLength(policyName, 1, 30)) {
- disableInlineError("policyNameField", "nameEmpty", "nameError");
- } else {
- enableInlineError("policyNameField", "nameEmpty", "nameError");
- }
-};
-
-$("#policy-name-input").focus(function(){
- clearInline["policy-name"]();
-}).blur(function(){
- validateInline["policy-name"]();
-});
-
-stepForwardFrom["policy-platform"] = function (actionButton) {
- policy["platform"] = $(actionButton).data("platform");
- policy["platformId"] = $(actionButton).data("platform-type");
- // updating next-page wizard title with selected platform
- $("#policy-profile-page-wizard-title").text("ADD " + policy["platform"] + " POLICY");
-
- var deviceType = policy["platform"];
- var policyOperationsTemplateSrc = context + '/public/cdmf.unit.device.type.' + deviceType +
- '.policy-wizard/templates/' + deviceType + '-policy-operations.hbs';
- var policyOperationsScriptSrc = context + '/public/cdmf.unit.device.type.' + deviceType +
- '.policy-wizard/js/' + deviceType + '-policy-operations.js';
- var policyOperationsStylesSrc = context + '/public/cdmf.unit.device.type.' + deviceType +
- '.policy-wizard/css/' + deviceType + '-policy-operations.css';
- var policyOperationsTemplateCacheKey = deviceType + '-policy-operations';
-
- $.isResourceExists(policyOperationsTemplateSrc, function (status) {
- if (status) {
- $.template(policyOperationsTemplateCacheKey, policyOperationsTemplateSrc, function (template) {
- var content = template();
- $(".wr-advance-operations").html(content);
- $(".policy-platform").addClass("hidden");
- });
- }
- });
-
- $.isResourceExists(policyOperationsScriptSrc, function (status) {
- if (status) {
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.src = policyOperationsScriptSrc;
- $(".wr-advance-operations").prepend(script);
- }
- });
-
- $.isResourceExists(policyOperationsStylesSrc, function (status) {
- if (status) {
- var style = document.createElement('link');
- style.type = 'text/css';
- style.rel = 'stylesheet';
- style.href = policyOperationsStylesSrc;
- $(".wr-advance-operations").prepend(style);
- }
- });
-};
-
-stepForwardFrom["policy-profile"] = function () {
- policy["profile"] = operationModule.generateProfile(policy["platform"], configuredOperations);
- // updating next-page wizard title with selected platform
- $("#policy-criteria-page-wizard-title").text("ADD " + policy["platform"] + " POLICY");
-};
-
-stepBackFrom["policy-profile"] = function () {
- // reinitialize configuredOperations
- configuredOperations = [];
- // clearing already-loaded platform specific hidden-operations html content from the relevant div
- // so that, the wrong content would not be shown at the first glance, in case
- // the user selects a different platform
- $(".wr-advance-operations").html(
- "