diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml index f3a79a1d98..0f439d6f86 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.annotations - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT bundle WSO2 Carbon - API Management Annotations WSO2 Carbon - API Management Custom Annotation Module diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index b4e8b76e8f..302f5ebc58 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -21,12 +21,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 4.0.0 - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT org.wso2.carbon.apimgt.application.extension.api war WSO2 Carbon - API Application Management API diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index 400548e774..a06f469a35 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -22,12 +22,12 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 4.0.0 - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT org.wso2.carbon.apimgt.application.extension bundle WSO2 Carbon - API Application Management diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml index f51212966d..f9aa8f7ef0 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/pom.xml @@ -21,13 +21,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.handlers - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT bundle WSO2 Carbon - API Security Handler Component WSO2 Carbon - API Management Security Handler Module diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml index 79c74feb99..fa52cd729e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.client/pom.xml @@ -13,13 +13,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.client - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT bundle WSO2 Carbon - API Management Integration Client WSO2 Carbon - API Management Integration Client diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml index 6ca2b20d5e..c5684fffba 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.integration.generated.client/pom.xml @@ -13,13 +13,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.integration.generated.client - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT bundle WSO2 Carbon - API Management Integration Generated Client WSO2 Carbon - API Management Integration Client diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index 432ea5ec56..15fd610524 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -22,13 +22,13 @@ apimgt-extensions org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.apimgt.webapp.publisher - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT bundle WSO2 Carbon - API Management Webapp Publisher WSO2 Carbon - API Management Webapp Publisher diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 1a82489815..880d9504de 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../../pom.xml 4.0.0 apimgt-extensions - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT pom WSO2 Carbon - API Management Extensions Component http://wso2.org diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/pom.xml index 163fc9d04a..c7ff5220b7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.addons/pom.xml @@ -5,15 +5,16 @@ application-mgt org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT + ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.addons - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT WSO2 Carbon - Application Management Add-Ons WSO2 Carbon - Application Management Add-Ons - http://wso2.org + https://entgra.io diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml index 14d1366133..6c1d182b85 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml @@ -22,17 +22,17 @@ application-mgt org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.api - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT war WSO2 Carbon - Application Management API WSO2 Carbon - Application Management API - http://wso2.org + https://entgra.io diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml index 6699a9b31e..343fd8674c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml @@ -21,17 +21,17 @@ org.wso2.carbon.devicemgt application-mgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.common - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT bundle WSO2 Carbon - Application Management Common WSO2 Carbon - Application Management Common - http://wso2.org + https://entgra.io diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml index ebd105472c..7f0d979cc5 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml @@ -21,17 +21,17 @@ org.wso2.carbon.devicemgt application-mgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.core - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT bundle WSO2 Carbon - Application Management Core WSO2 Carbon - Application Management Core - http://wso2.org + https://entgra.io 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/OracleApplicationDAOImpl.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/OracleApplicationDAOImpl.java index f78caaf7d3..1ed3ae0ec5 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/OracleApplicationDAOImpl.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/OracleApplicationDAOImpl.java @@ -135,12 +135,12 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql); ){ if (filter.getLimit() != -1) { + stmt.setInt(paramIndex++, filter.getOffset()); if (filter.getLimit() == 0) { stmt.setInt(paramIndex++, 100); } else { stmt.setInt(paramIndex++, filter.getLimit()); } - stmt.setInt(paramIndex++, filter.getOffset()); } stmt.setInt(paramIndex++, tenantId); 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/SQLServerApplicationDAOImpl.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/SQLServerApplicationDAOImpl.java index 8cfe1ea71f..6ed7ca72ce 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/SQLServerApplicationDAOImpl.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/SQLServerApplicationDAOImpl.java @@ -133,12 +133,12 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql); ){ if (filter.getLimit() != -1) { + stmt.setInt(paramIndex++, filter.getOffset()); if (filter.getLimit() == 0) { stmt.setInt(paramIndex++, 100); } else { stmt.setInt(paramIndex++, filter.getLimit()); } - stmt.setInt(paramIndex++, filter.getOffset()); } stmt.setInt(paramIndex++, tenantId); 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/review/OracleReviewDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/OracleReviewDAOImpl.java index b05391d306..f24aac96ca 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/OracleReviewDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/OracleReviewDAOImpl.java @@ -70,8 +70,8 @@ public class OracleReviewDAOImpl extends GenericReviewDAOImpl { statement.setInt(1, releaseId); statement.setInt(2, Constants.REVIEW_PARENT_ID); statement.setInt(3, tenantId); - statement.setInt(4, request.getLimit()); - statement.setInt(5, request.getOffSet()); + statement.setInt(4, request.getOffSet()); + statement.setInt(5, request.getLimit()); try (ResultSet rs = statement.executeQuery()) { return DAOUtil.loadReviews(rs); } @@ -124,8 +124,8 @@ public class OracleReviewDAOImpl extends GenericReviewDAOImpl { } ps.setInt(index++, Constants.REVIEW_PARENT_ID); ps.setInt(index++, tenantId); - ps.setInt(index++, request.getLimit()); - ps.setInt(index, request.getOffSet()); + ps.setInt(index++, request.getOffSet()); + ps.setInt(index, request.getLimit()); try (ResultSet rs = ps.executeQuery()) { return DAOUtil.loadReviews(rs); } @@ -180,8 +180,8 @@ public class OracleReviewDAOImpl extends GenericReviewDAOImpl { ps.setInt(index++, Constants.REVIEW_PARENT_ID); ps.setString(index++, username); ps.setInt(index++, tenantId); - ps.setInt(index++, request.getLimit()); - ps.setInt(index, request.getOffSet()); + ps.setInt(index++, request.getOffSet()); + ps.setInt(index, request.getLimit()); try (ResultSet rs = ps.executeQuery()) { return DAOUtil.loadReviews(rs); } 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/review/SQLServerReviewDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/SQLServerReviewDAOImpl.java index 91182b9e28..ccad696597 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/SQLServerReviewDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/SQLServerReviewDAOImpl.java @@ -70,8 +70,8 @@ public class SQLServerReviewDAOImpl extends GenericReviewDAOImpl { statement.setInt(1, releaseId); statement.setInt(2, Constants.REVIEW_PARENT_ID); statement.setInt(3, tenantId); - statement.setInt(4, request.getLimit()); - statement.setInt(5, request.getOffSet()); + statement.setInt(4, request.getOffSet()); + statement.setInt(5, request.getLimit()); try (ResultSet rs = statement.executeQuery()) { return DAOUtil.loadReviews(rs); } @@ -124,8 +124,8 @@ public class SQLServerReviewDAOImpl extends GenericReviewDAOImpl { } ps.setInt(index++, Constants.REVIEW_PARENT_ID); ps.setInt(index++, tenantId); - ps.setInt(index++, request.getLimit()); - ps.setInt(index, request.getOffSet()); + ps.setInt(index++, request.getOffSet()); + ps.setInt(index, request.getLimit()); try (ResultSet rs = ps.executeQuery()) { return DAOUtil.loadReviews(rs); } @@ -180,8 +180,8 @@ public class SQLServerReviewDAOImpl extends GenericReviewDAOImpl { ps.setInt(index++, Constants.REVIEW_PARENT_ID); ps.setString(index++, username); ps.setInt(index++, tenantId); - ps.setInt(index++, request.getLimit()); - ps.setInt(index, request.getOffSet()); + ps.setInt(index++, request.getOffSet()); + ps.setInt(index, request.getLimit()); try (ResultSet rs = ps.executeQuery()) { return DAOUtil.loadReviews(rs); } 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/subscription/OracleSubscriptionDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java index ffda6ed4c8..439fdbf117 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/OracleSubscriptionDAOImpl.java @@ -55,8 +55,8 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setInt(1, appReleaseId); stmt.setInt(2, tenantId); - stmt.setInt(3, limitValue); - stmt.setInt(4, offsetValue); + stmt.setInt(3, offsetValue); + stmt.setInt(4, limitValue); try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { subscribedUsers.add(rs.getString("USER")); @@ -95,8 +95,8 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setInt(2, tenantId); - ps.setInt(3, limitValue); - ps.setInt(4, offsetValue); + ps.setInt(3, offsetValue); + ps.setInt(4, limitValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedRoles.add(rs.getString("ROLE")); @@ -135,8 +135,8 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setInt(2, tenantId); - ps.setInt(3, limitValue); - ps.setInt(4, offsetValue); + ps.setInt(3, offsetValue); + ps.setInt(4, limitValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedGroups.add(rs.getString("GROUPS")); 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/subscription/SQLServerSubscriptionDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java index eefa4832ea..b3a93749e6 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/SQLServerSubscriptionDAOImpl.java @@ -55,8 +55,8 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setInt(1, appReleaseId); stmt.setInt(2, tenantId); - stmt.setInt(3, limitValue); - stmt.setInt(4, offsetValue); + stmt.setInt(3, offsetValue); + stmt.setInt(4, limitValue); try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { subscribedUsers.add(rs.getString("USER")); @@ -95,8 +95,8 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setInt(2, tenantId); - ps.setInt(3, limitValue); - ps.setInt(4, offsetValue); + ps.setInt(3, offsetValue); + ps.setInt(4, limitValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedRoles.add(rs.getString("ROLE")); @@ -135,8 +135,8 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setInt(2, tenantId); - ps.setInt(3, limitValue); - ps.setInt(4, offsetValue); + ps.setInt(3, offsetValue); + ps.setInt(4, limitValue); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedGroups.add(rs.getString("GROUPS")); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/pom.xml index eda02c7b01..9ae4dabaee 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/pom.xml @@ -22,17 +22,17 @@ application-mgt org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.publisher.api - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT war WSO2 Carbon - Application Management Publisher API WSO2 Carbon - Application Management Publisher API - http://wso2.org + https://entgra.io diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml index 1bd68c685b..c45caef1b7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/pom.xml @@ -24,13 +24,13 @@ org.wso2.carbon.devicemgt application-mgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT org.wso2.carbon.device.application.mgt.publisher.ui - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT war WSO2 Carbon - Application Management Publisher UI Component - http://wso2.org + https://entgra.io This Component contains Application Management publisher UI diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml index f0e215f944..10ca156419 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.api/pom.xml @@ -22,17 +22,17 @@ application-mgt org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.store.api - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT war WSO2 Carbon - Application Management Store API WSO2 Carbon - Application Management Store API - http://wso2.org + https://entgra.io diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml index 7bac04a171..167424442f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/pom.xml @@ -24,13 +24,13 @@ org.wso2.carbon.devicemgt application-mgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT org.wso2.carbon.device.application.mgt.store.ui - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT war WSO2 Carbon - Application Management Store UI Component - http://wso2.org + https://entgra.io This Component contains Application Management store UI diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 397dfb91f8..3c5e9b7878 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../../pom.xml 4.0.0 application-mgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT pom WSO2 Carbon - Application Management Component WSO2 Carbon - Application Management Component diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml index cc7194d28b..9a6d5649b4 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml index fc6cdb7064..d5aa3bb2c4 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index 2cc1097fa0..02c2d524e8 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -21,13 +21,13 @@ org.wso2.carbon.devicemgt certificate-mgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.certificate.mgt.core - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT bundle WSO2 Carbon - Certificate Management Core WSO2 Carbon - Certificate Management Core diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index 59e3242fb1..309d050b5c 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../../pom.xml 4.0.0 org.wso2.carbon.devicemgt certificate-mgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT pom WSO2 Carbon - Certificate Management Component http://wso2.org diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml index e552c57c59..81ca1d3706 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml index b297b30933..1b90595400 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml index d9d8745b09..f6cda97954 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml index 4213761388..f02d752383 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 5c686d6420..513f3e5b15 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index d5c1bb117c..de0fcbd4a0 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 69999e3b67..aff9b7d395 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml index 3186aa53f1..440d81856b 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/io.entgra.device.mgt.ui/pom.xml b/components/device-mgt/io.entgra.device.mgt.ui/pom.xml index d2087ab084..ed57f98019 100644 --- a/components/device-mgt/io.entgra.device.mgt.ui/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.ui/pom.xml @@ -24,10 +24,10 @@ org.wso2.carbon.devicemgt device-mgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT io.entgra.device.mgt.ui - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT war Entgra - Device Management UI Component https://entgra.io diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml index 4f095ccb11..ae9a4b03d0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml index ed2e6719de..180a359138 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.wsproxy/pom.xml @@ -20,7 +20,7 @@ device-mgt org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT 4.0.0 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index f349b331ab..e79b5f6bd3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/Adapter.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/Adapter.java index f3d3bcb639..f11c65efcc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/Adapter.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/Adapter.java @@ -29,10 +29,13 @@ public class Adapter { @ApiModelProperty(value = "Attached stream name:version") private String eventStreamWithVersion; @ApiModelProperty(value = "Adapter type") - private AdapterType adapterType; + private TransportType adapterType; @ApiModelProperty(value = "Adapter main configurations") private AdapterConfiguration adapterConfiguration; + @ApiModelProperty(value = "Adapter definition", notes = "use only when creating adapter as a String") + private String definition; + public String getAdapterName() { return adapterName; } @@ -49,11 +52,11 @@ public class Adapter { this.eventStreamWithVersion = eventStreamWithVersion; } - public AdapterType getAdapterType() { + public TransportType getAdapterType() { return adapterType; } - public void setAdapterType(AdapterType adapterType) { + public void setAdapterType(TransportType adapterType) { this.adapterType = adapterType; } @@ -65,4 +68,12 @@ public class Adapter { AdapterConfiguration adapterConfiguration) { this.adapterConfiguration = adapterConfiguration; } + + public String getDefinition() { + return definition; + } + + public void setDefinition(String definition) { + this.definition = definition; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AdapterMappingConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AdapterMappingConfiguration.java index 3984b23065..a9894f459e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AdapterMappingConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AdapterMappingConfiguration.java @@ -18,6 +18,8 @@ package org.wso2.carbon.device.mgt.jaxrs.beans.analytics; import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; import java.util.List; /** @@ -30,15 +32,15 @@ public class AdapterMappingConfiguration { @ApiModelProperty(value = "Input mapping for json,text and xml mappings") private String inputMappingString; @ApiModelProperty(value = "Input mapping for json,map and xml mappings") - private List inputMappingProperties; + private List inputMappingProperties = new ArrayList<>(); @ApiModelProperty(value = "Name-scape mapping for xml mapping") - private List namespaceMappingProperties; + private List namespaceMappingProperties = new ArrayList<>(); @ApiModelProperty(value = "Correlation mapping for wso2 mapping") - private List correlationMappingProperties; + private List correlationMappingProperties = new ArrayList<>(); @ApiModelProperty(value = "Payload mapping for wso2 mapping") - private List payloadMappingProperties; + private List payloadMappingProperties = new ArrayList<>(); @ApiModelProperty(value = "Meta mapping for wso2 mapping") - private List metaMappingProperties; + private List metaMappingProperties = new ArrayList<>(); public MessageFormat getMessageFormat() { return messageFormat; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AdapterType.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AdapterType.java deleted file mode 100644 index 413be9fd90..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AdapterType.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.wso2.carbon.device.mgt.jaxrs.beans.analytics; - -/** - * Available adapter types - */ -public enum AdapterType { - EMAIL, FILE_TAIL, HTTP, IOT_EVENT, JMS, KAFKA, MQTT, OAUTH_MQTT, SOAP, WEBSOCKET, WEBSOCKET_LOCAL, - WSO2_EVENT, XMPP, UI, RDBMS, SECURED_WEBSOCKET, CASSANDRA, LOGGER; - - public String toStringFormatted() { - return super.toString().toLowerCase().replace("_", "-"); - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AttributeType.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AttributeType.java index 32302986e7..131904671a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AttributeType.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/AttributeType.java @@ -28,4 +28,4 @@ public enum AttributeType { public String toString() { return super.toString().toLowerCase(); } -} \ No newline at end of file +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/EventPublisher.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/EventPublisher.java deleted file mode 100644 index a7e7a1f84b..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/EventPublisher.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.jaxrs.beans.analytics; - -import io.swagger.annotations.ApiModelProperty; - -public class EventPublisher { - @ApiModelProperty(value = "Publisher definition") - private String definition; - - public String getDefinition() { - return definition; - } - - public void setDefinition(String definition) { - this.definition = definition; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/EventReceiver.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/EventReceiver.java deleted file mode 100755 index dd0c00f8db..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/EventReceiver.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.wso2.carbon.device.mgt.jaxrs.beans.analytics; - -import io.swagger.annotations.ApiModelProperty; - -public class EventReceiver { - @ApiModelProperty(value = "Stream definition") - private String definition; - - public String getDefinition() { - return definition; - } - - public void setDefinition(String definition) { - this.definition = definition; - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/EventStream.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/EventStream.java index 17100e75f2..ed166446f3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/EventStream.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/EventStream.java @@ -17,10 +17,9 @@ */ package org.wso2.carbon.device.mgt.jaxrs.beans.analytics; -import com.sun.istack.NotNull; import io.swagger.annotations.ApiModelProperty; -import org.hibernate.validator.constraints.NotEmpty; +import java.util.ArrayList; import java.util.List; /** @@ -37,12 +36,13 @@ public class EventStream { @ApiModelProperty(value = "Stream description") private String description; @ApiModelProperty(value = "Meta attribute list") - private List metaData; + private List metaData = new ArrayList<>(); @ApiModelProperty(value = "Correlation attribute list") - private List correlationData; + private List correlationData = new ArrayList<>(); @ApiModelProperty(value = "Payload attribute list") - private List payloadData; - @ApiModelProperty(value = "Stream definition") @NotNull @NotEmpty + private List payloadData = new ArrayList<>(); + + @ApiModelProperty(value = "Stream definition" , notes = "use only when creating stream as a String") private String definition; public String getName() { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/TransportType.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/TransportType.java index abf6122459..bf53512b41 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/TransportType.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/TransportType.java @@ -21,6 +21,11 @@ package org.wso2.carbon.device.mgt.jaxrs.beans.analytics; * This hold the default transport types support by the server. */ public enum TransportType { - HTTP, MQTT; + EMAIL, FILE_TAIL, HTTP, IOT_EVENT, JMS, KAFKA, MQTT, OAUTH_MQTT, SOAP, WEBSOCKET, WEBSOCKET_LOCAL, + WSO2_EVENT, XMPP, UI, RDBMS, SECURED_WEBSOCKET, CASSANDRA, LOGGER; + + public String toStringFormatted() { + return super.toString().toLowerCase().replace("_", "-"); + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/exception/InvalidExecutionPlanException.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/exception/InvalidExecutionPlanException.java index c366b37ef4..cc094d3b77 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/exception/InvalidExecutionPlanException.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/exception/InvalidExecutionPlanException.java @@ -28,11 +28,11 @@ public class InvalidExecutionPlanException extends WebApplicationException { private static final long serialVersionUID = 7583096344745990515L; public InvalidExecutionPlanException(ErrorResponse error) { - super(Response.status(Response.Status.NOT_FOUND).entity(error).build()); + super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build()); } public InvalidExecutionPlanException(ErrorDTO errorDTO) { - super(Response.status(Response.Status.NOT_FOUND) + super(Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity(errorDTO) .header(Constants.DeviceConstants.HEADER_CONTENT_TYPE, Constants.DeviceConstants.APPLICATION_JSON) .build()); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/AnalyticsArtifactsManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/AnalyticsArtifactsManagementService.java index 260ec66a11..7e5456dadd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/AnalyticsArtifactsManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/AnalyticsArtifactsManagementService.java @@ -17,14 +17,13 @@ */ package org.wso2.carbon.device.mgt.jaxrs.service.api; +import io.swagger.annotations.ApiParam; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.Adapter; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventStream; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.SiddhiExecutionPlan; -import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventPublisher; -import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventReceiver; import org.wso2.carbon.device.mgt.jaxrs.util.Constants; import io.swagger.annotations.Api; @@ -91,17 +90,17 @@ import javax.ws.rs.core.Response; } ) -@Path("/analytics/artifacts") @Api(value = "Analytics Artifacts Management", description = "This API corresponds to services" + " related to Analytics Artifacts management") +@Path("/analytics/artifacts") +@Consumes(MediaType.APPLICATION_JSON) public interface AnalyticsArtifactsManagementService { @POST - @Consumes(MediaType.APPLICATION_JSON) @Path("/stream/{id}") @ApiOperation( httpMethod = "POST", - value = "Create Event Stream Artifact as String", + value = "Create Event Stream Artifact through a String argument.", notes = "Deploy a Json Stream Artifact in Analytics server.", tags = "Analytics Artifacts Management", extensions = { @@ -143,16 +142,20 @@ public interface AnalyticsArtifactsManagementService { response = ErrorResponse.class) } ) - Response deployEventDefinitionAsString(@PathParam("id") String id, - @QueryParam("isEdited") boolean isEdited, - @Valid EventStream stream); + Response deployEventDefinitionAsString( + @ApiParam(name = "id", value = "Stream id(name:version).") + @PathParam("id") String id, + @ApiParam(name = "isEdited", value = "This stream is being edited or created.") + @QueryParam("isEdited") boolean isEdited, + @ApiParam(name = "stream", value = "Add the data to complete the EventStream object.", + required = true) + @Valid EventStream stream); @POST - @Consumes(MediaType.APPLICATION_JSON) @Path("/stream") @ApiOperation( httpMethod = "POST", - value = "Create Event Stream Artifact as DTO", + value = "Create Event Stream Artifact through a DTO class.", notes = "Deploy a Json Stream Artifact in Analytics server.", tags = "Analytics Artifacts Management", extensions = { @@ -194,14 +197,16 @@ public interface AnalyticsArtifactsManagementService { response = ErrorResponse.class) } ) - Response deployEventDefinitionAsDto(@Valid EventStream stream); + Response deployEventDefinitionAsDto( + @ApiParam(name = "stream", value = "Add the data to complete the EventStream object.", + required = true) + @Valid EventStream stream); @POST - @Consumes(MediaType.APPLICATION_JSON) @Path("/receiver/{name}") @ApiOperation( httpMethod = "POST", - value = "Create Event Receiver Artifact as String", + value = "Create Event Receiver Artifact through a String argument.", notes = "Deploy a XML Event Receiver Artifact in Analytics server.", tags = "Analytics Artifacts Management", extensions = { @@ -244,16 +249,20 @@ public interface AnalyticsArtifactsManagementService { response = ErrorResponse.class) } ) - Response deployEventReceiverAsString(@PathParam("name") String name, - @QueryParam("isEdited") boolean isEdited, - @Valid EventReceiver receiver); + Response deployEventReceiverAsString( + @ApiParam(name = "name", value = "Receiver name.") + @PathParam("name") String name, + @ApiParam(name = "isEdited", value = "This stream is being edited or created.") + @QueryParam("isEdited") boolean isEdited, + @ApiParam(name = "receiver", value = "Add the data to complete the EventReceiver object.", + required = true) + @Valid Adapter receiver); @POST - @Consumes(MediaType.APPLICATION_JSON) @Path("/receiver") @ApiOperation( httpMethod = "POST", - value = "Create Event Receiver Artifact as DTO", + value = "Create Event Receiver Artifact through a DTO class.", notes = "Deploy a JSON Event Receiver Artifact in Analytics server.", tags = "Analytics Artifacts Management", extensions = { @@ -296,14 +305,16 @@ public interface AnalyticsArtifactsManagementService { response = ErrorResponse.class) } ) - Response deployEventReceiverAsDto(@Valid Adapter receiver); + Response deployEventReceiverAsDto( + @ApiParam(name = "receiver", value = "Add the data to complete the Adapter object.", + required = true) + @Valid Adapter receiver); @POST - @Consumes(MediaType.APPLICATION_JSON) @Path("/publisher/{name}") @ApiOperation( httpMethod = "POST", - value = "Create Event Publisher Artifact as String", + value = "Create Event Publisher Artifact through a String argument.", notes = "Deploy a XML Event Publisher Artifact in Analytics server.", tags = "Analytics Artifacts Management", extensions = { @@ -346,16 +357,20 @@ public interface AnalyticsArtifactsManagementService { response = ErrorResponse.class) } ) - Response deployEventPublisherAsString(@PathParam("name") String name, - @QueryParam("isEdited") boolean isEdited, - @Valid EventPublisher publisher); + Response deployEventPublisherAsString( + @ApiParam(name = "name", value = "Publisher name.") + @PathParam("name") String name, + @ApiParam(name = "isEdited", value = "This stream is being edited or created.") + @QueryParam("isEdited") boolean isEdited, + @ApiParam(name = "publisher", value = "Add the data to complete the EventPublisher object.", + required = true) + @Valid Adapter publisher); @POST - @Consumes(MediaType.APPLICATION_JSON) @Path("/publisher") @ApiOperation( httpMethod = "POST", - value = "Create Event Publisher Artifact as DTO", + value = "Create Event Publisher Artifact through a DTO class.", notes = "Deploy a JSON Event Publisher Artifact in Analytics server.", tags = "Analytics Artifacts Management", extensions = { @@ -398,15 +413,17 @@ public interface AnalyticsArtifactsManagementService { response = ErrorResponse.class) } ) - Response deployEventPublisherAsDto(@Valid Adapter publisher); + Response deployEventPublisherAsDto( + @ApiParam(name = "publisher", value = "Add the data to complete the Adapter object.", + required = true) + @Valid Adapter publisher); @POST - @Consumes(MediaType.APPLICATION_JSON) @Path("/siddhi-script/{name}") @ApiOperation( httpMethod = "POST", - value = "Create Siddhi Script Artifact as String", - notes = "Deploy a SiddhiQL Siddhi script Artifact in Analytics server.", + value = "Create Siddhi Script Artifact through a String argument.", + notes = "Deploy a SiddhiQL script Artifact in Analytics server.", tags = "Analytics Artifacts Management", extensions = { @Extension(properties = { @@ -449,6 +466,11 @@ public interface AnalyticsArtifactsManagementService { } ) Response deploySiddhiExecutableScript( - @PathParam("name") String name, @QueryParam("isEdited") boolean isEdited, + @ApiParam(name = "name", value = "Siddhi Executable Script name.") + @PathParam("name") String name, + @ApiParam(name = "isEdited", value = "This stream is being edited or created.") + @QueryParam("isEdited") boolean isEdited, + @ApiParam(name = "plan", value = "Add the data to complete the SiddhiExecutionPlan object.", + required = true) @Valid SiddhiExecutionPlan plan); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java index 21583f0f28..5c4f686254 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/AnalyticsArtifactsManagementServiceImpl.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.Attribute; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AdapterMappingConfiguration; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.MappingProperty; @@ -25,8 +26,7 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AdapterConfiguration; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AdapterProperty; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.MessageFormat; import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.SiddhiExecutionPlan; -import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventPublisher; -import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventReceiver; +import org.wso2.carbon.device.mgt.jaxrs.exception.BadRequestException; import org.wso2.carbon.device.mgt.jaxrs.exception.ErrorDTO; import org.wso2.carbon.device.mgt.jaxrs.exception.InvalidExecutionPlanException; import org.wso2.carbon.device.mgt.jaxrs.service.api.AnalyticsArtifactsManagementService; @@ -58,7 +58,6 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; -import java.nio.charset.StandardCharsets; import java.rmi.RemoteException; import java.util.List; @@ -67,14 +66,10 @@ import java.util.List; * siddhi scripts to the Analytics server as Artifacts */ @Path("/analytics/artifacts") -public class AnalyticsArtifactsManagementServiceImpl implements AnalyticsArtifactsManagementService { +public class AnalyticsArtifactsManagementServiceImpl + implements AnalyticsArtifactsManagementService { private static final Log log = LogFactory.getLog(AnalyticsArtifactsManagementServiceImpl.class); - /** - * @param stream EventStream object with the properties of the stream - * @return A status code depending on the code result - * Function - Used to deploy stream as an artifact using a String - */ @Override @POST @Path("/stream/{id}") @@ -84,90 +79,70 @@ public class AnalyticsArtifactsManagementServiceImpl implements AnalyticsArtifac String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); EventStreamAdminServiceStub eventStreamAdminServiceStub = null; try { - String streamDefinition = new String(stream.getDefinition().getBytes(), StandardCharsets.UTF_8); + String streamDefinition = stream.getDefinition(); eventStreamAdminServiceStub = DeviceMgtAPIUtils.getEventStreamAdminServiceStub(); if (!isEdited) { eventStreamAdminServiceStub.addEventStreamDefinitionAsString(streamDefinition); } else { - // Find and edit stream if (eventStreamAdminServiceStub.getStreamDetailsForStreamId(id) != null) { eventStreamAdminServiceStub.editEventStreamDefinitionAsString(streamDefinition, id); } } return Response.ok().build(); } catch (AxisFault e) { - log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (RemoteException e) { - log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the remote services for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (JWTClientException e) { - log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to generate jwt token for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (UserStoreException e) { - log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the user store for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } finally { cleanup(eventStreamAdminServiceStub); } } - /** - * @param stream EventStream object with the properties of the stream - * @return A status code depending on the code result - * Function - Used to deploy stream as an artifact using a DTO - */ @Override @POST @Path("/stream") public Response deployEventDefinitionAsDto(@Valid EventStream stream) { String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - // Categorize attributes to three lists depending on their type - List metaData = stream.getMetaData(); - List payloadData = stream.getPayloadData(); - List correlationData = stream.getCorrelationData(); - try { - /* Conditions - * - At least one list should always be not null - */ - if (metaData == null && correlationData == null && payloadData == null) { - log.error("Invalid payload: event attributes"); - return Response.status(Response.Status.BAD_REQUEST).build(); - - } else { - // Publish the event stream - publishStream(stream, metaData, correlationData, payloadData); - return Response.ok().build(); - } + deployStream(stream); + return Response.ok().build(); } catch (AxisFault e) { - log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to create event definitions for tenant " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (RemoteException e) { - log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the remote services for tenant " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (JWTClientException e) { - log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to generate jwt token for tenant " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (UserStoreException e) { - log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the user store for tenant " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } } - /** - * @param name Receiver name - * @param isEdited If receiver is created or edited - * @param receiver Receiver object with the properties of the receiver - * @return A status code depending on the code result - * Function - Used to deploy receiver as an artifact using a String - */ @Override @POST @Path("/receiver/{name}") public Response deployEventReceiverAsString(@PathParam("name") String name, @QueryParam("isEdited") boolean isEdited, - @Valid EventReceiver receiver) { + @Valid Adapter receiver) { String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); EventReceiverAdminServiceStub eventReceiverAdminServiceStub; try { @@ -178,202 +153,128 @@ public class AnalyticsArtifactsManagementServiceImpl implements AnalyticsArtifac } else { eventReceiverAdminServiceStub.editActiveEventReceiverConfiguration(receiverDefinition, name); } + return Response.ok().build(); } catch (AxisFault e) { - log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (RemoteException e) { - log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the remote services for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (JWTClientException e) { - log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to generate jwt token for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (UserStoreException e) { - log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the user store for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } - return Response.ok().entity(name).build(); } - /** - * @param receiver Receiver object with the properties of the receiver - * @return A status code depending on the code result - * Function - Used to deploy receiver as an artifact using a DTO - */ @Override @POST @Path("/receiver") public Response deployEventReceiverAsDto(@Valid Adapter receiver) { String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String receiverName = receiver.getAdapterName(); - String adapterType = receiver.getAdapterType().toStringFormatted(); - AdapterConfiguration adapterConfiguration = receiver.getAdapterConfiguration(); - AdapterMappingConfiguration adapterMappingConfiguration = adapterConfiguration.getAdapterMappingConfiguration(); - try { - List adapterProperties = adapterConfiguration.getAdapterProperties(); - if (adapterProperties == null) { - log.error("Invalid attribute payload"); - return Response.status(Response.Status.BAD_REQUEST).build(); - } - + AdapterConfiguration adapterConfiguration = receiver.getAdapterConfiguration(); boolean customMapping = adapterConfiguration.isCustomMappingEnabled(); - List inputMappingProperties = adapterMappingConfiguration.getInputMappingProperties(); - List namespaceMappingProperties = adapterMappingConfiguration.getNamespaceMappingProperties(); - List correlationMappingProperties = adapterMappingConfiguration.getCorrelationMappingProperties(); - List payloadMappingProperties = adapterMappingConfiguration.getPayloadMappingProperties(); - List metaMappingProperties = adapterMappingConfiguration.getMetaMappingProperties(); - MessageFormat messageFormat = adapterMappingConfiguration.getMessageFormat(); - /* - * Conditions - * - if CustomMappingEnabled check validity of property lists - * - if both inputMappingProperties and namespaceMappingProperties null check remaining property lists - * - if all correlationMappingProperties, payloadMappingProperties, metaMappingProperties null log error - * - if message format is null change the final result to TRUE - * - else continue - * */ - if ((customMapping && - (inputMappingProperties == null && namespaceMappingProperties == null) && - (correlationMappingProperties == null && payloadMappingProperties == null && - metaMappingProperties == null)) || messageFormat == null) { - String errMsg = "Invalid mapping payload"; - log.error(errMsg); - return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build(); + validateAdapterProperties(adapterConfiguration.getAdapterProperties()); + if (customMapping) { + validateAdapterMapping(adapterConfiguration.getAdapterMappingConfiguration()); } - String eventStreamWithVersion = receiver.getEventStreamWithVersion(); - - publishReceiver(receiverName, adapterType, adapterProperties, customMapping, inputMappingProperties, - namespaceMappingProperties, correlationMappingProperties, payloadMappingProperties, - metaMappingProperties, messageFormat, eventStreamWithVersion); + deployReceiver(receiver, customMapping, adapterConfiguration); return Response.ok().build(); } catch (AxisFault e) { - log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (RemoteException e) { - log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the remote services for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (JWTClientException e) { - log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to generate jwt token for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (UserStoreException e) { - log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the user store for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } } - /** - * @param name Publisher name - * @param isEdited If receiver is created or edited - * @param publisher Publisher object with the properties of the publisher - * @return A status code depending on the code result - * Function - Used to deploy publisher as an artifact using a String - */ @Override @POST @Path("/publisher/{name}") public Response deployEventPublisherAsString(@PathParam("name") String name, @QueryParam("isEdited") boolean isEdited, - @Valid EventPublisher publisher) { + @Valid Adapter publisher) { String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); EventPublisherAdminServiceStub eventPublisherAdminServiceStub; - try { String publisherDefinition = publisher.getDefinition(); - eventPublisherAdminServiceStub = DeviceMgtAPIUtils.getEventPublisherAdminServiceStub(); if (!isEdited) { eventPublisherAdminServiceStub.deployEventPublisherConfiguration(publisherDefinition); } else { eventPublisherAdminServiceStub.editActiveEventPublisherConfiguration(publisherDefinition, name); } + return Response.ok().build(); } catch (AxisFault e) { - log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (RemoteException e) { - log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the remote services for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (JWTClientException e) { - log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to generate jwt token for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (UserStoreException e) { - log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the user store for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } - return Response.ok().entity(publisher).build(); } - /** - * @param publisher Publisher object with the properties of the publisher - * @return A status code depending on the code result - * Function - Used to deploy publisher as an artifact using a DTO - */ @Override @POST @Path("/publisher") public Response deployEventPublisherAsDto(@Valid Adapter publisher) { String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - String publisherName = publisher.getAdapterName(); - String adapterType = publisher.getAdapterType().toStringFormatted(); AdapterConfiguration adapterConfiguration = publisher.getAdapterConfiguration(); - AdapterMappingConfiguration adapterMappingConfiguration = adapterConfiguration.getAdapterMappingConfiguration(); - try { - List adapterProperties = adapterConfiguration.getAdapterProperties(); - if (adapterProperties == null) { - log.error("Invalid attribute payload"); - return Response.status(Response.Status.BAD_REQUEST).build(); - } - + validateAdapterProperties(adapterConfiguration.getAdapterProperties()); boolean customMapping = adapterConfiguration.isCustomMappingEnabled(); - String inputMappingString = adapterMappingConfiguration.getInputMappingString(); - List inputMappingProperties = adapterMappingConfiguration.getInputMappingProperties(); - List correlationMappingProperties = adapterMappingConfiguration.getCorrelationMappingProperties(); - List payloadMappingProperties = adapterMappingConfiguration.getPayloadMappingProperties(); - List metaMappingProperties = adapterMappingConfiguration.getMetaMappingProperties(); - MessageFormat messageFormat = adapterMappingConfiguration.getMessageFormat(); - /* - * Conditions - * - if CustomMappingEnabled check validity of property lists - * - if all correlationMappingProperties, payloadMappingProperties, metaMappingProperties null log error - * - if message format is null change the final result to TRUE - * - else continue - */ - if ((customMapping && - (inputMappingProperties == null && inputMappingString == null) && - (correlationMappingProperties == null && payloadMappingProperties == null && - metaMappingProperties == null)) || messageFormat == null) { - String errMsg = "Invalid mapping payload"; - log.error(errMsg); - return Response.status(Response.Status.BAD_REQUEST).entity(errMsg).build(); + if (customMapping) { + validateAdapterMapping(adapterConfiguration.getAdapterMappingConfiguration()); } - String eventStreamWithVersion = publisher.getEventStreamWithVersion(); - - publishPublisher(publisherName, adapterType, adapterProperties, customMapping - , inputMappingString, inputMappingProperties, correlationMappingProperties - , payloadMappingProperties, metaMappingProperties, messageFormat - , eventStreamWithVersion); + deployPublisher(publisher, customMapping, adapterConfiguration); return Response.ok().build(); } catch (AxisFault e) { - log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (RemoteException e) { - log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the remote services for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (JWTClientException e) { - log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to generate jwt token for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (UserStoreException e) { - log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the user store for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } } - /** - * @param name Siddhi plan name - * @param isEdited If receiver is created or edited - * @param plan Siddhi plan definition - * @return a status code depending on the code execution - * Function - Used to deploy Siddhi script as an artifact using a String - */ @Override @POST @Path("/siddhi-script/{name}") @@ -385,38 +286,46 @@ public class AnalyticsArtifactsManagementServiceImpl implements AnalyticsArtifac publishSiddhiExecutionPlan(name, isEdited, plan.getDefinition()); return Response.ok().build(); } catch (AxisFault e) { - log.error("Failed to create event definitions for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to create event definitions for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (RemoteException e) { - log.error("Failed to connect with the remote services for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } catch (InvalidExecutionPlanException e) { - log.error("Invalid Execution plan: " + tenantDomain, e); - return e.getResponse(); + String errMsg = "Failed to connect with the remote services for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (JWTClientException e) { - log.error("Failed to generate jwt token for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to generate jwt token for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } catch (UserStoreException e) { - log.error("Failed to connect with the user store for tenantDomain: " + tenantDomain, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + String errMsg = "Failed to connect with the user store for tenantDomain: " + tenantDomain; + log.error(errMsg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).build(); } } /** - * @param stream Stream definition - * @param metaData Meta attributes of the stream - * @param correlationData Correlation attributes of the stream - * @param payloadData Payload attributes of the stream - * @throws RemoteException exception that may occur during a remote method call - * @throws UserStoreException exception that may occur during JWT token generation - * @throws JWTClientException exception that may occur during connecting to client store + * Set data to a Stream dto and deploy dto through a stub + * + * @param stream Stream definition */ - private void publishStream(EventStream stream, List metaData, - List correlationData, List payloadData) + private void deployStream(EventStream stream) throws RemoteException, UserStoreException, JWTClientException { - EventStreamAdminServiceStub eventStreamAdminServiceStub = - DeviceMgtAPIUtils.getEventStreamAdminServiceStub(); + EventStreamAdminServiceStub eventStreamAdminServiceStub = null; + List metaData = stream.getMetaData(); + List payloadData = stream.getPayloadData(); + List correlationData = stream.getCorrelationData(); + if (metaData.isEmpty() && correlationData.isEmpty() && payloadData.isEmpty()) { + String errMsg = String.format("Failed to validate Stream property attributes of %s:%s", + stream.getName(), stream.getVersion()); + ErrorResponse errorResponse = new ErrorResponse(); + errorResponse.setMessage(errMsg); + log.error(errMsg); + throw new BadRequestException(errorResponse); + } try { + eventStreamAdminServiceStub = DeviceMgtAPIUtils.getEventStreamAdminServiceStub(); + EventStreamDefinitionDto eventStreamDefinitionDto = new EventStreamDefinitionDto(); eventStreamDefinitionDto.setName(stream.getName()); eventStreamDefinitionDto.setVersion(stream.getVersion()); @@ -425,6 +334,7 @@ public class AnalyticsArtifactsManagementServiceImpl implements AnalyticsArtifac eventStreamDefinitionDto.setMetaData(addEventAttributesToDto(metaData)); eventStreamDefinitionDto.setPayloadData(addEventAttributesToDto(payloadData)); eventStreamDefinitionDto.setCorrelationData(addEventAttributesToDto(correlationData)); + String streamId = stream.getName() + ":" + stream.getVersion(); if (eventStreamAdminServiceStub.getStreamDefinitionDto(streamId) != null) { eventStreamAdminServiceStub.editEventStreamDefinitionAsDto(eventStreamDefinitionDto, streamId); @@ -438,86 +348,75 @@ public class AnalyticsArtifactsManagementServiceImpl implements AnalyticsArtifac } /** - * @param receiverName Receiver name - * @param adapterType Receiver type - * @param adapterProperties Receiver properties - * @param customMapping Is receiver mapped - * @param inputMappingProperties Receiver input attribute mapping - * @param namespaceMappingProperties Receiver name-scape attribute mapping - * @param correlationMappingProperties Receiver correlation attribute mapping - * @param payloadMappingProperties Receiver payload attribute mapping - * @param metaMappingProperties Receiver meta attribute mapping - * @param messageFormat Receiver mapping format - * @param eventStreamWithVersion Attached stream - * @throws RemoteException exception that may occur during a remote method call - * @throws UserStoreException exception that may occur during JWT token generation - * @throws JWTClientException exception that may occur during connecting to client store + * Set data to a receiver dto and deploy dto through a stub + * + * @param receiver Event Receiver adapter + * @param customMapping Is Receiver mapped + * @param adapterConfiguration Adapter property and mapping configuration + * @throws RemoteException Exception that may occur during a remote method call + * @throws UserStoreException Exception that may occur during JWT token generation + * @throws JWTClientException Exception that may occur during connecting to client store */ - private void publishReceiver(String receiverName, String adapterType, - List adapterProperties, boolean customMapping, - List inputMappingProperties, - List namespaceMappingProperties, - List correlationMappingProperties, - List payloadMappingProperties, - List metaMappingProperties, - MessageFormat messageFormat, - String eventStreamWithVersion) + private void deployReceiver(Adapter receiver, boolean customMapping, + AdapterConfiguration adapterConfiguration) throws RemoteException, UserStoreException, JWTClientException { EventReceiverAdminServiceStub eventReceiverAdminServiceStub = DeviceMgtAPIUtils.getEventReceiverAdminServiceStub(); try { + String receiverName = receiver.getAdapterName(); + String adapterType = receiver.getAdapterType().toStringFormatted(); + String eventStreamWithVersion = receiver.getEventStreamWithVersion(); + List adapterProperties = adapterConfiguration.getAdapterProperties(); EventReceiverConfigurationDto eventReceiverConfigurationDto = eventReceiverAdminServiceStub .getActiveEventReceiverConfiguration(receiverName); - - // Check if adapter already exists, if so un-deploy it if (eventReceiverConfigurationDto != null) { eventReceiverAdminServiceStub.undeployActiveEventReceiverConfiguration(receiverName); } + BasicInputAdapterPropertyDto[] basicInputAdapterPropertyDtos = addReceiverConfigToDto(adapterProperties); - // Adding attribute properties to DTOs - BasicInputAdapterPropertyDto[] basicInputAdapterPropertyDtos = - addReceiverConfigToDto(adapterProperties); - - if (eventReceiverAdminServiceStub.getActiveEventReceiverConfiguration(receiverName) == null) { - // Call stub deploy methods according to the message format - if (!messageFormat.toString().equals("wso2event")) { - EventMappingPropertyDto[] inputMappingPropertyDtos = - addReceiverMappingToDto(inputMappingProperties); - if (messageFormat.toString().equals("xml")) { - EventMappingPropertyDto[] namespaceMappingPropertyDtos = - addReceiverMappingToDto(namespaceMappingProperties); - - eventReceiverAdminServiceStub.deployXmlEventReceiverConfiguration(receiverName - , eventStreamWithVersion, adapterType, null - , namespaceMappingPropertyDtos, inputMappingPropertyDtos + AdapterMappingConfiguration adapterMappingConfiguration = adapterConfiguration.getAdapterMappingConfiguration(); + MessageFormat messageFormat = adapterMappingConfiguration.getMessageFormat(); + if (!messageFormat.toString().equals("wso2event")) { + EventMappingPropertyDto[] inputMappingPropertyDtos = + addReceiverMappingToDto(adapterMappingConfiguration.getInputMappingProperties()); + if (messageFormat.toString().equals("xml")) { + EventMappingPropertyDto[] namespaceMappingPropertyDtos = + addReceiverMappingToDto(adapterMappingConfiguration.getNamespaceMappingProperties()); + eventReceiverAdminServiceStub.deployXmlEventReceiverConfiguration(receiverName + , eventStreamWithVersion, adapterType, null + , namespaceMappingPropertyDtos, inputMappingPropertyDtos + , basicInputAdapterPropertyDtos, customMapping); + } else { + if (messageFormat.toString().equals("map")) { + eventReceiverAdminServiceStub.deployMapEventReceiverConfiguration(receiverName + , eventStreamWithVersion, adapterType, inputMappingPropertyDtos + , basicInputAdapterPropertyDtos, customMapping); + } else if (messageFormat.toString().equals("text")) { + eventReceiverAdminServiceStub.deployTextEventReceiverConfiguration(receiverName + , eventStreamWithVersion, adapterType, inputMappingPropertyDtos , basicInputAdapterPropertyDtos, customMapping); } else { - if (messageFormat.toString().equals("map")) { - eventReceiverAdminServiceStub.deployMapEventReceiverConfiguration(receiverName - , eventStreamWithVersion, adapterType, inputMappingPropertyDtos - , basicInputAdapterPropertyDtos, customMapping); - } else if (messageFormat.toString().equals("text")) { - eventReceiverAdminServiceStub.deployTextEventReceiverConfiguration(receiverName - , eventStreamWithVersion, adapterType, inputMappingPropertyDtos - , basicInputAdapterPropertyDtos, customMapping); - } else { - eventReceiverAdminServiceStub.deployJsonEventReceiverConfiguration(receiverName - , eventStreamWithVersion, adapterType, inputMappingPropertyDtos - , basicInputAdapterPropertyDtos, customMapping); - } + eventReceiverAdminServiceStub.deployJsonEventReceiverConfiguration(receiverName + , eventStreamWithVersion, adapterType, inputMappingPropertyDtos + , basicInputAdapterPropertyDtos, customMapping); } - } else { - EventMappingPropertyDto[] correlationMappingPropertyDtos = addReceiverMappingToDto(correlationMappingProperties); - EventMappingPropertyDto[] metaMappingPropertyDtos = addReceiverMappingToDto(metaMappingProperties); - EventMappingPropertyDto[] payloadMappingPropertyDtos = addReceiverMappingToDto(payloadMappingProperties); - - eventReceiverAdminServiceStub.deployWso2EventReceiverConfiguration(receiverName - , eventStreamWithVersion, adapterType, metaMappingPropertyDtos - , correlationMappingPropertyDtos, payloadMappingPropertyDtos - , basicInputAdapterPropertyDtos, customMapping - , eventStreamWithVersion); } - + } else { + EventMappingPropertyDto[] correlationMappingPropertyDtos = addReceiverMappingToDto( + adapterMappingConfiguration.getCorrelationMappingProperties() + ); + EventMappingPropertyDto[] metaMappingPropertyDtos = addReceiverMappingToDto( + adapterMappingConfiguration.getInputMappingProperties() + ); + EventMappingPropertyDto[] payloadMappingPropertyDtos = addReceiverMappingToDto( + adapterMappingConfiguration.getPayloadMappingProperties() + ); + + eventReceiverAdminServiceStub.deployWso2EventReceiverConfiguration(receiverName + , eventStreamWithVersion, adapterType, metaMappingPropertyDtos + , correlationMappingPropertyDtos, payloadMappingPropertyDtos + , basicInputAdapterPropertyDtos, customMapping + , eventStreamWithVersion); } } finally { cleanup(eventReceiverAdminServiceStub); @@ -525,120 +424,115 @@ public class AnalyticsArtifactsManagementServiceImpl implements AnalyticsArtifac } /** - * @param publisherName Publisher name - * @param adapterType Publisher type - * @param adapterProperties Publisher properties - * @param customMapping Is publisher mapped - * @param correlationMappingProperties Publisher correlation attribute mapping - * @param payloadMappingProperties Publisher payload attribute mapping - * @param metaMappingProperties Publisher meta attribute mapping - * @param messageFormat Publisher mapping format - * @param eventStreamWithVersion Attached stream - * @throws RemoteException exception that may occur during a remote method call - * @throws UserStoreException exception that may occur during JWT token generation - * @throws JWTClientException exception that may occur during connecting to client store + * Set data to a publisher dto and deploy dto through a stub + * + * @param publisher Event Publisher adapter + * @param customMapping Is Publisher mapped + * @param adapterConfiguration Publisher property and mapping configuration + * @throws RemoteException Exception that may occur during a remote method call + * @throws UserStoreException Exception that may occur during JWT token generation + * @throws JWTClientException Exception that may occur during connecting to client store */ - private void publishPublisher(String publisherName, String adapterType, - List adapterProperties, - boolean customMapping, - String inputMappingString, - List inputMappingProperties, - List correlationMappingProperties, - List payloadMappingProperties, - List metaMappingProperties, - MessageFormat messageFormat, - String eventStreamWithVersion) + private void deployPublisher(Adapter publisher, boolean customMapping, + AdapterConfiguration adapterConfiguration) throws RemoteException, UserStoreException, JWTClientException { EventPublisherAdminServiceStub eventPublisherAdminServiceStub = DeviceMgtAPIUtils.getEventPublisherAdminServiceStub(); - // Check if adapter already exists, if so un-deploy it try { + String publisherName = publisher.getAdapterName(); + String adapterType = publisher.getAdapterType().toStringFormatted(); + String eventStreamWithVersion = publisher.getEventStreamWithVersion(); + List adapterProperties = adapterConfiguration.getAdapterProperties(); EventPublisherConfigurationDto eventPublisherConfigurationDto = eventPublisherAdminServiceStub .getActiveEventPublisherConfiguration(publisherName); if (eventPublisherConfigurationDto != null) { eventPublisherAdminServiceStub.undeployActiveEventPublisherConfiguration(publisherName); } - // Adding attribute properties to DTOs BasicOutputAdapterPropertyDto[] basicOutputAdapterPropertyDtos = addPublisherConfigToDto(adapterProperties); - if (eventPublisherAdminServiceStub.getActiveEventPublisherConfiguration(publisherName) == null) { - // Call stub deploy methods according to the message format - if (!messageFormat.toString().equals("wso2event")) { - if (!messageFormat.toString().equals("map")) { - if (messageFormat.toString().equals("xml")) { - eventPublisherAdminServiceStub.deployXmlEventPublisherConfiguration(publisherName - , eventStreamWithVersion, adapterType, inputMappingString - , basicOutputAdapterPropertyDtos, eventStreamWithVersion - , customMapping); - } else if (messageFormat.toString().equals("text")) { - eventPublisherAdminServiceStub.deployTextEventPublisherConfiguration(publisherName - , eventStreamWithVersion, adapterType, inputMappingString - , basicOutputAdapterPropertyDtos, eventStreamWithVersion - , customMapping); - } else { - eventPublisherAdminServiceStub.deployJsonEventPublisherConfiguration(publisherName - , eventStreamWithVersion, adapterType, inputMappingString - , basicOutputAdapterPropertyDtos, eventStreamWithVersion - , customMapping); - } + AdapterMappingConfiguration adapterMappingConfiguration = adapterConfiguration.getAdapterMappingConfiguration(); + MessageFormat messageFormat = adapterMappingConfiguration.getMessageFormat(); + if (!messageFormat.toString().equals("wso2event")) { + if (!messageFormat.toString().equals("map")) { + if (messageFormat.toString().equals("xml")) { + eventPublisherAdminServiceStub.deployXmlEventPublisherConfiguration(publisherName + , eventStreamWithVersion, adapterType, adapterMappingConfiguration.getInputMappingString() + , basicOutputAdapterPropertyDtos, eventStreamWithVersion + , customMapping); + } else if (messageFormat.toString().equals("text")) { + eventPublisherAdminServiceStub.deployTextEventPublisherConfiguration(publisherName + , eventStreamWithVersion, adapterType, adapterMappingConfiguration.getInputMappingString() + , basicOutputAdapterPropertyDtos, eventStreamWithVersion + , customMapping); } else { - org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] inputMappingPropertyDtos = - addPublisherMappingToDto(inputMappingProperties); - eventPublisherAdminServiceStub.deployMapEventPublisherConfiguration(publisherName - , eventStreamWithVersion, adapterType, inputMappingPropertyDtos - , basicOutputAdapterPropertyDtos, customMapping); + eventPublisherAdminServiceStub.deployJsonEventPublisherConfiguration(publisherName + , eventStreamWithVersion, adapterType, adapterMappingConfiguration.getInputMappingString() + , basicOutputAdapterPropertyDtos, eventStreamWithVersion + , customMapping); } } else { - org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] correlationMappingPropertyDtos = - addPublisherMappingToDto(correlationMappingProperties); - org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] metaMappingPropertyDtos = - addPublisherMappingToDto(metaMappingProperties); - org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] payloadMappingPropertyDtos = - addPublisherMappingToDto(payloadMappingProperties); - - eventPublisherAdminServiceStub.deployWSO2EventPublisherConfiguration(publisherName - , eventStreamWithVersion, adapterType, metaMappingPropertyDtos - , correlationMappingPropertyDtos, payloadMappingPropertyDtos - , basicOutputAdapterPropertyDtos, customMapping - , eventStreamWithVersion); + org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] inputMappingPropertyDtos = + addPublisherMappingToDto( + adapterMappingConfiguration.getInputMappingProperties() + ); + eventPublisherAdminServiceStub.deployMapEventPublisherConfiguration(publisherName + , eventStreamWithVersion, adapterType, inputMappingPropertyDtos + , basicOutputAdapterPropertyDtos, customMapping); } - + } else { + org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] correlationMappingPropertyDtos = + addPublisherMappingToDto( + adapterMappingConfiguration.getCorrelationMappingProperties() + ); + org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] metaMappingPropertyDtos = + addPublisherMappingToDto( + adapterMappingConfiguration.getMetaMappingProperties() + ); + org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] payloadMappingPropertyDtos = + addPublisherMappingToDto( + adapterMappingConfiguration.getPayloadMappingProperties() + ); + eventPublisherAdminServiceStub.deployWSO2EventPublisherConfiguration(publisherName + , eventStreamWithVersion, adapterType, metaMappingPropertyDtos + , correlationMappingPropertyDtos, payloadMappingPropertyDtos + , basicOutputAdapterPropertyDtos, customMapping + , eventStreamWithVersion); } + } finally { cleanup(eventPublisherAdminServiceStub); } } /** - * @param name plan name - * @param isEdited is plan edited - * @param plan plan data - * @throws RemoteException exception that may occur during a remote method call - * @throws UserStoreException exception that may occur during JWT token generation - * @throws JWTClientException exception that may occur during connecting to client store - * @throws InvalidExecutionPlanException exception that may occur if execution plan validation fails + * Publish a siddhi execution plan using a stub + * + * @param name Plan name + * @param isEdited Is plan edited + * @param plan Plan data + * @throws RemoteException Exception that may occur during a remote method call + * @throws UserStoreException Exception that may occur during JWT token generation + * @throws JWTClientException Exception that may occur during connecting to client store + * @throws InvalidExecutionPlanException Exception that may occur if execution plan validation fails */ private void publishSiddhiExecutionPlan(String name, boolean isEdited, String plan) - throws RemoteException, UserStoreException, JWTClientException, - InvalidExecutionPlanException { + throws RemoteException, UserStoreException, JWTClientException { EventProcessorAdminServiceStub eventProcessorAdminServiceStub = null; try { eventProcessorAdminServiceStub = DeviceMgtAPIUtils.getEventProcessorAdminServiceStub(); - // Validate the plan code String validationResponse = eventProcessorAdminServiceStub.validateExecutionPlan(plan); if (validationResponse.equals("success")) { if (!isEdited) { - // Create a new plan eventProcessorAdminServiceStub.deployExecutionPlan(plan); } else { - // Edit plan eventProcessorAdminServiceStub.editActiveExecutionPlan(plan, name); } } else { ErrorDTO errorDTO = new ErrorDTO(); errorDTO.setMessage(validationResponse); + log.error(validationResponse); throw new InvalidExecutionPlanException(errorDTO); } } finally { @@ -646,18 +540,74 @@ public class AnalyticsArtifactsManagementServiceImpl implements AnalyticsArtifac } } + /** + * This will set payload of event attribute's mapping to the DTO + * + * @param attributes list of event attributes + * @return DTO with all the event attributes + */ private EventStreamAttributeDto[] addEventAttributesToDto(List attributes) { EventStreamAttributeDto[] eventStreamAttributeDtos = new EventStreamAttributeDto[attributes.size()]; - for (int i = 0; i < attributes.size(); i++) { + for (Attribute attribute : attributes) { EventStreamAttributeDto eventStreamAttributeDto = new EventStreamAttributeDto(); - eventStreamAttributeDto.setAttributeName(attributes.get(i).getName()); - eventStreamAttributeDto.setAttributeType(attributes.get(i).getType().toString()); - eventStreamAttributeDtos[i] = eventStreamAttributeDto; + eventStreamAttributeDto.setAttributeName(attribute.getName()); + eventStreamAttributeDto.setAttributeType(attribute.getType().toString()); + } return eventStreamAttributeDtos; } + /** + * Validate adapter payload attributes + * + * @param adapterProperties Adapter payload attributes + */ + private void validateAdapterProperties(List adapterProperties) { + if (adapterProperties.isEmpty()) { + String errMsg = "Invalid payload: event property attributes invalid!!!"; + ErrorResponse errorResponse = new ErrorResponse(); + errorResponse.setMessage(errMsg); + log.error(errMsg); + throw new BadRequestException(errorResponse); + } + } + /** + * Validate adapter mapping attributes + *

