From 795fbcb366d118bedfa81fffbc7396c7fc60bce3 Mon Sep 17 00:00:00 2001 From: dilanua Date: Tue, 6 Sep 2016 12:52:52 +0530 Subject: [PATCH 01/18] Updating ios operation endpoints - UI --- .../public/js/operation-mod.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-mod/public/js/operation-mod.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-mod/public/js/operation-mod.js index 3f1219765d4..f47bbd99768 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-mod/public/js/operation-mod.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.operation-mod/public/js/operation-mod.js @@ -115,8 +115,8 @@ var operationModule = function () { var featureMap = { "DEVICE_LOCK": "lock", "VPN": "vpn", - "PER_APP_VPN": "perappvpn", - "APP_TO_PER_APP_VPN_MAPPING": "apptoperappvpnmapping", + "PER_APP_VPN": "per-app-vpn", + "APP_TO_PER_APP_VPN_MAPPING": "app-to-per-app-vpn-mapping", "RING": "ring", "LOCATION": "location", "NOTIFICATION": "notification", @@ -124,12 +124,12 @@ var operationModule = function () { "RESTRICTION": "restriction", "CELLULAR": "cellular", "WIFI": "wifi", - "INSTALL_STORE_APPLICATION": "storeapplication", - "INSTALL_ENTERPRISE_APPLICATION": "enterpriseapplication", - "REMOVE_APPLICATION": "removeapplication", - "ENTERPRISE_WIPE": "enterprisewipe" + "INSTALL_STORE_APPLICATION": "store-application", + "INSTALL_ENTERPRISE_APPLICATION": "enterprise-application", + "REMOVE_APPLICATION": "remove-application", + "ENTERPRISE_WIPE": "enterprise-wipe" }; - return "/ios/operation/" + featureMap[operationCode]; + return "/api/device-mgt/ios/v1.0/admin/devices/" + featureMap[operationCode]; }; /** From 60a7796efbe1401c1a8d1f556c60445a098fb0ac Mon Sep 17 00:00:00 2001 From: harshanl Date: Tue, 6 Sep 2016 18:53:04 +0530 Subject: [PATCH 02/18] Fixed issues in DB scripts --- .../src/main/resources/dbscripts/cdm/h2.sql | 40 +-- .../main/resources/dbscripts/cdm/mssql.sql | 263 +++++++++++++++--- .../main/resources/dbscripts/cdm/mysql.sql | 25 -- .../main/resources/dbscripts/cdm/oracle.sql | 14 - .../resources/dbscripts/cdm/postgresql.sql | 12 + 5 files changed, 238 insertions(+), 116 deletions(-) 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 cd9560016a0..4684ec127ca 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 @@ -145,10 +145,6 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ON UPDATE NO ACTION ); - - - - CREATE TABLE IF NOT EXISTS DM_POLICY ( ID INT(11) NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , @@ -168,9 +164,6 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ON UPDATE NO ACTION ); - - - CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ID INT(11) NOT NULL AUTO_INCREMENT , DEVICE_ID INT(11) NOT NULL , @@ -190,9 +183,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ON UPDATE NO ACTION ); - - - CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ID INT(11) NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , @@ -210,10 +200,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ON UPDATE NO ACTION ); - - - - CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ID INT(11) NOT NULL AUTO_INCREMENT, PROFILE_ID INT(11) NOT NULL, @@ -229,9 +215,6 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ON UPDATE NO ACTION ); - - - CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( ID INT(11) NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , @@ -244,9 +227,6 @@ CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( ON UPDATE NO ACTION ); - - - CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( ID INT NOT NULL AUTO_INCREMENT , POLICY_ID INT NOT NULL , @@ -259,8 +239,7 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( ON UPDATE NO ACTION ); - - CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( +CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( ID INT NOT NULL AUTO_INCREMENT , DEVICE_ID INT NOT NULL , ENROLMENT_ID INT(11) NOT NULL, @@ -279,8 +258,6 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( ON UPDATE NO ACTION ); - - CREATE TABLE IF NOT EXISTS DM_CRITERIA ( ID INT NOT NULL AUTO_INCREMENT, TENANT_ID INT NOT NULL, @@ -288,8 +265,6 @@ CREATE TABLE IF NOT EXISTS DM_CRITERIA ( PRIMARY KEY (ID) ); - - CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA ( ID INT NOT NULL AUTO_INCREMENT, CRITERIA_ID INT NOT NULL, @@ -335,7 +310,6 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( PRIMARY KEY (ID) ); - CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, @@ -344,7 +318,6 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( PRIMARY KEY (ID) ); - CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES ( ID INT NOT NULL AUTO_INCREMENT, COMPLIANCE_STATUS_ID INT NOT NULL, @@ -406,8 +379,6 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( ); -- NOTIFICATION TABLE END -- -DROP TABLE IF EXISTS DM_DEVICE_INFO; - CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INT NULL, @@ -421,10 +392,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( ON UPDATE NO ACTION ); - - -DROP TABLE IF EXISTS DM_DEVICE_LOCATION; - CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INT NULL, @@ -445,7 +412,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( ON UPDATE NO ACTION ); - CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, @@ -473,9 +439,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( ON UPDATE NO ACTION ); - -- POLICY AND DEVICE GROUP MAPPING -- - CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_GROUP_ID INT NOT NULL, @@ -493,11 +457,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); - -- END OF POLICY AND DEVICE GROUP MAPPING -- -- DASHBOARD RELATED VIEWS -- - CREATE VIEW POLICY_COMPLIANCE_INFO AS SELECT DEVICE_INFO.DEVICE_ID, 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 6482fcb7760..d2307923278 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 @@ -1,31 +1,31 @@ CREATE TABLE DM_DEVICE_TYPE ( ID INTEGER IDENTITY(1,1) NOT NULL, - NAME VARCHAR(50) DEFAULT NULL, + NAME VARCHAR(300) DEFAULT NULL, + PROVIDER_TENANT_ID INTEGER NULL, + SHARED_WITH_ALL_TENANTS BIT NOT NULL DEFAULT 0, PRIMARY KEY (ID) ); -CREATE TABLE DM_DEVICE_CERTIFICATE ( - ID INTEGER IDENTITY(1,1) NOT NULL, - SERIAL_NUMBER VARCHAR(50) DEFAULT NULL, - CERTIFICATE VARBINARY(255) DEFAULT NULL, - PRIMARY KEY (ID) -); +CREATE INDEX IDX_DEVICE_TYPE ON DM_DEVICE_TYPE (NAME); CREATE TABLE DM_DEVICE ( ID INTEGER IDENTITY(1,1) NOT NULL, - DESCRIPTION TEXT DEFAULT NULL, - NAME VARCHAR(50) DEFAULT NULL, - DEVICE_TYPE_ID INTEGER DEFAULT NULL, - DEVICE_IDENTIFICATION VARCHAR(50) DEFAULT NULL, + DESCRIPTION VARBINARY(255) DEFAULT NULL, + NAME VARCHAR(100) DEFAULT NULL, + DEVICE_TYPE_ID INTEGER DEFAULT NULL, + DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, + LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID) REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +CREATE INDEX IDX_DM_DEVICE ON DM_DEVICE(TENANT_ID, DEVICE_TYPE_ID); + CREATE TABLE DM_OPERATION ( ID INTEGER IDENTITY(1,1) NOT NULL, - TYPE VARCHAR(50) NOT NULL, + TYPE VARCHAR(20) NOT NULL, CREATED_TIMESTAMP DATETIME2 NOT NULL, RECEIVED_TIMESTAMP DATETIME2 NULL, OPERATION_CODE VARCHAR(50) NOT NULL, @@ -80,11 +80,16 @@ CREATE TABLE DM_ENROLMENT ( DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +CREATE INDEX IDX_ENROLMENT_FK_DEVICE_ID ON DM_ENROLMENT(DEVICE_ID); +CREATE INDEX IDX_ENROLMENT_DEVICE_ID_TENANT_ID ON DM_ENROLMENT(DEVICE_ID, TENANT_ID); + CREATE TABLE DM_ENROLMENT_OP_MAPPING ( ID INTEGER IDENTITY(1,1) NOT NULL, ENROLMENT_ID INTEGER NOT NULL, OPERATION_ID INTEGER NOT NULL, STATUS VARCHAR(50) NULL, + CREATED_TIMESTAMP INTEGER NOT NULL, + UPDATED_TIMESTAMP INTEGER NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_OPERATION_MAPPING_DEVICE FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, @@ -92,11 +97,16 @@ CREATE TABLE DM_ENROLMENT_OP_MAPPING ( DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +CREATE INDEX IDX_ENROLMENT_OP_MAPPING ON DM_ENROLMENT_OP_MAPPING (UPDATED_TIMESTAMP); +CREATE INDEX IDX_EN_OP_MAPPING_EN_ID ON DM_ENROLMENT_OP_MAPPING(ENROLMENT_ID); +CREATE INDEX IDX_EN_OP_MAPPING_OP_ID ON DM_ENROLMENT_OP_MAPPING(OPERATION_ID); + CREATE TABLE DM_DEVICE_OPERATION_RESPONSE ( ID INTEGER IDENTITY(1,1) NOT NULL, ENROLMENT_ID INTEGER NOT NULL, OPERATION_ID INTEGER NOT NULL, OPERATION_RESPONSE VARBINARY(255) DEFAULT NULL, + RECEIVED_TIMESTAMP DATETIME2 DEFAULT NULL PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_OPERATION_RESP_ENROLMENT FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, @@ -104,10 +114,12 @@ CREATE TABLE DM_DEVICE_OPERATION_RESPONSE ( DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +CREATE INDEX IDX_ENID_OPID ON DM_DEVICE_OPERATION_RESPONSE(OPERATION_ID, ENROLMENT_ID); + -- POLICY RELATED TABLES -- -CREATE TABLE DM_PROFILE ( - ID INTEGER NOT NULL IDENTITY(1,1) , +CREATE TABLE DM_PROFILE ( + ID INTEGER IDENTITY(1,1) NOT NULL, PROFILE_NAME VARCHAR(45) NOT NULL , TENANT_ID INTEGER NOT NULL , DEVICE_TYPE_ID INTEGER NOT NULL , @@ -118,8 +130,8 @@ CREATE TABLE DM_PROFILE ( DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); -CREATE TABLE DM_POLICY ( - ID INTEGER NOT NULL IDENTITY(1,1) , +CREATE TABLE DM_POLICY ( + ID INTEGER IDENTITY(1,1) NOT NULL, NAME VARCHAR(45) DEFAULT NULL , DESCRIPTION VARCHAR(1000) NULL, TENANT_ID INTEGER NOT NULL , @@ -134,8 +146,8 @@ CREATE TABLE DM_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); -CREATE TABLE DM_DEVICE_POLICY ( - ID INTEGER NOT NULL IDENTITY(1,1) , +CREATE TABLE DM_DEVICE_POLICY ( + ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NOT NULL , ENROLMENT_ID INTEGER NOT NULL, DEVICE VARBINARY(255) NOT NULL, @@ -147,8 +159,8 @@ CREATE TABLE DM_DEVICE_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); -CREATE TABLE DM_DEVICE_TYPE_POLICY ( - ID INTEGER NOT NULL , +CREATE TABLE DM_DEVICE_TYPE_POLICY ( + ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_TYPE_ID INTEGER NOT NULL , POLICY_ID INTEGER NOT NULL , PRIMARY KEY (ID) , @@ -158,11 +170,11 @@ CREATE TABLE DM_DEVICE_TYPE_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); -CREATE TABLE DM_PROFILE_FEATURES ( - ID INTEGER NOT NULL IDENTITY(1,1), +CREATE TABLE DM_PROFILE_FEATURES ( + ID INTEGER IDENTITY(1,1) NOT NULL, PROFILE_ID INTEGER NOT NULL, - FEATURE_CODE VARCHAR(30) NOT NULL, - DEVICE_TYPE_ID INTEGER NOT NULL, + FEATURE_CODE VARCHAR(100) NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, TENANT_ID INTEGER NOT NULL , CONTENT VARBINARY(255) NULL DEFAULT NULL, PRIMARY KEY (ID), @@ -170,8 +182,8 @@ CREATE TABLE DM_PROFILE_FEATURES ( ON DELETE NO ACTION ON UPDATE NO ACTION ); -CREATE TABLE DM_ROLE_POLICY ( - ID INTEGER NOT NULL IDENTITY(1,1) , +CREATE TABLE DM_ROLE_POLICY ( + ID INTEGER IDENTITY(1,1) NOT NULL, ROLE_NAME VARCHAR(45) NOT NULL , POLICY_ID INTEGER NOT NULL , PRIMARY KEY (ID) , @@ -179,8 +191,8 @@ CREATE TABLE DM_ROLE_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); -CREATE TABLE DM_USER_POLICY ( - ID INTEGER NOT NULL IDENTITY(1,1) , +CREATE TABLE DM_USER_POLICY ( + ID INTEGER IDENTITY(1,1) NOT NULL, POLICY_ID INTEGER NOT NULL , USERNAME VARCHAR(45) NOT NULL , PRIMARY KEY (ID) , @@ -188,8 +200,8 @@ CREATE TABLE DM_USER_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); - CREATE TABLE DM_DEVICE_POLICY_APPLIED ( - ID INTEGER NOT NULL IDENTITY(1,1) , + CREATE TABLE DM_DEVICE_POLICY_APPLIED ( + ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NOT NULL , ENROLMENT_ID INTEGER NOT NULL, POLICY_ID INTEGER NOT NULL , @@ -205,14 +217,14 @@ CREATE TABLE DM_USER_POLICY ( ); CREATE TABLE DM_CRITERIA ( - ID INTEGER NOT NULL IDENTITY(1,1), + ID INTEGER IDENTITY(1,1) NOT NULL, TENANT_ID INTEGER NOT NULL, NAME VARCHAR(50) NULL, PRIMARY KEY (ID) ); CREATE TABLE DM_POLICY_CRITERIA ( - ID INTEGER NOT NULL IDENTITY(1,1), + ID INTEGER IDENTITY(1,1) NOT NULL, CRITERIA_ID INTEGER NOT NULL, POLICY_ID INTEGER NOT NULL, PRIMARY KEY (ID), @@ -223,7 +235,7 @@ CREATE TABLE DM_POLICY_CRITERIA ( ); CREATE TABLE DM_POLICY_CRITERIA_PROPERTIES ( - ID INTEGER NOT NULL IDENTITY(1,1), + ID INTEGER IDENTITY(1,1) NOT NULL, POLICY_CRITERION_ID INTEGER NOT NULL, PROP_KEY VARCHAR(45) NULL, PROP_VALUE VARCHAR(100) NULL, @@ -234,7 +246,7 @@ CREATE TABLE DM_POLICY_CRITERIA_PROPERTIES ( ); CREATE TABLE DM_POLICY_COMPLIANCE_STATUS ( - ID INTEGER NOT NULL IDENTITY(1,1), + ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, POLICY_ID INTEGER NOT NULL, @@ -248,18 +260,18 @@ CREATE TABLE DM_POLICY_COMPLIANCE_STATUS ( ); CREATE TABLE DM_POLICY_CHANGE_MGT ( - ID INTEGER NOT NULL IDENTITY(1,1), + ID INTEGER IDENTITY(1,1) NOT NULL, POLICY_ID INTEGER NOT NULL, - DEVICE_TYPE_ID INTEGER NOT NULL, + DEVICE_TYPE VARCHAR(300) NOT NULL, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ID) ); CREATE TABLE DM_POLICY_COMPLIANCE_FEATURES ( - ID INTEGER NOT NULL IDENTITY(1,1), + ID INTEGER IDENTITY(1,1) NOT NULL, COMPLIANCE_STATUS_ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL, - FEATURE_CODE VARCHAR(15) NOT NULL, + FEATURE_CODE VARCHAR(100) NOT NULL, STATUS INTEGER NULL, PRIMARY KEY (ID), CONSTRAINT FK_COMPLIANCE_FEATURES_STATUS FOREIGN KEY (COMPLIANCE_STATUS_ID) REFERENCES DM_POLICY_COMPLIANCE_STATUS (ID) @@ -277,6 +289,8 @@ CREATE TABLE DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES VARBINARY(255) NULL, + MEMORY_USAGE INTEGER NULL, + IS_ACTIVE BIT NOT NULL DEFAULT 0, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ID) ); @@ -295,6 +309,56 @@ CREATE TABLE DM_DEVICE_APPLICATION_MAPPING ( -- POLICY RELATED TABLES FINISHED -- + +-- DEVICE GROUP TABLES -- + +CREATE TABLE DM_GROUP ( + ID INTEGER IDENTITY(1,1) NOT NULL, + GROUP_NAME VARCHAR(100) DEFAULT NULL, + DESCRIPTION VARBINARY(255) NULL, + DATE_OF_CREATE BIGINT DEFAULT NULL, + DATE_OF_LAST_UPDATE BIGINT DEFAULT NULL, + OWNER VARCHAR(45) DEFAULT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +); + +CREATE TABLE DM_DEVICE_GROUP_MAP ( + ID INTEGER IDENTITY(1,1) NOT NULL, + DEVICE_ID INTEGER DEFAULT NULL, + GROUP_ID INTEGER DEFAULT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_GROUP_MAP_DM_DEVICE2 FOREIGN KEY (DEVICE_ID) + REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT fk_DM_DEVICE_GROUP_MAP_DM_GROUP2 FOREIGN KEY (GROUP_ID) + REFERENCES DM_GROUP (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +-- END OF DEVICE GROUP TABLES -- + +-- POLICY AND DEVICE GROUP MAPPING -- + +CREATE TABLE DM_DEVICE_GROUP_POLICY ( + ID INTEGER IDENTITY(1,1) NOT NULL, + DEVICE_GROUP_ID INTEGER NOT NULL, + POLICY_ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_DM_DEVICE_GROUP_POLICY + FOREIGN KEY (DEVICE_GROUP_ID) + REFERENCES DM_GROUP (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT FK_DM_DEVICE_GROUP_DM_POLICY + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +-- END OF POLICY AND DEVICE GROUP MAPPING -- + -- NOTIFICATION TABLE -- CREATE TABLE DM_NOTIFICATION ( NOTIFICATION_ID INTEGER IDENTITY(1,1) NOT NULL, @@ -311,3 +375,126 @@ CREATE TABLE DM_NOTIFICATION ( ); -- NOTIFICATION TABLE END -- +CREATE TABLE DM_DEVICE_INFO ( + ID INTEGER IDENTITY(1,1) NOT NULL, + DEVICE_ID INTEGER NULL, + KEY_FIELD VARCHAR(45) NULL, + VALUE_FIELD VARCHAR(100) NULL, + PRIMARY KEY (ID), + INDEX DM_DEVICE_INFO_DEVICE_idx (DEVICE_ID ASC), + CONSTRAINT DM_DEVICE_INFO_DEVICE FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE TABLE DM_DEVICE_LOCATION ( + ID INTEGER IDENTITY(1,1) NOT NULL, + DEVICE_ID INTEGER NULL, + LATITUDE FLOAT NULL, + LONGITUDE FLOAT NULL, + STREET1 VARCHAR(45) NULL, + STREET2 VARCHAR(45) NULL, + CITY VARCHAR(45) NULL, + ZIP VARCHAR(10) NULL, + STATE VARCHAR(45) NULL, + COUNTRY VARCHAR(45) NULL, + UPDATE_TIMESTAMP INTEGER NOT NULL, + PRIMARY KEY (ID), + INDEX DM_DEVICE_LOCATION_DEVICE_idx (DEVICE_ID ASC), + CONSTRAINT DM_DEVICE_LOCATION_DEVICE + FOREIGN KEY (DEVICE_ID) + REFERENCES DM_DEVICE (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +CREATE TABLE DM_DEVICE_DETAIL ( + ID INTEGER IDENTITY(1,1) NOT NULL, + DEVICE_ID INTEGER NOT NULL, + DEVICE_MODEL VARCHAR(45) NULL, + VENDOR VARCHAR(45) NULL, + OS_VERSION VARCHAR(45) NULL, + OS_BUILD_DATE VARCHAR(100) NULL, + BATTERY_LEVEL DECIMAL(4) NULL, + INTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL, + INTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL, + EXTERNAL_TOTAL_MEMORY DECIMAL(30,3) NULL, + EXTERNAL_AVAILABLE_MEMORY DECIMAL(30,3) NULL, + CONNECTION_TYPE VARCHAR(10) NULL, + SSID VARCHAR(45) NULL, + CPU_USAGE DECIMAL(5) NULL, + TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, + AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, + PLUGGED_IN INTEGER NULL, + UPDATE_TIMESTAMP INTEGER NOT NULL, + PRIMARY KEY (ID), + INDEX FK_DM_DEVICE_DETAILS_DEVICE_idx (DEVICE_ID ASC), + CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE + FOREIGN KEY (DEVICE_ID) + REFERENCES DM_DEVICE (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + +-- DASHBOARD RELATED VIEWS -- + +CREATE VIEW DEVICE_INFO_VIEW AS +SELECT +DM_DEVICE.ID AS DEVICE_ID, +DM_DEVICE.DEVICE_IDENTIFICATION, +DM_DEVICE_TYPE.NAME AS PLATFORM, +DM_ENROLMENT.OWNERSHIP, +DM_ENROLMENT.STATUS AS CONNECTIVITY_STATUS, +DM_DEVICE.TENANT_ID +FROM DM_DEVICE, DM_DEVICE_TYPE, DM_ENROLMENT +WHERE DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND DM_DEVICE.ID = DM_ENROLMENT.DEVICE_ID; + +CREATE VIEW DEVICE_WITH_POLICY_INFO_VIEW AS +SELECT +DEVICE_ID, +POLICY_ID, +STATUS AS IS_COMPLIANT +FROM DM_POLICY_COMPLIANCE_STATUS; + +CREATE VIEW POLICY_COMPLIANCE_INFO AS +SELECT +DEVICE_INFO_VIEW.DEVICE_ID, +DEVICE_INFO_VIEW.DEVICE_IDENTIFICATION, +DEVICE_INFO_VIEW.PLATFORM, +DEVICE_INFO_VIEW.OWNERSHIP, +DEVICE_INFO_VIEW.CONNECTIVITY_STATUS, +IFNULL(DEVICE_WITH_POLICY_INFO_VIEW.POLICY_ID, -1) AS POLICY_ID, +IFNULL(DEVICE_WITH_POLICY_INFO_VIEW.IS_COMPLIANT, -1) AS IS_COMPLIANT, +DEVICE_INFO_VIEW.TENANT_ID +FROM +DEVICE_INFO_VIEW +LEFT JOIN +DEVICE_WITH_POLICY_INFO_VIEW +ON DEVICE_INFO_VIEW.DEVICE_ID = DEVICE_WITH_POLICY_INFO_VIEW.DEVICE_ID +ORDER BY DEVICE_INFO_VIEW.DEVICE_ID; + +CREATE VIEW FEATURE_NON_COMPLIANCE_INFO AS +SELECT +DM_DEVICE.ID AS DEVICE_ID, +DM_DEVICE.DEVICE_IDENTIFICATION, +DM_DEVICE_DETAIL.DEVICE_MODEL, +DM_DEVICE_DETAIL.VENDOR, +DM_DEVICE_DETAIL.OS_VERSION, +DM_ENROLMENT.OWNERSHIP, +DM_ENROLMENT.OWNER, +DM_ENROLMENT.STATUS AS CONNECTIVITY_STATUS, +DM_POLICY_COMPLIANCE_STATUS.POLICY_ID, +DM_DEVICE_TYPE.NAME AS PLATFORM, +DM_POLICY_COMPLIANCE_FEATURES.FEATURE_CODE, +DM_POLICY_COMPLIANCE_FEATURES.STATUS AS IS_COMPLAINT, +DM_DEVICE.TENANT_ID +FROM +DM_POLICY_COMPLIANCE_FEATURES, DM_POLICY_COMPLIANCE_STATUS, DM_ENROLMENT, DM_DEVICE, DM_DEVICE_TYPE, DM_DEVICE_DETAIL +WHERE +DM_POLICY_COMPLIANCE_FEATURES.COMPLIANCE_STATUS_ID = DM_POLICY_COMPLIANCE_STATUS.ID AND +DM_POLICY_COMPLIANCE_STATUS.ENROLMENT_ID = DM_ENROLMENT.ID AND +DM_POLICY_COMPLIANCE_STATUS.DEVICE_ID = DM_DEVICE.ID AND +DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND +DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID +ORDER BY TENANT_ID, DEVICE_ID; + +-- END OF DASHBOARD RELATED VIEWS -- \ No newline at end of file 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 9c122d0764d..e8cb6f4f271 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 @@ -336,22 +336,6 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES ( ON UPDATE NO ACTION )ENGINE = InnoDB; - -CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( - ID INTEGER AUTO_INCREMENT NOT NULL, - DEVICE_ID INTEGER NOT NULL, - OWNER VARCHAR(50) NOT NULL, - OWNERSHIP VARCHAR(45) DEFAULT NULL, - STATUS VARCHAR(50) NULL, - DATE_OF_ENROLMENT TIMESTAMP NULL DEFAULT NULL, - DATE_OF_LAST_UPDATE TIMESTAMP NULL DEFAULT NULL, - TENANT_ID INT NOT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION -)ENGINE = InnoDB; - - CREATE TABLE IF NOT EXISTS DM_APPLICATION ( ID INTEGER AUTO_INCREMENT NOT NULL, NAME VARCHAR(150) NOT NULL, @@ -454,9 +438,6 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION ( -- END NOTIFICATION TABLES -- - -DROP TABLE IF EXISTS DM_DEVICE_INFO; - CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INT NULL, @@ -472,10 +453,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO ( ) ENGINE = InnoDB; - - -DROP TABLE IF EXISTS DM_DEVICE_LOCATION; - CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INT NULL, @@ -498,8 +475,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( ) ENGINE = InnoDB; -DROP TABLE IF EXISTS DM_DEVICE_DETAIL ; - CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, 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 8c98587ffea..c49d5301408 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 @@ -764,13 +764,6 @@ WHEN (NEW.ID IS NULL) END; / -BEGIN - EXECUTE IMMEDIATE 'DROP TABLE DM_DEVICE_LOCATION'; - EXCEPTION - WHEN OTHERS THEN NULL; -END; -/ - CREATE TABLE DM_DEVICE_LOCATION ( ID NUMBER(10) NOT NULL, DEVICE_ID NUMBER(10) NULL, @@ -802,13 +795,6 @@ WHEN (NEW.ID IS NULL) END; / -BEGIN - EXECUTE IMMEDIATE 'DROP TABLE DM_DEVICE_DETAIL'; - EXCEPTION - WHEN OTHERS THEN NULL; -END; -/ - CREATE TABLE DM_DEVICE_DETAIL ( ID NUMBER(10) NOT NULL, DEVICE_ID NUMBER(10) NOT NULL, 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 52083e9d8c8..828eca58cb5 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 @@ -6,6 +6,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE ( UNIQUE(NAME) ); +CREATE INDEX IDX_DEVICE_TYPE ON DM_DEVICE_TYPE (NAME); + CREATE TABLE IF NOT EXISTS DM_DEVICE ( ID BIGSERIAL NOT NULL PRIMARY KEY, DESCRIPTION TEXT DEFAULT NULL, @@ -18,6 +20,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE ( REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +CREATE INDEX IDX_DM_DEVICE ON DM_DEVICE(TENANT_ID, DEVICE_TYPE_ID); + CREATE TABLE IF NOT EXISTS DM_OPERATION ( ID BIGSERIAL NOT NULL PRIMARY KEY, TYPE VARCHAR(50) NOT NULL, @@ -73,6 +77,9 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +CREATE INDEX IDX_ENROLMENT_FK_DEVICE_ID ON DM_ENROLMENT(DEVICE_ID); +CREATE INDEX IDX_ENROLMENT_DEVICE_ID_TENANT_ID ON DM_ENROLMENT(DEVICE_ID, TENANT_ID); + CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( ID BIGSERIAL NOT NULL PRIMARY KEY, ENROLMENT_ID INTEGER NOT NULL, @@ -86,6 +93,10 @@ CREATE TABLE IF NOT EXISTS DM_ENROLMENT_OP_MAPPING ( DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +CREATE INDEX IDX_ENROLMENT_OP_MAPPING ON DM_ENROLMENT_OP_MAPPING (UPDATED_TIMESTAMP); +CREATE INDEX IDX_EN_OP_MAPPING_EN_ID ON DM_ENROLMENT_OP_MAPPING(ENROLMENT_ID); +CREATE INDEX IDX_EN_OP_MAPPING_OP_ID ON DM_ENROLMENT_OP_MAPPING(OPERATION_ID); + CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_RESPONSE ( ID BIGSERIAL NOT NULL PRIMARY KEY, ENROLMENT_ID INTEGER NOT NULL, @@ -98,6 +109,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_OPERATION_RESPONSE ( DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +CREATE INDEX IDX_ENID_OPID ON DM_DEVICE_OPERATION_RESPONSE(OPERATION_ID, ENROLMENT_ID); -- POLICY RELATED TABLES --- CREATE TABLE IF NOT EXISTS DM_PROFILE ( From f37c2c6de834758ba84019e64509b1c176f3cbec Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Wed, 7 Sep 2016 01:38:49 +0530 Subject: [PATCH 03/18] Fixing requesting invalid url for Roboto-Regular web font --- .../uuf-template-app/app/units/uuf.unit.theme/theme.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/theme.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/theme.hbs index a511639e8f9..b298d71d3b1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/theme.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/theme.hbs @@ -26,7 +26,7 @@ {{~css "lib/font-wso2_1.2/css/font-wso2.css" combine=false}} {{~css "less/theme.less" combine=false}} - {{~css "css/theme-wso2.css"}} + {{~css "css/theme-wso2.css" combine=false}} {{/zone}} {{~#zone "topJs"}} From a74862d73b41b301b1db901c3c684b1135b8c7b9 Mon Sep 17 00:00:00 2001 From: dilanua Date: Wed, 7 Sep 2016 14:56:27 +0530 Subject: [PATCH 04/18] Updating policy module - UI --- .../devicemgt/app/modules/business-controllers/policy.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js index 2d22a6f9cbc..bf3a9daba3a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js @@ -45,7 +45,12 @@ policyModule = function () { policyObjectToView["priorityId"] = policyObjectFromRestEndpoint["priorityId"]; policyObjectToView["name"] = policyObjectFromRestEndpoint["policyName"]; policyObjectToView["platform"] = policyObjectFromRestEndpoint["profile"]["deviceType"]; - policyObjectToView["icon"] = utility.getDeviceThumb(policyObjectToView["platform"]); + if (policyObjectToView["platform"] == "ios") { + policyObjectToView["deviceTypeIcon"] = "apple"; + } else { + policyObjectToView["deviceTypeIcon"] = policyObjectToView["platform"]; + } + //policyObjectToView["icon"] = utility.getDeviceThumb(policyObjectToView["platform"]); policyObjectToView["ownershipType"] = policyObjectFromRestEndpoint["ownershipType"]; var assignedRoleCount = policyObjectFromRestEndpoint["roles"].length; From b7ffaf0b0f59cf13935043101daf32dbff8140eb Mon Sep 17 00:00:00 2001 From: harshanl Date: Wed, 7 Sep 2016 15:01:09 +0530 Subject: [PATCH 05/18] Fixed issues in DAO implementations and MSSQL db script --- .../dao/impl/device/OracleDeviceDAOImpl.java | 21 ++- .../impl/device/PostgreSQLDeviceDAOImpl.java | 3 + .../impl/device/SQLServerDeviceDAOImpl.java | 23 ++- .../dao/OperationManagementDAOFactory.java | 3 +- .../impl/operation/H2OperationDAOImpl.java | 174 ------------------ .../main/resources/dbscripts/cdm/mssql.sql | 2 +- 6 files changed, 46 insertions(+), 180 deletions(-) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/operation/H2OperationDAOImpl.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java index ced650ebe1b..d070660d7ae 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/OracleDeviceDAOImpl.java @@ -31,6 +31,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -55,6 +56,8 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { boolean isOwnershipProvided = false; String status = request.getStatus(); boolean isStatusProvided = false; + Date since = request.getSince(); + boolean isSinceProvided = false; try { conn = this.getConnection(); String sql = "SELECT * FROM (SELECT ROWNUM offset, rs.* FROM (SELECT d1.ID AS DEVICE_ID, " + @@ -62,7 +65,20 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { "e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT, " + "e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " + "d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, " + - "DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; + "DM_DEVICE_TYPE t "; + + //Add the query to filter active devices on timestamp + if (since != null) { + sql = sql + ", DM_DEVICE_DETAIL dt"; + isSinceProvided = true; + } + + sql = sql + " WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; + + //Add query for last updated timestamp + if (isSinceProvided) { + sql = sql + " AND dt.DEVICE_ID = d.ID AND dt.UPDATE_TIMESTAMP > ?"; + } //Add the query for device-type if (deviceType != null && !deviceType.isEmpty()) { @@ -98,6 +114,9 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); int paramIdx = 2; + if (isSinceProvided) { + stmt.setLong(paramIdx++, since.getTime()); + } if (isDeviceTypeProvided) { stmt.setString(paramIdx++, request.getDeviceType()); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java index 878e3107422..26519160258 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/PostgreSQLDeviceDAOImpl.java @@ -30,6 +30,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -54,6 +55,8 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl { boolean isOwnershipProvided = false; String status = request.getStatus(); boolean isStatusProvided = false; + Date since = request.getSince(); + boolean isSinceProvided = false; try { conn = this.getConnection(); String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index 476b703ad8c..a8f6f5b345f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -30,6 +30,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -54,13 +55,28 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { boolean isOwnershipProvided = false; String status = request.getStatus(); boolean isStatusProvided = false; + Date since = request.getSince(); + boolean isSinceProvided = false; try { conn = this.getConnection(); String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " + "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, " + - "d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t " + - "WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; + "d.NAME, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE " + + "FROM DM_DEVICE d, DM_DEVICE_TYPE t "; + + //Add the query to filter active devices on timestamp + if (since != null) { + sql = sql + ", DM_DEVICE_DETAIL dt"; + isSinceProvided = true; + } + + sql = sql + " WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?"; + + //Add query for last updated timestamp + if (isSinceProvided) { + sql = sql + " AND dt.DEVICE_ID = d.ID AND dt.UPDATE_TIMESTAMP > ?"; + } //Add the query for device-type if (deviceType != null && !deviceType.isEmpty()) { @@ -96,6 +112,9 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); int paramIdx = 2; + if (isSinceProvided) { + stmt.setLong(paramIdx++, since.getTime()); + } if (isDeviceTypeProvided) { stmt.setString(paramIdx++, request.getDeviceType()); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java index e22a83c59e0..bfa28a66528 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/OperationManagementDAOFactory.java @@ -28,7 +28,6 @@ import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.*; -import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.operation.H2OperationDAOImpl; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.operation.MySQLOperationDAOImpl; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.operation.OracleOperationDAOImpl; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.operation.PostgreSQLOperationDAOImpl; @@ -77,7 +76,7 @@ public class OperationManagementDAOFactory { case DeviceManagementConstants.DataBaseTypes.DB_TYPE_POSTGRESQL: return new PostgreSQLOperationDAOImpl(); case DeviceManagementConstants.DataBaseTypes.DB_TYPE_H2: - return new H2OperationDAOImpl(); + return new GenericOperationDAOImpl(); case DeviceManagementConstants.DataBaseTypes.DB_TYPE_MYSQL: return new MySQLOperationDAOImpl(); default: 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/operation/H2OperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/operation/H2OperationDAOImpl.java deleted file mode 100644 index ef2b57b2a55..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/operation/H2OperationDAOImpl.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2016a, 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.core.operation.mgt.dao.impl.operation; - -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; -import org.wso2.carbon.device.mgt.common.operation.mgt.ActivityStatus; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationResponse; -import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException; -import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; -import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOUtil; -import org.wso2.carbon.device.mgt.core.operation.mgt.dao.impl.GenericOperationDAOImpl; -import org.wso2.carbon.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil; - -import java.io.IOException; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -/** - * This class holds the implementation of OperationDAO which can be used to support H2 db syntax. - */ -public class H2OperationDAOImpl extends GenericOperationDAOImpl { - - @Override - public List getActivitiesUpdatedAfter(long timestamp, int limit, int offset) throws OperationManagementDAOException { - PreparedStatement stmt = null; - ResultSet rs = null; - List activities = new ArrayList<>(); - try { - Connection conn = OperationManagementDAOFactory.getConnection(); - String sql = "SELECT feom.ENROLMENT_ID, feom.OPERATION_ID, feom.CREATED_TIMESTAMP, o.TYPE AS OPERATION_TYPE, " + - "o.OPERATION_CODE, orsp.OPERATION_RESPONSE, orsp.LATEST_RECEIVED_TIMESTAMP AS RECEIVED_TIMESTAMP, " + - "orsp.ID AS OP_RES_ID, feom.STATUS, feom.UPDATED_TIMESTAMP, feom.DEVICE_IDENTIFICATION, " + - "feom.DEVICE_TYPE FROM (SELECT eom.ENROLMENT_ID, eom.OPERATION_ID, eom.STATUS, eom.CREATED_TIMESTAMP, " + - "eom.UPDATED_TIMESTAMP, fe.DEVICE_IDENTIFICATION, fe.DEVICE_TYPE FROM " + - "(SELECT ENROLMENT_ID, OPERATION_ID, STATUS, CREATED_TIMESTAMP, UPDATED_TIMESTAMP " + - "FROM DM_ENROLMENT_OP_MAPPING WHERE UPDATED_TIMESTAMP > ? ORDER BY OPERATION_ID LIMIT ? OFFSET ?) eom " + - "LEFT OUTER JOIN (SELECT e.ID AS ENROLMENT_ID, d.ID AS DEVICE_ID, d.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE FROM DM_ENROLMENT e LEFT OUTER JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + - "LEFT OUTER JOIN DM_DEVICE_TYPE t ON d.DEVICE_TYPE_ID = t.ID WHERE d.TENANT_ID = ? AND " + - "e.TENANT_ID = ?) fe ON fe.ENROLMENT_ID = eom.ENROLMENT_ID) feom LEFT OUTER JOIN DM_OPERATION o " + - "ON feom.OPERATION_ID = o.ID LEFT OUTER JOIN (SELECT ID, ENROLMENT_ID, OPERATION_ID, " + - "OPERATION_RESPONSE, MAX(RECEIVED_TIMESTAMP) LATEST_RECEIVED_TIMESTAMP " + - "FROM DM_DEVICE_OPERATION_RESPONSE GROUP BY ENROLMENT_ID , OPERATION_ID) orsp " + - "ON o.ID = orsp.OPERATION_ID AND feom.ENROLMENT_ID = orsp.ENROLMENT_ID GROUP BY feom.ENROLMENT_ID, " + - "feom.OPERATION_ID, feom.CREATED_TIMESTAMP, o.TYPE, o.OPERATION_CODE, orsp.OPERATION_RESPONSE, " + - "orsp.LATEST_RECEIVED_TIMESTAMP, orsp.ID, feom.STATUS, feom.UPDATED_TIMESTAMP, " + - "feom.DEVICE_IDENTIFICATION, feom.DEVICE_TYPE"; - - stmt = conn.prepareStatement(sql); - - stmt.setLong(1, timestamp); - stmt.setInt(2, limit); - stmt.setInt(3, offset); - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - stmt.setInt(4, tenantId); - stmt.setInt(5, tenantId); - - rs = stmt.executeQuery(); - - int operationId = 0; - int enrolmentId = 0; - int responseId = 0; - Activity activity = null; - ActivityStatus activityStatus = null; - while (rs.next()) { - - if (operationId != rs.getInt("OPERATION_ID")) { - activity = new Activity(); - activities.add(activity); - List statusList = new ArrayList<>(); - activityStatus = new ActivityStatus(); - - operationId = rs.getInt("OPERATION_ID"); - enrolmentId = rs.getInt("ENROLMENT_ID"); - - activity.setType(Activity.Type.valueOf(rs.getString("OPERATION_TYPE"))); - activity.setCreatedTimeStamp(new java.util.Date(rs.getLong(("CREATED_TIMESTAMP")) * 1000).toString()); - activity.setCode(rs.getString("OPERATION_CODE")); - - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION")); - deviceIdentifier.setType(rs.getString("DEVICE_TYPE")); - activityStatus.setDeviceIdentifier(deviceIdentifier); - - activityStatus.setStatus(ActivityStatus.Status.valueOf(rs.getString("STATUS"))); - - List operationResponses = new ArrayList<>(); - if (rs.getInt("UPDATED_TIMESTAMP") != 0) { - activityStatus.setUpdatedTimestamp(new java.util.Date( - rs.getLong(("UPDATED_TIMESTAMP")) * 1000).toString()); - - } - if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) { - operationResponses.add(OperationDAOUtil.getOperationResponse(rs)); - responseId = rs.getInt("OP_RES_ID"); - } - activityStatus.setResponses(operationResponses); - statusList.add(activityStatus); - activity.setActivityStatus(statusList); - activity.setActivityId(OperationDAOUtil.getActivityId(rs.getInt("OPERATION_ID"))); - - } - - if (operationId == rs.getInt("OPERATION_ID") && enrolmentId != rs.getInt("ENROLMENT_ID")) { - activityStatus = new ActivityStatus(); - - activity.setType(Activity.Type.valueOf(rs.getString("OPERATION_TYPE"))); - activity.setCreatedTimeStamp(new java.util.Date(rs.getLong(("CREATED_TIMESTAMP")) * 1000).toString()); - activity.setCode(rs.getString("OPERATION_CODE")); - - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); - deviceIdentifier.setId(rs.getString("DEVICE_IDENTIFICATION")); - deviceIdentifier.setType(rs.getString("DEVICE_TYPE")); - activityStatus.setDeviceIdentifier(deviceIdentifier); - - activityStatus.setStatus(ActivityStatus.Status.valueOf(rs.getString("STATUS"))); - - List operationResponses = new ArrayList<>(); - if (rs.getInt("UPDATED_TIMESTAMP") != 0) { - activityStatus.setUpdatedTimestamp(new java.util.Date( - rs.getLong(("UPDATED_TIMESTAMP")) * 1000).toString()); - } - if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) { - operationResponses.add(OperationDAOUtil.getOperationResponse(rs)); - responseId = rs.getInt("OP_RES_ID"); - } - activityStatus.setResponses(operationResponses); - activity.getActivityStatus().add(activityStatus); - - enrolmentId = rs.getInt("ENROLMENT_ID"); - } - - if (rs.getInt("OP_RES_ID") != 0 && responseId != rs.getInt("OP_RES_ID")) { - if (rs.getTimestamp("RECEIVED_TIMESTAMP") != (null)) { - activityStatus.getResponses().add(OperationDAOUtil.getOperationResponse(rs)); - responseId = rs.getInt("OP_RES_ID"); - } - } - } - } catch (SQLException e) { - throw new OperationManagementDAOException("Error occurred while getting the operation details from " + - "the database.", e); - } catch (ClassNotFoundException e) { - throw new OperationManagementDAOException("Error occurred while converting the operation response to string.", e); - } catch (IOException e) { - throw new OperationManagementDAOException("IO exception occurred while converting the operations responses.", e); - } finally { - OperationManagementDAOUtil.cleanupResources(stmt, rs); - } - return activities; - } -} \ No newline at end of file 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 d2307923278..f66ed455785 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 @@ -14,7 +14,7 @@ CREATE TABLE DM_DEVICE ( NAME VARCHAR(100) DEFAULT NULL, DEVICE_TYPE_ID INTEGER DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, - LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, + LAST_UPDATED_TIMESTAMP DATETIME2 NOT NULL, TENANT_ID INTEGER DEFAULT 0, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID) From d24ba9864314d34cd8129317a5b2ead50b40258b Mon Sep 17 00:00:00 2001 From: dilanua Date: Wed, 7 Sep 2016 16:15:26 +0530 Subject: [PATCH 06/18] Updating activate and deactivate policy endpoints from PUT to POST --- .../device/mgt/jaxrs/service/api/PolicyManagementService.java | 2 +- .../mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java index 1ede29f3e87..da0931e10fe 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java @@ -374,7 +374,7 @@ public interface PolicyManagementService { required = true) List policyIds); - @PUT + @POST @Path("/deactivate-policy") @ApiOperation( consumes = MediaType.APPLICATION_JSON, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java index 109bb189d42..bb8759e685e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java @@ -254,7 +254,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService { } } - @PUT + @POST @Path("/activate-policy") @Override public Response activatePolicies(List policyIds) { @@ -286,7 +286,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService { } } - @PUT + @POST @Path("/deactivate-policy") @Override public Response deactivatePolicies(List policyIds) { From 2e17dce0aebe33c738a577a4934271d75fb2cfb4 Mon Sep 17 00:00:00 2001 From: harshanl Date: Wed, 7 Sep 2016 16:19:50 +0530 Subject: [PATCH 07/18] Fixed DM_DEVICE column issue in MSSQL scrpt --- .../src/main/resources/dbscripts/cdm/mssql.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 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 f66ed455785..45c25fc856f 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 @@ -10,7 +10,7 @@ CREATE INDEX IDX_DEVICE_TYPE ON DM_DEVICE_TYPE (NAME); CREATE TABLE DM_DEVICE ( ID INTEGER IDENTITY(1,1) NOT NULL, - DESCRIPTION VARBINARY(255) DEFAULT NULL, + DESCRIPTION VARCHAR(MAX) DEFAULT NULL, NAME VARCHAR(100) DEFAULT NULL, DEVICE_TYPE_ID INTEGER DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, @@ -315,7 +315,7 @@ CREATE TABLE DM_DEVICE_APPLICATION_MAPPING ( CREATE TABLE DM_GROUP ( ID INTEGER IDENTITY(1,1) NOT NULL, GROUP_NAME VARCHAR(100) DEFAULT NULL, - DESCRIPTION VARBINARY(255) NULL, + DESCRIPTION VARCHAR(MAX) DEFAULT NULL, DATE_OF_CREATE BIGINT DEFAULT NULL, DATE_OF_LAST_UPDATE BIGINT DEFAULT NULL, OWNER VARCHAR(45) DEFAULT NULL, From e80daf7709e3db73b6e0b1dd108cca09da1d999a Mon Sep 17 00:00:00 2001 From: thusithakalugamage Date: Thu, 8 Sep 2016 12:29:49 +0530 Subject: [PATCH 08/18] responsive small device view defect fixes --- .../uuf.unit.theme/public/css/theme-wso2.css | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/css/theme-wso2.css b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/css/theme-wso2.css index 5fe5c2e37d3..7d570d33e02 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/css/theme-wso2.css +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.theme/public/css/theme-wso2.css @@ -5398,6 +5398,9 @@ button.close { -moz-border-radius: 0; border-radius: 0; } +.panel-body .message { + margin:0px; +} .message h4 { margin-top: 0; margin-bottom: 5px; @@ -7438,17 +7441,13 @@ ul.sidebar-messages > li { * ======================================================================== */ .body-wrapper { padding: 40px; + margin-bottom:40px; } .body-wrapper a.btn:hover,.body-wrapper a:hover { text-decoration: none; } -@media (max-width: 767px) { - .body-wrapper { - padding: 40px 0px; - } -} .page-header { margin: 0 0 20px; } @@ -7791,9 +7790,16 @@ ul.sidebar-messages > li { background: transparent; font-size: 24px; font-weight: 300; - border-bottom: 1px solid #e4e4e4; - padding-bottom: 10px; - margin-bottom: 20px; +} + +.panel-default > .panel-heading a[data-toggle="collapse"]{ + display:block; + padding:10px; +} +.media.tab-responsive .panel-group .panel-heading + .panel-collapse > .panel-body, +.media.tab-responsive .panel-group .panel-heading + .panel-collapse > .list-group{ + border:none; + border-top:1px solid #ddd; } /* ======================================================================== @@ -8321,7 +8327,6 @@ a.list-group-item:hover { border-style: solid; border-color: #ddd; padding: 20px; - min-height: 300px; } From 2fde165b7c40de81dc3c68a638dd76fa0a144727 Mon Sep 17 00:00:00 2001 From: charitha Date: Thu, 8 Sep 2016 14:46:01 +0530 Subject: [PATCH 09/18] Fix SQL error when could happen due to duplicate enrollments. (cherry picked from commit c75307f) --- .../device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 1ecdb88459b..44062cffc7e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -763,10 +763,9 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { ResultSet rs = null; try { conn = this.getConnection(); - String sql = "SELECT ID AS ENROLMENT_ID FROM DM_ENROLMENT WHERE DEVICE_ID = (SELECT DISTINCT d.ID " + - "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE d.DEVICE_TYPE_ID = t.ID " + - "AND d.DEVICE_IDENTIFICATION = ? AND t.NAME = ? AND d.TENANT_ID = ?) " + - "AND STATUS = ? AND TENANT_ID = ?"; + String sql = "SELECT e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT d.ID FROM DM_DEVICE d, DM_DEVICE_TYPE t " + + "WHERE d.DEVICE_TYPE_ID = t.ID AND d.DEVICE_IDENTIFICATION = ? AND t.NAME = ? AND d.TENANT_ID = ?) dtm " + + "WHERE e.DEVICE_ID = dtm.ID AND e.STATUS = ? AND e.TENANT_ID = ?;"; stmt = conn.prepareStatement(sql); stmt.setString(1, deviceId.getId()); stmt.setString(2, deviceId.getType()); From 411641bc57704c62b26f07f59827057e631cdc7b Mon Sep 17 00:00:00 2001 From: kamidu Date: Thu, 8 Sep 2016 18:41:51 +0530 Subject: [PATCH 10/18] Enable permission check according to the new permissions --- .../cdmf.page.certificate.create/create.js | 24 ++++---- .../cdmf.page.certificates/certificates.js | 15 ++--- .../app/pages/cdmf.page.policies/policies.hbs | 8 +-- .../app/pages/cdmf.page.policies/policies.js | 9 +-- .../pages/cdmf.page.user.create/create.hbs | 9 +++ .../app/pages/cdmf.page.user.create/create.js | 3 + .../app/pages/cdmf.page.user.edit/edit.hbs | 11 +++- .../app/pages/cdmf.page.user.edit/edit.js | 4 ++ .../app/pages/cdmf.page.user.view/view.hbs | 9 +++ .../app/pages/cdmf.page.user.view/view.js | 7 ++- .../app/pages/cdmf.page.users/users.hbs | 59 +++++++++++-------- .../app/pages/cdmf.page.users/users.js | 17 ++---- .../cdmf.unit.notification.listing/listing.js | 2 +- .../configuration.hbs | 9 +++ .../configuration.js | 9 ++- 15 files changed, 120 insertions(+), 75 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js index 4e7585163a2..6244fc1f099 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js @@ -19,8 +19,8 @@ /** * Returns the dynamic state to be populated by add-user page. * - * @param context Object that gets updated with the dynamic state of this page to be presented - * @returns {*} A context object that returns the dynamic state of this page to be presented + * @param viewModel Object that gets updated with the dynamic state of this page to be presented + * @returns {*} A viewModel object that returns the dynamic state of this page to be presented */ function onRequest(context) { // var log = new Log("units/user-create/create.js"); @@ -29,17 +29,17 @@ function onRequest(context) { var response = userModule.getRolesByUserStore(); if (response["status"] == "success") { - context["roles"] = response["content"]; + viewModel["roles"] = response["content"]; } - context["charLimit"] = mdmProps["usernameLength"]; - context["usernameJSRegEx"] = mdmProps["userValidationConfig"]["usernameJSRegEx"]; - context["usernameHelpText"] = mdmProps["userValidationConfig"]["usernameHelpMsg"]; - context["usernameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["usernameRegExViolationErrorMsg"]; - context["firstnameJSRegEx"] = mdmProps["userValidationConfig"]["firstnameJSRegEx"]; - context["firstnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["firstnameRegExViolationErrorMsg"]; - context["lastnameJSRegEx"] = mdmProps["userValidationConfig"]["lastnameJSRegEx"]; - context["lastnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["lastnameRegExViolationErrorMsg"]; + viewModel["charLimit"] = mdmProps["usernameLength"]; + viewModel["usernameJSRegEx"] = mdmProps["userValidationConfig"]["usernameJSRegEx"]; + viewModel["usernameHelpText"] = mdmProps["userValidationConfig"]["usernameHelpMsg"]; + viewModel["usernameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["usernameRegExViolationErrorMsg"]; + viewModel["firstnameJSRegEx"] = mdmProps["userValidationConfig"]["firstnameJSRegEx"]; + viewModel["firstnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["firstnameRegExViolationErrorMsg"]; + viewModel["lastnameJSRegEx"] = mdmProps["userValidationConfig"]["lastnameJSRegEx"]; + viewModel["lastnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["lastnameRegExViolationErrorMsg"]; - return context; + return viewModel; } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.js index 8aeb02353e3..a4be059e947 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificates/certificates.js @@ -1,15 +1,16 @@ function onRequest(context) { var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; + var viewModel = {}; - context["permissions"] = userModule.getUIPermissions(); - if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/certificate/Get")) { - context["removePermitted"] = true; + if (userModule.isAuthorized("/permission/admin/device-mgt/certificates/manage")) { + viewModel["removePermitted"] = true; } - if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/certificate/Get")) { - context["viewPermitted"] = true; + if (userModule.isAuthorized("/permission/admin/device-mgt/certificates/view")) { + viewModel["viewPermitted"] = true; } - context["adminUser"] = mdmProps.adminUser; - return context; + + viewModel.adminUser = mdmProps.adminUser; + return viewModel; } \ No newline at end of file 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 2dcfb0122e0..9a3a1137910 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 @@ -40,7 +40,7 @@ {{/zone}} {{#zone "navbarActions"}} - {{#if permissions.ADD_ADMIN_POLICY}} + {{#if managePermitted}}
  • @@ -50,8 +50,6 @@ Add Policy
  • - {{/if}} - {{#if permissions.CHANGE_POLICY_PRIORITY}} {{#equal noPolicy false}}
  • @@ -81,7 +79,7 @@