'
+ value[i].type + ' | '
- + value[i].version + ' | ';
+ + value[i].version + ''
+ + '' + enrollmentAppInstallInput + ' | '
+ + '' + installGooglePolicy + ' | '
+ +'';
$('[data-add-form-container="#enrollment-app-install-grid"]').append(content);
}
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/configuration.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/configuration.hbs
index 63018835c..84e23a02b 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/configuration.hbs
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/configuration.hbs
@@ -201,12 +201,92 @@
-
+
+
+
+
+ Android For Work Configurations
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unenroll from EMM
+
+
+
+
+
+
+
+
+
+
+
Do you really want to unenroll? This cannot be undone.
+
+
+
+
+
+
+
+
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/public/js/platform-configuration.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/public/js/platform-configuration.js
index 0faae04ee..48069ebec 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/public/js/platform-configuration.js
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.platform.configuration/public/js/platform-configuration.js
@@ -92,6 +92,16 @@ var kioskConfigs = {
"serverIP" : "android.app.extra.serverIp"
};
+function getParameterByName(name, url) {
+ if (!url) url = window.location.href;
+ name = name.replace(/[\[\]]/g, '\\$&');
+ var regex = new RegExp('[?&]' + name + '(=([^]*)|&|#|$)'),
+ results = regex.exec(url);
+ if (!results) return null;
+ if (!results[2]) return '';
+ return decodeURIComponent(results[2].replace(/\+/g, ' '));
+}
+
$(document).ready(function () {
$("#fcm-inputs").hide();
tinymce.init({
@@ -109,6 +119,12 @@ $(document).ready(function () {
var androidConfigAPI = "/api/device-mgt/android/v1.0/configuration";
+ var enterpriseSuccess = getParameterByName('enterprise-success');
+ if (enterpriseSuccess) {
+ $("#config-save-form").addClass("hidden");
+ $("#record-created-msg").removeClass("hidden");
+ }
+
/**
* Following requests would execute
* on page load event of platform configuration page in WSO2 EMM Console.
@@ -152,11 +168,16 @@ $(document).ready(function () {
$("input#android-kiosk-config-download-url").val(config.value);
} else if (config.name === kioskConfigs["skipEncryption"]) {
$("#android-kiosk-config-encryption").val(config.value);
+ } else if (config.name === "esa") {
+ $("#afw-esa").val(config.value);
+ } else if (config.name === "enterpriseId") {
+ $("#afw-enterprise-id").val(config.value);
} else if (config.name === kioskConfigs["defaultOwnership"]) {
$("#android-kiosk-config-defaultOwner").val(config.value);
} else if (config.name === kioskConfigs["serverIP"]) {
$("#android-kiosk-config-server-ip").val(config.value);
}
+
}
}
}, function (data) {
@@ -191,6 +212,8 @@ $(document).ready(function () {
var androidLicense = tinyMCE.activeEditor.getContent();
var errorMsgWrapper = "#android-config-error-msg";
var errorMsg = "#android-config-error-msg span";
+ var esa = $("input#afw-esa").val();
+ var enterpriseId = $("input#afw-enterprise-id").val();
// KIOSK configs
var adminComponentName = $("input#android-kiosk-config-admin-component").val();
@@ -289,6 +312,18 @@ $(document).ready(function () {
"contentType": "text"
};
+ var esa = {
+ "name": "esa",
+ "value": esa,
+ "contentType": "text"
+ };
+
+ var enterpriseId = {
+ "name": "enterpriseId",
+ "value": enterpriseId,
+ "contentType": "text"
+ };
+
var kioskDefaultOwner = {
"name": kioskConfigs["defaultOwnership"],
"value": defaultOwner,
@@ -312,6 +347,8 @@ $(document).ready(function () {
configList.push(kioskWifiSSID);
configList.push(kioskWifiPassword);
configList.push(kioskWifiSecurity);
+ configList.push(esa);
+ configList.push(enterpriseId);
configList.push(kioskDefaultOwner);
configList.push(kioskServerIp);
@@ -341,8 +378,136 @@ $(document).ready(function () {
$(errorMsg).text("An unexpected error occurred.");
}
$(errorMsgWrapper).removeClass("hidden");
+ $(window).scrollTop(0);
}
);
}
});
-});
\ No newline at end of file
+
+ function getSignupUrl(serverUrl, emmToken) {
+
+ var appContext = window.location.href;// mgt:9443 call to jaggery API
+ var tokenURL = appContext.replace("platform-configuration", "api/enterprise/token");
+ var callbackURL = appContext.replace("platform-configuration", "api/enterprise/enroll-complete");
+
+ var requestData = {};
+ requestData.externalToken = emmToken;
+ requestData.endpoint = serverUrl + "/api/android-for-work/v1.0/google/enterprise/signup-url";
+ requestData.callbackURL = callbackURL;
+
+ $.ajax({
+ type: "POST",
+ url: tokenURL,
+ data: JSON.stringify(requestData),
+ contentType: "application/json",
+ success: function(response) {
+ window.location.replace(response.signupURL);
+ },
+ error: function(data) {
+ var errorMsgWrapper = "#android-config-error-msg";
+ var errorMsg = "#android-config-error-msg span";
+ if (data.status == 500) {
+ $(errorMsg).text("Exception occurred at backend.");
+ } else if (data.status == 403) {
+ $(errorMsg).text("Action was not permitted.");
+ } else {
+ $(errorMsg).text("An unexpected error occurred.");
+ }
+ $(errorMsgWrapper).removeClass("hidden");
+ $(window).scrollTop(0);
+ },
+ dataType: 'json'
+ });
+ }
+
+ $("button#afw-configure").click(function() {
+ var serverDetails = $("input#afw-server-details").val();
+ var emmToken = $("input#afw-backend-token").val();
+ getSignupUrl(serverDetails, emmToken)
+ });
+
+
+ var modalPopup = ".modal";
+ var modalPopupContainer = modalPopup + " .modal-content";
+ var modalPopupContent = modalPopup + " .modal-content";
+ var body = "body";
+
+ function unenroll(serverUrl, emmToken) {
+
+ var appContext = window.location.href;
+ var unenrollURL = appContext.replace("platform-configuration", "api/enterprise/unenroll");
+
+ var requestData = {};
+ requestData.externalToken = emmToken;
+ requestData.endpoint = serverUrl;
+
+ $.ajax({
+ type: "PUT",
+ url: unenrollURL,
+ data: JSON.stringify(requestData),
+ contentType: "application/json",
+ success: function(response) {
+ $("input#afw-server-details").val("") ;
+ $("input#afw-backend-token").val("");
+ $("input#afw-esa").val("");
+ $("input#afw-enterprise-id").val("");
+ },
+ error: function(data) {
+ var errorMsgWrapper = "#android-config-error-msg";
+ var errorMsg = "#android-config-error-msg span";
+ if (data.status == 200) {
+ $(errorMsg).text("hari.");
+ }
+ else if (data.status == 500) {
+ $(errorMsg).text("Exception occurred at backend.");
+ } else if (data.status == 403) {
+ $(errorMsg).text("Action was not permitted.");
+ } else {
+ $(errorMsg).text("An unexpected error occurred.");
+ }
+ $(errorMsgWrapper).removeClass("hidden");
+ $(window).scrollTop(0);
+ },
+ dataType: 'text'
+ });
+ }
+
+
+ $("button#afw-unenroll").click(function() {
+
+ $(modalPopupContent).html($('#remove-unenroll-modal-content').html());
+ showPopup();
+
+ $("a#remove-unenroll-yes-link").click(function () {
+ var serverDetails = $("input#afw-server-details").val() + "/api/device-mgt/android/v1.0/enterprise/324/unenroll";
+ var emmToken = $("input#afw-backend-token").val();
+ unenroll(serverDetails, emmToken);
+ hidePopup();
+ });
+
+ $("a#remove-unenroll-cancel-link").click(function () {
+ hidePopup();
+ });
+
+ });
+
+ /*
+ * show popup function.
+ */
+ function showPopup() {
+ $(modalPopup).modal('show');
+ }
+
+ /*
+ * hide popup function.
+ */
+ function hidePopup() {
+ $(modalPopupContent).html("");
+ $(modalPopupContent).removeClass("operation-data");
+ $(modalPopup).modal('hide');
+ $('body').removeClass('modal-open').css('padding-right', '0px');
+ $('.modal-backdrop').remove();
+ }
+
+
+});
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js
index c34646467..abbbd343d 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js
@@ -151,6 +151,122 @@ var inputIsValidAgainstRange = function (numberInput, min, max) {
return (numberInput == min || (numberInput > min && numberInput < max) || numberInput == max);
};
+var enrollmentAppInstallClick = function (input) {
+ if (input.checked) {
+ $("div#install-app-enrollment").find("input").filterByData("child-key", "installGooglePolicy").filterByData
+ ("app-id",
+ input.getAttribute("data-app-id")).parent().parents("tr").last().find("input").each(function () {
+ if(!$(this).hasClass("child-input")) {
+ $(this).addClass("child-input");
+ }
+ });
+ } else {
+ var isInstallPolicyChecked = $("div#install-app-enrollment").find("input")
+ .filterByData("app-id", input.getAttribute("data-app-id"))
+ .filterByData("child-key", "installGooglePolicy").prop('checked');
+
+ if (!isInstallPolicyChecked) {
+ $("div#install-app-enrollment").find("input").filterByData("child-key", "installGooglePolicy").filterByData("app-id",
+ input.getAttribute("data-app-id")).parent().parents("tr").last().find
+ ("input").each(function () {
+ $(this).removeClass("child-input");
+ });
+ }
+ }
+};
+
+var appAvailabilityClick = function (input) {
+ var appAvailabilityConfigFormTitle = document.getElementById("app-availability-config-form-title");
+ var isEnrollmentAppTicked = $("div#install-app-enrollment").find("input").filterByData("child-key",
+ "enrollmentAppInstall").filterByData("app-id", input.getAttribute("data-app-id")).prop('checked');
+ if (input.checked) {
+
+ var configureAppAvailabilityFormData = {};
+ configureAppAvailabilityFormData.autoInstallMode = "autoInstallOnce";
+ configureAppAvailabilityFormData.autoInstallPriority = "50";
+ configureAppAvailabilityFormData.chargingStateConstraint = "chargingNotRequired";
+ configureAppAvailabilityFormData.deviceIdleStateConstraint = "deviceIdleNotRequired";
+ configureAppAvailabilityFormData.networkTypeConstraint = "anyNetwork";
+ configureAppAvailabilityForm(configureAppAvailabilityFormData);
+
+ var title = "Add Configurations for " + input.getAttribute("data-app-name");
+ appAvailabilityConfigFormTitle.innerHTML = title;
+ $("input#app-install-config-save").attr("data-app-id", input.getAttribute("data-app-id"));
+ $("input#app-install-config-save").attr("data-package-name", input.getAttribute("data-package-name"));
+ $("div#app-availability-config-form").attr("hidden", false);
+
+ } else {
+ $("input#app-install-config-save").attr("data-app-id", "");
+ $("input#app-install-config-save").attr("data-package-name", "");
+ $("div#app-availability-config-form").attr("hidden", true);
+ if (!isEnrollmentAppTicked) {
+ // Enrollment app install tick is also not present. Meaning this row is not needed.
+ $("div#install-app-enrollment").find("input").filterByData("child-key",
+ "enrollmentAppInstall").filterByData("app-id", input
+ .getAttribute("data-app-id")).parent().parents("tr")
+ .last().find("input").each(function () {
+ $(this).removeClass("child-input");
+ });
+
+ }
+ }
+};
+
+var configureAppAvailabilityForm = function (input) {
+ $("select#app-availability-auto-install-mode").val(input.autoInstallMode).change();
+ $("select#app-availability-install-priority").val(input.autoInstallPriority).change();
+ $("select#app-availability-install-charging").val(input.chargingStateConstraint).change();
+ $("select#app-availability-install-idle").val(input.deviceIdleStateConstraint).change();
+ $("select#app-availability-install-network").val(input.networkTypeConstraint).change();
+};
+
+
+loadedGooglePolicyCount = 0;
+var changeSavedGlobalAppConfig = function (input) {
+ // Adding this console log as, it is not possible to access the JS files otherwise.
+ console.log("This is printing from android-policy-*,js that is in accessible via source.");
+ $("div#install-app-enrollment").find("input").filterByData("child-key", "productSetBehavior")
+ .each(function () {
+ $(this).val($("select#product-set-behaviour").val());
+ });
+ $("div#install-app-enrollment").find("input").filterByData("child-key", "autoUpdatePolicy")
+ .each(function () {
+ $(this).val($("select#auto-update-policy").val());
+ });
+
+ var behaviour = $('select#product-set-behaviour').data('product-set-behavior');
+ var autoUpdatePolicy = $('select#auto-update-policy').data('auto-update-policy');
+ loadedGooglePolicyCount++;
+ if (autoUpdatePolicy && loadedGooglePolicyCount == 2) {
+ $("select#auto-update-policy").val(autoUpdatePolicy).change();
+ $("select#product-set-behaviour").val(behaviour).change()
+ }
+};
+
+var changeSavedAppInstallData = function (input) {
+ var appId = input.getAttribute("data-app-id");
+ var packageName = input.getAttribute("data-package-name")
+
+ var json = {};
+ json.appId = appId;
+ json.packageName = packageName;
+ json.autoInstallMode = $("select#app-availability-auto-install-mode").val();
+ json.autoInstallPriority = $("select#app-availability-install-priority").val();
+ json.chargingStateConstraint = $("select#app-availability-install-charging").val();
+ json.deviceIdleStateConstraint = $("select#app-availability-install-idle").val();
+ json.networkTypeConstraint = $("select#app-availability-install-network").val();
+
+ var payload = JSON.stringify(json);
+
+
+ $("div#install-app-enrollment").find("input").filterByData("package-name", packageName).parent().find("input")[1].value = payload;
+ $("div#install-app-enrollment").find("input").filterByData("package-name", packageName).parent().parents("tr")
+ .last().find("input").each(function () {
+ $(this).addClass("child-input");
+ });
+ $("div#app-availability-config-form").attr("hidden", true);
+};
+
var ovpnConfigUploaded = function () {
var ovpnFileInput = document.getElementById("ovpn-file");
if ('files' in ovpnFileInput) {
@@ -1188,7 +1304,7 @@ var showHideHelpText = function (addFormContainer) {
var applyDataTable = function() {
$("#enrollment-app-install-table").datatables_extended({
ordering: false,
- lengthMenu: [5, 10, 25, 50, 100]
+ lengthMenu: [100, 200, 500]
});
};
var myFrom;
@@ -1387,22 +1503,4 @@ $(document).ready(function () {
setId(addFormContainer);
showHideHelpText(addFormContainer);
});
-
- // add app entry for enrollment-app-install
- $(advanceOperations).on("click", "[data-click-event=add-enrollment-app]", function () {
- $(this).attr("hidden", true);
- $(this).siblings("a").removeAttr("hidden");
- $(this).parent().parent().find("input").each(function () {
- $(this).addClass("child-input");
- });
- });
-
- // remove app entry for enrollment-app-install
- $(advanceOperations).on("click", "[data-click-event=remove-enrollment-app]", function () {
- $(this).attr("hidden", true);
- $(this).siblings("a").removeAttr("hidden");
- $(this).parent().parent().find("input").each(function () {
- $(this).removeClass("child-input");
- });
- });
});
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs
index 69e30efc1..835ffbdee 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/templates/android-policy-edit.hbs
@@ -315,6 +315,146 @@
+
+
+ Passcode policy for work profile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2973,14 +3113,15 @@
+
+
@@ -3030,4 +3320,4 @@
-
+
\ No newline at end of file
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs
index e2a9ab316..4fef569d6 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-view/public/templates/android-policy-view.hbs
@@ -297,6 +297,144 @@
+
+
+ Passcode policy for work profile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -3083,6 +3221,8 @@
Application Name |
Type |
Version |
+ Auto Install |
+ Work Profile Availability |
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js
index 381fa6f5d..330bdee1a 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js
@@ -93,6 +93,122 @@ var inputIsValidAgainstRange = function (numberInput, min, max) {
return (numberInput == min || (numberInput > min && numberInput < max) || numberInput == max);
};
+var enrollmentAppInstallClick = function (input) {
+ if (input.checked) {
+ $("div#install-app-enrollment").find("input").filterByData("child-key", "installGooglePolicy").filterByData
+ ("app-id",
+ input.getAttribute("data-app-id")).parent().parents("tr").last().find("input").each(function () {
+ if(!$(this).hasClass("child-input")) {
+ $(this).addClass("child-input");
+ }
+ });
+ } else {
+ var isInstallPolicyChecked = $("div#install-app-enrollment").find("input")
+ .filterByData("app-id", input.getAttribute("data-app-id"))
+ .filterByData("child-key", "installGooglePolicy").prop('checked');
+
+ if (!isInstallPolicyChecked) {
+ $("div#install-app-enrollment").find("input").filterByData("child-key", "installGooglePolicy").filterByData("app-id",
+ input.getAttribute("data-app-id")).parent().parents("tr").last().find
+ ("input").each(function () {
+ $(this).removeClass("child-input");
+ });
+ }
+ }
+};
+
+var appAvailabilityClick = function (input) {
+ var appAvailabilityConfigFormTitle = document.getElementById("app-availability-config-form-title");
+ var isEnrollmentAppTicked = $("div#install-app-enrollment").find("input").filterByData("child-key",
+ "enrollmentAppInstall").filterByData("app-id", input.getAttribute("data-app-id")).prop('checked');
+ if (input.checked) {
+
+ var configureAppAvailabilityFormData = {};
+ configureAppAvailabilityFormData.autoInstallMode = "autoInstallOnce";
+ configureAppAvailabilityFormData.autoInstallPriority = "50";
+ configureAppAvailabilityFormData.chargingStateConstraint = "chargingNotRequired";
+ configureAppAvailabilityFormData.deviceIdleStateConstraint = "deviceIdleNotRequired";
+ configureAppAvailabilityFormData.networkTypeConstraint = "anyNetwork";
+ configureAppAvailabilityForm(configureAppAvailabilityFormData);
+
+ var title = "Add Configurations for " + input.getAttribute("data-app-name");
+ appAvailabilityConfigFormTitle.innerHTML = title;
+ $("input#app-install-config-save").attr("data-app-id", input.getAttribute("data-app-id"));
+ $("input#app-install-config-save").attr("data-package-name", input.getAttribute("data-package-name"));
+ $("div#app-availability-config-form").attr("hidden", false);
+
+ $("div#install-app-enrollment").find("input").filterByData("child-key", "productSetBehavior").each(function () {
+ if (!$(this).val()) {
+ $(this).val("whitelist");
+ }
+ });
+ $("div#install-app-enrollment").find("input").filterByData("child-key", "autoUpdatePolicy").each(function () {
+ if (!$(this).val()) {
+ $(this).val("wifiOnly");
+ }
+ });
+
+ } else {
+ $("input#app-install-config-save").attr("data-app-id", "");
+ $("input#app-install-config-save").attr("data-package-name", "");
+ $("div#app-availability-config-form").attr("hidden", true);
+ if (!isEnrollmentAppTicked) {
+ // Enrollment app install tick is also not present. Meaning this row is not needed.
+ $("div#install-app-enrollment").find("input").filterByData("child-key",
+ "enrollmentAppInstall").filterByData("app-id", input
+ .getAttribute("data-app-id")).parent().parents("tr")
+ .last().find("input").each(function () {
+ $(this).removeClass("child-input");
+ });
+
+ }
+ }
+};
+
+var configureAppAvailabilityForm = function (input) {
+ $("select#app-availability-auto-install-mode").val(input.autoInstallMode).change();
+ $("select#app-availability-install-priority").val(input.autoInstallPriority).change();
+ $("select#app-availability-install-charging").val(input.chargingStateConstraint).change();
+ $("select#app-availability-install-idle").val(input.deviceIdleStateConstraint).change();
+ $("select#app-availability-install-network").val(input.networkTypeConstraint).change();
+};
+
+var changeSavedGlobalAppConfig = function (input) {
+ $("div#install-app-enrollment").find("input").filterByData("child-key", "productSetBehavior")
+ .each(function () {
+ $(this).val($("select#product-set-behaviour").val());
+ });
+ $("div#install-app-enrollment").find("input").filterByData("child-key", "autoUpdatePolicy")
+ .each(function () {
+ $(this).val($("select#auto-update-policy").val());
+ });
+};
+
+var changeSavedAppInstallData = function (input) {
+ var appId = input.getAttribute("data-app-id");
+ var packageName = input.getAttribute("data-package-name")
+
+ var json = {};
+ json.appId = appId;
+ json.packageName = packageName;
+ json.autoInstallMode = $("select#app-availability-auto-install-mode").val();
+ json.autoInstallPriority = $("select#app-availability-install-priority").val();
+ json.chargingStateConstraint = $("select#app-availability-install-charging").val();
+ json.deviceIdleStateConstraint = $("select#app-availability-install-idle").val();
+ json.networkTypeConstraint = $("select#app-availability-install-network").val();
+
+ var payload = JSON.stringify(json);
+
+
+ $("div#install-app-enrollment").find("input").filterByData("package-name", packageName).parent().find("input")[1].value = payload;
+ $("div#install-app-enrollment").find("input").filterByData("package-name", packageName).parent().parents("tr")
+ .last().find("input").each(function () {
+ $(this).addClass("child-input");
+ });
+ $("div#app-availability-config-form").attr("hidden", true);
+};
+
+
var ovpnConfigUploaded = function () {
var ovpnFileInput = document.getElementById("ovpn-file");
if ('files' in ovpnFileInput) {
@@ -1163,7 +1279,7 @@ var showHideHelpText = function (addFormContainer) {
var applyDataTable = function() {
$("#enrollment-app-install-table").datatables_extended({
ordering: false,
- lengthMenu: [5, 10, 25, 50, 100]
+ lengthMenu: [100, 200, 500]
});
};
@@ -1344,22 +1460,4 @@ $(document).ready(function () {
setId(addFormContainer);
showHideHelpText(addFormContainer);
});
-
- // add app entry for enrollment-app-install
- $(advanceOperations).on("click", "[data-click-event=add-enrollment-app]", function () {
- $(this).attr("hidden", true);
- $(this).siblings("a").removeAttr("hidden");
- $(this).parent().parent().find("input").each(function () {
- $(this).addClass("child-input");
- });
- });
-
- // remove app entry for enrollment-app-install
- $(advanceOperations).on("click", "[data-click-event=remove-enrollment-app]", function () {
- $(this).attr("hidden", true);
- $(this).siblings("a").removeAttr("hidden");
- $(this).parent().parent().find("input").each(function () {
- $(this).removeClass("child-input");
- });
- });
});
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs
index 42a02561f..3eb127619 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/templates/android-policy-operations.hbs
@@ -323,9 +323,150 @@
+
+
+ Passcode policy for work profile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ data-key="enrollmentAppInstall" data-column-count="11">
+
+
+
+
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/WEB-INF/cxf-servlet.xml
new file mode 100644
index 000000000..4009733b4
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.v09.api/src/main/webapp/WEB-INF/cxf-servlet.xml
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/AndroidPluginService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/AndroidPluginService.java
new file mode 100644
index 000000000..7bc4ad3be
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/AndroidPluginService.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.
+ */
+
+package org.wso2.carbon.device.mgt.mobile.android;
+
+import org.wso2.carbon.device.mgt.mobile.android.impl.EnterpriseServiceException;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser;
+
+import java.util.List;
+
+public interface AndroidPluginService {
+
+ void addEnterpriseUser(AndroidEnterpriseUser androidEnterpriseUser) throws EnterpriseServiceException;
+
+ List getEnterpriseUser(String username) throws EnterpriseServiceException;
+
+ AndroidEnterpriseUser getEnterpriseUserByDevice(String deviceId) throws EnterpriseServiceException;
+
+ AndroidEnterpriseManagedConfig getConfigByPackageName(String packageName) throws EnterpriseServiceException;
+
+ void addConfig(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseServiceException;
+
+ boolean updateMobileDevice(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseServiceException;
+
+ boolean deleteMobileDevice(String id) throws EnterpriseServiceException;
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java
index 5e7f0ac28..bccceedbb 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java
@@ -84,8 +84,7 @@ public class AndroidDeviceManagementService implements DeviceManagementService {
@Override
public void init() throws DeviceManagementException {
- this.deviceManager = new AndroidDeviceManager();
- this.policyMonitoringManager = new AndroidPolicyMonitoringManager();
+
}
@Override
@@ -105,29 +104,6 @@ public class AndroidDeviceManagementService implements DeviceManagementService {
@Override
public PushNotificationConfig getPushNotificationConfig() {
- try {
- DeviceManagementService deviceManagementService = AndroidDeviceManagementDataHolder.getInstance().
- getAndroidDeviceManagementService();
- if (deviceManagementService != null && deviceManagementService.getDeviceManager() != null) {
- PlatformConfiguration androidConfig = deviceManagementService.getDeviceManager().getConfiguration();
- if (androidConfig != null) {
- List configuration = androidConfig.getConfiguration();
- String notifierValue = this.getConfigProperty(configuration, NOTIFIER_PROPERTY);
- if (notifierValue != null && !notifierValue.isEmpty()) {
- int notifierType = Integer.parseInt(notifierValue);
- if (notifierType == 2) {
- HashMap config = new HashMap<>();
- config.put(FCM_API_KEY, this.getConfigProperty(configuration, FCM_API_KEY));
- config.put(FCM_SENDER_ID, this.getConfigProperty(configuration, FCM_SENDER_ID));
- return new PushNotificationConfig(AndroidPluginConstants.NotifierType.FCM, false,
- config);
- }
- }
- }
- }
- } catch (DeviceManagementException e) {
- log.error("Unable to get the Android platform configuration from registry.");
- }
return null;
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java
deleted file mode 100644
index 5cb44b23f..000000000
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * 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.
- *
- */
-package org.wso2.carbon.device.mgt.mobile.android.impl;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.common.Device;
-import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
-import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
-import org.wso2.carbon.device.mgt.common.DeviceManager;
-import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
-import org.wso2.carbon.device.mgt.common.FeatureManager;
-import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
-import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
-import org.wso2.carbon.device.mgt.common.license.mgt.License;
-import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
-import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
-import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AbstractMobileDeviceManagementDAOFactory;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice;
-import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants;
-import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginUtils;
-import org.wso2.carbon.device.mgt.mobile.android.impl.util.MobileDeviceManagementUtil;
-import org.wso2.carbon.registry.api.RegistryException;
-import org.wso2.carbon.registry.api.Resource;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.List;
-
-public class AndroidDeviceManager implements DeviceManager {
-
- private AbstractMobileDeviceManagementDAOFactory daoFactory;
- private static final Log log = LogFactory.getLog(AndroidDeviceManagementService.class);
- private FeatureManager featureManager = new AndroidFeatureManager();
- private LicenseManager licenseManager;
-
- public AndroidDeviceManager() {
- this.daoFactory = new AndroidDAOFactory();
- this.licenseManager = new RegistryBasedLicenseManager();
- License defaultLicense;
-
- try {
- if (licenseManager.getLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID,
- AndroidPluginConstants.MobilePluginConstants.LANGUAGE_CODE_ENGLISH_US) ==
- null) {
- defaultLicense = AndroidPluginUtils.getDefaultLicense();
- licenseManager.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, defaultLicense);
- }
- featureManager.addSupportedFeaturesToDB();
- } catch (LicenseManagementException e) {
- log.error("Error occurred while adding default license for Android devices", e);
- } catch (DeviceManagementException e) {
- log.error("Error occurred while adding supported device features for Android platform", e);
- }
- }
-
- @Override
- public FeatureManager getFeatureManager() {
- return featureManager;
- }
-
- @Override
- public boolean saveConfiguration(PlatformConfiguration tenantConfiguration)
- throws DeviceManagementException {
- boolean status;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Persisting android configurations in Registry");
- }
- String resourcePath = MobileDeviceManagementUtil.getPlatformConfigPath(
- DeviceManagementConstants.
- MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
- StringWriter writer = new StringWriter();
- JAXBContext context = JAXBContext.newInstance(PlatformConfiguration.class);
- Marshaller marshaller = context.createMarshaller();
- marshaller.marshal(tenantConfiguration, writer);
-
- Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newResource();
- resource.setContent(writer.toString());
- resource.setMediaType(AndroidPluginConstants.MobilePluginConstants.MEDIA_TYPE_XML);
- MobileDeviceManagementUtil.putRegistryResource(resourcePath, resource);
- status = true;
- } catch (AndroidDeviceMgtPluginException e) {
- throw new DeviceManagementException(
- "Error occurred while retrieving the Registry instance : " + e.getMessage(), e);
- } catch (RegistryException e) {
- throw new DeviceManagementException(
- "Error occurred while persisting the Registry resource of Android Configuration : " + e.getMessage(), e);
- } catch (JAXBException e) {
- throw new DeviceManagementException(
- "Error occurred while parsing the Android configuration : " + e.getMessage(), e);
- }
- return status;
- }
-
- @Override
- public PlatformConfiguration getConfiguration() throws DeviceManagementException {
- Resource resource;
- try {
- String androidRegPath =
- MobileDeviceManagementUtil.getPlatformConfigPath(DeviceManagementConstants.
- MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
- resource = MobileDeviceManagementUtil.getRegistryResource(androidRegPath);
- if (resource != null) {
- XMLInputFactory factory = XMLInputFactory.newInstance();
- factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
- factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
- XMLStreamReader reader = factory.createXMLStreamReader(
- new StringReader(new String((byte[]) resource.getContent(), Charset.
- forName(AndroidPluginConstants.MobilePluginConstants.CHARSET_UTF8))));
- JAXBContext context = JAXBContext.newInstance(PlatformConfiguration.class);
- Unmarshaller unmarshaller = context.createUnmarshaller();
- return (PlatformConfiguration) unmarshaller.unmarshal(reader);
- }
- return null;
- } catch (AndroidDeviceMgtPluginException e) {
- throw new DeviceManagementException(
- "Error occurred while retrieving the Registry instance : " + e.getMessage(), e);
- } catch (JAXBException | XMLStreamException e) {
- throw new DeviceManagementException(
- "Error occurred while parsing the Android configuration : " + e.getMessage(), e);
- } catch (RegistryException e) {
- throw new DeviceManagementException(
- "Error occurred while retrieving the Registry resource of Android Configuration : " + e.getMessage(), e);
- }
- }
-
- @Override
- public boolean enrollDevice(Device device) throws DeviceManagementException {
- boolean status = false;
- boolean isEnrolled = this.isEnrolled(
- new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
-
- try {
- if (log.isDebugEnabled()) {
- log.debug("Enrolling a new Android device : " + device.getDeviceIdentifier());
- }
-
- if (isEnrolled) {
- this.modifyEnrollment(device);
- } else {
- MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
- AndroidDAOFactory.beginTransaction();
- status = daoFactory.getMobileDeviceDAO().addMobileDevice(mobileDevice);
- AndroidDAOFactory.commitTransaction();
- }
- } catch (MobileDeviceManagementDAOException e) {
- try {
- AndroidDAOFactory.rollbackTransaction();
- } catch (MobileDeviceManagementDAOException mobileDAOEx) {
- String msg = "Error occurred while roll back the device enrol transaction :" +
- device.toString();
- log.warn(msg, mobileDAOEx);
- }
- String msg =
- "Error while enrolling the Android device : " + device.getDeviceIdentifier();
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public boolean modifyEnrollment(Device device) throws DeviceManagementException {
- boolean status;
- MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
- try {
- if (log.isDebugEnabled()) {
- log.debug("Modifying the Android device enrollment data");
- }
- AndroidDAOFactory.beginTransaction();
- status = daoFactory.getMobileDeviceDAO().updateMobileDevice(mobileDevice);
- AndroidDAOFactory.commitTransaction();
- } catch (MobileDeviceManagementDAOException e) {
- try {
- AndroidDAOFactory.rollbackTransaction();
- } catch (MobileDeviceManagementDAOException mobileDAOEx) {
- String msg = "Error occurred while roll back the update device transaction :" +
- device.toString();
- log.warn(msg, mobileDAOEx);
- }
- String msg = "Error while updating the enrollment of the Android device : " +
- device.getDeviceIdentifier();
- throw new DeviceManagementException(msg, e);
- }
- return status;
- }
-
- @Override
- public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
- //Here we don't have anything specific to do. Hence returning.
- return true;
- }
-
-
- @Override
- public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
- boolean isEnrolled = false;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Checking the enrollment of Android device : " + deviceId.getId());
- }
- MobileDevice mobileDevice =
- daoFactory.getMobileDeviceDAO().getMobileDevice(deviceId.getId());
- if (mobileDevice != null) {
- isEnrolled = true;
- }
- } catch (MobileDeviceManagementDAOException e) {
- String msg = "Error while checking the enrollment status of Android device : " +
- deviceId.getId();
- throw new DeviceManagementException(msg, e);
- }
- return isEnrolled;
- }
-
- @Override
- public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
- return true;
- }
-
- @Override
- public boolean setActive(DeviceIdentifier deviceId, boolean status)
- throws DeviceManagementException {
- return true;
- }
-
- @Override
- public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
- Device device;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Getting the details of Android device : '" + deviceId.getId() + "'");
- }
- MobileDevice mobileDevice = daoFactory.getMobileDeviceDAO().
- getMobileDevice(deviceId.getId());
- device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
- } catch (MobileDeviceManagementDAOException e) {
- throw new DeviceManagementException(
- "Error occurred while fetching the Android device: '" +
- deviceId.getId() + "'", e);
- }
- return device;
- }
-
- @Override
- public boolean updateDeviceProperties(DeviceIdentifier deviceIdentifier, List list) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
- throws DeviceManagementException {
- return true;
- }
-
- @Override
- public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public boolean setStatus(DeviceIdentifier deviceIdentifier, String currentUser,
- EnrolmentInfo.Status status) throws DeviceManagementException {
- return false;
- }
-
- @Override
- public License getLicense(String languageCode) throws LicenseManagementException {
- return licenseManager.
- getLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, languageCode);
- }
-
- @Override
- public void addLicense(License license) throws LicenseManagementException {
- licenseManager.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, license);
- }
-
- @Override
- public boolean requireDeviceAuthorization() {
- return true;
- }
-
- @Override
- public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device)
- throws DeviceManagementException {
- boolean status;
- Device existingDevice = this.getDevice(deviceIdentifier);
- // This object holds the current persisted device object
- MobileDevice existingMobileDevice =
- MobileDeviceManagementUtil.convertToMobileDevice(existingDevice);
-
- // This object holds the newly received device object from response
- MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
-
- // Updating current object features using newer ones
- existingMobileDevice.setLatitude(mobileDevice.getLatitude());
- existingMobileDevice.setLongitude(mobileDevice.getLongitude());
- existingMobileDevice.setAltitude(mobileDevice.getAltitude());
- existingMobileDevice.setSpeed(mobileDevice.getSpeed());
- existingMobileDevice.setBearing(mobileDevice.getBearing());
- existingMobileDevice.setDistance(mobileDevice.getDistance());
- existingMobileDevice.setDeviceProperties(mobileDevice.getDeviceProperties());
-
- try {
- if (log.isDebugEnabled()) {
- log.debug(
- "updating the details of Android device : " + device.getDeviceIdentifier());
- }
- AndroidDAOFactory.beginTransaction();
- status = daoFactory.getMobileDeviceDAO().updateMobileDevice(existingMobileDevice);
- AndroidDAOFactory.commitTransaction();
- } catch (MobileDeviceManagementDAOException e) {
- try {
- AndroidDAOFactory.rollbackTransaction();
- } catch (MobileDeviceManagementDAOException e1) {
- log.warn("Error occurred while roll back the update device info transaction : '" +
- device.toString() + "'", e1);
- }
- throw new DeviceManagementException(
- "Error occurred while updating the Android device: '" +
- device.getDeviceIdentifier() + "'", e);
- }
- return status;
- }
-
- @Override
- public List getAllDevices() throws DeviceManagementException {
- List devices = null;
- try {
- if (log.isDebugEnabled()) {
- log.debug("Fetching the details of all Android devices");
- }
- List mobileDevices =
- daoFactory.getMobileDeviceDAO().getAllMobileDevices();
- if (mobileDevices != null) {
- devices = new ArrayList<>(mobileDevices.size());
- for (MobileDevice mobileDevice : mobileDevices) {
- devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice));
- }
- }
- } catch (MobileDeviceManagementDAOException e) {
- throw new DeviceManagementException("Error occurred while fetching all Android devices",
- e);
- }
- return devices;
- }
-
- @Override
- public void deleteDevices(List deviceIdentifiers) throws DeviceManagementException {
- //Does nothing since AndroidDeviceManager is not used instead DeviceTypeManager is used.
- }
-
-}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java
deleted file mode 100644
index 71ac1c031..000000000
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java
+++ /dev/null
@@ -1,580 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * 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.
- *
- */
-
-/*
- * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
- *
- * Entgra (Pvt) Ltd. 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.
- */
-
-package org.wso2.carbon.device.mgt.mobile.android.impl;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.common.Feature;
-import org.wso2.carbon.device.mgt.common.FeatureManager;
-import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOFactory;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileFeatureDAO;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileFeature;
-import org.wso2.carbon.device.mgt.mobile.android.impl.util.MobileDeviceManagementUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class AndroidFeatureManager implements FeatureManager {
-
- private MobileFeatureDAO featureDAO;
- private static final Log log = LogFactory.getLog(AndroidFeatureManager.class);
-
- public AndroidFeatureManager() {
- MobileDeviceManagementDAOFactory daoFactory = new AndroidDAOFactory();
- this.featureDAO = daoFactory.getMobileFeatureDAO();
- }
-
- @Override
- public boolean addFeature(Feature feature) throws DeviceManagementException {
- try {
- AndroidDAOFactory.beginTransaction();
- MobileFeature mobileFeature = MobileDeviceManagementUtil.convertToMobileFeature(feature);
- featureDAO.addFeature(mobileFeature);
- AndroidDAOFactory.commitTransaction();
- return true;
- } catch (MobileDeviceManagementDAOException e) {
- try {
- AndroidDAOFactory.rollbackTransaction();
- } catch (MobileDeviceManagementDAOException e1) {
- log.warn("Error occurred while roll-backing the transaction", e);
- }
- throw new DeviceManagementException("Error occurred while adding the feature", e);
- }
- }
-
- @Override
- public boolean addFeatures(List features) throws DeviceManagementException {
- List mobileFeatures = new ArrayList(features.size());
- for (Feature feature : features) {
- mobileFeatures.add(MobileDeviceManagementUtil.convertToMobileFeature(feature));
- }
- try {
- AndroidDAOFactory.beginTransaction();
- featureDAO.addFeatures(mobileFeatures);
- AndroidDAOFactory.commitTransaction();
- return true;
- } catch (MobileDeviceManagementDAOException e) {
- try {
- AndroidDAOFactory.rollbackTransaction();
- } catch (MobileDeviceManagementDAOException e1) {
- log.warn("Error occurred while roll-backing the transaction", e);
- }
- throw new DeviceManagementException("Error occurred while adding the features", e);
- }
- }
-
- @Override
- public Feature getFeature(String name) throws DeviceManagementException {
- try {
- MobileFeature mobileFeature = featureDAO.getFeatureByCode(name);
- Feature feature = MobileDeviceManagementUtil.convertToFeature(mobileFeature);
- return feature;
- } catch (MobileDeviceManagementDAOException e) {
- throw new DeviceManagementException("Error occurred while retrieving the feature", e);
- }
- }
-
- @Override
- public List getFeatures() throws DeviceManagementException {
- try {
- List mobileFeatures = featureDAO.getAllFeatures();
- return mobileFeatures.stream().map(MobileDeviceManagementUtil::convertToFeature).collect(
- Collectors.toList());
- } catch (MobileDeviceManagementDAOException e) {
- throw new DeviceManagementException("Error occurred while retrieving the list of features registered for " +
- "Android platform", e);
- }
- }
-
- @Override
- public List getFeatures(String featureType) throws DeviceManagementException {
- if (StringUtils.isEmpty(featureType)) {
- return this.getFeatures();
- }
- try {
- List mobileFeatures = featureDAO.getFeaturesByFeatureType(featureType);
- return mobileFeatures.stream().map(MobileDeviceManagementUtil::convertToFeature).collect(
- Collectors.toList());
- } catch (MobileDeviceManagementDAOException e) {
- throw new DeviceManagementException("Error occurred while retrieving the list of features registered for " +
- "Android platform", e);
- }
- }
-
- @Override
- public List getFeatures(String featureType, boolean isHidden) throws DeviceManagementException {
- try {
- List mobileFeatures;
- if (StringUtils.isNotEmpty(featureType)) {
- mobileFeatures = featureDAO.getFeaturesByFeatureType(featureType, isHidden);
- } else {
- mobileFeatures = featureDAO.getAllFeatures(isHidden);
- }
- return mobileFeatures.stream().map(MobileDeviceManagementUtil::convertToFeature).collect(
- Collectors.toList());
- } catch (MobileDeviceManagementDAOException e) {
- throw new DeviceManagementException("Error occurred while retrieving the list of features registered for " +
- "Android platform", e);
- }
- }
-
- @Override
- public boolean removeFeature(String code) throws DeviceManagementException {
- boolean status;
- try {
- AndroidDAOFactory.beginTransaction();
- featureDAO.deleteFeatureByCode(code);
- AndroidDAOFactory.commitTransaction();
- status = true;
- } catch (MobileDeviceManagementDAOException e) {
- try {
- AndroidDAOFactory.rollbackTransaction();
- } catch (MobileDeviceManagementDAOException e1) {
- log.warn("Error occurred while roll-backing the transaction", e);
- }
- throw new DeviceManagementException("Error occurred while removing the feature", e);
- }
- return status;
- }
-
- @Override
- public boolean addSupportedFeaturesToDB() throws DeviceManagementException {
- synchronized (this) {
- List supportedFeatures = getSupportedFeatures();
- List existingFeatures = this.getFeatures();
- List missingFeatures = MobileDeviceManagementUtil.
- getMissingFeatures(supportedFeatures, existingFeatures);
- if (missingFeatures.size() > 0) {
- return this.addFeatures(missingFeatures);
- }
- return true;
- }
- }
-
- //Get the supported feature list.
- private static List getSupportedFeatures() {
- List supportedFeatures = new ArrayList();
- Feature feature = new Feature();
- feature.setCode("DEVICE_LOCK");
- feature.setName("Device Lock");
- feature.setDescription("Lock the device");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("DEVICE_LOCATION");
- feature.setName("Location");
- feature.setDescription("Request coordinates of device location");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("WIFI");
- feature.setName("wifi");
- feature.setDescription("Setting up wifi configuration");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("CAMERA");
- feature.setName("camera");
- feature.setDescription("Enable or disable camera");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("BACKUP_SERVICE");
- feature.setName("Set Backup Service");
- feature.setDescription("set backup service");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("EMAIL");
- feature.setName("Email");
- feature.setDescription("Configure email settings");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("DEVICE_MUTE");
- feature.setName("mute");
- feature.setDescription("Enable mute in the device");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("DEVICE_INFO");
- feature.setName("Device info");
- feature.setDescription("Request device information");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("ENTERPRISE_WIPE");
- feature.setName("Enterprise Wipe");
- feature.setDescription("Remove enterprise applications");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("CLEAR_PASSWORD");
- feature.setName("Clear Password");
- feature.setDescription("Clear current password");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("WIPE_DATA");
- feature.setName("Wipe Data");
- feature.setDescription("Factory reset the device");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("APPLICATION_LIST");
- feature.setName("Application List");
- feature.setDescription("Request list of current installed applications");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("CHANGE_LOCK_CODE");
- feature.setName("Change Lock-code");
- feature.setDescription("Change current lock code");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("INSTALL_APPLICATION");
- feature.setName("Install App");
- feature.setDescription("Install Enterprise or Market application");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("UNINSTALL_APPLICATION");
- feature.setName("Uninstall App");
- feature.setDescription("Uninstall application");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("BLACKLIST_APPLICATIONS");
- feature.setName("Blacklist app");
- feature.setDescription("Blacklist applications");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("ENCRYPT_STORAGE");
- feature.setName("Encrypt storage");
- feature.setDescription("Encrypt storage");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("DEVICE_RING");
- feature.setName("Ring");
- feature.setDescription("Ring the device");
- supportedFeatures.add(feature);
- feature = new Feature();
- feature.setCode("PASSCODE_POLICY");
- feature.setName("Password Policy");
- feature.setDescription("Set passcode policy");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("NOTIFICATION");
- feature.setName("Message");
- feature.setDescription("Send message");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DEVICE_REBOOT");
- feature.setName("Reboot");
- feature.setDescription("Reboot the device");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("UPGRADE_FIRMWARE");
- feature.setName("Upgrade Firmware");
- feature.setDescription("Upgrade Firmware");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("VPN");
- feature.setName("Configure VPN");
- feature.setDescription("Configure VPN settings");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_ADJUST_VOLUME");
- feature.setName("Adjust Volume");
- feature.setDescription("allow or disallow user to change volume");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_CONFIG_BLUETOOTH");
- feature.setName("Disallow bluetooth configuration");
- feature.setDescription("allow or disallow user to change bluetooth configurations");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_CONFIG_CELL_BROADCASTS");
- feature.setName("Disallow cell broadcast configuration");
- feature.setDescription("allow or disallow user to change cell broadcast configurations");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_CONFIG_CREDENTIALS");
- feature.setName("Disallow credential configuration");
- feature.setDescription("allow or disallow user to change user credentials");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_CONFIG_MOBILE_NETWORKS");
- feature.setName("Disallow mobile network configure");
- feature.setDescription("allow or disallow user to change mobile networks configurations");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_CONFIG_TETHERING");
- feature.setName("Disallow tethering configuration");
- feature.setDescription("allow or disallow user to change tethering configurations");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_CONFIG_VPN");
- feature.setName("Disallow VPN configuration");
- feature.setDescription("allow or disallow user to change VPN configurations");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_CONFIG_WIFI");
- feature.setName("Disallow WIFI configuration");
- feature.setDescription("allow or disallow user to change WIFI configurations");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_APPS_CONTROL");
- feature.setName("Disallow APP control configuration");
- feature.setDescription("allow or disallow user to change app control");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_CREATE_WINDOWS");
- feature.setName("Disallow window creation");
- feature.setDescription("allow or disallow window creation");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_APPS_CONTROL");
- feature.setName("Disallow APP control configuration");
- feature.setDescription("allow or disallow user to change app control configurations");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_CROSS_PROFILE_COPY_PASTE");
- feature.setName("Disallow cross profile copy paste");
- feature.setDescription("allow or disallow cross profile copy paste");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_DEBUGGING_FEATURES");
- feature.setName("Disallow debugging features");
- feature.setDescription("allow or disallow debugging features");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_FACTORY_RESET");
- feature.setName("Disallow factory reset");
- feature.setDescription("allow or disallow factory reset");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_ADD_USER");
- feature.setName("Disallow add user");
- feature.setDescription("allow or disallow add user");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_INSTALL_APPS");
- feature.setName("Disallow install apps");
- feature.setDescription("allow or disallow install apps");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_INSTALL_UNKNOWN_SOURCES");
- feature.setName("Disallow install unknown sources");
- feature.setDescription("allow or disallow install unknown sources");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_MODIFY_ACCOUNTS");
- feature.setName("Disallow modify account");
- feature.setDescription("allow or disallow modify account");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_MOUNT_PHYSICAL_MEDIA");
- feature.setName("Disallow mount physical media");
- feature.setDescription("allow or disallow mount physical media.");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_NETWORK_RESET");
- feature.setName("Disallow network reset");
- feature.setDescription("allow or disallow network reset");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_OUTGOING_BEAM");
- feature.setName("Disallow outgoing beam");
- feature.setDescription("allow or disallow outgoing beam.");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_OUTGOING_CALLS");
- feature.setName("Disallow outgoing calls");
- feature.setDescription("allow or disallow outgoing calls");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_REMOVE_USER");
- feature.setName("Disallow remove users");
- feature.setDescription("allow or disallow remove users");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_SAFE_BOOT");
- feature.setName("Disallow safe boot");
- feature.setDescription("allow or disallow safe boot");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_SHARE_LOCATION");
- feature.setName("Disallow share location");
- feature.setDescription("allow or disallow share location.");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_SMS");
- feature.setName("Disallow sms");
- feature.setDescription("allow or disallow sms");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_UNINSTALL_APPS");
- feature.setName("Disallow uninstall app");
- feature.setDescription("allow or disallow uninstall app");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_UNMUTE_MICROPHONE");
- feature.setName("Disallow unmute mic");
- feature.setDescription("allow or disallow unmute mic");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_USB_FILE_TRANSFER");
- feature.setName("Disallow usb file transfer");
- feature.setDescription("allow or disallow usb file transfer");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("ALLOW_PARENT_PROFILE_APP_LINKING");
- feature.setName("Disallow parent profile app linking");
- feature.setDescription("allow or disallow parent profile app linking");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("ENSURE_VERIFY_APPS");
- feature.setName("Disallow ensure verify apps");
- feature.setDescription("allow or disallow ensure verify apps");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("AUTO_TIME");
- feature.setName("Allow auto timing");
- feature.setDescription("allow or disallow auto timing");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("REMOVE_DEVICE_OWNER");
- feature.setName("Remove device owner");
- feature.setDescription("remove device owner");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("LOGCAT");
- feature.setName("Fetch Logcat");
- feature.setDescription("Fetch device logcat");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DEVICE_UNLOCK");
- feature.setName("Device Unlock");
- feature.setDescription("Unlock the device");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_SET_WALLPAPER");
- feature.setName("Device Unlock");
- feature.setDescription("Unlock the device");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_SET_USER_ICON");
- feature.setName("Device Unlock");
- feature.setDescription("Unlock the device");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_REMOVE_MANAGEMENT_PROFILE");
- feature.setName("Device Unlock");
- feature.setDescription("Unlock the device");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_AUTOFILL");
- feature.setName("Device Unlock");
- feature.setDescription("Unlock the device");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_BLUETOOTH");
- feature.setName("Device Unlock");
- feature.setDescription("Unlock the device");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_BLUETOOTH_SHARING");
- feature.setName("Device Unlock");
- feature.setDescription("Unlock the device");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_REMOVE_USER");
- feature.setName("Device Unlock");
- feature.setDescription("Unlock the device");
- supportedFeatures.add(feature);
-
- feature = new Feature();
- feature.setCode("DISALLOW_DATA_ROAMING");
- feature.setName("Device Unlock");
- feature.setDescription("Unlock the device");
- supportedFeatures.add(feature);
-
- return supportedFeatures;
- }
-}
\ No newline at end of file
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPluginServiceImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPluginServiceImpl.java
new file mode 100644
index 000000000..1fc0754f9
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPluginServiceImpl.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * 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.
+ *
+ * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.
+ */
+
+package org.wso2.carbon.device.mgt.mobile.android.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.context.CarbonContext;
+import org.wso2.carbon.device.mgt.mobile.android.AndroidPluginService;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dao.EnterpriseDAO;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dao.EnterpriseManagementDAOException;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser;
+
+import java.util.List;
+
+/**
+ * This represents the Android implementation of DeviceManagerService.
+ */
+public class AndroidPluginServiceImpl implements AndroidPluginService {
+
+ private static final Log log = LogFactory.getLog(AndroidPluginServiceImpl.class);
+ private EnterpriseDAO enterpriseDAO;
+
+ public AndroidPluginServiceImpl() {
+ enterpriseDAO = AndroidDAOFactory.getEnterpriseDAO();
+ }
+
+ @Override
+ public void addEnterpriseUser(AndroidEnterpriseUser androidEnterpriseUser) throws EnterpriseServiceException {
+ if (log.isDebugEnabled()) {
+ log.debug("Calling add user service by device identifier: " + androidEnterpriseUser.getEmmDeviceId());
+ }
+ try {
+ AndroidDAOFactory.beginTransaction();
+ this.enterpriseDAO.addUser(androidEnterpriseUser);
+ AndroidDAOFactory.commitTransaction();
+ } catch (EnterpriseManagementDAOException e) {
+ String msg = "Error occurred while adding the user "
+ + CarbonContext.getThreadLocalCarbonContext().getUsername();
+ log.error(msg, e);
+ AndroidDAOFactory.rollbackTransaction();
+ throw new EnterpriseServiceException(msg, e);
+ } finally {
+ AndroidDAOFactory.closeConnection();
+ }
+ }
+
+ @Override
+ public List getEnterpriseUser(String username) throws EnterpriseServiceException {
+
+ List androidEnterpriseUsers;
+ if (log.isDebugEnabled()) {
+ log.debug("Calling get user service by device identifier: " + CarbonContext
+ .getThreadLocalCarbonContext().getUsername());
+ }
+ try {
+ AndroidDAOFactory.openConnection();
+ androidEnterpriseUsers = this.enterpriseDAO.getUser(username, CarbonContext.getThreadLocalCarbonContext()
+ .getTenantId());
+
+ } catch (EnterpriseManagementDAOException e) {
+ String msg = "Error occurred while adding the user "
+ + CarbonContext.getThreadLocalCarbonContext().getUsername();
+ log.error(msg, e);
+ throw new EnterpriseServiceException(msg, e);
+ } finally {
+ AndroidDAOFactory.closeConnection();
+ }
+ return androidEnterpriseUsers;
+ }
+
+ @Override
+ public AndroidEnterpriseUser getEnterpriseUserByDevice(String deviceId) throws EnterpriseServiceException {
+
+ AndroidEnterpriseUser androidEnterpriseUsers;
+ if (log.isDebugEnabled()) {
+ log.debug("Calling get user service by device identifier: " + CarbonContext
+ .getThreadLocalCarbonContext().getUsername());
+ }
+ try {
+ AndroidDAOFactory.openConnection();
+ androidEnterpriseUsers = this.enterpriseDAO.getUserByDevice(deviceId, CarbonContext.getThreadLocalCarbonContext()
+ .getTenantId());
+
+ } catch (EnterpriseManagementDAOException e) {
+ String msg = "Error occurred while adding the user "
+ + CarbonContext.getThreadLocalCarbonContext().getUsername();
+ log.error(msg, e);
+ throw new EnterpriseServiceException(msg, e);
+ } finally {
+ AndroidDAOFactory.closeConnection();
+ }
+ return androidEnterpriseUsers;
+ }
+
+ @Override
+ public AndroidEnterpriseManagedConfig getConfigByPackageName(String packageName) throws EnterpriseServiceException {
+ AndroidEnterpriseManagedConfig enterpriseManagedConfig;
+ if (log.isDebugEnabled()) {
+ log.debug("Calling get user service by device identifier: " + CarbonContext
+ .getThreadLocalCarbonContext().getUsername());
+ }
+ try {
+ AndroidDAOFactory.openConnection();
+ enterpriseManagedConfig = this.enterpriseDAO.getConfigByPackageName(packageName, CarbonContext
+ .getThreadLocalCarbonContext().getTenantId());
+
+ } catch (EnterpriseManagementDAOException e) {
+ String msg = "Error occurred while getting configs for the package " + packageName;
+ log.error(msg, e);
+ throw new EnterpriseServiceException(msg, e);
+ } finally {
+ AndroidDAOFactory.closeConnection();
+ }
+ return enterpriseManagedConfig;
+ }
+
+ @Override
+ public void addConfig(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseServiceException {
+ if (log.isDebugEnabled()) {
+ log.debug("Calling add managed config for package : " + managedConfig.getPackageName());
+ }
+
+ // Block from fetching other tenants data.
+ managedConfig.setTenantID(CarbonContext.getThreadLocalCarbonContext().getTenantId());
+ try {
+ AndroidDAOFactory.beginTransaction();
+ this.enterpriseDAO.addConfig(managedConfig);
+ AndroidDAOFactory.commitTransaction();
+ } catch (EnterpriseManagementDAOException e) {
+ String msg = "Error occurred while adding managed configs for package " + managedConfig.getPackageName();
+ log.error(msg, e);
+ AndroidDAOFactory.rollbackTransaction();
+ throw new EnterpriseServiceException(msg, e);
+ } finally {
+ AndroidDAOFactory.closeConnection();
+ }
+ }
+
+ @Override
+ public boolean updateMobileDevice(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseServiceException {
+ boolean status;
+ if (log.isDebugEnabled()) {
+ log.debug("Calling update managed config for mcm id : " + managedConfig.getMcmId());
+ }
+
+ // Block from fetching other tenants data.
+ managedConfig.setTenantID(CarbonContext.getThreadLocalCarbonContext().getTenantId());
+ try {
+ AndroidDAOFactory.beginTransaction();
+ status = this.enterpriseDAO.updateConfig(managedConfig);
+ AndroidDAOFactory.commitTransaction();
+ } catch (EnterpriseManagementDAOException e) {
+ String msg = "Error occurred while updating managed configs for mcm id " + managedConfig.getMcmId();
+ log.error(msg, e);
+ AndroidDAOFactory.rollbackTransaction();
+ throw new EnterpriseServiceException(msg, e);
+ } finally {
+ AndroidDAOFactory.closeConnection();
+ }
+ return status;
+ }
+
+ @Override
+ public boolean deleteMobileDevice(String id) throws EnterpriseServiceException {
+ boolean status;
+ if (log.isDebugEnabled()) {
+ log.debug("Calling update managed config for mcm id : " + id);
+ }
+
+ try {
+ AndroidDAOFactory.beginTransaction();
+ status = this.enterpriseDAO.deleteConfig(id,CarbonContext.getThreadLocalCarbonContext().getTenantId());
+ AndroidDAOFactory.commitTransaction();
+ } catch (EnterpriseManagementDAOException e) {
+ String msg = "Error occurred while updating managed configs for mcm id " + id;
+ log.error(msg, e);
+ AndroidDAOFactory.rollbackTransaction();
+ throw new EnterpriseServiceException(msg, e);
+ } finally {
+ AndroidDAOFactory.closeConnection();
+ }
+ return status;
+ }
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPolicyMonitoringManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPolicyMonitoringManager.java
deleted file mode 100644
index 11d2f5332..000000000
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPolicyMonitoringManager.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * 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.
- */
-
-
-package org.wso2.carbon.device.mgt.mobile.android.impl;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParser;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
-import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
-import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
-import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
-import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
-import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class AndroidPolicyMonitoringManager implements PolicyMonitoringManager {
-
- private static Log log = LogFactory.getLog(AndroidPolicyMonitoringManager.class);
-
- @Override
- public NonComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy,
- Object compliancePayload) throws PolicyComplianceException {
- if (log.isDebugEnabled()) {
- log.debug("Checking policy compliance status of device '" + deviceIdentifier.getId() + "'");
- }
- NonComplianceData complianceData = new NonComplianceData();
- if (compliancePayload == null || policy == null) {
- return complianceData;
- }
- String compliancePayloadString = new Gson().toJson(compliancePayload);
- // Parsing json string to get compliance features.
- JsonElement jsonElement;
- if (compliancePayloadString instanceof String) {
- jsonElement = new JsonParser().parse(compliancePayloadString);
- } else {
- throw new PolicyComplianceException("Invalid policy compliance payload");
- }
-
- JsonArray jsonArray = jsonElement.getAsJsonArray();
- Gson gson = new Gson();
- ComplianceFeature complianceFeature;
- List complianceFeatures = new ArrayList(jsonArray.size());
- List nonComplianceFeatures = new ArrayList<>();
-
- for (JsonElement element : jsonArray) {
- complianceFeature = gson.fromJson(element, ComplianceFeature.class);
- complianceFeatures.add(complianceFeature);
- }
-
- for (ComplianceFeature cf : complianceFeatures) {
- if (!cf.isCompliant()) {
- complianceData.setStatus(false);
- nonComplianceFeatures.add(cf);
- break;
- }
- }
-
- complianceData.setComplianceFeatures(nonComplianceFeatures);
- return complianceData;
- }
-
-}
\ No newline at end of file
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/EnterpriseServiceException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/EnterpriseServiceException.java
new file mode 100644
index 000000000..d8b5e80df
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/EnterpriseServiceException.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.
+ */
+
+package org.wso2.carbon.device.mgt.mobile.android.impl;
+
+/**
+ * Custom exception class for enterprise specific data access related exceptions.
+ */
+public class EnterpriseServiceException extends Exception {
+
+ private String message;
+ private static final long serialVersionUID = 2021891706072918865L;
+
+ /**
+ * Constructs a new EnterpriseServiceException with the specified detail message and
+ * nested exception.
+ *
+ * @param message error message
+ * @param nestedException exception
+ */
+ public EnterpriseServiceException(String message, Exception nestedException) {
+ super(message, nestedException);
+ setErrorMessage(message);
+ }
+
+ /**
+ * Constructs a new EnterpriseServiceException with the specified detail message
+ * and cause.
+ *
+ * @param message the detail message.
+ * @param cause the cause of this exception.
+ */
+ public EnterpriseServiceException(String message, Throwable cause) {
+ super(message, cause);
+ setErrorMessage(message);
+ }
+
+ /**
+ * Constructs a new EnterpriseServiceException with the specified detail message.
+ *
+ * @param message the detail message.
+ */
+ public EnterpriseServiceException(String message) {
+ super(message);
+ setErrorMessage(message);
+ }
+
+ /**
+ * Constructs a new EnterpriseServiceException with the specified and cause.
+ *
+ * @param cause the cause of this exception.
+ */
+ public EnterpriseServiceException(Throwable cause) {
+ super(cause);
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.message = errorMessage;
+ }
+
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/AndroidDataSourceConfigurations.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/AndroidDataSourceConfigurations.java
new file mode 100644
index 000000000..9409bab13
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/AndroidDataSourceConfigurations.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.
+ */
+
+package org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource;
+
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "iosDBConfigurations")
+public class AndroidDataSourceConfigurations {
+
+ private MobileDataSourceConfig iosDataSourceConfiguration;
+ @XmlElement(name = "DataSourceConfiguration")
+ public MobileDataSourceConfig getIosDataSourceConfiguration() {
+ return iosDataSourceConfiguration;
+ }
+
+ public void setIosDataSourceConfiguration(MobileDataSourceConfig iosDataSourceConfiguration) {
+ this.iosDataSourceConfiguration = iosDataSourceConfiguration;
+ }
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java
index c96b603a8..634951826 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java
@@ -34,7 +34,7 @@ import java.util.Map;
/**
* Factory class used to create MobileDeviceManagement related DAO objects.
*/
-public abstract class AbstractMobileDeviceManagementDAOFactory implements MobileDeviceManagementDAOFactory {
+public abstract class AbstractMobileDeviceManagementDAOFactory {
private static final Log log = LogFactory.getLog(AbstractMobileDeviceManagementDAOFactory.class);
private static Map dataSourceMap = new HashMap<>();
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java
index e3949b16a..2ccd09374 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java
@@ -21,8 +21,7 @@ package org.wso2.carbon.device.mgt.mobile.android.impl.dao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidDeviceDAOImpl;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidFeatureDAOImpl;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.EnterpriseDAOImpl;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -38,38 +37,52 @@ public class AndroidDAOFactory extends AbstractMobileDeviceManagementDAOFactory
this.dataSource = getDataSourceMap().get(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
}
- @Override
- public MobileDeviceDAO getMobileDeviceDAO() {
- return new AndroidDeviceDAOImpl();
- }
+ public static EnterpriseDAO getEnterpriseDAO() {
+ if (dataSource == null) {
+ dataSource = getDataSourceMap().get(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
+ }
- public MobileFeatureDAO getMobileFeatureDAO() {
- return new AndroidFeatureDAOImpl();
+ return new EnterpriseDAOImpl();
}
- public static void beginTransaction() throws MobileDeviceManagementDAOException {
+ public static void beginTransaction() throws EnterpriseManagementDAOException {
try {
Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);
currentConnection.set(conn);
} catch (SQLException e) {
- throw new MobileDeviceManagementDAOException("Error occurred while retrieving datasource connection", e);
+ throw new EnterpriseManagementDAOException("Error occurred while retrieving datasource connection", e);
+ }
+ }
+
+ public static void openConnection() throws EnterpriseManagementDAOException {
+ Connection conn = currentConnection.get();
+ if (conn != null) {
+ throw new EnterpriseManagementDAOException("A transaction is already active within the context of " +
+ "this particular thread. Therefore, calling 'beginTransaction/openConnection' while another " +
+ "transaction is already active is a sign of improper transaction handling");
+ }
+ try {
+ conn = dataSource.getConnection();
+ } catch (SQLException e) {
+ throw new EnterpriseManagementDAOException("Error occurred while opening connection", e);
}
+ currentConnection.set(conn);
}
- public static Connection getConnection() throws MobileDeviceManagementDAOException {
+ public static Connection getConnection() throws EnterpriseManagementDAOException {
if (currentConnection.get() == null) {
try {
currentConnection.set(dataSource.getConnection());
} catch (SQLException e) {
- throw new MobileDeviceManagementDAOException("Error occurred while retrieving data source connection",
+ throw new EnterpriseManagementDAOException("Error occurred while retrieving data source connection",
e);
}
}
return currentConnection.get();
}
- public static void commitTransaction() throws MobileDeviceManagementDAOException {
+ public static void commitTransaction() throws EnterpriseManagementDAOException {
try {
Connection conn = currentConnection.get();
if (conn != null) {
@@ -81,11 +94,11 @@ public class AndroidDAOFactory extends AbstractMobileDeviceManagementDAOFactory
}
}
} catch (SQLException e) {
- throw new MobileDeviceManagementDAOException("Error occurred while committing the transaction", e);
+ throw new EnterpriseManagementDAOException("Error occurred while committing the transaction", e);
}
}
- public static void closeConnection() throws MobileDeviceManagementDAOException {
+ public static void closeConnection() {
Connection conn = currentConnection.get();
try {
if (conn != null) {
@@ -97,7 +110,7 @@ public class AndroidDAOFactory extends AbstractMobileDeviceManagementDAOFactory
currentConnection.remove();
}
- public static void rollbackTransaction() throws MobileDeviceManagementDAOException {
+ public static void rollbackTransaction() {
try {
Connection conn = currentConnection.get();
if (conn != null) {
@@ -109,7 +122,7 @@ public class AndroidDAOFactory extends AbstractMobileDeviceManagementDAOFactory
}
}
} catch (SQLException e) {
- throw new MobileDeviceManagementDAOException("Error occurred while rollback the transaction", e);
+ log.warn("Error occurred while roll-backing the transaction", e);
}
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidFeatureManagementDAOException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidFeatureManagementDAOException.java
deleted file mode 100644
index 61db0cc04..000000000
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidFeatureManagementDAOException.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * 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.
- *
- */
-package org.wso2.carbon.device.mgt.mobile.android.impl.dao;
-
-public class AndroidFeatureManagementDAOException extends MobileDeviceManagementDAOException {
-
- private String message;
- private static final long serialVersionUID = 2021891706072918865L;
-
- /**
- * Constructs a new MobileDeviceManagementDAOException with the specified detail message and
- * nested exception.
- *
- * @param message error message
- * @param nestedException exception
- */
- public AndroidFeatureManagementDAOException(String message, Exception nestedException) {
- super(message, nestedException);
- setErrorMessage(message);
- }
-
- /**
- * Constructs a new MobileDeviceManagementDAOException with the specified detail message
- * and cause.
- *
- * @param message the detail message.
- * @param cause the cause of this exception.
- */
- public AndroidFeatureManagementDAOException(String message, Throwable cause) {
- super(message, cause);
- setErrorMessage(message);
- }
-
- /**
- * Constructs a new MobileDeviceManagementDAOException with the specified detail message.
- *
- * @param message the detail message.
- */
- public AndroidFeatureManagementDAOException(String message) {
- super(message);
- setErrorMessage(message);
- }
-
- /**
- * Constructs a new MobileDeviceManagementDAOException with the specified and cause.
- *
- * @param cause the cause of this exception.
- */
- public AndroidFeatureManagementDAOException(Throwable cause) {
- super(cause);
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setErrorMessage(String errorMessage) {
- this.message = errorMessage;
- }
-
-}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseDAO.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseDAO.java
new file mode 100644
index 000000000..87aafb814
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseDAO.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.
+ */
+
+package org.wso2.carbon.device.mgt.mobile.android.impl.dao;
+
+import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser;
+
+import java.util.List;
+
+/**
+ * This class represents the key operations associated with working with Enterprise data
+ */
+public interface EnterpriseDAO {
+
+ /**
+ * Add a new user to Enterprise.
+ *
+ * @param androidEnterpriseUser Enterprise user and device details.
+ * @return User addition status.
+ * @throws EnterpriseManagementDAOException
+ */
+ boolean addUser(AndroidEnterpriseUser androidEnterpriseUser) throws EnterpriseManagementDAOException;
+
+ List getUser(String username, int tenantId) throws EnterpriseManagementDAOException;
+
+ AndroidEnterpriseUser getUserByDevice(String deviceId, int tenantId) throws EnterpriseManagementDAOException;
+
+ AndroidEnterpriseManagedConfig getConfigByPackageName(String packageName, int tenantId)
+ throws EnterpriseManagementDAOException;
+
+ boolean addConfig(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseManagementDAOException;
+
+ boolean updateConfig(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseManagementDAOException;
+
+ boolean deleteConfig(String id, int tenantId) throws EnterpriseManagementDAOException;
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseManagementDAOException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseManagementDAOException.java
new file mode 100644
index 000000000..86af32e80
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/EnterpriseManagementDAOException.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * 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.
+ */
+/*
+ * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.
+ */
+
+package org.wso2.carbon.device.mgt.mobile.android.impl.dao;
+
+/**
+ * Custom exception class for enterprise specific data access related exceptions.
+ */
+public class EnterpriseManagementDAOException extends Exception {
+
+ private String message;
+ private static final long serialVersionUID = 2021891702072938865L;
+
+ /**
+ * Constructs a new EnterpriseManagementDAOException with the specified detail message and
+ * nested exception.
+ *
+ * @param message error message
+ * @param nestedException exception
+ */
+ public EnterpriseManagementDAOException(String message, Exception nestedException) {
+ super(message, nestedException);
+ setErrorMessage(message);
+ }
+
+ /**
+ * Constructs a new EnterpriseManagementDAOException with the specified detail message
+ * and cause.
+ *
+ * @param message the detail message.
+ * @param cause the cause of this exception.
+ */
+ public EnterpriseManagementDAOException(String message, Throwable cause) {
+ super(message, cause);
+ setErrorMessage(message);
+ }
+
+ /**
+ * Constructs a new EnterpriseManagementDAOException with the specified detail message.
+ *
+ * @param message the detail message.
+ */
+ public EnterpriseManagementDAOException(String message) {
+ super(message);
+ setErrorMessage(message);
+ }
+
+ /**
+ * Constructs a new EnterpriseManagementDAOException with the specified and cause.
+ *
+ * @param cause the cause of this exception.
+ */
+ public EnterpriseManagementDAOException(Throwable cause) {
+ super(cause);
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.message = errorMessage;
+ }
+
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceDAO.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceDAO.java
deleted file mode 100644
index d9209a1cb..000000000
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceDAO.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * 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.
- */
-
-package org.wso2.carbon.device.mgt.mobile.android.impl.dao;
-
-import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice;
-import java.util.List;
-
-/**
- * This class represents the key operations associated with persisting mobile-device related
- * information.
- */
-public interface MobileDeviceDAO {
-
- /**
- * Fetches a MobileDevice from MDM database.
- *
- * @param mblDeviceId Id of the Mobile-Device.
- * @return MobileDevice corresponding to given device-id.
- * @throws MobileDeviceManagementDAOException
- */
- MobileDevice getMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException;
-
- /**
- * Adds a new MobileDevice to the MDM database.
- *
- * @param mobileDevice MobileDevice to be added.
- * @return The status of the operation.
- * @throws MobileDeviceManagementDAOException
- */
- boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
-
- /**
- * Updates MobileDevice information in MDM database.
- *
- * @param mobileDevice MobileDevice to be updated.
- * @return The status of the operation.
- * @throws MobileDeviceManagementDAOException
- */
- boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
-
- /**
- * Deletes a given MobileDevice from MDM database.
- *
- * @param mblDeviceId Id of MobileDevice to be deleted.
- * @return The status of the operation.
- * @throws MobileDeviceManagementDAOException
- */
- boolean deleteMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException;
-
- /**
- * Fetches all MobileDevices from MDM database.
- *
- * @return List of MobileDevices.
- * @throws MobileDeviceManagementDAOException
- */
- List getAllMobileDevices() throws MobileDeviceManagementDAOException;
-
-}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java
index 1b28ac285..d4746f623 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java
@@ -20,8 +20,5 @@ package org.wso2.carbon.device.mgt.mobile.android.impl.dao;
public interface MobileDeviceManagementDAOFactory {
- MobileDeviceDAO getMobileDeviceDAO();
-
- MobileFeatureDAO getMobileFeatureDAO();
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileFeatureDAO.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileFeatureDAO.java
deleted file mode 100644
index aba4c13b3..000000000
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileFeatureDAO.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * 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.
- */
-
-/*
- * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
- *
- * Entgra (Pvt) Ltd. 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.
- */
-
-package org.wso2.carbon.device.mgt.mobile.android.impl.dao;
-
-import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileFeature;
-
-import java.util.List;
-
-/**
- * This class represents the key operations associated with persisting mobile feature related
- * information.
- */
-public interface MobileFeatureDAO {
-
- /**
- * Adds a new MobileFeature to Mobile-Feature table.
- *
- * @param mobileFeature MobileFeature object that holds data related to the feature to be inserted.
- * @return boolean status of the operation.
- * @throws MobileDeviceManagementDAOException
- */
- boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException;
-
- /**
- * Adda a list of MobileFeatures to Mobile-Feature table.
- *
- * @param mobileFeatures List of MobileFeature objects.
- * @return boolean status of the operation.
- * @throws MobileDeviceManagementDAOException
- */
- boolean addFeatures(List mobileFeatures) throws MobileDeviceManagementDAOException;
-
- /**
- * Updates a MobileFeature in Mobile-Feature table.
- *
- * @param mobileFeature MobileFeature object that holds data has to be updated.
- * @return The status of the operation.
- * @throws MobileDeviceManagementDAOException
- */
- boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException;
-
- /**
- * Deletes a MobileFeature from Mobile-Feature table when the feature id is given.
- *
- * @param mblFeatureId MobileFeature id of the MobileFeature to be deleted.
- * @return The status of the operation.
- * @throws MobileDeviceManagementDAOException
- */
- boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException;
-
- /**
- * Deletes a MobileFeature from Mobile-Feature table when the feature code is given.
- *
- * @param mblFeatureCode MobileFeature code of the feature to be deleted.
- * @return The status of the operation.
- * @throws MobileDeviceManagementDAOException
- */
- boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException;
-
- /**
- * Retrieves a given MobileFeature from Mobile-Feature table when the feature id is given.
- *
- * @param mblFeatureId Feature id of the feature to be retrieved.
- * @return MobileFeature object that holds data of the feature represented by featureId.
- * @throws MobileDeviceManagementDAOException
- */
- MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException;
-
- /**
- * Retrieves a given MobileFeature from Mobile-Feature table when the feature code is given.
- *
- * @param mblFeatureCode Feature code of the feature to be retrieved.
- * @return MobileFeature object that holds data of the feature represented by featureCode.
- * @throws MobileDeviceManagementDAOException
- */
- MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException;
-
- /**
- * Retrieves all MobileFeatures of a MobileDevice type from Mobile-Feature table.
- *
- * @param deviceType MobileDevice type of the MobileFeatures to be retrieved
- * @return MobileFeature object list.
- * @throws MobileDeviceManagementDAOException
- */
- List getFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException;
-
- /**
- * Retrieve all the MobileFeatures from Mobile-Feature table.
- *
- * @return MobileFeature object list.
- * @throws MobileDeviceManagementDAOException
- */
- List getAllFeatures() throws MobileDeviceManagementDAOException;
-
- /**
- * Get all the MobileFeatures by a given ui visibility
- *
- * @param isHidden Whether the operation is hidden from UI or not.
- * @return {@link MobileFeature} object list.
- * @throws MobileDeviceManagementDAOException If an error occurred while retrieving the Feature list
- */
- List getAllFeatures(boolean isHidden) throws MobileDeviceManagementDAOException;
-
- /**
- * Retrieve all MobileFeatures of a given feature type
- *
- * @param featureType Feature type.
- * @return {@link MobileFeature} object list.
- * @throws MobileDeviceManagementDAOException If an error occurred while retrieving the Feature list
- */
- List getFeaturesByFeatureType(String featureType) throws MobileDeviceManagementDAOException;
-
- /**
- * Retrieve all MobileFeatures of a given feature type and ui visibility
- *
- * @param featureType Feature type.
- * @param isHidden Whether the operation is hidden from UI or not.
- * @return {@link MobileFeature} object list.
- * @throws MobileDeviceManagementDAOException If an error occurred while retrieving the Feature list
- */
- List getFeaturesByFeatureType(String featureType, boolean isHidden) throws MobileDeviceManagementDAOException;
-}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java
deleted file mode 100644
index 416a4d90d..000000000
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * 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.
- */
-
-package org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceDAO;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.util.MobileDeviceManagementDAOUtil;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice;
-import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Implements MobileDeviceDAO for Android Devices.
- */
-public class AndroidDeviceDAOImpl implements MobileDeviceDAO{
-
- private static final Log log = LogFactory.getLog(AndroidDeviceDAOImpl.class);
-
- @Override
- public MobileDevice getMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException {
- Connection conn;
- PreparedStatement stmt = null;
- MobileDevice mobileDevice = null;
- ResultSet rs = null;
- try {
- conn = AndroidDAOFactory.getConnection();
- String selectDBQuery =
- "SELECT DEVICE_ID, FCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " +
- "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION, OS_BUILD_DATE" +
- " FROM AD_DEVICE WHERE DEVICE_ID = ?";
- stmt = conn.prepareStatement(selectDBQuery);
- stmt.setString(1, mblDeviceId);
- rs = stmt.executeQuery();
-
- if (rs.next()) {
- mobileDevice = new MobileDevice();
- mobileDevice.setMobileDeviceId(rs.getString(AndroidPluginConstants.DEVICE_ID));
- mobileDevice.setModel(rs.getString(AndroidPluginConstants.DEVICE_MODEL));
- mobileDevice.setSerial(rs.getString(AndroidPluginConstants.SERIAL));
- mobileDevice.setVendor(rs.getString(AndroidPluginConstants.VENDOR));
- mobileDevice.setLatitude(rs.getString(AndroidPluginConstants.LATITUDE));
- mobileDevice.setLongitude(rs.getString(AndroidPluginConstants.LONGITUDE));
- mobileDevice.setImei(rs.getString(AndroidPluginConstants.IMEI));
- mobileDevice.setImsi(rs.getString(AndroidPluginConstants.IMSI));
- mobileDevice.setOsVersion(rs.getString(AndroidPluginConstants.OS_VERSION));
- mobileDevice.setOsBuildDate(rs.getString(AndroidPluginConstants.OS_BUILD_DATE));
-
- Map propertyMap = new HashMap();
- propertyMap.put(AndroidPluginConstants.FCM_TOKEN, rs.getString(AndroidPluginConstants.FCM_TOKEN));
- propertyMap.put(AndroidPluginConstants.DEVICE_INFO, rs.getString(AndroidPluginConstants.DEVICE_INFO));
- propertyMap.put(AndroidPluginConstants.DEVICE_NAME, rs.getString(AndroidPluginConstants.DEVICE_NAME));
- mobileDevice.setDeviceProperties(propertyMap);
-
- if (log.isDebugEnabled()) {
- log.debug("Android device " + mblDeviceId + " data has been fetched from " +
- "Android database.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while fetching Android device : '" + mblDeviceId + "'";
- log.error(msg, e);
- throw new MobileDeviceManagementDAOException(msg, e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
- AndroidDAOFactory.closeConnection();
- }
-
- return mobileDevice;
- }
-
- @Override
- public boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException {
- boolean status = false;
- Connection conn;
- PreparedStatement stmt = null;
- try {
- conn = AndroidDAOFactory.getConnection();
- String createDBQuery =
- "INSERT INTO AD_DEVICE(DEVICE_ID, FCM_TOKEN, DEVICE_INFO, SERIAL, " +
- "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, " +
- "OS_VERSION, DEVICE_MODEL, OS_BUILD_DATE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
-
- stmt = conn.prepareStatement(createDBQuery);
- stmt.setString(1, mobileDevice.getMobileDeviceId());
-
- Map properties = mobileDevice.getDeviceProperties();
- stmt.setString(2, properties.get(AndroidPluginConstants.FCM_TOKEN));
- stmt.setString(3, properties.get(AndroidPluginConstants.DEVICE_INFO));
- stmt.setString(4, mobileDevice.getSerial());
- stmt.setString(5, mobileDevice.getVendor());
- stmt.setString(6, mobileDevice.getMobileDeviceId());
- stmt.setString(7, properties.get(AndroidPluginConstants.DEVICE_NAME));
- stmt.setString(8, mobileDevice.getLatitude());
- stmt.setString(9, mobileDevice.getLongitude());
- stmt.setString(10, mobileDevice.getImei());
- stmt.setString(11, mobileDevice.getImsi());
- stmt.setString(12, mobileDevice.getOsVersion());
- stmt.setString(13, mobileDevice.getModel());
- stmt.setString(14, mobileDevice.getOsBuildDate());
- int rows = stmt.executeUpdate();
- if (rows > 0) {
- status = true;
- if (log.isDebugEnabled()) {
- log.debug("Android device " + mobileDevice.getMobileDeviceId() + " data has been" +
- " added to the Android database.");
- }
- }
- } catch (SQLException e) {
- throw new MobileDeviceManagementDAOException("Error occurred while adding the Android device '" +
- mobileDevice.getMobileDeviceId() + "' information to the Android plugin data store.", e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
- }
- return status;
- }
-
- @Override
- public boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException {
- boolean status = false;
- Connection conn;
- PreparedStatement stmt = null;
- try {
- conn = AndroidDAOFactory.getConnection();
- String updateDBQuery =
- "UPDATE AD_DEVICE SET FCM_TOKEN = ?, DEVICE_INFO = ?, SERIAL = ?, VENDOR = ?, " +
- "MAC_ADDRESS = ?, DEVICE_NAME = ?, LATITUDE = ?, LONGITUDE = ?, IMEI = ?, " +
- "IMSI = ?, OS_VERSION = ?, DEVICE_MODEL = ?, OS_BUILD_DATE = ? WHERE DEVICE_ID = ?";
- stmt = conn.prepareStatement(updateDBQuery);
-
- Map properties = mobileDevice.getDeviceProperties();
- stmt.setString(1, properties.get(AndroidPluginConstants.FCM_TOKEN));
- stmt.setString(2, properties.get(AndroidPluginConstants.DEVICE_INFO));
- stmt.setString(3, mobileDevice.getSerial());
- stmt.setString(4, mobileDevice.getVendor());
- stmt.setString(5, properties.get(AndroidPluginConstants.MAC_ADDRESS));
- stmt.setString(6, properties.get(AndroidPluginConstants.DEVICE_NAME));
- stmt.setString(7, mobileDevice.getLatitude());
- stmt.setString(8, mobileDevice.getLongitude());
- stmt.setString(9, mobileDevice.getImei());
- stmt.setString(10, mobileDevice.getImsi());
- stmt.setString(11, mobileDevice.getOsVersion());
- stmt.setString(12, mobileDevice.getModel());
- stmt.setString(13, mobileDevice.getOsBuildDate());
- stmt.setString(14, mobileDevice.getMobileDeviceId());
- int rows = stmt.executeUpdate();
- if (rows > 0) {
- status = true;
- if (log.isDebugEnabled()) {
- log.debug("Android device " + mobileDevice.getMobileDeviceId() + " data has been" +
- " modified.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while modifying the Android device '" +
- mobileDevice.getMobileDeviceId() + "' data.";
- log.error(msg, e);
- throw new MobileDeviceManagementDAOException(msg, e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
- }
- return status;
- }
-
- @Override
- public boolean deleteMobileDevice(String mblDeviceId)
- throws MobileDeviceManagementDAOException {
- boolean status = false;
- Connection conn;
- PreparedStatement stmt = null;
- try {
- conn = AndroidDAOFactory.getConnection();
- String deleteDBQuery =
- "DELETE FROM AD_DEVICE WHERE DEVICE_ID = ?";
- stmt = conn.prepareStatement(deleteDBQuery);
- stmt.setString(1, mblDeviceId);
- int rows = stmt.executeUpdate();
- if (rows > 0) {
- status = true;
- if (log.isDebugEnabled()) {
- log.debug("Android device " + mblDeviceId + " data has deleted" +
- " from the Android database.");
- }
- }
- } catch (SQLException e) {
- throw new MobileDeviceManagementDAOException("Error occurred while deleting android device '" +
- mblDeviceId + "'", e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
- }
- return status;
- }
-
- @Override
- public List getAllMobileDevices() throws MobileDeviceManagementDAOException {
- Connection conn;
- PreparedStatement stmt = null;
- ResultSet rs = null;
- MobileDevice mobileDevice;
- List mobileDevices = new ArrayList();
- try {
- conn = AndroidDAOFactory.getConnection();
- String selectDBQuery =
- "SELECT DEVICE_ID, FCM_TOKEN, DEVICE_INFO, DEVICE_MODEL, SERIAL, " +
- "VENDOR, MAC_ADDRESS, DEVICE_NAME, LATITUDE, LONGITUDE, IMEI, IMSI, OS_VERSION, OS_BUILD_DATE " +
- "FROM AD_DEVICE";
- stmt = conn.prepareStatement(selectDBQuery);
- rs = stmt.executeQuery();
-
- while (rs.next()) {
- mobileDevice = new MobileDevice();
- mobileDevice.setMobileDeviceId(rs.getString(AndroidPluginConstants.DEVICE_ID));
- mobileDevice.setModel(rs.getString(AndroidPluginConstants.DEVICE_MODEL));
- mobileDevice.setSerial(rs.getString(AndroidPluginConstants.SERIAL));
- mobileDevice.setVendor(rs.getString(AndroidPluginConstants.VENDOR));
- mobileDevice.setLatitude(rs.getString(AndroidPluginConstants.LATITUDE));
- mobileDevice.setLongitude(rs.getString(AndroidPluginConstants.LONGITUDE));
- mobileDevice.setImei(rs.getString(AndroidPluginConstants.IMEI));
- mobileDevice.setImsi(rs.getString(AndroidPluginConstants.IMSI));
- mobileDevice.setOsVersion(rs.getString(AndroidPluginConstants.OS_VERSION));
- mobileDevice.setOsBuildDate(rs.getString(AndroidPluginConstants.OS_BUILD_DATE));
-
- Map propertyMap = new HashMap<>();
- propertyMap.put(AndroidPluginConstants.FCM_TOKEN, rs.getString(AndroidPluginConstants.FCM_TOKEN));
- propertyMap.put(AndroidPluginConstants.DEVICE_INFO, rs.getString(AndroidPluginConstants.DEVICE_INFO));
- propertyMap.put(AndroidPluginConstants.DEVICE_NAME, rs.getString(AndroidPluginConstants.DEVICE_NAME));
- mobileDevice.setDeviceProperties(propertyMap);
-
- mobileDevices.add(mobileDevice);
- }
- if (log.isDebugEnabled()) {
- log.debug("All Android device details have fetched from Android database.");
- }
- return mobileDevices;
- } catch (SQLException e) {
- throw new MobileDeviceManagementDAOException("Error occurred while fetching all Android device data", e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
- AndroidDAOFactory.closeConnection();
- }
- }
-
-}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidFeatureDAOImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidFeatureDAOImpl.java
deleted file mode 100644
index 2d9fe21d0..000000000
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidFeatureDAOImpl.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * 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.
- *
- */
-
-/*
- * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
- *
- * Entgra (Pvt) Ltd. 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.
- */
-
-package org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidFeatureManagementDAOException;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileFeatureDAO;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dao.util.MobileDeviceManagementDAOUtil;
-import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileFeature;
-import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class AndroidFeatureDAOImpl implements MobileFeatureDAO {
-
- private static final Log log = LogFactory.getLog(AndroidFeatureDAOImpl.class);
-
- public AndroidFeatureDAOImpl() {
-
- }
-
- @Override
- public boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException {
- PreparedStatement stmt = null;
- boolean status = false;
- Connection conn;
- try {
- conn = AndroidDAOFactory.getConnection();
- String sql = "INSERT INTO AD_FEATURE(CODE, NAME, TYPE, HIDDEN, DESCRIPTION) VALUES (?, ?, ?, ?, ?)";
- stmt = conn.prepareStatement(sql);
- stmt.setString(1, mobileFeature.getCode());
- stmt.setString(2, mobileFeature.getName());
- stmt.setString(3, mobileFeature.getType());
- stmt.setBoolean(4, mobileFeature.isHidden());
- stmt.setString(5, mobileFeature.getDescription());
- stmt.executeUpdate();
- status = true;
- } catch (SQLException e) {
- throw new AndroidFeatureManagementDAOException(
- "Error occurred while adding android feature '" +
- mobileFeature.getName() + "' into the metadata repository", e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
- }
- return status;
- }
-
- @Override
- public boolean addFeatures(List mobileFeatures) throws MobileDeviceManagementDAOException {
- PreparedStatement stmt = null;
- Connection conn;
- try {
- conn = AndroidDAOFactory.getConnection();
- stmt = conn.prepareStatement("INSERT INTO AD_FEATURE(CODE, NAME, TYPE, HIDDEN, DESCRIPTION) " +
- "VALUES (?, ?, ?, ?, ?)");
- for (MobileFeature mobileFeature : mobileFeatures) {
- stmt.setString(1, mobileFeature.getCode());
- stmt.setString(2, mobileFeature.getName());
- stmt.setString(3, mobileFeature.getType());
- stmt.setBoolean(4, mobileFeature.isHidden());
- stmt.setString(5, mobileFeature.getDescription());
- stmt.addBatch();
- }
- stmt.executeBatch();
- return true;
- } catch (SQLException e) {
- throw new AndroidFeatureManagementDAOException(
- "Error occurred while adding android features into the metadata repository", e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
- }
- }
-
- @Override
- public boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException {
- boolean status = false;
- Connection conn;
- PreparedStatement stmt = null;
- try {
- conn = AndroidDAOFactory.getConnection();
- String updateDBQuery =
- "UPDATE AD_FEATURE SET NAME = ?, TYPE = ?, HIDDEN = ? ,DESCRIPTION = ?" +
- "WHERE CODE = ?";
-
- stmt = conn.prepareStatement(updateDBQuery);
- stmt.setString(1, mobileFeature.getName());
- stmt.setString(2, mobileFeature.getType());
- stmt.setBoolean(3, mobileFeature.isHidden());
- stmt.setString(4, mobileFeature.getDescription());
- stmt.setString(5, mobileFeature.getCode());
-
- int rows = stmt.executeUpdate();
- if (rows > 0) {
- status = true;
- if (log.isDebugEnabled()) {
- log.debug("Android Feature " + mobileFeature.getCode() + " data has been " +
- "modified.");
- }
- }
- } catch (SQLException e) {
- String msg = "Error occurred while updating the Android Feature '" +
- mobileFeature.getCode() + "' to the Android db.";
- log.error(msg, e);
- throw new AndroidFeatureManagementDAOException(msg, e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
- }
- return status;
- }
-
- @Override
- public boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException {
-
- PreparedStatement stmt = null;
- boolean status = false;
- Connection conn;
- try {
- conn = AndroidDAOFactory.getConnection();
- String sql = "DELETE FROM AD_FEATURE WHERE ID = ?";
- stmt = conn.prepareStatement(sql);
- stmt.setInt(1, mblFeatureId);
- stmt.execute();
- status = true;
- } catch (SQLException e) {
- throw new AndroidFeatureManagementDAOException(
- "Error occurred while deleting android feature '" +
- mblFeatureId + "' from Android database.", e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
- }
- return status;
- }
-
- @Override
- public boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException {
- PreparedStatement stmt = null;
- boolean status;
- Connection conn;
- try {
- conn = AndroidDAOFactory.getConnection();
- String sql = "DELETE FROM AD_FEATURE WHERE CODE = ?";
- stmt = conn.prepareStatement(sql);
- stmt.setString(1, mblFeatureCode);
- stmt.execute();
- status = true;
- } catch (SQLException e) {
- throw new AndroidFeatureManagementDAOException(
- "Error occurred while deleting android feature '" +
- mblFeatureCode + "' from Android database.", e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
- }
- return status;
- }
-
- @Override
- public MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException {
- PreparedStatement stmt = null;
- ResultSet rs = null;
- Connection conn;
- try {
- conn = AndroidDAOFactory.getConnection();
- String sql = "SELECT ID, CODE, NAME, TYPE, HIDDEN, DESCRIPTION FROM AD_FEATURE WHERE ID = ?";
- stmt = conn.prepareStatement(sql);
- stmt.setInt(1, mblFeatureId);
- rs = stmt.executeQuery();
-
- MobileFeature mobileFeature = null;
- if (rs.next()) {
- mobileFeature = new MobileFeature();
- mobileFeature.setId(rs.getInt(AndroidPluginConstants.ANDROID_FEATURE_ID));
- mobileFeature.setCode(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_CODE));
- mobileFeature.setName(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_NAME));
- mobileFeature.setType(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_TYPE));
- mobileFeature.setHidden(rs.getBoolean(AndroidPluginConstants.ANDROID_FEATURE_HIDDEN));
- mobileFeature.setDescription(rs.getString(AndroidPluginConstants.
- ANDROID_FEATURE_DESCRIPTION));
- mobileFeature.setDeviceType(
- DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
- }
- return mobileFeature;
- } catch (SQLException e) {
- throw new AndroidFeatureManagementDAOException(
- "Error occurred while retrieving android feature '" +
- mblFeatureId + "' from the Android database.", e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
- AndroidDAOFactory.closeConnection();
- }
- }
-
- @Override
- public MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException {
- PreparedStatement stmt = null;
- ResultSet rs = null;
- Connection conn;
-
- try {
- conn = AndroidDAOFactory.getConnection();
- String sql = "SELECT ID, CODE, NAME, TYPE, HIDDEN, DESCRIPTION FROM AD_FEATURE WHERE CODE = ?";
- stmt = conn.prepareStatement(sql);
- stmt.setString(1, mblFeatureCode);
- rs = stmt.executeQuery();
-
- MobileFeature mobileFeature = null;
- if (rs.next()) {
- mobileFeature = populateMobileFeature(rs);
- }
- return mobileFeature;
- } catch (SQLException e) {
- throw new AndroidFeatureManagementDAOException(
- "Error occurred while retrieving android feature '" +
- mblFeatureCode + "' from the Android database.", e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
- AndroidDAOFactory.closeConnection();
- }
- }
-
- @Override
- public List getFeatureByDeviceType(String deviceType)
- throws MobileDeviceManagementDAOException {
- return this.getAllFeatures();
- }
-
- @Override
- public List getAllFeatures() throws MobileDeviceManagementDAOException {
- PreparedStatement stmt = null;
- ResultSet rs = null;
- Connection conn = null;
- List features = new ArrayList<>();
- try {
- conn = AndroidDAOFactory.getConnection();
- String sql = "SELECT ID, CODE, NAME, TYPE, HIDDEN, DESCRIPTION FROM AD_FEATURE";
- stmt = conn.prepareStatement(sql);
- rs = stmt.executeQuery();
-
- while (rs.next()) {
- features.add(populateMobileFeature(rs));
- }
- return features;
- } catch (SQLException e) {
- throw new AndroidFeatureManagementDAOException("Error occurred while retrieving all android features " +
- "from the android database.", e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
- AndroidDAOFactory.closeConnection();
- }
- }
-
- @Override
- public List getAllFeatures(boolean isHidden) throws MobileDeviceManagementDAOException {
- PreparedStatement stmt = null;
- ResultSet rs = null;
- Connection conn = null;
- List features = new ArrayList<>();
- try {
- conn = AndroidDAOFactory.getConnection();
- String sql = "SELECT ID, CODE, NAME, TYPE, HIDDEN, DESCRIPTION FROM AD_FEATURE WHERE HIDDEN = ?";
- stmt = conn.prepareStatement(sql);
- stmt.setBoolean(1, isHidden);
- rs = stmt.executeQuery();
-
- while (rs.next()) {
- features.add(populateMobileFeature(rs));
- }
- return features;
- } catch (SQLException e) {
- throw new AndroidFeatureManagementDAOException("Error occurred while retrieving all android features " +
- "from the android database.", e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
- AndroidDAOFactory.closeConnection();
- }
- }
-
- @Override
- public List getFeaturesByFeatureType(String featureType) throws MobileDeviceManagementDAOException {
- PreparedStatement stmt = null;
- ResultSet rs = null;
- Connection conn;
- List features = new ArrayList<>();
- try {
- conn = AndroidDAOFactory.getConnection();
- String sql = "SELECT ID, CODE, NAME, TYPE, HIDDEN, DESCRIPTION FROM AD_FEATURE WHERE TYPE = ?";
- stmt = conn.prepareStatement(sql);
- stmt.setString(1, featureType);
- rs = stmt.executeQuery();
-
- while (rs.next()) {
- features.add(populateMobileFeature(rs));
- }
- return features;
- } catch (SQLException e) {
- throw new AndroidFeatureManagementDAOException("Error occurred while retrieving all android features of " +
- "type " + featureType + " from the android database.", e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
- AndroidDAOFactory.closeConnection();
- }
- }
-
- @Override
- public List getFeaturesByFeatureType(String featureType, boolean isHidden) throws MobileDeviceManagementDAOException {
- PreparedStatement stmt = null;
- ResultSet rs = null;
- Connection conn;
- List features = new ArrayList<>();
- try {
- conn = AndroidDAOFactory.getConnection();
- String sql = "SELECT ID, CODE, NAME, TYPE, HIDDEN, DESCRIPTION " +
- "FROM AD_FEATURE " +
- "WHERE TYPE = ? AND HIDDEN = ?";
- stmt = conn.prepareStatement(sql);
- stmt.setString(1, featureType);
- stmt.setBoolean(2, isHidden);
- rs = stmt.executeQuery();
-
- while (rs.next()) {
- features.add(populateMobileFeature(rs));
- }
- return features;
- } catch (SQLException e) {
- throw new AndroidFeatureManagementDAOException("Error occurred while retrieving all android features of " +
- "[type: " + featureType + " & hidden: " + isHidden + "] from the android database.", e);
- } finally {
- MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
- AndroidDAOFactory.closeConnection();
- }
- }
-
- /**
- * Generate {@link MobileFeature} from the SQL {@link ResultSet}
- *
- * @param rs Result set
- * @return populated {@link MobileFeature}
- * @throws SQLException if unable to extract data from {@link ResultSet}
- */
- private MobileFeature populateMobileFeature(ResultSet rs) throws SQLException {
- MobileFeature mobileFeature = new MobileFeature();
- mobileFeature.setId(rs.getInt(AndroidPluginConstants.ANDROID_FEATURE_ID));
- mobileFeature.setCode(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_CODE));
- mobileFeature.setName(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_NAME));
- mobileFeature.setDescription(rs.getString(AndroidPluginConstants.
- ANDROID_FEATURE_DESCRIPTION));
- mobileFeature.setType(rs.getString(AndroidPluginConstants.ANDROID_FEATURE_TYPE));
- mobileFeature.setHidden(rs.getBoolean(AndroidPluginConstants.ANDROID_FEATURE_HIDDEN));
- mobileFeature.setDeviceType(
- DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
-
- return mobileFeature;
- }
-}
\ No newline at end of file
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/EnterpriseDAOImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/EnterpriseDAOImpl.java
new file mode 100644
index 000000000..8dbdb6e29
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/EnterpriseDAOImpl.java
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.
+ */
+
+package org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dao.EnterpriseDAO;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dao.EnterpriseManagementDAOException;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dao.util.MobileDeviceManagementDAOUtil;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseManagedConfig;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dto.AndroidEnterpriseUser;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice;
+import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Implements EnterpriseDAO for Android Devices.
+ */
+public class EnterpriseDAOImpl implements EnterpriseDAO {
+
+ private static final Log log = LogFactory.getLog(EnterpriseDAOImpl.class);
+
+ public List getUser(String username, int tenantId) throws EnterpriseManagementDAOException {
+ Connection conn;
+ PreparedStatement stmt = null;
+ List enterpriseUsers = new ArrayList<>();
+ ResultSet rs = null;
+ try {
+ conn = AndroidDAOFactory.getConnection();
+ String selectDBQuery =
+ "SELECT * FROM AD_ENTERPRISE_USER_DEVICE WHERE EMM_USERNAME = ? AND TENANT_ID = ?";
+ stmt = conn.prepareStatement(selectDBQuery);
+ stmt.setString(1, username);
+ stmt.setInt(2, tenantId);
+
+ rs = stmt.executeQuery();
+
+ while (rs.next()) {
+ AndroidEnterpriseUser enterpriseUser = new AndroidEnterpriseUser();
+ enterpriseUser.setEmmUsername(rs.getString("EMM_USERNAME"));
+ enterpriseUser.setTenantId(rs.getInt("TENANT_ID"));
+ enterpriseUser.setLastUpdatedTime(rs.getString("LAST_UPDATED_TIMESTAMP"));
+ enterpriseUser.setAndroidPlayDeviceId(rs.getString("ANDROID_PLAY_DEVICE_ID"));
+ enterpriseUser.setEnterpriseId(rs.getString("ENTERPRISE_ID"));
+ enterpriseUser.setGoogleUserId(rs.getString("GOOGLE_USER_ID"));
+ enterpriseUser.setEmmDeviceId(rs.getString("EMM_DEVICE_ID"));
+ enterpriseUsers.add(enterpriseUser);
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while fetching user : '" + username + "'";
+ log.error(msg, e);
+ throw new EnterpriseManagementDAOException(msg, e);
+ } finally {
+ MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ AndroidDAOFactory.closeConnection();
+ }
+
+ return enterpriseUsers;
+ }
+
+ public AndroidEnterpriseUser getUserByDevice(String deviceId, int tenantId) throws
+ EnterpriseManagementDAOException {
+ Connection conn;
+ PreparedStatement stmt = null;
+ AndroidEnterpriseUser enterpriseUser = null;
+ ResultSet rs = null;
+ try {
+ conn = AndroidDAOFactory.getConnection();
+ String selectDBQuery =
+ "SELECT * FROM AD_ENTERPRISE_USER_DEVICE WHERE EMM_DEVICE_ID = ? AND TENANT_ID = ? " +
+ "ORDER BY LAST_UPDATED_TIMESTAMP DESC";
+ stmt = conn.prepareStatement(selectDBQuery);
+ stmt.setString(1, deviceId);
+ stmt.setInt(2, tenantId);
+
+ rs = stmt.executeQuery();
+
+ if (rs.next()) {
+ enterpriseUser = new AndroidEnterpriseUser();
+ enterpriseUser.setEmmUsername(rs.getString("EMM_USERNAME"));
+ enterpriseUser.setTenantId(rs.getInt("TENANT_ID"));
+ enterpriseUser.setLastUpdatedTime(rs.getString("LAST_UPDATED_TIMESTAMP"));
+ enterpriseUser.setAndroidPlayDeviceId(rs.getString("ANDROID_PLAY_DEVICE_ID"));
+ enterpriseUser.setEnterpriseId(rs.getString("ENTERPRISE_ID"));
+ enterpriseUser.setGoogleUserId(rs.getString("GOOGLE_USER_ID"));
+ enterpriseUser.setEmmDeviceId(rs.getString("EMM_DEVICE_ID"));
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while fetching user for device : '" + deviceId + "'";
+ log.error(msg, e);
+ throw new EnterpriseManagementDAOException(msg, e);
+ } finally {
+ MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ AndroidDAOFactory.closeConnection();
+ }
+
+ return enterpriseUser;
+ }
+
+ public boolean addUser(AndroidEnterpriseUser androidEnterpriseUser) throws EnterpriseManagementDAOException {
+ boolean status = false;
+ Connection conn;
+ PreparedStatement stmt = null;
+ try {
+ conn = AndroidDAOFactory.getConnection();
+ String createDBQuery =
+ "INSERT INTO AD_ENTERPRISE_USER_DEVICE(EMM_USERNAME, TENANT_ID, LAST_UPDATED_TIMESTAMP" +
+ ", ANDROID_PLAY_DEVICE_ID, ENTERPRISE_ID, GOOGLE_USER_ID, EMM_DEVICE_ID)"
+ + " VALUES (?, ?, ?, ?, ?, ?, ?)";
+
+ stmt = conn.prepareStatement(createDBQuery);
+ stmt.setString(1, androidEnterpriseUser.getEmmUsername());
+ stmt.setInt(2, androidEnterpriseUser.getTenantId());
+ stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+ stmt.setString(4, androidEnterpriseUser.getAndroidPlayDeviceId());
+ stmt.setString(5, androidEnterpriseUser.getEnterpriseId());
+ stmt.setString(6, androidEnterpriseUser.getGoogleUserId());
+ stmt.setString(7, androidEnterpriseUser.getEmmDeviceId());
+
+ int rows = stmt.executeUpdate();
+ if (rows > 0) {
+ status = true;
+ if (log.isDebugEnabled()) {
+ log.debug("Added user " + androidEnterpriseUser.getEmmUsername());
+ }
+ }
+ } catch (SQLException e) {
+ throw new EnterpriseManagementDAOException("Error occurred while adding the user "
+ + androidEnterpriseUser.getEmmUsername(), e);
+ } finally {
+ MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
+ }
+ return status;
+ }
+
+ public AndroidEnterpriseManagedConfig getConfigByPackageName(String packageName, int tenantId)
+ throws EnterpriseManagementDAOException {
+ Connection conn;
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ AndroidEnterpriseManagedConfig managedConfig = null;
+ try {
+ conn = AndroidDAOFactory.getConnection();
+ String selectDBQuery =
+ "SELECT * FROM AD_ENTERPRISE_MANAGED_CONFIGS WHERE PACKAGE_NAME = ? AND TENANT_ID = ?";
+ stmt = conn.prepareStatement(selectDBQuery);
+ stmt.setString(1, packageName);
+ stmt.setInt(2, tenantId);
+
+ rs = stmt.executeQuery();
+
+ if (rs.next()) {
+ managedConfig = new AndroidEnterpriseManagedConfig();
+ managedConfig.setId(rs.getInt("ID"));
+ managedConfig.setMcmId(rs.getString("MCM_ID"));
+ managedConfig.setProfileName(rs.getString("PROFILE_NAME"));
+ managedConfig.setPackageName(rs.getString("PACKAGE_NAME"));
+ managedConfig.setTenantID(rs.getInt("TENANT_ID"));
+ managedConfig.setLastUpdatedTime(rs.getString("LAST_UPDATED_TIMESTAMP"));
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while fetching config for package name : '" + packageName + "'";
+ log.error(msg, e);
+ throw new EnterpriseManagementDAOException(msg, e);
+ } finally {
+ MobileDeviceManagementDAOUtil.cleanupResources(stmt, rs);
+ AndroidDAOFactory.closeConnection();
+ }
+ return managedConfig;
+ }
+
+ public boolean addConfig(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseManagementDAOException {
+ boolean status = false;
+ Connection conn;
+ PreparedStatement stmt = null;
+ try {
+ conn = AndroidDAOFactory.getConnection();
+ String createDBQuery =
+ "INSERT INTO AD_ENTERPRISE_MANAGED_CONFIGS(MCM_ID, PROFILE_NAME, PACKAGE_NAME" +
+ ", TENANT_ID, LAST_UPDATED_TIMESTAMP) VALUES (?, ?, ?, ?, ?)";
+
+ stmt = conn.prepareStatement(createDBQuery);
+ stmt.setString(1, managedConfig.getMcmId());
+ stmt.setString(2, managedConfig.getProfileName());
+ stmt.setString(3, managedConfig.getPackageName());
+ stmt.setInt(4, managedConfig.getTenantID());
+ stmt.setTimestamp(5, new Timestamp(new Date().getTime()));
+
+ int rows = stmt.executeUpdate();
+ if (rows > 0) {
+ status = true;
+ if (log.isDebugEnabled()) {
+ log.debug("Added config for package " + managedConfig.getPackageName());
+ }
+ }
+ } catch (SQLException e) {
+ throw new EnterpriseManagementDAOException("Error occurred while adding the config for package "
+ + managedConfig.getPackageName(), e);
+ } finally {
+ MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
+ }
+ return status;
+ }
+
+ public boolean updateConfig(AndroidEnterpriseManagedConfig managedConfig) throws EnterpriseManagementDAOException {
+ boolean status = false;
+ Connection conn;
+ PreparedStatement stmt = null;
+ try {
+ conn = AndroidDAOFactory.getConnection();
+ String updateDBQuery =
+ "UPDATE AD_ENTERPRISE_MANAGED_CONFIGS SET PROFILE_NAME = ?, LAST_UPDATED_TIMESTAMP = ?" +
+ " WHERE MCM_ID = ? AND TENANT_ID = ?";
+ stmt = conn.prepareStatement(updateDBQuery);
+
+ stmt.setString(1, managedConfig.getProfileName());
+ stmt.setString(2, managedConfig.getLastUpdatedTime());
+ stmt.setString(3, managedConfig.getMcmId());
+ stmt.setInt(4, managedConfig.getTenantID());
+ int rows = stmt.executeUpdate();
+ if (rows > 0) {
+ status = true;
+ if (log.isDebugEnabled()) {
+ log.debug("Managed config for mcm id " + managedConfig.getMcmId() + " data has been" +
+ " modified.");
+ }
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while modifying the details for mcm id '" +
+ managedConfig.getMcmId() + "' data.";
+ log.error(msg, e);
+ throw new EnterpriseManagementDAOException(msg, e);
+ } finally {
+ MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
+ }
+ return status;
+ }
+
+ public boolean deleteConfig(String id, int tenantId)
+ throws EnterpriseManagementDAOException {
+ boolean status = false;
+ Connection conn;
+ PreparedStatement stmt = null;
+ try {
+ conn = AndroidDAOFactory.getConnection();
+ String deleteDBQuery =
+ "DELETE FROM AD_ENTERPRISE_MANAGED_CONFIGS WHERE MCM_ID = ? AND TENANT_ID = ?";
+ stmt = conn.prepareStatement(deleteDBQuery);
+ stmt.setString(1, id);
+ stmt.setInt(2, tenantId);
+ int rows = stmt.executeUpdate();
+ if (rows > 0) {
+ status = true;
+ if (log.isDebugEnabled()) {
+ log.debug("Error when deleting MCM ID " + id);
+ }
+ }
+ } catch (SQLException e) {
+ throw new EnterpriseManagementDAOException("Error occurred while deleting MCM ID '" + id + "'", e);
+ } finally {
+ MobileDeviceManagementDAOUtil.cleanupResources(stmt, null);
+ }
+ return status;
+ }
+
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseManagedConfig.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseManagedConfig.java
new file mode 100644
index 000000000..687327d6d
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseManagedConfig.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.
+ */
+
+package org.wso2.carbon.device.mgt.mobile.android.impl.dto;
+
+public class AndroidEnterpriseManagedConfig {
+
+ String mcmId;
+ String profileName;
+ String packageName;
+ int tenantID;
+ String lastUpdatedTime;
+ int id;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getMcmId() {
+ return mcmId;
+ }
+
+ public void setMcmId(String mcmId) {
+ this.mcmId = mcmId;
+ }
+
+ public String getProfileName() {
+ return profileName;
+ }
+
+ public void setProfileName(String profileName) {
+ this.profileName = profileName;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public int getTenantID() {
+ return tenantID;
+ }
+
+ public void setTenantID(int tenantID) {
+ this.tenantID = tenantID;
+ }
+
+ public String getLastUpdatedTime() {
+ return lastUpdatedTime;
+ }
+
+ public void setLastUpdatedTime(String lastUpdatedTime) {
+ this.lastUpdatedTime = lastUpdatedTime;
+ }
+
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseUser.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseUser.java
new file mode 100644
index 000000000..48bddbb03
--- /dev/null
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/AndroidEnterpriseUser.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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.
+ */
+
+package org.wso2.carbon.device.mgt.mobile.android.impl.dto;
+
+public class AndroidEnterpriseUser {
+ String emmUsername;
+ int tenantId;
+ String enterpriseId;//from configs
+ String googleUserId;// generated internally
+ String androidPlayDeviceId; //sent by device
+ String emmDeviceId; //set internally
+ String lastUpdatedTime; //set internally
+
+ public String getLastUpdatedTime() {
+ return lastUpdatedTime;
+ }
+
+ public void setLastUpdatedTime(String lastUpdatedTime) {
+ this.lastUpdatedTime = lastUpdatedTime;
+ }
+
+ public String getEmmUsername() {
+ return emmUsername;
+ }
+
+ public void setEmmUsername(String emmUsername) {
+ this.emmUsername = emmUsername;
+ }
+
+ public int getTenantId() {
+ return tenantId;
+ }
+
+ public void setTenantId(int tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getEnterpriseId() {
+ return enterpriseId;
+ }
+
+ public void setEnterpriseId(String enterpriseId) {
+ this.enterpriseId = enterpriseId;
+ }
+
+ public String getGoogleUserId() {
+ return googleUserId;
+ }
+
+ public void setGoogleUserId(String googleUserId) {
+ this.googleUserId = googleUserId;
+ }
+
+ public String getAndroidPlayDeviceId() {
+ return androidPlayDeviceId;
+ }
+
+ public void setAndroidPlayDeviceId(String androidPlayDeviceId) {
+ this.androidPlayDeviceId = androidPlayDeviceId;
+ }
+
+ public String getEmmDeviceId() {
+ return emmDeviceId;
+ }
+
+ public void setEmmDeviceId(String emmDeviceId) {
+ this.emmDeviceId = emmDeviceId;
+ }
+}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeatureProperty.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeatureProperty.java
deleted file mode 100644
index fb226d107..000000000
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeatureProperty.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * 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.
- */
-
-package org.wso2.carbon.device.mgt.mobile.android.impl.dto;
-
-/**
- * DTO of Mobile feature property. Represents a property of a mobile feature.
- */
-public class MobileFeatureProperty {
-
- private String property;
- private Integer featureID;
-
- public Integer getFeatureID() {
- return featureID;
- }
-
- public void setFeatureID(Integer featureID) {
- this.featureID = featureID;
- }
-
- public String getProperty() {
- return property;
- }
-
- public void setProperty(String property) {
- this.property = property;
- }
-
-}
\ No newline at end of file
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginUtils.java
deleted file mode 100644
index 40ea3c18b..000000000
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginUtils.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * 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.
- */
-
-package org.wso2.carbon.device.mgt.mobile.android.impl.util;
-
-import org.wso2.carbon.device.mgt.common.license.mgt.License;
-import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidDeviceManagementService;
-
-/**
- * Contains utility methods used by Android plugin.
- */
-public class AndroidPluginUtils {
-
- public static License getDefaultLicense() {
- License license = new License();
- license.setName(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID);
- license.setLanguage("en_US");
- license.setVersion("1.0.0");
- license.setText("This End User License Agreement (\"Agreement\") is a legal agreement between you (\"You\") " +
- "and WSO2, Inc., regarding the enrollment of Your personal mobile device (\"Device\") in SoR's " +
- "mobile device management program, and the loading to and removal from Your Device and Your use " +
- "of certain applications and any associated software and user documentation, whether provided in " +
- "\"online\" or electronic format, used in connection with the operation of or provision of services " +
- "to WSO2, Inc., BY SELECTING \"I ACCEPT\" DURING INSTALLATION, YOU ARE ENROLLING YOUR DEVICE, AND " +
- "THEREBY AUTHORIZING SOR OR ITS AGENTS TO INSTALL, UPDATE AND REMOVE THE APPS FROM YOUR DEVICE AS " +
- "DESCRIBED IN THIS AGREEMENT. YOU ARE ALSO EXPLICITLY ACKNOWLEDGING AND AGREEING THAT (1) THIS IS " +
- "A BINDING CONTRACT AND (2) YOU HAVE READ AND AGREE TO THE TERMS OF THIS AGREEMENT.\n" +
- "\n" +
- "IF YOU DO NOT ACCEPT THESE TERMS, DO NOT ENROLL YOUR DEVICE AND DO NOT PROCEED ANY FURTHER.\n" +
- "\n" +
- "You agree that: (1) You understand and agree to be bound by the terms and conditions contained " +
- "in this Agreement, and (2) You are at least 21 years old and have the legal capacity to enter " +
- "into this Agreement as defined by the laws of Your jurisdiction. SoR shall have the right, " +
- "without prior notice, to terminate or suspend (i) this Agreement, (ii) the enrollment of Your " +
- "Device, or (iii) the functioning of the Apps in the event of a violation of this Agreement or " +
- "the cessation of Your relationship with SoR (including termination of Your employment if You are " +
- "an employee or expiration or termination of Your applicable franchise or supply agreement if You " +
- "are a franchisee of or supplier to the WSO2 WSO2, Inc., system). SoR expressly reserves all " +
- "rights not expressly granted herein.");
- return license;
- }
-
-}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidUtils.java
deleted file mode 100644
index 583a6cef0..000000000
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidUtils.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * 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.
- */
-
-package org.wso2.carbon.device.mgt.mobile.android.impl.util;
-
-import java.util.Map;
-
-/**
- * Contains utility methods used by Android plugin.
- */
-public class AndroidUtils {
-
- public static String getDeviceProperty(Map deviceProperties, String property) {
- return deviceProperties.get(property);
- }
-}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java
index efe969834..1ea1543a4 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java
@@ -45,6 +45,9 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
+import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.AndroidDataSourceConfigurations;
+import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.MobileDataSourceConfig;
+import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.MobileDataSourceConfigurations;
import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice;
import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDeviceOperationMapping;
@@ -55,8 +58,11 @@ import org.wso2.carbon.device.mgt.mobile.android.internal.AndroidDeviceManagemen
import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.api.Resource;
import org.wso2.carbon.registry.core.Registry;
+import org.wso2.carbon.utils.CarbonUtils;
import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
@@ -373,4 +379,37 @@ public class MobileDeviceManagementUtil {
}
return missingFeatures;
}
+
+ public static final String IOS_DB_CONFIG_PATH = CarbonUtils.getCarbonConfigDirPath() + File.separator +
+ "/android-dbconfig.xml";
+
+ public static AndroidDataSourceConfigurations iosDataSourceConfigurations;
+ public static AndroidDataSourceConfigurations getIosDataSourceConfigurations() {
+ return iosDataSourceConfigurations;
+ }
+
+ public static synchronized void initConfig() throws DeviceManagementException {
+ try {
+ File mobileDeviceMgtConfig = new File(IOS_DB_CONFIG_PATH);
+ Document doc = convertToDocuments(mobileDeviceMgtConfig);
+ JAXBContext iosDeviceMgtContext = JAXBContext.newInstance(AndroidDataSourceConfigurations.class);
+ Unmarshaller unmarshaller = iosDeviceMgtContext.createUnmarshaller();
+ iosDataSourceConfigurations = (AndroidDataSourceConfigurations) unmarshaller.unmarshal(doc);
+ } catch (Exception e) {
+ throw new DeviceManagementException(
+ "Error occurred while initializing Mobile Device Management config", e);
+ }
+ }
+
+ public static Document convertToDocuments(File file) throws DeviceManagementException {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ try {
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ return docBuilder.parse(file);
+ } catch (Exception e) {
+ throw new DeviceManagementException("Error occurred while parsing file, while converting " +
+ "to a org.w3c.dom.Document : " + e.getMessage(), e);
+ }
+ }
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java
index 94efdfbf7..09d111fca 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementDataHolder.java
@@ -19,6 +19,7 @@
package org.wso2.carbon.device.mgt.mobile.android.internal;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
+import org.wso2.carbon.device.mgt.mobile.android.AndroidPluginService;
import org.wso2.carbon.registry.core.service.RegistryService;
/**
@@ -27,7 +28,7 @@ import org.wso2.carbon.registry.core.service.RegistryService;
public class AndroidDeviceManagementDataHolder {
private RegistryService registryService;
- private DeviceManagementService androidDeviceManagementService;
+ private AndroidPluginService androidDeviceManagementService;
private static AndroidDeviceManagementDataHolder thisInstance = new AndroidDeviceManagementDataHolder();
@@ -46,12 +47,12 @@ public class AndroidDeviceManagementDataHolder {
this.registryService = registryService;
}
- public DeviceManagementService getAndroidDeviceManagementService() {
+ public AndroidPluginService getAndroidDeviceManagementService() {
return androidDeviceManagementService;
}
public void setAndroidDeviceManagementService(
- DeviceManagementService androidDeviceManagementService) {
+ AndroidPluginService androidDeviceManagementService) {
this.androidDeviceManagementService = androidDeviceManagementService;
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidPluginServiceComponent.java
similarity index 77%
rename from components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java
rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidPluginServiceComponent.java
index 84fbb3c17..08f0c1c95 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidPluginServiceComponent.java
@@ -20,14 +20,17 @@ package org.wso2.carbon.device.mgt.mobile.android.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
-import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidDeviceManagementService;
+import org.wso2.carbon.device.mgt.mobile.android.AndroidPluginService;
+import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidPluginServiceImpl;
+import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AbstractMobileDeviceManagementDAOFactory;
+import org.wso2.carbon.device.mgt.mobile.android.impl.util.MobileDeviceManagementUtil;
import org.wso2.carbon.ndatasource.core.DataSourceService;
import org.wso2.carbon.registry.core.service.RegistryService;
/**
- * @scr.component name="org.wso2.carbon.device.mgt.mobile.android.impl.internal.AndroidDeviceManagementServiceComponent"
+ * @scr.component name="org.wso2.carbon.device.mgt.mobile.android.impl.internal.AndroidPluginServiceComponent"
* immediate="true"
* @scr.reference name="org.wso2.carbon.ndatasource"
* interface="org.wso2.carbon.ndatasource.core.DataSourceService"
@@ -43,9 +46,9 @@ import org.wso2.carbon.registry.core.service.RegistryService;
* initializing APIMgtDAOs attempting to register APIs programmatically. APIMgtDAO needs to be proper cleaned up
* to avoid as an ideal fix
*/
-public class AndroidDeviceManagementServiceComponent {
+public class AndroidPluginServiceComponent {
- private static final Log log = LogFactory.getLog(AndroidDeviceManagementServiceComponent.class);
+ private static final Log log = LogFactory.getLog(AndroidPluginServiceComponent.class);
protected void activate(ComponentContext ctx) {
@@ -53,9 +56,17 @@ public class AndroidDeviceManagementServiceComponent {
log.debug("Activating Android Mobile Device Management Service Component");
}
try {
- DeviceManagementService androidDeviceManagementService = new AndroidDeviceManagementService();
+ BundleContext bundleContext = ctx.getBundleContext();
+
+
+ MobileDeviceManagementUtil.initConfig();
+ AbstractMobileDeviceManagementDAOFactory.init("android", MobileDeviceManagementUtil
+ .getIosDataSourceConfigurations().getIosDataSourceConfiguration());
+
+ AndroidPluginService androidPluginService = new AndroidPluginServiceImpl();
AndroidDeviceManagementDataHolder.getInstance().setAndroidDeviceManagementService(
- androidDeviceManagementService);
+ androidPluginService);
+ bundleContext.registerService(AndroidPluginService.class.getName(), androidPluginService, null);
if (log.isDebugEnabled()) {
log.debug("Android Mobile Device Management Service Component has been successfully activated");
}
diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/conf/android-dbconfig.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/conf/android-dbconfig.xml
new file mode 100644
index 000000000..384f3fd16
--- /dev/null
+++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/conf/android-dbconfig.xml
@@ -0,0 +1,25 @@
+
+
+
+
+ jdbc/MobileAndroidDM_DS
+
+
+
diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql
index 845dbe88e..329290335 100644
--- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql
+++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/h2.sql
@@ -31,3 +31,31 @@ CREATE TABLE IF NOT EXISTS `AD_FEATURE` (
`DESCRIPTION` VARCHAR(200) NULL,
PRIMARY KEY (`ID`));
+-- -----------------------------------------------------
+-- Table `AD_ENTERPRISE_USER_DEVICE`
+-- -----------------------------------------------------
+
+CREATE TABLE IF NOT EXISTS `AD_ENTERPRISE_USER_DEVICE` (
+ `ID` INT NOT NULL AUTO_INCREMENT,
+ `ENTERPRISE_ID` VARCHAR(50) NULL,
+ `EMM_USERNAME` VARCHAR(100) NOT NULL,
+ `GOOGLE_USER_ID` VARCHAR(50) NULL,
+ `ANDROID_PLAY_DEVICE_ID` VARCHAR(50) NULL,
+ `EMM_DEVICE_ID` VARCHAR(50) NULL,
+ `TENANT_ID` INT(11) NULL DEFAULT '0',
+ `LAST_UPDATED_TIMESTAMP` TIMESTAMP NOT NULL,
+ PRIMARY KEY (`ID`));
+
+-- -----------------------------------------------------
+-- Table `AD_ENTERPRISE_MANAGED_CONFIGS`
+-- -----------------------------------------------------
+
+CREATE TABLE IF NOT EXISTS `AD_ENTERPRISE_MANAGED_CONFIGS` (
+ `ID` INT NOT NULL AUTO_INCREMENT,
+ `MCM_ID` VARCHAR(50) NULL,
+ `PROFILE_NAME` VARCHAR(100) NULL,
+ `PACKAGE_NAME` VARCHAR(100) NOT NULL,
+ `TENANT_ID` INT(11) NULL DEFAULT '0',
+ `LAST_UPDATED_TIMESTAMP` TIMESTAMP NOT NULL,
+ PRIMARY KEY (`ID`));
+
diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql
index ed7976347..adbb578a4 100644
--- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql
+++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mssql.sql
@@ -32,3 +32,25 @@ CREATE TABLE AD_FEATURE (
DESCRIPTION VARCHAR(200) NULL,
PRIMARY KEY (ID)
);
+
+CREATE TABLE AD_ENTERPRISE_USER_DEVICE (
+ [ID] INT NOT NULL IDENTITY,
+ [ENTERPRISE_ID] VARCHAR(50) NULL,
+ [EMM_USERNAME] VARCHAR(100) NOT NULL,
+ [GOOGLE_USER_ID] VARCHAR(50) NULL,
+ [ANDROID_PLAY_DEVICE_ID] VARCHAR(50) NULL,
+ [EMM_DEVICE_ID] VARCHAR(50) NULL,
+ [TENANT_ID] INT NULL DEFAULT '0',
+ [LAST_UPDATED_TIMESTAMP] DATETIME2(0) NOT NULL,
+ PRIMARY KEY ([ID])
+);
+
+CREATE TABLE AD_ENTERPRISE_MANAGED_CONFIGS (
+ [ID] INT NOT NULL IDENTITY,
+ [MCM_ID] VARCHAR(50) NULL,
+ [PROFILE_NAME] VARCHAR(100) NULL,
+ [PACKAGE_NAME] VARCHAR(100) NOT NULL,
+ [TENANT_ID] INT NULL DEFAULT '0',
+ [LAST_UPDATED_TIMESTAMP] DATETIME2(0) NOT NULL,
+ PRIMARY KEY ([ID])
+) ;
diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql
index 655af9948..f66dd121b 100644
--- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql
+++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/mysql.sql
@@ -31,3 +31,26 @@ CREATE TABLE IF NOT EXISTS `AD_FEATURE` (
`DESCRIPTION` VARCHAR(200) NULL,
PRIMARY KEY (`ID`)
) ENGINE = InnoDB;
+
+CREATE TABLE IF NOT EXISTS `AD_ENTERPRISE_USER_DEVICE` (
+ `ID` INT NOT NULL AUTO_INCREMENT,
+ `ENTERPRISE_ID` VARCHAR(50) NULL,
+ `EMM_USERNAME` VARCHAR(100) NOT NULL,
+ `GOOGLE_USER_ID` VARCHAR(50) NULL,
+ `ANDROID_PLAY_DEVICE_ID` VARCHAR(50) NULL,
+ `EMM_DEVICE_ID` VARCHAR(50) NULL,
+ `TENANT_ID` INT(11) NULL DEFAULT '0',
+ `LAST_UPDATED_TIMESTAMP` TIMESTAMP NOT NULL,
+ PRIMARY KEY (`ID`)
+) ENGINE = InnoDB;
+
+CREATE TABLE IF NOT EXISTS `AD_ENTERPRISE_MANAGED_CONFIGS` (
+ `ID` INT NOT NULL AUTO_INCREMENT,
+ `MCM_ID` VARCHAR(50) NULL,
+ `PROFILE_NAME` VARCHAR(100) NULL,
+ `PACKAGE_NAME` VARCHAR(100) NOT NULL,
+ `TENANT_ID` INT(11) NULL DEFAULT '0',
+ `LAST_UPDATED_TIMESTAMP` TIMESTAMP NOT NULL,
+ PRIMARY KEY (`ID`)
+) ENGINE = InnoDB;
+
diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql
index 6ad72c41c..246ee5df9 100644
--- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql
+++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/oracle.sql
@@ -50,4 +50,49 @@ FOR EACH ROW
BEGIN
SELECT AD_FEATURE_ID_INC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
END;
+/
+
+
+CREATE TABLE AD_ENTERPRISE_USER_DEVICE (
+ ID NUMBER(10) NOT NULL,
+ ENTERPRISE_ID VARCHAR2(50) NULL,
+ EMM_USERNAME VARCHAR2(100) NOT NULL,
+ GOOGLE_USER_ID VARCHAR2(50) NULL,
+ ANDROID_PLAY_DEVICE_ID VARCHAR2(50) NULL,
+ EMM_DEVICE_ID VARCHAR2(50) NULL,
+ TENANT_ID NUMBER(10) DEFAULT '0' NULL,
+ LAST_UPDATED_TIMESTAMP TIMESTAMP(0) NOT NULL,
+ PRIMARY KEY (ID)
+);
+
+-- Generate ID using sequence and trigger
+CREATE SEQUENCE AD_ENTERPRISE_USER_DEVICE_seq START WITH 1 INCREMENT BY 1;
+
+CREATE OR REPLACE TRIGGER AD_ENTERPRISE_USER_DEVICE_seq_tr
+ BEFORE INSERT ON AD_ENTERPRISE_USER_DEVICE FOR EACH ROW
+ WHEN (NEW.ID IS NULL)
+BEGIN
+ SELECT AD_ENTERPRISE_USER_DEVICE_seq.NEXTVAL INTO :NEW.ID FROM DUAL;
+END;
+/
+
+CREATE TABLE AD_ENTERPRISE_MANAGED_CONFIGS (
+ ID NUMBER(10) NOT NULL,
+ MCM_ID VARCHAR2(50) NULL,
+ PROFILE_NAME VARCHAR2(100) NULL,
+ PACKAGE_NAME VARCHAR2(100) NOT NULL,
+ TENANT_ID NUMBER(10) DEFAULT '0' NULL,
+ LAST_UPDATED_TIMESTAMP TIMESTAMP(0) NOT NULL,
+ PRIMARY KEY (ID)
+) ;
+
+-- Generate ID using sequence and trigger
+CREATE SEQUENCE AD_ENTERPRISE_MANAGED_CONFIGS_seq START WITH 1 INCREMENT BY 1;
+
+CREATE OR REPLACE TRIGGER AD_ENTERPRISE_MANAGED_CONFIGS_seq_tr
+ BEFORE INSERT ON AD_ENTERPRISE_MANAGED_CONFIGS FOR EACH ROW
+ WHEN (NEW.ID IS NULL)
+BEGIN
+ SELECT AD_ENTERPRISE_MANAGED_CONFIGS_seq.NEXTVAL INTO :NEW.ID FROM DUAL;
+END;
/
\ No newline at end of file
diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql
index 908d1c21f..a34075d5a 100644
--- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql
+++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/dbscripts/plugins/postgresql.sql
@@ -30,3 +30,29 @@ CREATE TABLE IF NOT EXISTS AD_FEATURE (
HIDDEN BOOLEAN DEFAULT FALSE,
DESCRIPTION VARCHAR(200) NULL
);
+
+CREATE SEQUENCE AD_ENTERPRISE_USER_DEVICE_seq;
+
+CREATE TABLE IF NOT EXISTS AD_ENTERPRISE_USER_DEVICE (
+ ID INT NOT NULL DEFAULT NEXTVAL ('AD_ENTERPRISE_USER_DEVICE_seq'),
+ ENTERPRISE_ID VARCHAR(50) NULL,
+ EMM_USERNAME VARCHAR(100) NOT NULL,
+ GOOGLE_USER_ID VARCHAR(50) NULL,
+ ANDROID_PLAY_DEVICE_ID VARCHAR(50) NULL,
+ EMM_DEVICE_ID VARCHAR(50) NULL,
+ TENANT_ID INT NULL DEFAULT '0',
+ LAST_UPDATED_TIMESTAMP TIMESTAMP(0) NOT NULL,
+ PRIMARY KEY (ID)
+);
+
+CREATE SEQUENCE AD_ENTERPRISE_MANAGED_CONFIGS_seq;
+
+CREATE TABLE IF NOT EXISTS AD_ENTERPRISE_MANAGED_CONFIGS (
+ ID INT NOT NULL DEFAULT NEXTVAL ('AD_ENTERPRISE_MANAGED_CONFIGS_seq'),
+ MCM_ID VARCHAR(50) NULL,
+ PROFILE_NAME VARCHAR(100) NULL,
+ PACKAGE_NAME VARCHAR(100) NOT NULL,
+ TENANT_ID INT NULL DEFAULT '0',
+ LAST_UPDATED_TIMESTAMP TIMESTAMP(0) NOT NULL,
+ PRIMARY KEY (ID)
+) ;
diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml
index 7fab44c07..6f99ea30c 100644
--- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml
+++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml
@@ -685,40 +685,145 @@
+
- 4.0
+ 1
- 4.1
+ 2
- 4.4
+ 3
- 5.0
+ 4
- 6.0
+ 5
- 7.0
+ 6
- 8.0
+ 7
- 9.0
+ 8
- 10.0
+ 9
+
+
+
+ 10
+
+
+
+ 11
+
+
+
+ 12
+
+
+
+ 13
+
+
+
+ 14
+
+
+
+ 15
+
+
+
+ 16
+
+
+
+ 17
+
+
+
+ 18
+
+
+
+ 19
+
+
+
+ 20
+
+
+
+ 21
+
+
+
+ 22
+
+
+
+ 23
+
+
+
+ 24
+
+
+
+ 25
+
+
+
+ 26
+
+
+
+ 27
+
+
+
+ 28
+
+
+
+ 29
+
+
+
+ 30
+
+
+
+ 31
+
+
+
+ 32
+
+
+
+ 33
+
+
+
+ 34
+
+
+
+ 35
diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf
index e188ddf4e..5edb8b23b 100644
--- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf
+++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf
@@ -12,6 +12,7 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/apis/admin--Android-Mutual-SSL-Configuration-Management.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Android-Mutual-SSL-Configuration-Management.xml,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/apis/admin--Android-Mutual-SSL-Device-Management.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Android-Mutual-SSL-Device-Management.xml,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/apis/admin--Android-Mutual-SSL-Event-Receiver.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/admin--Android-Mutual-SSL-Event-Receiver.xml,overwrite:true);\
+org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/conf/android-dbconfig.xml,target:${installFolder}/../../conf/android-dbconfig.xml,overwrite:true);\
instructions.unconfigure = \
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/mdm-android-agent.war);\