+ * Conditions + * - if both inputMappingProperties and namespaceMappingProperties null check remaining property lists + * - if all correlationMappingProperties, payloadMappingProperties, metaMappingProperties null log error + * - if message format is null change the final result to TRUE + * - else continue + * + * @param adapterMappingConfiguration Adapter mapping attributes + */ + private void validateAdapterMapping(AdapterMappingConfiguration adapterMappingConfiguration) { + + if (adapterMappingConfiguration.getInputMappingString() == null && + (adapterMappingConfiguration.getInputMappingProperties().isEmpty() && + adapterMappingConfiguration.getNamespaceMappingProperties().isEmpty()) && + ( + adapterMappingConfiguration.getCorrelationMappingProperties().isEmpty() && + adapterMappingConfiguration.getPayloadMappingProperties().isEmpty() && + adapterMappingConfiguration.getMetaMappingProperties().isEmpty() + ) + || adapterMappingConfiguration.getMessageFormat() == null) { + String errMsg = "Invalid payload: event mapping attributes invalid!!!"; + ErrorResponse errorResponse = new ErrorResponse(); + errorResponse.setMessage(errMsg); + log.error(errMsg); + throw new BadRequestException(errorResponse); + } + } + + /** + * This will set payload of receiver attributes to the DTO + * + * @param adapterProperties List of receiver attributes + * @return DTO with all the receiver attributes + */ private BasicInputAdapterPropertyDto[] addReceiverConfigToDto( List adapterProperties) { BasicInputAdapterPropertyDto[] basicInputAdapterPropertyDtos @@ -671,7 +621,14 @@ public class AnalyticsArtifactsManagementServiceImpl implements AnalyticsArtifac return basicInputAdapterPropertyDtos; } - private EventMappingPropertyDto[] addReceiverMappingToDto(List mapProperties) { + /** + * This will set payload of receiver mapping attributes to the DTO + * + * @param mapProperties List of receiver mapping attributes + * @return DTO with all the receiver mapping attributes + */ + private EventMappingPropertyDto[] addReceiverMappingToDto + (List mapProperties) { EventMappingPropertyDto[] eventMappingPropertyDtos = new EventMappingPropertyDto[mapProperties.size()]; for (int i = 0; i < mapProperties.size(); i++) { EventMappingPropertyDto eventMappingPropertyDto = new EventMappingPropertyDto(); @@ -683,6 +640,12 @@ public class AnalyticsArtifactsManagementServiceImpl implements AnalyticsArtifac return eventMappingPropertyDtos; } + /** + * This will set payload of publisher attributes to the DTO + * + * @param adapterProperties List of publisher attributes + * @return DTO with all the publisher attributes + */ private BasicOutputAdapterPropertyDto[] addPublisherConfigToDto( List adapterProperties) { BasicOutputAdapterPropertyDto[] basicOutputAdapterPropertyDtos = @@ -697,8 +660,14 @@ public class AnalyticsArtifactsManagementServiceImpl implements AnalyticsArtifac return basicOutputAdapterPropertyDtos; } + /** + * This will set payload of publisher mapping attributes to the DTO + * + * @param mapProperties List of publisher mapping attributes + * @return DTO with all the publisher mapping attributes + */ private org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] addPublisherMappingToDto - (List mapProperties) { + (List mapProperties) { org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[] eventMappingPropertyDtos = new org.wso2.carbon.event.publisher.stub.types.EventMappingPropertyDto[mapProperties.size()]; for (int i = 0; i < mapProperties.size(); i++) { @@ -712,6 +681,11 @@ public class AnalyticsArtifactsManagementServiceImpl implements AnalyticsArtifac return eventMappingPropertyDtos; } + /** + * Clean Service client in the stub + * + * @param stub Stud that needs to be cleaned + */ private void cleanup(Stub stub) { if (stub != null) { try { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index c56de855be..5cd5126b47 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt org.wso2.carbon.devicemgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 560b693618..f8a478cd61 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml 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 5471fa3a6f..0fe6a8215f 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 @@ -1724,6 +1724,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { return deviceLocationHistories; } + @Override public void deleteDevices(List deviceIdentifiers, List deviceIds, List enrollmentIds) throws DeviceManagementDAOException { Connection conn; @@ -1793,8 +1794,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { } } } catch (SQLException e) { - String msg ="Error occurred while deleting the devices: " + deviceIdentifiers; - log.error(msg,e); + String msg = "Error occurred while deleting the devices: " + deviceIdentifiers; + log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } } @@ -1808,9 +1809,14 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { private void removeDeviceDetail(Connection conn, List deviceIds) throws DeviceManagementDAOException { String sql = "DELETE FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ?"; try { - executeBatchOperation(conn, sql, deviceIds); + if (!executeBatchOperation(conn, sql, deviceIds)) { + String msg = "Failed to remove device details of devices with deviceIds : " + deviceIds + + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing device details."; + String msg = "SQL error occurred while removing device details of devices with deviceIds : " + deviceIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -1825,9 +1831,14 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { private void removeDeviceLocation(Connection conn, List deviceIds) throws DeviceManagementDAOException { String sql = "DELETE FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ?"; try { - executeBatchOperation(conn, sql, deviceIds); + if (!executeBatchOperation(conn, sql, deviceIds)) { + String msg = "Failed to remove locations of devices with deviceIds : " + deviceIds + + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while obtaining locations of devices."; + String msg = "SQL error occurred while removing locations of devices with deviceIds : " + deviceIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -1842,9 +1853,14 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { private void removeDeviceInfo(Connection conn, List deviceIds) throws DeviceManagementDAOException { String sql = "DELETE FROM DM_DEVICE_INFO WHERE DEVICE_ID = ?"; try { - executeBatchOperation(conn, sql, deviceIds); + if (!executeBatchOperation(conn, sql, deviceIds)) { + String msg = "Failed to remove device info of devices with deviceIds : " + deviceIds + + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing device info."; + String msg = "SQL error occurred while removing device info of devices with deviceIds : " + deviceIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -1859,9 +1875,14 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { private void removeDeviceNotification(Connection conn, List deviceIds) throws DeviceManagementDAOException { String sql = "DELETE FROM DM_NOTIFICATION WHERE DEVICE_ID = ?"; try { - executeBatchOperation(conn, sql, deviceIds); + if (!executeBatchOperation(conn, sql, deviceIds)) { + String msg = "Failed to remove device notifications of devices with deviceIds : " + deviceIds + + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing device notifications."; + String msg = "SQL error occurred while removing device notifications of devices with deviceIds : " + deviceIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -1878,9 +1899,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { throws DeviceManagementDAOException { String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ?"; try { - executeBatchOperation(conn, sql, deviceIds); + if (!executeBatchOperation(conn, sql, deviceIds)) { + String msg = "Failed to remove device application mapping of of devices with deviceIds : " + deviceIds + + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing device application mapping"; + String msg = "SQL error occurred while removing device application mapping of devices with deviceIds : " + + deviceIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -1896,9 +1923,14 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { throws DeviceManagementDAOException { String sql = "DELETE FROM DM_DEVICE_POLICY_APPLIED WHERE DEVICE_ID = ?"; try { - executeBatchOperation(conn, sql, deviceIds); + if (!executeBatchOperation(conn, sql, deviceIds)) { + String msg = "Failed to remove policies applied on devices with deviceIds : " + deviceIds + + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing policies applied on devices"; + String msg = "SQL error occurred while removing policies applied on devices with deviceIds : " + deviceIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -1913,9 +1945,14 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { private void removeDevicePolicy(Connection conn, List deviceIds) throws DeviceManagementDAOException { String sql = "DELETE FROM DM_DEVICE_POLICY WHERE DEVICE_ID = ?"; try { - executeBatchOperation(conn, sql, deviceIds); + if (!executeBatchOperation(conn, sql, deviceIds)) { + String msg = "Failed to remove policies of devices with deviceIds : " + deviceIds + + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing policies of devices"; + String msg = "SQL error occurred while removing policies of devices with deviceIds : " + deviceIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -1931,9 +1968,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { throws DeviceManagementDAOException { String sql = "DELETE FROM DM_DEVICE_DETAIL WHERE ENROLMENT_ID = ?"; try { - executeBatchOperation(conn, sql, enrollmentIds); + if (!executeBatchOperation(conn, sql, enrollmentIds)) { + String msg = "Failed to remove enrollment details of devices with enrollmentIds : " + enrollmentIds + + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing enrollment details of devices"; + String msg = "SQL error occurred while removing enrollment details of devices with enrollmentIds : " + + enrollmentIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -1949,9 +1992,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { throws DeviceManagementDAOException { String sql = "DELETE FROM DM_DEVICE_LOCATION WHERE ENROLMENT_ID = ?"; try { - executeBatchOperation(conn, sql, enrollmentIds); + if (!executeBatchOperation(conn, sql, enrollmentIds)) { + String msg = "Failed to remove enrollment locations of devices with enrollmentIds : " + enrollmentIds + + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing enrollment locations of devices"; + String msg = "SQL error occurred while removing enrollment locations of devices with enrollmentIds : " + + enrollmentIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -1967,9 +2016,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { throws DeviceManagementDAOException { String sql = "DELETE FROM DM_DEVICE_INFO WHERE ENROLMENT_ID = ?"; try { - executeBatchOperation(conn, sql, enrollmentIds); + if (!executeBatchOperation(conn, sql, enrollmentIds)) { + String msg = "Failed to remove enrollment info of devices with enrollmentIds : " + enrollmentIds + + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing enrollment info of devices"; + String msg = "SQL error occurred while removing enrollment info of devices with enrollmentIds : " + + enrollmentIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -1985,9 +2040,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { throws DeviceManagementDAOException { String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE ENROLMENT_ID = ?"; try { - executeBatchOperation(conn, sql, enrollmentIds); + if (!executeBatchOperation(conn, sql, enrollmentIds)) { + String msg = "Failed to remove enrollment device application mapping of devices with enrollmentIds : " + + enrollmentIds + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing enrollment device application mapping"; + String msg = "SQL error occurred while removing enrollment device application mapping of devices with " + + "enrollmentIds : " + enrollmentIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -2003,9 +2064,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { throws DeviceManagementDAOException { String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE ENROLMENT_ID = ?"; try { - executeBatchOperation(conn, sql, enrollmentIds); + if (!executeBatchOperation(conn, sql, enrollmentIds)) { + String msg = "Failed to remove device operation response of devices with enrollmentIds : " + + enrollmentIds + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing device operation response"; + String msg = "SQL error occurred while removing device operation response of devices with enrollmentIds : " + + enrollmentIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -2021,9 +2088,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { throws DeviceManagementDAOException { String sql = "DELETE FROM DM_ENROLMENT_OP_MAPPING WHERE ENROLMENT_ID = ?"; try { - executeBatchOperation(conn, sql, enrollmentIds); + if (!executeBatchOperation(conn, sql, enrollmentIds)) { + String msg = "Failed to remove enrollment operation mapping of devices with enrollmentIds : " + + enrollmentIds + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing enrollment operation mapping"; + String msg = "SQL error occurred while removing enrollment operation mapping of devices with enrollmentIds :" + + enrollmentIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -2039,9 +2112,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { throws DeviceManagementDAOException { String sql = "DELETE FROM DM_ENROLMENT WHERE DEVICE_ID = ?"; try { - executeBatchOperation(conn, sql, enrollmentIds); + if (!executeBatchOperation(conn, sql, enrollmentIds)) { + String msg = "Failed to remove enrollments of devices with enrollmentIds : " + enrollmentIds + + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing enrollments of devices"; + String msg = "SQL error occurred while removing enrollments of devices with enrollmentIds : " + + enrollmentIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -2056,9 +2135,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { private void removeDeviceGroupMapping(Connection conn, List deviceIds) throws DeviceManagementDAOException { String sql = "DELETE FROM DM_DEVICE_GROUP_MAP WHERE DEVICE_ID = ?"; try { - executeBatchOperation(conn, sql, deviceIds); + if (!executeBatchOperation(conn, sql, deviceIds)) { + String msg = "Failed to remove device group mapping of devices with deviceIds : " + deviceIds + + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing device group mapping"; + String msg = "SQL error occurred while removing device group mapping of devices with deviceIds : " + + deviceIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -2073,9 +2158,13 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { private void removeDevice(Connection conn, List deviceIds) throws DeviceManagementDAOException { String sql = "DELETE FROM DM_DEVICE WHERE ID = ?"; try { - executeBatchOperation(conn, sql, deviceIds); + if (!executeBatchOperation(conn, sql, deviceIds)) { + String msg = "Failed to remove devices with deviceIds : " + deviceIds + " while executing batch operation"; + log.error(msg); + throw new DeviceManagementDAOException(msg); + } } catch (SQLException e) { - String msg = "Error occurred while removing devices."; + String msg = "SQL error occurred while removing devices with deviceIds : " + deviceIds; log.error(msg, e); throw new DeviceManagementDAOException(msg, e); } @@ -2085,12 +2174,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { * This method executes batch operations for a given list of primary keys * where the statement only has one param of type int, following the given pattern: * DELETE FROM TABLE WHERE ID = ? + * + * This method does not check if the number of rows affected by the executeBatch() method is 0 + * because there can be tables with no records to delete. * @param sql SQL statement * @param conn Connection object * @param identifiers list of device ids (primary keys) * @throws SQLException if deletion fails. */ - private void executeBatchOperation(Connection conn, String sql, List identifiers) throws SQLException { + private boolean executeBatchOperation(Connection conn, String sql, List identifiers) throws SQLException { try (PreparedStatement ps = conn.prepareStatement(sql)) { if (conn.getMetaData().supportsBatchUpdates()) { for (int identifier : identifiers) { @@ -2098,19 +2190,18 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { ps.addBatch(); } for (int i : ps.executeBatch()) { - if (i == 0 || i == Statement.SUCCESS_NO_INFO || i == Statement.EXECUTE_FAILED) { - break; + if (i == Statement.SUCCESS_NO_INFO || i == Statement.EXECUTE_FAILED) { + return false; } } } else { - for (int enrollmentId : identifiers) { - ps.setInt(1, enrollmentId); - if (ps.executeUpdate() == 0) { - break; - } + for (int identifier : identifiers) { + ps.setInt(1, identifier); + ps.executeUpdate(); } } } + return true; } private int getDeviceId(Connection conn, DeviceIdentifier deviceIdentifier, int tenantId) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 3be6900f90..d4732d172d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -528,43 +528,39 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } @Override - public boolean deleteDevices(List deviceIdentifiers) throws DeviceManagementException, InvalidDeviceException { - List deviceIds = new ArrayList<>(); + public boolean deleteDevices(List deviceIdentifiers) throws DeviceManagementException, + InvalidDeviceException { + if (deviceIdentifiers == null || deviceIdentifiers.isEmpty()) { + String msg = "Required values of device identifiers are not set to permanently delete device/s."; + log.error(msg); + throw new InvalidDeviceException(msg); + } + HashSet deviceIds = new HashSet<>(); List enrollmentIds = new ArrayList<>(); + List validDeviceIdentifiers = new ArrayList<>(); Map> deviceIdentifierMap = new HashMap<>(); Map deviceManagerMap = new HashMap<>(); List deviceCacheKeyList = new ArrayList<>(); int tenantId = this.getTenantId(); - List existingDevices; try { DeviceManagementDAOFactory.beginTransaction(); - existingDevices = deviceDAO.getDevicesByIdentifiers(deviceIdentifiers, tenantId); - if (existingDevices.size() != deviceIdentifiers.size()) { - for (Device device : existingDevices) { - deviceIdentifiers.remove(device.getDeviceIdentifier()); - } - String msg = - "Couldn't find device ids for all the requested device identifiers. " + - "Therefore payload should contain device identifiers which are not in the system. " + - "Invalid device identifiers are " + deviceIdentifiers.toString(); - log.error(msg); - DeviceManagementDAOFactory.rollbackTransaction(); - throw new InvalidDeviceException(msg); - } + List existingDevices = deviceDAO.getDevicesByIdentifiers(deviceIdentifiers, tenantId); + DeviceCacheKey deviceCacheKey; for (Device device : existingDevices) { - if (!device.getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.REMOVED)) { + if (!EnrolmentInfo.Status.REMOVED.equals(device.getEnrolmentInfo().getStatus())) { + DeviceManagementDAOFactory.rollbackTransaction(); String msg = "Device " + device.getDeviceIdentifier() + " of type " + device.getType() - + " is not dis-enrolled to permanently delete the device"; + + " is not dis-enrolled to permanently delete the device"; log.error(msg); - DeviceManagementDAOFactory.rollbackTransaction(); throw new InvalidDeviceException(msg); } - DeviceCacheKey deviceCacheKey = new DeviceCacheKey(); + deviceCacheKey = new DeviceCacheKey(); deviceCacheKey.setDeviceId(device.getDeviceIdentifier()); deviceCacheKey.setDeviceType(device.getType()); deviceCacheKey.setTenantId(tenantId); deviceCacheKeyList.add(deviceCacheKey); deviceIds.add(device.getId()); + validDeviceIdentifiers.add(device.getDeviceIdentifier()); enrollmentIds.add(device.getEnrolmentInfo().getId()); if (deviceIdentifierMap.containsKey(device.getType())) { deviceIdentifierMap.get(device.getType()).add(device.getDeviceIdentifier()); @@ -573,17 +569,23 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv new ArrayList<>(Arrays.asList(device.getDeviceIdentifier()))); DeviceManager deviceManager = this.getDeviceManager(device.getType()); if (deviceManager == null) { - if (log.isDebugEnabled()) { - log.debug("Device Manager associated with the device type '" - + device.getType() + "' is null. Therefore, not attempting method 'deleteDevice'"); - } + log.error("Device Manager associated with the device type '" +device.getType() + + "' is null. Therefore, not attempting method 'deleteDevice'"); return false; } deviceManagerMap.put(device.getType(), deviceManager); } } + if (deviceIds.isEmpty()) { + String msg = "No device IDs found for the device identifiers '" + deviceIdentifiers + "'"; + log.error(msg); + throw new InvalidDeviceException(msg); + } + if (log.isDebugEnabled()) { + log.debug("Permanently deleting the details of devices : " + validDeviceIdentifiers); + } //deleting device from the core - deviceDAO.deleteDevices(deviceIdentifiers, deviceIds, enrollmentIds); + deviceDAO.deleteDevices(validDeviceIdentifiers, new ArrayList<>(deviceIds), enrollmentIds); for (Map.Entry entry : deviceManagerMap.entrySet()) { try { // deleting device from the plugin level @@ -600,6 +602,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv } DeviceManagementDAOFactory.commitTransaction(); this.removeDevicesFromCache(deviceCacheKeyList); + if (log.isDebugEnabled()) { + log.debug("Successfully permanently deleted the details of devices : " + validDeviceIdentifiers); + } return true; } catch (TransactionManagementException e) { String msg = "Error occurred while initiating transaction"; @@ -611,6 +616,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv "' devices"; log.error(msg, e); throw new DeviceManagementException(msg, e); + } finally { + DeviceManagementDAOFactory.closeConnection(); } } 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 106a2942b5..dbbd88e2e9 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 - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/DeviceTypePluginDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/DeviceTypePluginDAOImpl.java index e1427897d2..c7378f1631 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/DeviceTypePluginDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/DeviceTypePluginDAOImpl.java @@ -220,7 +220,6 @@ public class DeviceTypePluginDAOImpl implements PluginDAO { public boolean deleteDevices(List deviceIdentifiers) throws DeviceTypeMgtPluginException { try { Connection conn = deviceTypeDAOHandler.getConnection(); - boolean status = true; try (PreparedStatement ps = conn.prepareStatement(deleteDBQueryForDeleteDevice)) { if (conn.getMetaData().supportsBatchUpdates()) { for (String deviceId : deviceIdentifiers) { @@ -228,22 +227,18 @@ public class DeviceTypePluginDAOImpl implements PluginDAO { ps.addBatch(); } for (int i : ps.executeBatch()) { - if (i == 0 || i == Statement.SUCCESS_NO_INFO || i == Statement.EXECUTE_FAILED) { - status = false; - break; + if (i == Statement.SUCCESS_NO_INFO || i == Statement.EXECUTE_FAILED) { + return false; } } } else { for (String deviceId : deviceIdentifiers) { ps.setString(1, deviceId); - if (ps.executeUpdate() == 0) { - status = false; - break; - } + ps.executeUpdate(); } } } - return status; + return true; } catch (SQLException e) { String msg = "Error occurred while deleting the data in " + deviceDAODefinition.getDeviceTableName(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/PropertyBasedPluginDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/PropertyBasedPluginDAOImpl.java index 7cc32f6315..b60e70c4c2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/PropertyBasedPluginDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/dao/PropertyBasedPluginDAOImpl.java @@ -222,7 +222,6 @@ public class PropertyBasedPluginDAOImpl implements PluginDAO { public boolean deleteDevices(List deviceIdentifiers) throws DeviceTypeMgtPluginException { try { Connection conn = deviceTypeDAOHandler.getConnection(); - boolean status = true; try (PreparedStatement ps = conn.prepareStatement("DELETE FROM DM_DEVICE_PROPERTIES WHERE DEVICE_IDENTIFICATION = ?")) { if (conn.getMetaData().supportsBatchUpdates()) { for (String deviceId : deviceIdentifiers) { @@ -230,22 +229,18 @@ public class PropertyBasedPluginDAOImpl implements PluginDAO { ps.addBatch(); } for (int i : ps.executeBatch()) { - if (i == 0 || i == Statement.SUCCESS_NO_INFO || i == Statement.EXECUTE_FAILED) { - status = false; - break; + if (i == Statement.SUCCESS_NO_INFO || i == Statement.EXECUTE_FAILED) { + return false; } } } else { for (String deviceId : deviceIdentifiers) { ps.setString(1, deviceId); - if (ps.executeUpdate() == 0) { - status = false; - break; - } + ps.executeUpdate(); } } } - return status; + return true; } catch (SQLException e) { String msg = "Error occurred while deleting the data of the devices: '" + deviceIdentifiers + "'of type: " + deviceType; 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 607dc3b391..4c88fc1312 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 - 3.2.9-SNAPSHOT + 4.0.0-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 60757b8461..55cc5f3dd8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -161,6 +161,7 @@ "perm:device:enroll", "perm:geo-service:analytics-view", "perm:geo-service:alerts-manage", + "perm:devices:permanent-delete", "appm:read" ], "isOAuthEnabled": true, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js index 25f92f9c7a..344206796c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js @@ -623,6 +623,9 @@ var userModule = function () { if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/devices/update-enrollment")) { permissions["UPDATE_ENROLLMENT"] = true; } + if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/devices/permanent-delete")) { + permissions["PERMANENT_DELETE"] = true; + } return permissions; }; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.search/public/templates/device-listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.search/public/templates/device-listing.hbs index c0fe171866..53cb478806 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.search/public/templates/device-listing.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.search/public/templates/device-listing.hbs @@ -23,7 +23,7 @@ {{#equal enrolmentInfo.status "ACTIVE"}} Active{{/equal}} {{#equal enrolmentInfo.status "INACTIVE"}} Inactive{{/equal}} {{#equal enrolmentInfo.status "BLOCKED"}} Blocked{{/equal}} - {{#equal enrolmentInfo.status "REMOVED"}} Removed{{/equal}} + {{#equal enrolmentInfo.status "REMOVED"}} Removed{{/equal}} {{type}} {{enrolmentInfo.ownership}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs index cb067c464c..3a12ea975e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs @@ -218,15 +218,31 @@ data-toggle="modal" data-target="#modalDemo"> - + {{#if group}} Remove from group {{else}} - Remove Device + Dis-enroll Device {{/if}} + + {{#if permissions.permanentDelete}} +

  • + + + + + + Delete Device + +
  • + {{/if}} + {{#if permissions.updateEnrollment}}
  • @@ -423,6 +439,58 @@ +
    + + + +
    + +
    + + + +
    +
    +
    + + + +
    +