From cd8ed2d677db7581a9550d6c5e94ecb1fbbebd48 Mon Sep 17 00:00:00 2001 From: Jayasanka Weerasinghe Date: Wed, 26 Feb 2020 12:26:40 +0530 Subject: [PATCH 1/3] Add cross environment build support for react applications --- .../react-app/package.json | 5 +++-- .../react-app/package.json | 5 +++-- .../io.entgra.device.mgt.ui/react-app/package.json | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json index f0002c6fea..d39cce7d49 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json @@ -55,6 +55,7 @@ "babel-preset-stage-0": "^6.24.1", "body-parser": "^1.19.0", "chai": "^4.1.2", + "cross-env": "^7.0.0", "css-loader": "^0.28.11", "eslint": "^5.16.0", "eslint-config-prettier": "4.3.0", @@ -100,8 +101,8 @@ "watch": "webpack --watch --mode development", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", - "build_prod": "NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 webpack -p --display errors-only --hide-modules", - "build_dev": "NODE_ENV=development webpack -d --watch ", + "build_prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 webpack -p --display errors-only --hide-modules", + "build_dev": "cross-env NODE_ENV=development webpack -d --watch ", "server": "node-env-run server --exec nodemon | pino-colada", "dev2": "run-p server start", "lint": "eslint \"src/**/*.js\"" diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/package.json index db8ec651f8..56aa61b49b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/package.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/package.json @@ -44,6 +44,7 @@ "babel-loader": "^8.0.6", "body-parser": "^1.19.0", "chai": "^4.1.2", + "cross-env": "^7.0.0", "css-loader": "^0.28.11", "eslint": "^5.16.0", "eslint-config-prettier": "4.3.0", @@ -87,8 +88,8 @@ "watch": "webpack --watch --mode development", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", - "build_prod": "NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 webpack -p --display errors-only --hide-modules", - "build_dev": "NODE_ENV=development webpack -d --watch ", + "build_prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 webpack -p --display errors-only --hide-modules", + "build_dev": "cross-env NODE_ENV=development webpack -d --watch ", "server": "node-env-run server --exec nodemon | pino-colada", "dev2": "run-p server start", "lint": "eslint \"src/**/*.js\"" diff --git a/components/device-mgt/io.entgra.device.mgt.ui/react-app/package.json b/components/device-mgt/io.entgra.device.mgt.ui/react-app/package.json index f744291973..84b0d6c416 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/react-app/package.json +++ b/components/device-mgt/io.entgra.device.mgt.ui/react-app/package.json @@ -47,6 +47,7 @@ "babel-loader": "^8.0.6", "body-parser": "^1.19.0", "chai": "^4.1.2", + "cross-env": "^7.0.0", "css-loader": "^0.28.11", "eslint": "^5.16.0", "eslint-config-prettier": "4.3.0", @@ -91,8 +92,8 @@ "watch": "webpack --watch --mode development", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", - "build_prod": "NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 webpack -p --display errors-only --hide-modules", - "build_dev": "NODE_ENV=development webpack -d --watch ", + "build_prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 webpack -p --display errors-only --hide-modules", + "build_dev": "cross-env NODE_ENV=development webpack -d --watch ", "server": "node-env-run server --exec nodemon | pino-colada", "dev2": "run-p server start", "lint": "eslint \"src/**/*.js\"" From 7b010f045d155c8fd33203c71815bcdbd61d88a3 Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Wed, 26 Feb 2020 17:05:00 +0530 Subject: [PATCH 2/3] Prevent null pointer for device info --- .../core/device/details/mgt/dao/impl/DeviceDetailsDAOImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/dao/impl/DeviceDetailsDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/dao/impl/DeviceDetailsDAOImpl.java index 731c74b2e1..6404051c1c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/dao/impl/DeviceDetailsDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/device/details/mgt/dao/impl/DeviceDetailsDAOImpl.java @@ -124,7 +124,7 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO { Connection conn; PreparedStatement stmt = null; ResultSet rs = null; - DeviceInfo deviceInfo = null; + DeviceInfo deviceInfo = new DeviceInfo(); try { conn = this.getConnection(); @@ -135,7 +135,6 @@ public class DeviceDetailsDAOImpl implements DeviceDetailsDAO { rs = stmt.executeQuery(); if (rs.next()) { - deviceInfo = new DeviceInfo(); // deviceInfo.setIMEI(rs.getString("IMEI")); // deviceInfo.setIMSI(rs.getString("IMSI")); deviceInfo.setDeviceModel(rs.getString("DEVICE_MODEL")); From 6cab3293c07749e65809c0460e301f011dff996b Mon Sep 17 00:00:00 2001 From: nipunnadeen Date: Thu, 27 Feb 2020 20:25:57 +0530 Subject: [PATCH 3/3] Improve the getApplication query to check the tenant --- .../dao/impl/application/GenericApplicationDAOImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 57fdd4021a..b0d4f7f381 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -99,7 +99,6 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic log.debug("Getting application data from the database"); log.debug(String.format("Filter: limit=%s, offset=%s", filter.getLimit(), filter.getOffset())); } - int paramIndex = 1; String sql = "SELECT " + "AP_APP.ID AS APP_ID, " + "AP_APP.NAME AS APP_NAME, " @@ -132,7 +131,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic + "FROM AP_APP " + "INNER JOIN AP_APP_RELEASE ON " + "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID " - + "INNER JOIN (SELECT ID FROM AP_APP LIMIT ? OFFSET ? ) AS app_data ON app_data.ID = AP_APP.ID " + + "INNER JOIN (SELECT ID FROM AP_APP WHERE AP_APP.TENANT_ID = ? LIMIT ? OFFSET ? ) AS app_data ON app_data.ID = AP_APP.ID " + "WHERE AP_APP.TENANT_ID = ?"; if (filter == null) { @@ -183,8 +182,9 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic try { Connection conn = this.getDBConnection(); - try (PreparedStatement stmt = conn.prepareStatement(sql); - ){ + try (PreparedStatement stmt = conn.prepareStatement(sql)){ + int paramIndex = 1; + stmt.setInt(paramIndex++, tenantId); if (filter.getLimit() != -1) { if (filter.getLimit() == 0) { stmt.setInt(paramIndex++, 100);