operations = new ArrayList<>();
-
+ String owner = request.getOwner();
if (!isActionAuthorized(deviceId)) {
throw new OperationManagementException("User '" + getUser() + "' is not authorized to access the '" +
deviceId.getType() + "' device, which carries the identifier '" +
- deviceId.getId() + "'");
+ deviceId.getId() + "' of owner '" + owner + "'" );
}
- EnrolmentInfo enrolmentInfo = this.getEnrolmentInfo(deviceId);
+ EnrolmentInfo enrolmentInfo = this.getEnrolmentInfo(deviceId, owner);
if (enrolmentInfo == null) {
throw new OperationManagementException("Device not found for given device " +
"Identifier:" + deviceId.getId() + " and given type" +
@@ -923,31 +923,33 @@ public class OperationManagerImpl implements OperationManager {
return enrolmentId;
}
- private EnrolmentInfo getEnrolmentInfo(DeviceIdentifier deviceId) throws OperationManagementException {
- EnrolmentInfo enrolmentInfo;
+ private EnrolmentInfo getEnrolmentInfo(DeviceIdentifier deviceId, String owner) throws OperationManagementException {
+ EnrolmentInfo enrolmentInfo = null;
try {
- DeviceManagementDAOFactory.openConnection();
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
String user = this.getUser();
- enrolmentInfo = deviceDAO.getEnrolment(deviceId, user, tenantId);
- if (enrolmentInfo == null) {
+ DeviceManagementDAOFactory.openConnection();
+ if (this.isSameUser(user, owner)) {
+ enrolmentInfo = deviceDAO.getEnrolment(deviceId, owner, tenantId);
+ } else {
boolean isAdminUser = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
isDeviceAdminUser();
if (isAdminUser) {
- enrolmentInfo = deviceDAO.getEnrolment(deviceId, tenantId);
+ enrolmentInfo = deviceDAO.getEnrolment(deviceId, owner, tenantId);
}
+ //TODO : Add a check for group admin if this fails
}
} catch (DeviceManagementDAOException e) {
throw new OperationManagementException("Error occurred while retrieving enrollment data of '" +
deviceId.getType() + "' device carrying the identifier '" +
- deviceId.getId() + "'", e);
+ deviceId.getId() + "' of owner '" + owner + "'", e);
} catch (SQLException e) {
throw new OperationManagementException(
"Error occurred while opening a connection to the data source", e);
} catch (DeviceAccessAuthorizationException e) {
throw new OperationManagementException("Error occurred while checking the device access permissions for '" +
deviceId.getType() + "' device carrying the identifier '" +
- deviceId.getId() + "'", e);
+ deviceId.getId() + "' of owner '" + owner + "'", e);
} finally {
DeviceManagementDAOFactory.closeConnection();
}
@@ -1021,4 +1023,8 @@ public class OperationManagerImpl implements OperationManager {
}
return false;
}
+
+ private boolean isSameUser(String user, String owner) {
+ return user.equalsIgnoreCase(owner);
+ }
}
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java
index d21872b103..fcf57ab022 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/CommandOperationDAOImpl.java
@@ -76,7 +76,7 @@ public class CommandOperationDAOImpl extends GenericOperationDAOImpl {
try {
super.deleteOperation(id);
Connection connection = OperationManagementDAOFactory.getConnection();
- stmt = connection.prepareStatement("DELETE DM_COMMAND_OPERATION WHERE OPERATION_ID = ?");
+ stmt = connection.prepareStatement("DELETE FROM DM_COMMAND_OPERATION WHERE OPERATION_ID = ?");
stmt.setInt(1, id);
stmt.executeUpdate();
} catch (SQLException e) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java
index e6994977ad..c847c7652c 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java
@@ -64,7 +64,7 @@ public class ConfigOperationDAOImpl extends GenericOperationDAOImpl {
try {
super.deleteOperation(id);
Connection connection = OperationManagementDAOFactory.getConnection();
- stmt = connection.prepareStatement("DELETE DM_CONFIG_OPERATION WHERE OPERATION_ID = ?") ;
+ stmt = connection.prepareStatement("DELETE FROM DM_CONFIG_OPERATION WHERE OPERATION_ID = ?") ;
stmt.setInt(1, id);
stmt.executeUpdate();
} catch (SQLException e) {
@@ -82,7 +82,7 @@ public class ConfigOperationDAOImpl extends GenericOperationDAOImpl {
try {
super.updateOperation(operation);
Connection connection = OperationManagementDAOFactory.getConnection();
- stmt = connection.prepareStatement("UPDATE DM_CONFIG_OPERATION SET OPERATION_CONFIG = ? " +
+ stmt = connection.prepareStatement("UPDATE FROM DM_CONFIG_OPERATION SET OPERATION_CONFIG = ? " +
"WHERE OPERATION_ID = ?");
bao = new ByteArrayOutputStream();
oos = new ObjectOutputStream(bao);
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java
index a43a089640..c70a2a87aa 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java
@@ -620,7 +620,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
PreparedStatement stmt = null;
try {
Connection connection = OperationManagementDAOFactory.getConnection();
- stmt = connection.prepareStatement("DELETE DM_OPERATION WHERE ID = ?");
+ stmt = connection.prepareStatement("DELETE FROM DM_OPERATION WHERE ID = ?");
stmt.setInt(1, id);
stmt.executeUpdate();
} catch (SQLException e) {
@@ -867,12 +867,9 @@ public class GenericOperationDAOImpl implements OperationDAO {
String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, " +
"OPERATION_CODE, om.STATUS, om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
- "WHERE dm.ENROLMENT_ID = ?) om ON o.ID = om.OPERATION_ID ORDER BY o.CREATED_TIMESTAMP DESC"
- + "LIMIT ?,?";
+ "WHERE dm.ENROLMENT_ID = ?) om ON o.ID = om.OPERATION_ID ORDER BY o.CREATED_TIMESTAMP DESC";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, enrolmentId);
- /*stmt.setInt(2, request.getStartIndex());
- stmt.setInt(3, request.getRowCount());*/
rs = stmt.executeQuery();
while (rs.next()) {
@@ -880,11 +877,6 @@ public class GenericOperationDAOImpl implements OperationDAO {
operation.setId(rs.getInt("ID"));
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
-// if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null) {
-// operation.setReceivedTimeStamp("");
-// } else {
-// operation.setReceivedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString());
-// }
if (rs.getLong("UPDATED_TIMESTAMP") == 0) {
operation.setReceivedTimeStamp("");
} else {
@@ -893,7 +885,6 @@ public class GenericOperationDAOImpl implements OperationDAO {
}
operation.setCode(rs.getString("OPERATION_CODE"));
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
-// this.setActivityId(operation, rs.getInt("OM_MAPPING_ID"));
operations.add(operation);
}
} catch (SQLException e) {
@@ -929,11 +920,6 @@ public class GenericOperationDAOImpl implements OperationDAO {
operation.setId(rs.getInt("ID"));
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
-// if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null) {
-// operation.setReceivedTimeStamp("");
-// } else {
-// operation.setReceivedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString());
-// }
if (rs.getLong("UPDATED_TIMESTAMP") == 0) {
operation.setReceivedTimeStamp("");
} else {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/PolicyOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/PolicyOperationDAOImpl.java
index 957f206f3a..4c0243ac80 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/PolicyOperationDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/PolicyOperationDAOImpl.java
@@ -128,7 +128,7 @@ public class PolicyOperationDAOImpl extends GenericOperationDAOImpl {
try {
super.deleteOperation(operationId);
Connection connection = OperationManagementDAOFactory.getConnection();
- stmt = connection.prepareStatement("DELETE DM_POLICY_OPERATION WHERE OPERATION_ID=?");
+ stmt = connection.prepareStatement("DELETE FROM DM_POLICY_OPERATION WHERE OPERATION_ID=?");
stmt.setInt(1, operationId);
stmt.executeUpdate();
} catch (SQLException e) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java
index 4cc496c853..931cc079f4 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java
@@ -129,7 +129,7 @@ public class ProfileOperationDAOImpl extends GenericOperationDAOImpl {
try {
super.deleteOperation(id);
Connection connection = OperationManagementDAOFactory.getConnection();
- stmt = connection.prepareStatement("DELETE DM_PROFILE_OPERATION WHERE OPERATION_ID=?");
+ stmt = connection.prepareStatement("DELETE FROM DM_PROFILE_OPERATION WHERE OPERATION_ID=?");
stmt.setInt(1, id);
stmt.executeUpdate();
} catch (SQLException e) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml
index 24811bc969..ad565fbe63 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml
@@ -22,7 +22,7 @@
device-mgt
org.wso2.carbon.devicemgt
- 1.2.6-SNAPSHOT
+ 1.2.7-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml
index fdd192103b..e66303d3a7 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/pom.xml
@@ -22,7 +22,7 @@
device-mgt
org.wso2.carbon.devicemgt
- 1.2.6-SNAPSHOT
+ 1.2.7-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js
index 26233a32d8..bec644d249 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js
@@ -118,13 +118,18 @@ deviceModule = function () {
if (properties["DEVICE_INFO"]) {
var initialDeviceInfoList = parse(properties["DEVICE_INFO"]);
var initialDeviceInfo = {};
- for (var j = 0; j < initialDeviceInfoList.length; j++) {
- if (initialDeviceInfoList[j]["value"]) {
- initialDeviceInfo[initialDeviceInfoList[j]["name"]] =
- initialDeviceInfoList[j]["value"];
+ if (Array.isArray(initialDeviceInfoList)) {
+ for (var j = 0; j < initialDeviceInfoList.length; j++) {
+ if (initialDeviceInfoList[j]["value"]) {
+ initialDeviceInfo[initialDeviceInfoList[j]["name"]] =
+ initialDeviceInfoList[j]["value"];
+ }
}
+ } else {
+ initialDeviceInfo = initialDeviceInfoList;
}
+
filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"] = initialDeviceInfo;
}
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs
index 4d0f953422..46e213d374 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs
@@ -51,14 +51,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
Do you really want to remove this certificate ?
-
-
-
-
-
-
-
-
-
-
-
-
{{/zone}}
{{#zone "bottomJs"}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js
index 01acf088d1..959a3472da 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/public/js/certificate-listing.js
@@ -54,8 +54,11 @@ function hidePopup() {
*/
function removeCertificate(serialNumber) {
var serviceUrl = base_api_url + "/admin/certificates/" + serialNumber;
- $(modalPopupContent).html($('#remove-certificate-modal-content').html());
- showPopup();
+ modalDialog.header('Do you really want to remove this certificate ?');
+ modalDialog.footer('');
+ modalDialog.show();
$("a#remove-certificate-yes-link").click(function () {
invokerUtil.delete(
@@ -63,23 +66,29 @@ function removeCertificate(serialNumber) {
function () {
$("#" + serialNumber).remove();
var newCertificateListCount = $(".user-list > span").length;
- $("#certificate-listing-status-msg").text("Total number of Certificates found : " + newCertificateListCount);
- $(modalPopupContent).html($('#remove-certificate-success-content').html());
+ $("#certificate-listing-status-msg").text("Total number of Certificates found : " +
+ newCertificateListCount);
+ modalDialog.header('Done. Certificate was successfully removed.');
+ modalDialog.footer('');
$("a#remove-certificate-success-link").click(function () {
- hidePopup();
+ modalDialog.hide();
});
},
function () {
- $(modalPopupContent).html($('#remove-certificate-error-content').html());
+ modalDialog.header('An unexpected error occurred. Please try again later.');
+ modalDialog.footer('');
+ modalDialog.showAsError();
$("a#remove-certificate-error-link").click(function () {
- hidePopup();
+ modalDialog.hide();
});
}
);
});
$("a#remove-certificate-cancel-link").click(function () {
- hidePopup();
+ modalDialog.hide();
});
}
@@ -103,8 +112,9 @@ function InitiateViewOption() {
if ($("#can-view").val()) {
$(location).attr('href', $(this).data("url"));
} else {
- $(modalPopupContent).html($('#errorCertificateView').html());
- showPopup();
+ modalDialog.header('Unauthorized action!');
+ modalDialog.content('You do not have permission to view this certificate.');
+ modalDialog.showAsAWarning();
}
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs
index fe9663f24f..8ae4393a8f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/create.hbs
@@ -1,4 +1,5 @@
{{unit "cdmf.unit.ui.title" pageTitle="Group Management"}}
+{{unit "cdmf.unit.ui.modal"}}
{{#zone "breadcrumbs"}}
@@ -55,22 +56,6 @@
-
-
-
-
-
-
Unexpected error occurred!
-
-
-
-
-
-
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/group-add.js"}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js
index 2dc32ce70f..b2a5598c0f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.create/public/js/group-add.js
@@ -70,10 +70,13 @@ $(function () {
});
function displayErrors(message) {
- showPopup();
$('#error-msg').html(message.responseText);
- $(modalPopupContent).html($('#group-error-content').html());
+ modalDialog.header('Unexpected error occurred!');
+ modalDialog.content('');
+ modalDialog.footer('');
+ modalDialog.showAsError();
$("a#group-unexpected-error-link").click(function () {
- hidePopup();
+ modalDialog.hide();
});
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs
index 1eb81672aa..4c5280f154 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.policies/policies.hbs
@@ -17,6 +17,7 @@
}}
{{unit "cdmf.unit.ui.title" pageTitle="Policy Management"}}
{{unit "cdmf.unit.data-tables-extended"}}
+{{unit "cdmf.unit.ui.modal"}}
{{#zone "topCss"}}