From 4379232c25a8c26d5b7dd422e6a17e7b33fd9789 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Mon, 16 Nov 2015 22:01:21 +0530 Subject: [PATCH 1/7] Refactored Enrollment DAO class --- .../carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java index f3a5a585117..61e99798023 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/EnrollmentDAOImpl.java @@ -71,6 +71,7 @@ public class EnrollmentDAOImpl implements EnrollmentDAO { PreparedStatement stmt = null; ResultSet rs = null; int status = -1; + int rows; try { conn = this.getConnection(); String sql = "UPDATE DM_ENROLMENT SET OWNERSHIP = ?, STATUS = ?, " + @@ -85,12 +86,12 @@ public class EnrollmentDAOImpl implements EnrollmentDAO { stmt.setString(6, enrolmentInfo.getOwner()); stmt.setInt(7, tenantId); stmt.setInt(8, enrolmentInfo.getId()); - stmt.executeUpdate(); + rows = stmt.executeUpdate(); - rs = stmt.getGeneratedKeys(); - if (rs.next()) { + if (rows > 0) { status = 1; } + return status; } catch (SQLException e) { throw new DeviceManagementDAOException("Error occurred while updating enrolment configuration", e); From 6b9dc0d6a5327ac5daa260781386d01967652573 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Tue, 17 Nov 2015 16:46:04 +0530 Subject: [PATCH 2/7] Removing the unnessary unique key --- .../src/main/resources/dbscripts/cdm/h2.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql index fb95df9ab00..e1503ffaddf 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -302,7 +302,6 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( LAST_FAILED_TIME TIMESTAMP NULL, ATTEMPTS INT NULL, PRIMARY KEY (ID), - UNIQUE INDEX DEVICE_ID_UNIQUE (DEVICE_ID ASC), CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY FOREIGN KEY (POLICY_ID) REFERENCES DM_POLICY (ID) From 6e95451f57c0b5db439e05a7315377bf17141d81 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Tue, 17 Nov 2015 17:26:55 +0530 Subject: [PATCH 3/7] Refactored Operation DAO class --- .../mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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/OperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java index 97e140fd909..09beecc38ed 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java @@ -87,8 +87,8 @@ public class OperationDAOImpl implements OperationDAO { PreparedStatement stmt = null; try { Connection connection = OperationManagementDAOFactory.getConnection(); - stmt = connection.prepareStatement("UPDATE DM_ENROLMENT_OP_MAPPING O SET O.STATUS=? " + - "WHERE O.ENROLMENT_ID=? and O.OPERATION_ID=?"); + stmt = connection.prepareStatement("UPDATE DM_ENROLMENT_OP_MAPPING SET STATUS=? " + + "WHERE ENROLMENT_ID=? and OPERATION_ID=?"); stmt.setString(1, status.toString()); stmt.setInt(2, enrolmentId); stmt.setInt(3, operationId); From f0471203e70a23bbf8d2fe51f772f5b7b6461af4 Mon Sep 17 00:00:00 2001 From: harshanl Date: Tue, 17 Nov 2015 18:28:42 +0530 Subject: [PATCH 4/7] Added logic to skip device authorization for policy operations --- .../mgt/core/DeviceManagementConstants.java | 11 +++++++++++ .../operation/mgt/OperationManagerImpl.java | 19 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java index d5554fbf53f..1b0cf9ee103 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.device.mgt.core; +import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation; + public final class DeviceManagementConstants { public static final class Common { @@ -47,4 +49,13 @@ public final class DeviceManagementConstants { public static final String ENROL_NOTIFICATION_TYPE = "enrol"; public static final String USER_REGISTRATION_NOTIFICATION_TYPE = "userRegistration"; } + + public static final class AuthorizationSkippedOperationCodes { + private AuthorizationSkippedOperationCodes() { + throw new AssertionError(); + } + + public static final String MONITOR_OPERATION_CODE = "MONITOR"; + public static final String POLICY_OPERATION_CODE = PolicyOperation.POLICY_OPERATION_CODE; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index 0337a0a0795..3238fcdb322 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -28,6 +28,7 @@ import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorization import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; +import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; @@ -83,7 +84,7 @@ public class OperationManagerImpl implements OperationManager { } try { List authorizedDeviceList; - if (operation != null && PolicyOperation.POLICY_OPERATION_CODE.equals(operation.getCode())) { + if (operation != null && isAuthenticationSkippedOperation(operation)) { authorizedDeviceList = deviceIds; } else { authorizedDeviceList = DeviceManagementDataHolder.getInstance(). @@ -618,4 +619,20 @@ public class OperationManagerImpl implements OperationManager { return CarbonContext.getThreadLocalCarbonContext().getUsername(); } + private boolean isAuthenticationSkippedOperation(Operation operation) { + boolean status; + switch (operation.getCode()) { + case DeviceManagementConstants.AuthorizationSkippedOperationCodes.POLICY_OPERATION_CODE : + status = true; + break; + case DeviceManagementConstants.AuthorizationSkippedOperationCodes.MONITOR_OPERATION_CODE : + status = true; + break; + default: + status = false; + } + + return status; + } + } From f3cfb79bac5c49336b60d8df72b8102efcbcdf18 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Tue, 17 Nov 2015 19:28:32 +0530 Subject: [PATCH 5/7] Refactored Operation DAO classes --- .../core/operation/mgt/dao/impl/CommandOperationDAOImpl.java | 2 +- .../core/operation/mgt/dao/impl/ConfigOperationDAOImpl.java | 4 ++-- .../mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java | 4 ++-- .../core/operation/mgt/dao/impl/PolicyOperationDAOImpl.java | 4 ++-- .../core/operation/mgt/dao/impl/ProfileOperationDAOImpl.java | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) 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 d65835a7608..e5663b38445 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 @@ -59,7 +59,7 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { try { Connection connection = OperationManagementDAOFactory.getConnection(); stmt = connection.prepareStatement( - "UPDATE DM_COMMAND_OPERATION O SET O.ENABLED = ? WHERE O.OPERATION_ID = ?"); + "UPDATE DM_COMMAND_OPERATION SET ENABLED = ? WHERE OPERATION_ID = ?"); stmt.setBoolean(1, operation.isEnabled()); stmt.setInt(2, operation.getId()); stmt.executeUpdate(); 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 be3b1ab7880..f56bbff51b4 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 @@ -82,8 +82,8 @@ public class ConfigOperationDAOImpl extends OperationDAOImpl { try { super.updateOperation(operation); Connection connection = OperationManagementDAOFactory.getConnection(); - stmt = connection.prepareStatement("UPDATE DM_CONFIG_OPERATION O SET O.OPERATION_CONFIG = ? " + - "WHERE O.OPERATION_ID = ?"); + stmt = connection.prepareStatement("UPDATE DM_CONFIG_OPERATION SET OPERATION_CONFIG = ? " + + "WHERE OPERATION_ID = ?"); bao = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bao); oos.writeObject(operation); 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/OperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java index 09beecc38ed..90c0565c2eb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/OperationDAOImpl.java @@ -70,8 +70,8 @@ public class OperationDAOImpl implements OperationDAO { PreparedStatement stmt = null; try { Connection connection = OperationManagementDAOFactory.getConnection(); - stmt = connection.prepareStatement("UPDATE DM_OPERATION O SET O.RECEIVED_TIMESTAMP=? " + - "WHERE O.ID=?"); + stmt = connection.prepareStatement("UPDATE DM_OPERATION SET RECEIVED_TIMESTAMP=? " + + "WHERE ID=?"); stmt.setTimestamp(1, new Timestamp(new Date().getTime())); stmt.setInt(2, operation.getId()); stmt.executeUpdate(); 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 1bff85ae61c..6b2a848809e 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 @@ -90,8 +90,8 @@ public class PolicyOperationDAOImpl extends OperationDAOImpl { try { super.updateOperation(operation); Connection connection = OperationManagementDAOFactory.getConnection(); - stmt = connection.prepareStatement("UPDATE DM_POLICY_OPERATION O SET O.OPERATION_DETAILS=? " + - "WHERE O.OPERATION_ID=?"); + stmt = connection.prepareStatement("UPDATE DM_POLICY_OPERATION SET OPERATION_DETAILS=? " + + "WHERE OPERATION_ID=?"); bao = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bao); oos.writeObject(operation); 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 04e39eef98a..a82e7c5e5f4 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 @@ -90,8 +90,8 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl { try { super.updateOperation(operation); Connection connection = OperationManagementDAOFactory.getConnection(); - stmt = connection.prepareStatement("UPDATE DM_PROFILE_OPERATION O SET O.OPERATION_DETAILS=? " + - "WHERE O.OPERATION_ID=?"); + stmt = connection.prepareStatement("UPDATE DM_PROFILE_OPERATION SET OPERATION_DETAILS=? " + + "WHERE OPERATION_ID=?"); bao = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bao); From 5772ca4a3526ec613b18e2b94ec2ecdc84f49571 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Wed, 18 Nov 2015 21:08:57 +0530 Subject: [PATCH 6/7] Removing the unique key --- .../src/main/resources/dbscripts/cdm/mssql.sql | 1 - .../src/main/resources/dbscripts/cdm/mysql.sql | 1 - .../src/main/resources/dbscripts/cdm/oracle.sql | 1 - .../src/main/resources/dbscripts/cdm/postgresql.sql | 1 - 4 files changed, 4 deletions(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql index f812b1575d7..447a99f1426 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -305,7 +305,6 @@ CREATE TABLE DM_POLICY_COMPLIANCE_STATUS ( LAST_FAILED_TIME DATETIME2(0) NULL, ATTEMPTS INT NULL, PRIMARY KEY (ID), - CONSTRAINT DEVICE_ID_UNIQUE UNIQUE (DEVICE_ID ASC), CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY FOREIGN KEY (POLICY_ID) REFERENCES DM_POLICY (ID) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql index cdb2d3c0194..e340450d4cf 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -297,7 +297,6 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( LAST_FAILED_TIME TIMESTAMP NULL, ATTEMPTS INT NULL, PRIMARY KEY (ID), - UNIQUE INDEX DEVICE_ID_UNIQUE (DEVICE_ID ASC), CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY FOREIGN KEY (POLICY_ID) REFERENCES DM_POLICY (ID) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql index 2b33f64118e..229556c1104 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -486,7 +486,6 @@ CREATE TABLE DM_POLICY_COMPLIANCE_STATUS ( LAST_FAILED_TIME TIMESTAMP(0) NULL, ATTEMPTS NUMBER(10) NULL, CONSTRAINT PK_DM_POLICY_COMP_STATUS PRIMARY KEY (ID), - CONSTRAINT DEVICE_ID_UNIQUE UNIQUE (DEVICE_ID), CONSTRAINT FK_POLICY_COMP_STATUS_POLICY FOREIGN KEY (POLICY_ID) REFERENCES DM_POLICY (ID) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 1740e5d551b..7b14cbb5cb1 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -267,7 +267,6 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( ON DELETE NO ACTION ON UPDATE NO ACTION ); -CREATE UNIQUE INDEX DEVICE_ID_UNIQUE ON DM_POLICY_COMPLIANCE_STATUS (DEVICE_ID ASC); CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID BIGSERIAL NOT NULL PRIMARY KEY, From 767ea70436bb597cc5aa69bf406b2366e65d06e6 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Wed, 18 Nov 2015 22:05:15 +0530 Subject: [PATCH 7/7] Refactored CommandOperation DAO class --- .../mgt/dao/impl/CommandOperationDAOImpl.java | 3 ++- .../src/main/resources/dbscripts/cdm/postgresql.sql | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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 e5663b38445..8fdd35591a7 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 @@ -134,7 +134,8 @@ public class CommandOperationDAOImpl extends OperationDAOImpl { while (rs.next()) { commandOperation = new CommandOperation(); commandOperation.setId(rs.getInt("ID")); - commandOperation.setEnabled(rs.getInt("ENABLED") != 0); + //commandOperation.setEnabled(rs.getInt("ENABLED") != 0); + commandOperation.setEnabled(rs.getBoolean("ENABLED") != false); commandOperation.setStatus(Operation.Status.valueOf(rs.getString("STATUS"))); commandOperation.setType(Operation.Type.valueOf(rs.getString("TYPE"))); commandOperation.setCreatedTimeStamp(rs.getString("CREATED_TIMESTAMP")); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 1740e5d551b..f42655f7903 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -316,6 +316,17 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( TENANT_ID INTEGER NOT NULL ); +CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING ( + ID BIGSERIAL NOT NULL PRIMARY KEY, + DEVICE_ID INTEGER NOT NULL, + APPLICATION_ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES + DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + -- POLICY RELATED TABLES FINISHED -- -- NOTIFICATION TABLE --