diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml
index c9f5407e89..c8011c08f3 100644
--- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml
+++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
grafana-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml
index d59249ee1b..ad2b76aea8 100644
--- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml
+++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
grafana-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml
index 9d518c2f07..2d708f2e34 100644
--- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml
+++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
grafana-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml
index 6604c333c9..1687efce72 100644
--- a/components/analytics-mgt/grafana-mgt/pom.xml
+++ b/components/analytics-mgt/grafana-mgt/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
analytics-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml
index 2527b4a26d..00d4c90659 100644
--- a/components/analytics-mgt/pom.xml
+++ b/components/analytics-mgt/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core.parent
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml
index 873de0a444..062250c578 100644
--- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml
@@ -20,7 +20,7 @@
apimgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
4.0.0
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml
index 21d7a55e99..e3f137438d 100644
--- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml
@@ -22,7 +22,7 @@
apimgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml
index 9dea6b0aa3..fb993c89e1 100644
--- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml
@@ -21,7 +21,7 @@
apimgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml
index 87f1e5ae16..9715d49004 100644
--- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml
@@ -22,7 +22,7 @@
apimgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml
index df83bd339a..153009c3e8 100644
--- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml
@@ -22,7 +22,7 @@
apimgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml
index 526744e2ed..3a0bbffa59 100644
--- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml
@@ -21,7 +21,7 @@
apimgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
4.0.0
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml
index 071c6e7f63..9d9fc52a3c 100644
--- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml
@@ -21,7 +21,7 @@
apimgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml
index 74f7954857..10bfbf4145 100644
--- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml
@@ -22,7 +22,7 @@
apimgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml
index 94bf6dc1bc..8120dc4f6a 100644
--- a/components/apimgt-extensions/pom.xml
+++ b/components/apimgt-extensions/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml
index d23e140f7a..ffb8a053df 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
application-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java
index 25d3c92f47..4a1be2ea1e 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationManager.java
@@ -538,4 +538,13 @@ public interface ApplicationManager {
*/
void updateAppIconInfo(ApplicationRelease applicationRelease, String oldPackageName)
throws ApplicationManagementException;
+
+ /**
+ * Delete all application related data of a tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementException thrown if an error occurs when deleting data
+ */
+ void deleteApplicationDataOfTenant(int tenantId) throws ApplicationManagementException;
+ void deleteApplicationDataByTenantDomain(String tenantDomain) throws ApplicationManagementException;
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationStorageManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationStorageManager.java
index 68b82facbc..698c57f55a 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationStorageManager.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/ApplicationStorageManager.java
@@ -132,4 +132,12 @@ public interface ApplicationStorageManager {
* @throws StorageManagementException if errors while generating md5 string
*/
String getMD5(InputStream inputStream) throws StorageManagementException;
+
+ /**
+ * Delete the folder containing all the app releases of a tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationStorageManagementException thrown if
+ */
+ void deleteAppFolderOfTenant(int tenantId) throws ApplicationStorageManagementException;
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml
index dc417eb255..ed00b9b0f9 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
application-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
@@ -384,6 +384,11 @@
com.squareup.okio
okio
+
+ org.wso2.carbon.multitenancy
+ org.wso2.carbon.tenant.mgt
+ compile
+
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationDAO.java
index ffa85b260d..3d460fb4db 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationDAO.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationDAO.java
@@ -238,4 +238,52 @@ public interface ApplicationDAO {
int getApplicationCount(Filter filter, int deviceTypeId, int tenantId) throws ApplicationManagementDAOException;
void deleteApplication(int appId, int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete favourite applications of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteAppFavouritesByTenant(int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete Application category mapping of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteApplicationCategoryMappingByTenant(int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete Application categories of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteApplicationCategoriesByTenant(int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete Application tags mapping of Tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteApplicationTagsMappingByTenant(int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete Application tags of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteApplicationTagsByTenant(int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete Applications of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteApplicationsByTenant(int tenantId) throws ApplicationManagementDAOException;
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationReleaseDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationReleaseDAO.java
index cd893979dd..8314388798 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationReleaseDAO.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ApplicationReleaseDAO.java
@@ -127,4 +127,12 @@ public interface ApplicationReleaseDAO {
*/
List getReleaseByPackages(List packages, int tenantId)
throws ApplicationManagementDAOException;
+
+ /**
+ * Delete Application releases of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteReleasesByTenant(int tenantId) throws ApplicationManagementDAOException;
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/LifecycleStateDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/LifecycleStateDAO.java
index 3f8656f858..ecf8b1e807 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/LifecycleStateDAO.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/LifecycleStateDAO.java
@@ -18,6 +18,7 @@
package io.entgra.device.mgt.core.application.mgt.core.dao;
import io.entgra.device.mgt.core.application.mgt.common.LifecycleState;
+import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException;
import io.entgra.device.mgt.core.application.mgt.core.exception.LifeCycleManagementDAOException;
import java.util.List;
@@ -75,4 +76,11 @@ public interface LifecycleStateDAO {
*/
String getAppReleaseCreatedUsername(int appId, String uuid, int tenantId) throws LifeCycleManagementDAOException;
- }
+ /**
+ * Delete Application lifecycle states of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws LifeCycleManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteAppLifecycleStatesByTenant(int tenantId) throws LifeCycleManagementDAOException;
+}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ReviewDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ReviewDAO.java
index 9a12859b5c..8fcc3abb54 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ReviewDAO.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/ReviewDAO.java
@@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.application.mgt.core.dao;
import io.entgra.device.mgt.core.application.mgt.common.response.Review;
import io.entgra.device.mgt.core.application.mgt.common.PaginationRequest;
import io.entgra.device.mgt.core.application.mgt.common.dto.ReviewDTO;
+import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException;
import io.entgra.device.mgt.core.application.mgt.core.exception.ReviewManagementDAOException;
import java.util.List;
@@ -119,4 +120,11 @@ import java.util.List;
void deleteAllChildCommentsOfReview(int rootParentId, int tenantId) throws ReviewManagementDAOException;
+ /**
+ * Delete reviews of a tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ReviewManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteReviewsByTenant(int tenantId) throws ReviewManagementDAOException;
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SPApplicationDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SPApplicationDAO.java
index 712a0e28b3..aa84543e6f 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SPApplicationDAO.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SPApplicationDAO.java
@@ -128,4 +128,20 @@ public interface SPApplicationDAO {
* @throws ApplicationManagementDAOException if any db error occurred
*/
void deleteIdentityServer(int id, int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete Identity servers of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteIdentityServerByTenant(int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete Service provide mapping details of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteSPApplicationMappingByTenant(int tenantId) throws ApplicationManagementDAOException;
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java
index 804a4a29e2..3213db3484 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/SubscriptionDAO.java
@@ -264,4 +264,52 @@ public interface SubscriptionDAO {
* @throws ApplicationManagementDAOException if error occurred while retrieving the app details
*/
Activity getOperationAppDetails(int operationId, int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete Operation mapping details of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteOperationMappingByTenant(int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete device subscriptions of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteDeviceSubscriptionByTenant(int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete group subscriptions of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteGroupSubscriptionByTenant(int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete role subscriptions of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteRoleSubscriptionByTenant(int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete user subscriptions of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteUserSubscriptionByTenant(int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete scheduled subscription details of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteScheduledSubscriptionByTenant(int tenantId) throws ApplicationManagementDAOException;
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/VisibilityDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/VisibilityDAO.java
index 45664a9d61..49290336c4 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/VisibilityDAO.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/VisibilityDAO.java
@@ -17,6 +17,7 @@
*/
package io.entgra.device.mgt.core.application.mgt.core.dao;
+import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException;
import io.entgra.device.mgt.core.application.mgt.core.exception.VisibilityManagementDAOException;
import java.util.List;
@@ -70,4 +71,11 @@ public interface VisibilityDAO {
*/
void deleteAppUnrestrictedRoles(int applicationId, int tenantId) throws VisibilityManagementDAOException;
+ /**
+ * Delete app unrestricted roles of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws VisibilityManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteAppUnrestrictedRolesByTenant(int tenantId) throws VisibilityManagementDAOException;
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/VppApplicationDAO.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/VppApplicationDAO.java
index 02aec95174..a9b637ab86 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/VppApplicationDAO.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/VppApplicationDAO.java
@@ -43,4 +43,28 @@ public interface VppApplicationDAO {
int addAssociation(VppAssociationDTO vppAssociationDTO, int tenantId) throws ApplicationManagementDAOException;
VppAssociationDTO updateAssociation(VppAssociationDTO vppAssociationDTO, int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete associations of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteAssociationByTenant(int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete Vpp users of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteVppUserByTenant(int tenantId) throws ApplicationManagementDAOException;
+
+ /**
+ * Delete assets of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws ApplicationManagementDAOException thrown if an error occurs while deleting data
+ */
+ void deleteAssetsByTenant(int tenantId) throws ApplicationManagementDAOException;
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java
index 09bea80fa5..7c71880fa6 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java
@@ -1884,4 +1884,165 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic
}
}
+ @Override
+ public void deleteAppFavouritesByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete app of tenant of id " + tenantId + " from favourites");
+ }
+ String sql = "DELETE FROM AP_APP_FAVOURITES "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing app from favourites of tenant "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing app of tenant of id " + tenantId + " from favourites. " +
+ "Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteApplicationCategoryMappingByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete application category mapping of tenant of id " + tenantId);
+ }
+ String sql = "DELETE FROM AP_APP_CATEGORY_MAPPING "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing application category mapping of tenant"
+ +tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing application category mapping of tenant of id " + tenantId +
+ "Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteApplicationCategoriesByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete application category of tenant of id " + tenantId);
+ }
+ String sql = "DELETE FROM AP_APP_CATEGORY "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing application category of tenant "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing application category of tenant of id " + tenantId +
+ "Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteApplicationTagsMappingByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete application tags mapping of tenant of id " + tenantId);
+ }
+ String sql = "DELETE FROM AP_APP_TAG_MAPPING "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing application tags mapping of tenant"
+ +tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing application tags mapping of tenant of id " + tenantId +
+ "Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteApplicationTagsByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete application tags of tenant of id " + tenantId);
+ }
+ String sql = "DELETE FROM AP_APP_TAG "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing application tags of tenant"
+ +tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing application tags of tenant of id " + tenantId +
+ "Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteApplicationsByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete applications of tenant of id " + tenantId);
+ }
+ String sql = "DELETE FROM AP_APP "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing applications of tenant"
+ +tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing applications of tenant of id " + tenantId +
+ "Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java
index 400ff9e7ef..70ad2f4e17 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java
@@ -624,4 +624,30 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
throw new ApplicationManagementDAOException(msg, e);
}
}
-}
+
+ @Override
+ public void deleteReleasesByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete application releases of tenant of id " + tenantId);
+ }
+ String sql = "DELETE FROM AP_APP_RELEASE "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing application release of tenant"
+ +tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing application release of tenant of id " + tenantId +
+ "Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+ }
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/GenericSPApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/GenericSPApplicationDAOImpl.java
index 5a5b130157..0b4d14073b 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/GenericSPApplicationDAOImpl.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/GenericSPApplicationDAOImpl.java
@@ -484,4 +484,57 @@ public class GenericSPApplicationDAOImpl extends AbstractDAOImpl implements SPAp
}
}
+ @Override
+ public void deleteIdentityServerByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete identity server of the tenant of id: " + tenantId);
+ }
+ String sql = "DELETE FROM AP_IDENTITY_SERVER " +
+ "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection to delete an identity server of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "Error occurred while executing SQL to delete an identity server of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+
+ @Override
+ public void deleteSPApplicationMappingByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete applications of tenant of id " + tenantId
+ + " from service providers");
+ }
+ String sql = "DELETE FROM AP_IS_SP_APP_MAPPING "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing applications of tenant"
+ +tenantId+ "from service providers";
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing applications of tenant of id " + tenantId +
+ "from service providers. Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/OracleSPApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/OracleSPApplicationDAOImpl.java
index d190d88296..993e9476f4 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/OracleSPApplicationDAOImpl.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/OracleSPApplicationDAOImpl.java
@@ -485,4 +485,57 @@ public class OracleSPApplicationDAOImpl extends AbstractDAOImpl implements SPAp
}
}
+ @Override
+ public void deleteIdentityServerByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete identity server of the tenant of id: " + tenantId);
+ }
+ String sql = "DELETE FROM AP_IDENTITY_SERVER " +
+ "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection to delete an identity server of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "Error occurred while executing SQL to delete an identity server of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+
+ @Override
+ public void deleteSPApplicationMappingByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete applications of tenant of id " + tenantId
+ + " from service providers");
+ }
+ String sql = "DELETE FROM AP_IS_SP_APP_MAPPING "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing applications of tenant"
+ +tenantId+ "from service providers";
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing applications of tenant of id " + tenantId +
+ "from service providers. Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/PostgreSQLSPApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/PostgreSQLSPApplicationDAOImpl.java
index d599d0db69..bc1fc660e9 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/PostgreSQLSPApplicationDAOImpl.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/PostgreSQLSPApplicationDAOImpl.java
@@ -485,4 +485,57 @@ public class PostgreSQLSPApplicationDAOImpl extends AbstractDAOImpl implements S
}
}
+ @Override
+ public void deleteIdentityServerByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete identity server of the tenant of id: " + tenantId);
+ }
+ String sql = "DELETE FROM AP_IDENTITY_SERVER " +
+ "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection to delete an identity server of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "Error occurred while executing SQL to delete an identity server of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+
+ @Override
+ public void deleteSPApplicationMappingByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete applications of tenant of id " + tenantId
+ + " from service providers");
+ }
+ String sql = "DELETE FROM AP_IS_SP_APP_MAPPING "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing applications of tenant"
+ +tenantId+ "from service providers";
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing applications of tenant of id " + tenantId +
+ "from service providers. Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/SQLServerSPApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/SQLServerSPApplicationDAOImpl.java
index 3061b96a86..5b6b2571ab 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/SQLServerSPApplicationDAOImpl.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/spapplication/SQLServerSPApplicationDAOImpl.java
@@ -485,4 +485,57 @@ public class SQLServerSPApplicationDAOImpl extends AbstractDAOImpl implements S
}
}
+ @Override
+ public void deleteIdentityServerByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete identity server of the tenant of id: " + tenantId);
+ }
+ String sql = "DELETE FROM AP_IDENTITY_SERVER " +
+ "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection to delete an identity server of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "Error occurred while executing SQL to delete an identity server of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+
+ @Override
+ public void deleteSPApplicationMappingByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete applications of tenant of id " + tenantId
+ + " from service providers");
+ }
+ String sql = "DELETE FROM AP_IS_SP_APP_MAPPING "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing applications of tenant"
+ +tenantId+ "from service providers";
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing applications of tenant of id " + tenantId +
+ "from service providers. Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java
index f1fdece953..c32afcd79a 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java
@@ -114,6 +114,32 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif
}
}
+ @Override
+ public void deleteAppLifecycleStatesByTenant(int tenantId) throws LifeCycleManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete app lifecycle states of tenant of id " + tenantId);
+ }
+ String sql = "DELETE FROM AP_APP_LIFECYCLE_STATE "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing app lifecycle states of tenant"
+ +tenantId;
+ log.error(msg, e);
+ throw new LifeCycleManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing app lifecycle states of tenant of id " + tenantId +
+ "Executed Query: " + sql;
+ log.error(msg, e);
+ throw new LifeCycleManagementDAOException(msg, e);
+ }
+ }
+
@Override
public List getLifecycleStates(int appReleaseId, int tenantId) throws LifeCycleManagementDAOException {
try {
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/GenericReviewDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/GenericReviewDAOImpl.java
index 075ba6b01f..e31db113ef 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/GenericReviewDAOImpl.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/review/GenericReviewDAOImpl.java
@@ -602,4 +602,30 @@ public class GenericReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
throw new ReviewManagementDAOException(msg, e);
}
}
+
+ @Override
+ public void deleteReviewsByTenant(int tenantId) throws ReviewManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete app reviews of tenant of id " + tenantId);
+ }
+ String sql = "DELETE FROM AP_APP_REVIEW "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing app reviews of tenant "
+ + tenantId;
+ log.error(msg, e);
+ throw new ReviewManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing app reviews of tenant of id " + tenantId +
+ "Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ReviewManagementDAOException(msg, e);
+ }
+ }
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java
index 457de13bee..79e7b76660 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java
@@ -1476,4 +1476,163 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
throw new ApplicationManagementDAOException(msg, e);
}
}
+
+ @Override
+ public void deleteOperationMappingByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete operation mapping of the tenant of id: " + tenantId);
+ }
+ String sql = "DELETE FROM AP_APP_SUB_OP_MAPPING " +
+ "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection to delete operation mapping of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "Error occurred while executing SQL to delete operation mapping of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+
+ @Override
+ public void deleteRoleSubscriptionByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete role subscription of the tenant of id: " + tenantId);
+ }
+ String sql = "DELETE FROM AP_ROLE_SUBSCRIPTION " +
+ "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection to delete role subscription of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "Error occurred while executing SQL to delete role subscription of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteUserSubscriptionByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete user subscription of the tenant of id: " + tenantId);
+ }
+ String sql = "DELETE FROM AP_USER_SUBSCRIPTION " +
+ "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection to delete user subscription of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "Error occurred while executing SQL to delete user subscription of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteGroupSubscriptionByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete user subscription of the tenant of id: " + tenantId);
+ }
+ String sql = "DELETE FROM AP_GROUP_SUBSCRIPTION " +
+ "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection to delete group subscription of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "Error occurred while executing SQL to delete group subscription of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+
+ @Override
+ public void deleteScheduledSubscriptionByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete scheduled subscription of the tenant of id: " + tenantId);
+ }
+ String sql = "DELETE FROM AP_SCHEDULED_SUBSCRIPTION " +
+ "WHERE APPLICATION_UUID IN " +
+ "(SELECT UUID FROM AP_APP_RELEASE WHERE TENANT_ID = ?)";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeBatch();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection to delete scheduled subscription of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "Error occurred while executing SQL to delete scheduled subscription of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+
+ @Override
+ public void deleteDeviceSubscriptionByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete device subscription of the tenant of id: " + tenantId);
+ }
+ String sql = "DELETE FROM AP_DEVICE_SUBSCRIPTION " +
+ "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection to delete device subscription of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "Error occurred while executing SQL to delete device subscription of tenant of id "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java
index ea0b0fb758..1033af9bef 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java
@@ -176,4 +176,32 @@ public class GenericVisibilityDAOImpl extends AbstractDAOImpl implements Visibil
throw new VisibilityManagementDAOException(msg, e);
}
}
+
+ @Override
+ public void deleteAppUnrestrictedRolesByTenant(int tenantId) throws VisibilityManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete Application unrestricted roles of tenant of ID "
+ + tenantId);
+ }
+ String sql = "DELETE "
+ + "FROM AP_UNRESTRICTED_ROLE "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection to delete application unrestricted roles of tenant: "
+ + tenantId;
+ log.error(msg, e);
+ throw new VisibilityManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "Error occurred while executing query to delete application unrestricted roles which of"
+ + " tenant Id " + tenantId + ". executed query: " + sql;
+ log.error(msg, e);
+ throw new VisibilityManagementDAOException(msg, e);
+ }
+ }
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/vpp/GenericVppApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/vpp/GenericVppApplicationDAOImpl.java
index 7ff06c41eb..8cc62b4dbc 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/vpp/GenericVppApplicationDAOImpl.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/vpp/GenericVppApplicationDAOImpl.java
@@ -506,4 +506,84 @@ public class GenericVppApplicationDAOImpl extends AbstractDAOImpl implements Vp
throw new ApplicationManagementDAOException(msg, e);
}
}
+
+ @Override
+ public void deleteAssetsByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete application releases of tenant of id " + tenantId);
+ }
+ String sql = "DELETE FROM AP_ASSETS "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing application release of tenant "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing application release of tenant of id " + tenantId +
+ " Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+ }
+
+ @Override
+ public void deleteVppUserByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete vpp user of tenant of id " + tenantId);
+ }
+ String sql = "DELETE FROM AP_VPP_USER "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing vpp user of tenant "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing vpp user of tenant of id " + tenantId +
+ "Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteAssociationByTenant(int tenantId) throws ApplicationManagementDAOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to delete association of tenant of id " + tenantId);
+ }
+ String sql = "DELETE FROM AP_VPP_ASSOCIATION "
+ + "WHERE TENANT_ID = ?";
+ try {
+ Connection conn = this.getDBConnection();
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while obtaining the DB connection when removing association of tenant"
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ } catch (SQLException e) {
+ String msg = "SQL Error occurred while removing association of tenant of id " + tenantId +
+ " Executed Query: " + sql;
+ log.error(msg, e);
+ throw new ApplicationManagementDAOException(msg, e);
+ }
+
+ }
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java
index 50c2c2b25a..efb55e60cb 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java
@@ -21,6 +21,8 @@ package io.entgra.device.mgt.core.application.mgt.core.impl;
import io.entgra.device.mgt.core.application.mgt.common.exception.FileDownloaderServiceException;
import io.entgra.device.mgt.core.application.mgt.common.exception.FileTransferServiceException;
import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException;
+import io.entgra.device.mgt.core.application.mgt.core.dao.*;
+import io.entgra.device.mgt.core.application.mgt.core.exception.*;
import io.entgra.device.mgt.core.device.mgt.common.Base64File;
import io.entgra.device.mgt.core.application.mgt.core.dao.SPApplicationDAO;
import io.entgra.device.mgt.core.application.mgt.core.util.ApplicationManagementUtil;
@@ -78,11 +80,6 @@ import io.entgra.device.mgt.core.application.mgt.common.wrapper.PublicAppWrapper
import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppReleaseWrapper;
import io.entgra.device.mgt.core.application.mgt.common.wrapper.WebAppWrapper;
import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager;
-import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationDAO;
-import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationReleaseDAO;
-import io.entgra.device.mgt.core.application.mgt.core.dao.LifecycleStateDAO;
-import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO;
-import io.entgra.device.mgt.core.application.mgt.core.dao.VisibilityDAO;
import io.entgra.device.mgt.core.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
import io.entgra.device.mgt.core.application.mgt.core.util.APIUtil;
import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException;
@@ -99,6 +96,8 @@ import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementEx
import io.entgra.device.mgt.core.device.mgt.core.dto.DeviceType;
import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService;
+import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
+import org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService;
import org.wso2.carbon.user.api.UserRealm;
import org.wso2.carbon.user.api.UserStoreException;
@@ -133,6 +132,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
private SubscriptionDAO subscriptionDAO;
private LifecycleStateManager lifecycleStateManager;
private SPApplicationDAO spApplicationDAO;
+ private VppApplicationDAO vppApplicationDAO;
+ private ReviewDAO reviewDAO;
public ApplicationManagerImpl() {
initDataAccessObjects();
@@ -146,6 +147,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
this.applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO();
this.subscriptionDAO = ApplicationManagementDAOFactory.getSubscriptionDAO();
this.spApplicationDAO = ApplicationManagementDAOFactory.getSPApplicationDAO();
+ this.vppApplicationDAO = ApplicationManagementDAOFactory.getVppApplicationDAO();
+ this.reviewDAO = ApplicationManagementDAOFactory.getCommentDAO();
}
@Override
@@ -508,6 +511,8 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
}
+ // TODO: artifact URLs are not working for Windows AppX installations https://roadmap.entgra.net/issues/11010
+ //ApplicationManagementUtil.addInstallerPathToMetadata(releaseDTO);
applicationDTO.getApplicationReleaseDTOs().clear();
applicationDTO.getApplicationReleaseDTOs().add(releaseDTO);
return applicationDTO;
@@ -2614,21 +2619,25 @@ public class ApplicationManagerImpl implements ApplicationManager {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
ApplicationDTO applicationDTO = getApplication(applicationId);
+ String sanitizedName = "";
+ if (!StringUtils.isEmpty(applicationUpdateWrapper.getName())) {
+ sanitizedName = ApplicationManagementUtil.sanitizeName(applicationUpdateWrapper.getName(),
+ Constants.ApplicationProperties.NAME );
+ }
try {
ConnectionManagerUtil.beginDBTransaction();
- if (!StringUtils.isEmpty(applicationUpdateWrapper.getName()) && !applicationDTO.getName()
- .equals(applicationUpdateWrapper.getName())) {
+ if (!StringUtils.isEmpty(sanitizedName) && !applicationDTO.getName()
+ .equals(sanitizedName)) {
if (applicationDAO
- .isExistingAppName(applicationUpdateWrapper.getName().trim(), applicationDTO.getDeviceTypeId(),
+ .isExistingAppName(sanitizedName.trim(), applicationDTO.getDeviceTypeId(),
tenantId)) {
- String msg = "Already an application registered with same name " + applicationUpdateWrapper.getName()
+ String msg = "Already an application registered with same name " + sanitizedName
+ ". Hence you can't update the application name from " + applicationDTO.getName() + " to "
- + applicationUpdateWrapper.getName();
+ + sanitizedName;
log.error(msg);
throw new BadRequestException(msg);
}
- applicationDTO.setName(ApplicationManagementUtil.sanitizeName(applicationUpdateWrapper.getName(),
- Constants.ApplicationProperties.NAME));
+ applicationDTO.setName(sanitizedName);
}
if (!StringUtils.isEmpty(applicationUpdateWrapper.getSubMethod()) && !applicationDTO.getSubType()
.equals(applicationUpdateWrapper.getSubMethod())) {
@@ -4385,4 +4394,145 @@ public class ApplicationManagerImpl implements ApplicationManager {
throw new ApplicationManagementException(msg, e);
}
}
+
+ @Override
+ public void deleteApplicationDataOfTenant(int tenantId) throws ApplicationManagementException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request is received to delete application related data of tenant with ID: " + tenantId);
+ }
+ try {
+ ConnectionManagerUtil.beginDBTransaction();
+
+ vppApplicationDAO.deleteAssociationByTenant(tenantId);
+ vppApplicationDAO.deleteVppUserByTenant(tenantId);
+ vppApplicationDAO.deleteAssetsByTenant(tenantId);
+ reviewDAO.deleteReviewsByTenant(tenantId);
+ subscriptionDAO.deleteOperationMappingByTenant(tenantId);
+ subscriptionDAO.deleteDeviceSubscriptionByTenant(tenantId);
+ subscriptionDAO.deleteGroupSubscriptionByTenant(tenantId);
+ subscriptionDAO.deleteRoleSubscriptionByTenant(tenantId);
+ subscriptionDAO.deleteUserSubscriptionByTenant(tenantId);
+ applicationDAO.deleteAppFavouritesByTenant(tenantId);
+ applicationDAO.deleteApplicationTagsMappingByTenant(tenantId);
+ applicationDAO.deleteApplicationTagsByTenant(tenantId);
+ applicationDAO.deleteApplicationCategoryMappingByTenant(tenantId);
+ applicationDAO.deleteApplicationCategoriesByTenant(tenantId);
+ subscriptionDAO.deleteScheduledSubscriptionByTenant(tenantId);
+ lifecycleStateDAO.deleteAppLifecycleStatesByTenant(tenantId);
+ applicationReleaseDAO.deleteReleasesByTenant(tenantId);
+ visibilityDAO.deleteAppUnrestrictedRolesByTenant(tenantId);
+ spApplicationDAO.deleteSPApplicationMappingByTenant(tenantId);
+ spApplicationDAO.deleteIdentityServerByTenant(tenantId);
+ applicationDAO.deleteApplicationsByTenant(tenantId);
+ APIUtil.getApplicationStorageManager().deleteAppFolderOfTenant(tenantId);
+
+ ConnectionManagerUtil.commitDBTransaction();
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while observing the database connection to delete applications for tenant with ID: "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementException(msg, e);
+ } catch (ApplicationManagementDAOException e) {
+ ConnectionManagerUtil.rollbackDBTransaction();
+ String msg = "Database access error is occurred when getting applications for tenant with ID: " + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementException(msg, e);
+ } catch (LifeCycleManagementDAOException e) {
+ ConnectionManagerUtil.rollbackDBTransaction();
+ String msg = "Error occurred while deleting life-cycle state data of application releases of the tenant"
+ + " of ID: " + tenantId ;
+ log.error(msg, e);
+ throw new ApplicationManagementException(msg, e);
+ } catch (ReviewManagementDAOException e) {
+ ConnectionManagerUtil.rollbackDBTransaction();
+ String msg = "Error occurred while deleting reviews of application releases of the applications"
+ + " of tenant ID: " + tenantId ;
+ log.error(msg, e);
+ throw new ApplicationManagementException(msg, e);
+ } catch (ApplicationStorageManagementException e) {
+ ConnectionManagerUtil.rollbackDBTransaction();
+ String msg = "Error occurred while deleting App folder of tenant"
+ + " of tenant ID: " + tenantId ;
+ log.error(msg, e);
+ throw new ApplicationManagementException(msg, e);
+ } finally {
+ ConnectionManagerUtil.closeDBConnection();
+ }
+ }
+
+ @Override
+ public void deleteApplicationDataByTenantDomain(String tenantDomain) throws ApplicationManagementException {
+ int tenantId;
+ try{
+ TenantMgtAdminService tenantMgtAdminService = new TenantMgtAdminService();
+ TenantInfoBean tenantInfoBean = tenantMgtAdminService.getTenant(tenantDomain);
+ tenantId = tenantInfoBean.getTenantId();
+
+ } catch (Exception e) {
+ String msg = "Error getting tenant ID from domain: "
+ + tenantDomain;
+ log.error(msg, e);
+ throw new ApplicationManagementException(msg, e);
+ }
+
+ try {
+ ConnectionManagerUtil.beginDBTransaction();
+
+ vppApplicationDAO.deleteAssociationByTenant(tenantId);
+ vppApplicationDAO.deleteVppUserByTenant(tenantId);
+ vppApplicationDAO.deleteAssetsByTenant(tenantId);
+ reviewDAO.deleteReviewsByTenant(tenantId);
+ subscriptionDAO.deleteOperationMappingByTenant(tenantId);
+ subscriptionDAO.deleteDeviceSubscriptionByTenant(tenantId);
+ subscriptionDAO.deleteGroupSubscriptionByTenant(tenantId);
+ subscriptionDAO.deleteRoleSubscriptionByTenant(tenantId);
+ subscriptionDAO.deleteUserSubscriptionByTenant(tenantId);
+ applicationDAO.deleteAppFavouritesByTenant(tenantId);
+ applicationDAO.deleteApplicationTagsMappingByTenant(tenantId);
+ applicationDAO.deleteApplicationTagsByTenant(tenantId);
+ applicationDAO.deleteApplicationCategoryMappingByTenant(tenantId);
+ applicationDAO.deleteApplicationCategoriesByTenant(tenantId);
+ subscriptionDAO.deleteScheduledSubscriptionByTenant(tenantId);
+ lifecycleStateDAO.deleteAppLifecycleStatesByTenant(tenantId);
+ applicationReleaseDAO.deleteReleasesByTenant(tenantId);
+ visibilityDAO.deleteAppUnrestrictedRolesByTenant(tenantId);
+ spApplicationDAO.deleteSPApplicationMappingByTenant(tenantId);
+ spApplicationDAO.deleteIdentityServerByTenant(tenantId);
+ applicationDAO.deleteApplicationsByTenant(tenantId);
+ APIUtil.getApplicationStorageManager().deleteAppFolderOfTenant(tenantId);
+
+ ConnectionManagerUtil.commitDBTransaction();
+ } catch (DBConnectionException e) {
+ String msg = "Error occurred while observing the database connection to delete applications for tenant with ID: "
+ + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementException(msg, e);
+ } catch (ApplicationManagementDAOException e) {
+ ConnectionManagerUtil.rollbackDBTransaction();
+ String msg = "Database access error is occurred when getting applications for tenant with ID: " + tenantId;
+ log.error(msg, e);
+ throw new ApplicationManagementException(msg, e);
+ } catch (LifeCycleManagementDAOException e) {
+ ConnectionManagerUtil.rollbackDBTransaction();
+ String msg = "Error occurred while deleting life-cycle state data of application releases of the tenant"
+ + " of ID: " + tenantId ;
+ log.error(msg, e);
+ throw new ApplicationManagementException(msg, e);
+ } catch (ReviewManagementDAOException e) {
+ ConnectionManagerUtil.rollbackDBTransaction();
+ String msg = "Error occurred while deleting reviews of application releases of the applications"
+ + " of tenant ID: " + tenantId ;
+ log.error(msg, e);
+ throw new ApplicationManagementException(msg, e);
+ } catch (ApplicationStorageManagementException e) {
+ ConnectionManagerUtil.rollbackDBTransaction();
+ String msg = "Error occurred while deleting App folder of tenant"
+ + " of tenant ID: " + tenantId ;
+ log.error(msg, e);
+ throw new ApplicationManagementException(msg, e);
+ } finally {
+ ConnectionManagerUtil.closeDBConnection();
+ }
+
+ }
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java
index a79a3d23ee..158361232c 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationStorageManagerImpl.java
@@ -310,4 +310,18 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
throw new StorageManagementException(msg, e);
}
}
+
+ @Override
+ public void deleteAppFolderOfTenant(int tenantId) throws ApplicationStorageManagementException{
+ String folderPath = storagePath + File.separator + tenantId;
+ File folder = new File(folderPath);
+ if (folder.exists()) {
+ try {
+ StorageManagementUtil.delete(folder);
+ } catch (IOException e) {
+ throw new ApplicationStorageManagementException(
+ "Error occurred while deleting App folder of tenant:" + tenantId, e);
+ }
+ }
+ }
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileDownloaderServiceProvider.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileDownloaderServiceProvider.java
index 73facdc367..f8fe6f2f94 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileDownloaderServiceProvider.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/FileDownloaderServiceProvider.java
@@ -27,6 +27,7 @@ import io.entgra.device.mgt.core.application.mgt.common.exception.FileTransferSe
import io.entgra.device.mgt.core.application.mgt.common.services.FileDownloaderService;
import io.entgra.device.mgt.core.application.mgt.common.services.FileTransferService;
import io.entgra.device.mgt.core.application.mgt.core.internal.DataHolder;
+import io.entgra.device.mgt.core.application.mgt.core.util.Constants;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
@@ -111,10 +112,18 @@ public class FileDownloaderServiceProvider {
throw new FileDownloaderServiceException("Unexpected response code received for the remote url " + downloadUrl);
}
String contentDisposition = response.header("Content-Disposition");
- String[] fileNameSegments = getFileNameSegments(contentDisposition);
+ String contentType = response.header("Content-Type");
+ String[] fileNameSegments = extractFileNameSegmentsFromUrl(downloadUrl);
+
+ // if the url parsing failed to resolve the file name segments
+ // falling to remote file name segment resolving
+ if (fileNameSegments == null) {
+ fileNameSegments = getFileNameSegments(contentDisposition, contentType);
+ }
+
FileMetaEntry fileMetaEntry = new FileMetaEntry();
fileMetaEntry.setSize(Long.parseLong(Objects.requireNonNull(response.header("Content-Length"))));
- fileMetaEntry.setFileName(fileNameSegments[0] + "-" + UUID.randomUUID());
+ fileMetaEntry.setFileName(fileNameSegments[0]);
fileMetaEntry.setExtension(fileNameSegments[1]);
return fileMetaEntry;
} catch (IOException e) {
@@ -123,15 +132,70 @@ public class FileDownloaderServiceProvider {
}
/**
- * Extract file name segments(filename & extensions) from content disposition header
+ * Extracting file name segments by parsing the URL
+ * @param url Remote URL to extract file name segments
+ * @return Array containing file name segments or null when failed to extract
+ */
+ public static String[] extractFileNameSegmentsFromUrl(URL url) {
+ if (url == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Null received as the remote URL");
+ }
+ return null;
+ }
+
+ String []urlSegments = url.toString().split("/");
+ if (urlSegments.length < 1) {
+ if (log.isDebugEnabled()) {
+ log.debug("Cannot determine the file name for the remote file");
+ }
+ return null;
+ }
+
+ String fullQualifiedName = urlSegments[urlSegments.length - 1];
+ String []fileNameSegments = fullQualifiedName.split("\\.(?=[^.]+$)");
+ if (fileNameSegments.length != 2) {
+ if (log.isDebugEnabled()) {
+ log.debug("Error encountered when constructing file name");
+ }
+ return null;
+ }
+ return fileNameSegments;
+ }
+
+ /**
+ * Extract file name segments(filename & extensions) from content disposition header and content type header
* @param contentDisposition Content disposition header value
+ * @param contentType Content type header value
* @return Array of name segments
* @throws FileDownloaderServiceException Throws when error occurred while extracting name segments
*/
- private static String[] getFileNameSegments(String contentDisposition) throws FileDownloaderServiceException {
- if (contentDisposition == null) {
+ private static String[] getFileNameSegments(String contentDisposition, String contentType) throws FileDownloaderServiceException {
+ if (contentDisposition == null && contentType == null) {
throw new FileDownloaderServiceException("Cannot determine the file name for the remote file");
}
+
+ if (contentDisposition == null) {
+ String extension;
+ if (contentType.equals(Constants.MIME_TYPE_VND_ANDROID_PACKAGE_ARCHIVE)) {
+ extension = Constants.EXTENSION_APK;
+ } else if (contentType.equals(Constants.MIME_TYPE_OCTET_STREAM)) {
+ extension = Constants.EXTENSION_IPA;
+ } else if (contentType.equals(Constants.MIME_TYPE_VND_APPX)) {
+ extension = Constants.EXTENSION_APPX;
+ } else if (contentType.equals(Constants.MIME_TYPE_X_MS_INSTALLER)
+ || contentType.equals(Constants.MIME_TYPE_VND_MS_WINDOWS_MSI)) {
+ extension = Constants.EXTENSION_MSI;
+ } else {
+ String []contentTypeSegments = contentType.split("/");
+ if (contentTypeSegments.length != 2) {
+ throw new FileDownloaderServiceException("Encountered wrong content type header value");
+ }
+ extension = contentTypeSegments[contentTypeSegments.length - 1];
+ }
+ return new String[]{ UUID.randomUUID().toString(), extension};
+ }
+
String []contentDispositionSegments = contentDisposition.split("=");
if (contentDispositionSegments.length != 2) {
throw new FileDownloaderServiceException("Error encountered when constructing file name");
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java
index 789ac3de0a..7c2034eb11 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java
@@ -496,7 +496,6 @@ public class APIUtil {
List screenshotPaths = new ArrayList<>();
ApplicationRelease applicationRelease = new ApplicationRelease();
- UrlValidator urlValidator = new UrlValidator();
applicationRelease.setDescription(applicationReleaseDTO.getDescription());
applicationRelease.setVersion(applicationReleaseDTO.getVersion());
@@ -519,13 +518,8 @@ public class APIUtil {
.getBannerName());
}
- if (urlValidator.isValid(applicationReleaseDTO.getInstallerName())) {
- applicationRelease.setInstallerPath(applicationReleaseDTO.getInstallerName());
- } else {
- applicationRelease.setInstallerPath(
- basePath + Constants.APP_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO
- .getInstallerName());
- }
+ applicationRelease.setInstallerPath(constructInstallerPath(applicationReleaseDTO.getInstallerName(),
+ applicationReleaseDTO.getAppHashValue()));
if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName1())) {
screenshotPaths
@@ -546,6 +540,21 @@ public class APIUtil {
return applicationRelease;
}
+ /**
+ * Construct installer path
+ * @param installerName Installer name
+ * @param appHash Application hash
+ * @return Constructed installer path value
+ * @throws ApplicationManagementException Throws when error encountered while constructing installer path
+ */
+ public static String constructInstallerPath(String installerName, String appHash) throws ApplicationManagementException {
+ int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
+ UrlValidator urlValidator = new UrlValidator();
+ String basePath = getArtifactDownloadBaseURL() + tenantId + Constants.FORWARD_SLASH + appHash + Constants.FORWARD_SLASH;
+ return urlValidator.isValid(installerName) ? installerName
+ : basePath + Constants.APP_ARTIFACT + Constants.FORWARD_SLASH + installerName;
+ }
+
public static String getArtifactDownloadBaseURL() throws ApplicationManagementException {
String host = System.getProperty(Constants.IOT_CORE_HOST);
MDMConfig mdmConfig = ConfigurationManager.getInstance().getConfiguration().getMdmConfig();
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationManagementUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationManagementUtil.java
index b3b2d65f0a..846777c794 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationManagementUtil.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/ApplicationManagementUtil.java
@@ -17,11 +17,16 @@
*/
package io.entgra.device.mgt.core.application.mgt.core.util;
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
import io.entgra.device.mgt.core.application.mgt.common.ApplicationArtifact;
import io.entgra.device.mgt.core.application.mgt.common.FileDataHolder;
import io.entgra.device.mgt.core.application.mgt.common.FileDescriptor;
import io.entgra.device.mgt.core.application.mgt.common.LifecycleChanger;
import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO;
+import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.ItuneAppDTO;
import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException;
import io.entgra.device.mgt.core.application.mgt.common.exception.FileDownloaderServiceException;
@@ -60,6 +65,7 @@ import io.entgra.device.mgt.core.device.mgt.core.common.util.FileUtil;
import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.MetadataManagementServiceImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jetbrains.annotations.NotNull;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -80,6 +86,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.TreeMap;
/**
@@ -649,4 +656,62 @@ public class ApplicationManagementUtil {
}
return releaseWrappers;
}
+
+ /**
+ * Add installer path metadata value to windows applications
+ * @param applicationReleaseDTO {@link ApplicationReleaseDTO}
+ * @throws ApplicationManagementException Throws when error encountered while updating the app metadata
+ */
+ public static void addInstallerPathToMetadata(ApplicationReleaseDTO applicationReleaseDTO)
+ throws ApplicationManagementException {
+ if (applicationReleaseDTO.getMetaData() == null) return;
+ Gson gson = new Gson();
+ String installerPath = APIUtil.constructInstallerPath(applicationReleaseDTO.getInstallerName(), applicationReleaseDTO.getAppHashValue());
+ String[] fileNameSegments = extractNameSegments(applicationReleaseDTO, installerPath);
+ String extension = fileNameSegments[fileNameSegments.length - 1];
+ if (!Objects.equals(extension, "appx") && !Objects.equals(extension, "msi")) {
+ return;
+ }
+
+ String installerPaths = "[ {" +
+ "\"key\": \"Content_Uri\", " +
+ "\"value\" : \"" + installerPath + "\"" +
+ "}]";
+
+ if (Objects.equals(extension, "appx")) {
+ installerPaths = "[ {" +
+ "\"key\": \"Package_Url\", " +
+ "\"value\" : \"" + installerPath + "\"" +
+ "}]";
+ }
+
+ JsonArray parsedMetadataList = gson.fromJson(applicationReleaseDTO.getMetaData(), JsonArray.class);
+ JsonArray installerPathsArray = gson.fromJson(installerPaths, JsonArray.class);
+ parsedMetadataList.addAll(installerPathsArray);
+ applicationReleaseDTO.setMetaData(gson.toJson(parsedMetadataList));
+ }
+
+ /**
+ * Extract name segments from installer path
+ * @param applicationReleaseDTO {@link ApplicationReleaseDTO}
+ * @param installerPath Installer path
+ * @return Extracted file name segments
+ * @throws ApplicationManagementException Throws when error encountered while extracting name segments from installer path
+ */
+ private static String[] extractNameSegments(ApplicationReleaseDTO applicationReleaseDTO, String installerPath)
+ throws ApplicationManagementException {
+ String []installerPathSegments = installerPath.split("/");
+ if (installerPathSegments.length == 0) {
+ throw new ApplicationManagementException("Received malformed url for installer path of the app : "
+ + applicationReleaseDTO.getInstallerName());
+ }
+ String fullQualifiedName = installerPathSegments[installerPathSegments.length - 1];
+ String []fileNameSegments = fullQualifiedName.split("\\.(?=[^.]+$)");
+ if (fileNameSegments.length != 2) {
+ throw new ApplicationManagementException("Received malformed url for installer path of the app : "
+ + applicationReleaseDTO.getInstallerName());
+ }
+ return fileNameSegments;
+ }
+
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java
index b96fd66058..b5b5fd5154 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/Constants.java
@@ -220,4 +220,14 @@ public class Constants {
*/
public static final int MAX_APP_NAME_CHARACTERS = 350;
public static final String APP_NAME_REGEX = "[^a-zA-Z0-9.\\s-]";
+
+ public static final String EXTENSION_APK = ".apk";
+ public static final String EXTENSION_IPA = ".ipa";
+ public static final String EXTENSION_MSI = ".msi";
+ public static final String EXTENSION_APPX = ".appx";
+ public static final String MIME_TYPE_OCTET_STREAM = "application/octet-stream";
+ public static final String MIME_TYPE_VND_ANDROID_PACKAGE_ARCHIVE = "application/vnd.android.package-archive";
+ public static final String MIME_TYPE_VND_MS_WINDOWS_MSI = "application/vnd.ms-windows.msi";
+ public static final String MIME_TYPE_X_MS_INSTALLER = "application/x-ms-installer";
+ public static final String MIME_TYPE_VND_APPX = "application/vnd.appx";
}
diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/management/ApplicationManagementTest.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/management/ApplicationManagementTest.java
index e78b6196d0..793b28d0f9 100644
--- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/management/ApplicationManagementTest.java
+++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/test/java/io/entgra/device/mgt/core/application/mgt/core/management/ApplicationManagementTest.java
@@ -107,7 +107,7 @@ public class ApplicationManagementTest extends BaseTestCase {
EntAppReleaseWrapper releaseWrapper = new EntAppReleaseWrapper();
releaseWrapper.setDescription("First release");
releaseWrapper.setIsSharedWithAllTenants(false);
- releaseWrapper.setMetaData("Just meta data");
+ releaseWrapper.setMetaData("[{\"key\": \"Just a metadata\"}]");
releaseWrapper.setReleaseType("free");
releaseWrapper.setPrice(5.7);
releaseWrapper.setSupportedOsVersions("4.0-7.0");
diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml
index fa161d4500..360dad0a6c 100644
--- a/components/application-mgt/pom.xml
+++ b/components/application-mgt/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml
index 0fcb0039f1..254c6ad535 100644
--- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
cea-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml
index 2a0a4eea20..2e6e9efc5b 100644
--- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml
@@ -23,7 +23,7 @@
io.entgra.device.mgt.core
cea-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml
index 77cb92489d..ec906b7507 100644
--- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.core/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
cea-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml
index 8c3ed4c63c..09822882ff 100644
--- a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.enforce/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
cea-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/cea-mgt/pom.xml b/components/cea-mgt/pom.xml
index 0164f1703e..665b30df0c 100644
--- a/components/cea-mgt/pom.xml
+++ b/components/cea-mgt/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml
index 151bb29dd4..29bef57226 100644
--- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml
+++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api/pom.xml
@@ -22,7 +22,7 @@
certificate-mgt
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml
index 15181403d8..03b8374637 100644
--- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml
+++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api/pom.xml
@@ -22,7 +22,7 @@
certificate-mgt
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml
index b6dce37a13..53c8057109 100644
--- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml
+++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
certificate-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml
index 138f8e3b17..62ba9f87aa 100644
--- a/components/certificate-mgt/pom.xml
+++ b/components/certificate-mgt/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml
index 9d9580d203..07e7b949c5 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml
index d28ffb8b94..55aea2d343 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml
index 2aa594ec89..92cbacef55 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql
index 158615a137..046e93de83 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql
@@ -116,6 +116,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION
OPERATION_CODE VARCHAR(1000) NOT NULL,
INITIATED_BY VARCHAR(100) NULL,
OPERATION_DETAILS BLOB DEFAULT NULL,
+ OPERATION_PROPERTIES BLOB DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (ID)
);
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/sql/h2.sql b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/sql/h2.sql
index b4d2bde228..c079d1e214 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/sql/h2.sql
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization/src/test/resources/sql/h2.sql
@@ -140,6 +140,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
OPERATION_CODE VARCHAR(1000) NOT NULL,
INITIATED_BY VARCHAR(100) NULL,
OPERATION_DETAILS BLOB DEFAULT NULL,
+ OPERATION_PROPERTIES BLOB DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID)
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml
index fc3f0fbc06..cce520cc68 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml
index 729cfca98a..34427cb7de 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger/pom.xml
@@ -21,7 +21,7 @@
device-mgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml
index f2c5c88d31..90e4d05ed7 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.pull.notification/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml
index 2296ef71e3..ffb529ef29 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml
index 166daf727e..8909230131 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml
index 07996a400b..167b1dcc67 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml
index f020ccbbb1..6546e5d8f2 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml
index 29fa228111..efe179f503 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml
index 5204eec39a..4c0f550469 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensions
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml
index 6059343d83..5912b6f830 100644
--- a/components/device-mgt-extensions/pom.xml
+++ b/components/device-mgt-extensions/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core.parent
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml
index 089107bd7f..d975ad3715 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml
@@ -22,7 +22,7 @@
device-mgt
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/AccessAuthorizationService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/AccessAuthorizationService.java
new file mode 100644
index 0000000000..1de058f4fc
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/AccessAuthorizationService.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.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 io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api;
+
+import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse;
+import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAuthorizationRequest;
+import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAuthorizationRequest;
+import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAuthorizationResult;
+import io.swagger.annotations.*;
+import org.apache.axis2.transport.http.HTTPConstants;
+
+import javax.validation.Valid;
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+@SwaggerDefinition(
+ info = @Info(
+ version = "1.0.0",
+ title = "",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = "name", value = "AccessAuthorizationService"),
+ @ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/access"),
+ })
+ }
+ ),
+ tags = {
+ @Tag(name = "device_management", description = "")
+ }
+)
+@Path("/access")
+@Api(value = "AccessAuthorizationService", description = "This API carries all device group management related " +
+ "access authorization")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface AccessAuthorizationService {
+
+ @POST
+ @Path("/device")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = HTTPConstants.HEADER_GET,
+ value = "check device access authorization",
+ notes = "Returns device access acutorization info",
+ tags = "device_management"
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 201,
+ message = "Created. \n Device group has successfully been created",
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Location",
+ description = "The URL of the added group."),
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "The content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource has been modified the last time" +
+ ".\n" + "Used by caches, or in conditional requests.")
+ }
+ ),
+ @ApiResponse(
+ code = 303,
+ message = "See Other. \n Source can be retrieved from the URL specified at the Location " +
+ "header.",
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Location",
+ description = "The Source URL of the document.")}),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 401,
+ message = "Unauthorized. \n Current logged in user is not authorized for this request",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 415,
+ message = "Unsupported media type. \n The entity of the request was in a not supported " +
+ "format."),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while checking access",
+ response = ErrorResponse.class)
+ })
+ Response checkDeviceAccess(
+ @ApiParam(
+ name = "deviceAccessRequest",
+ value = "Define the device access request object with data.",
+ required = true)
+ @Valid DeviceAuthorizationRequest deviceAuthorizationRequest);
+
+ @POST
+ @Path("/group")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = HTTPConstants.HEADER_GET,
+ value = "check device access authorization",
+ notes = "Returns device access acutorization info",
+ tags = "device_management"
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 201,
+ message = "Created. \n Device group has successfully been created",
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Location",
+ description = "The URL of the added group."),
+ @ResponseHeader(
+ name = "Content-Type",
+ description = "The content type of the body"),
+ @ResponseHeader(
+ name = "ETag",
+ description = "Entity Tag of the response resource.\n" +
+ "Used by caches, or in conditional requests."),
+ @ResponseHeader(
+ name = "Last-Modified",
+ description = "Date and time the resource has been modified the last time" +
+ ".\n" + "Used by caches, or in conditional requests.")
+ }
+ ),
+ @ApiResponse(
+ code = 303,
+ message = "See Other. \n Source can be retrieved from the URL specified at the Location " +
+ "header.",
+ responseHeaders = {
+ @ResponseHeader(
+ name = "Content-Location",
+ description = "The Source URL of the document.")}),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 401,
+ message = "Unauthorized. \n Current logged in user is not authorized for this request",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 415,
+ message = "Unsupported media type. \n The entity of the request was in a not supported " +
+ "format."),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while checking access",
+ response = ErrorResponse.class)
+ })
+ Response checkGroupAccess(
+ @ApiParam(
+ name = "groupAccessRequest",
+ value = "Define the group access request object with data.",
+ required = true)
+ @Valid GroupAuthorizationRequest request);
+}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java
index 7cc2aaf0bf..27d855b3b1 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java
@@ -491,7 +491,7 @@ public interface ActivityInfoProviderService {
name = "status",
value = "Operation response status to filter"
)
- @QueryParam("status") String status,
+ @QueryParam("status") List statuses,
@ApiParam(
name = "If-Modified-Since",
value = "Checks if the requested variant was modified, since the specified date-time\n." +
@@ -615,7 +615,7 @@ public interface ActivityInfoProviderService {
name = "status",
value = "Operation response status to filter"
)
- @QueryParam("status") String status,
+ @QueryParam("status") List statuses,
@ApiParam(
name = "If-Modified-Since",
value = "Checks if the requested variant was modified, since the specified date-time\n." +
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/UserManagementAdminService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/UserManagementAdminService.java
index a62341756e..5d324aeb02 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/UserManagementAdminService.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/UserManagementAdminService.java
@@ -61,6 +61,13 @@ import javax.ws.rs.core.Response;
key = "um:admin:users:remove",
roles = {"Internal/devicemgt-admin"},
permissions = {"/device-mgt/admin/users/delete"}
+ ),
+ @Scope(
+ name = "Delete Tenant Information",
+ description = "Delete tenant details",
+ key = "um:admin:tenants:remove",
+ roles = {"Internal/devicemgt-admin"},
+ permissions = {"/device-mgt/admin/tenants/delete"}
)
}
)
@@ -258,5 +265,41 @@ public interface UserManagementAdminService {
@Size(max = 45)
String deviceId);
+ @DELETE
+ @Path("/domain/{tenantDomain}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ApiOperation(
+ consumes = MediaType.APPLICATION_JSON,
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "DELETE",
+ value = "Delete a tenant by tenant domain.",
+ notes = "This API allows the deletion of a tenant by providing the tenant domain.",
+ tags = "Tenant details remove",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "um:admin:tenants:remove")
+ })
+ }
+ )
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "OK. \n Tenant has been deleted successfully."),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n The tenant with the provided domain does not exist.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n Server error occurred while removing the tenant.",
+ response = ErrorResponse.class)
+ })
+ Response deleteTenantByDomain(
+ @ApiParam(
+ name = "tenantDomain",
+ value = "The domain of the tenant to be deleted.",
+ required = true)
+
+ @PathParam("tenantDomain")
+ String tenantDomain);
}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/AccessAuthorizationServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/AccessAuthorizationServiceImpl.java
new file mode 100644
index 0000000000..f6d555a273
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/AccessAuthorizationServiceImpl.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.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 io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl;
+
+import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.AccessAuthorizationService;
+import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils;
+import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier;
+import io.entgra.device.mgt.core.device.mgt.common.authorization.*;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class AccessAuthorizationServiceImpl implements AccessAuthorizationService {
+
+ private static final Log log = LogFactory.getLog(AccessAuthorizationServiceImpl.class);
+ @Override
+ public Response checkDeviceAccess(DeviceAuthorizationRequest deviceAuthorizationRequest) {
+
+ if (StringUtils.isEmpty(deviceAuthorizationRequest.getType())) {
+ String msg = "device type not specified";
+ return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
+ }
+
+ if (deviceAuthorizationRequest.getDeviceIds().isEmpty()) {
+ String msg = "device ids not specified";
+ return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
+ }
+
+ if (deviceAuthorizationRequest.getPermissions().isEmpty()) {
+ String msg = "permissions not specified";
+ return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
+ }
+
+ List deviceIdentifiers = new ArrayList<>();
+ for(String id : deviceAuthorizationRequest.getDeviceIds()) {
+ DeviceIdentifier identifier = new DeviceIdentifier(id, deviceAuthorizationRequest.getType());
+ deviceIdentifiers.add(identifier);
+ }
+ try {
+ DeviceAuthorizationResult result = DeviceMgtAPIUtils.getDeviceAccessAuthorizationService()
+ .isUserAuthorized(deviceIdentifiers, deviceAuthorizationRequest.getUsername(),
+ deviceAuthorizationRequest.getPermissions().toArray(new String[0]));
+ return Response.status(Response.Status.OK).entity(result).build();
+ } catch (DeviceAccessAuthorizationException e) {
+ String msg = "Error occurred while checking access info";
+ log.error(msg, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ }
+ }
+
+ @Override
+ public Response checkGroupAccess(GroupAuthorizationRequest request) {
+
+ if (request.getGroupIds().isEmpty()) {
+ String msg = "group ids not specified";
+ return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
+ }
+
+ if (request.getPermissions().isEmpty()) {
+ String msg = "permissions not specified";
+ return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
+ }
+
+ try {
+ GroupAuthorizationResult result = DeviceMgtAPIUtils.getGroupAccessAuthorizationService()
+ .isUserAuthorized(request.getGroupIds(), request.getUsername(),
+ request.getPermissions().toArray(new String[0]));
+ return Response.status(Response.Status.OK).entity(result).build();
+ } catch (GroupAccessAuthorizationException e) {
+ String msg = "Error occurred while checking access info";
+ log.error(msg, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ }
+ }
+}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java
index 2fca4e46f3..a4148f07a8 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java
@@ -50,6 +50,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -259,7 +260,7 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
@QueryParam("deviceType") String deviceType,
@QueryParam("deviceId") List deviceIds,
@QueryParam("type") String type,
- @QueryParam("status") String status,
+ @QueryParam("status") List statuses,
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@QueryParam("startTimestamp") long startTimestamp,
@QueryParam("endTimestamp") long endTimestamp) {
@@ -336,8 +337,12 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
if (type != null && !type.isEmpty()) {
activityPaginationRequest.setType(Operation.Type.valueOf(type.toUpperCase()));
}
- if (status != null && !status.isEmpty()) {
- activityPaginationRequest.setStatus(Operation.Status.valueOf(status.toUpperCase()));
+ if (statuses != null && !statuses.isEmpty()) {
+ List statusEnums = new ArrayList<>();
+ for (String status : statuses) {
+ statusEnums.add(Operation.Status.valueOf(status.toUpperCase()));
+ }
+ activityPaginationRequest.setStatuses(statusEnums);
}
if (timestamp > 0) {
activityPaginationRequest.setSince(timestamp);
@@ -382,7 +387,7 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
@QueryParam("deviceType") String deviceType,
@QueryParam("deviceId") List deviceIds,
@QueryParam("type") String type,
- @QueryParam("status") String status,
+ @QueryParam("status") List statuses,
@HeaderParam("If-Modified-Since") String ifModifiedSince,
@QueryParam("startTimestamp") long startTimestamp,
@QueryParam("endTimestamp") long endTimestamp) {
@@ -457,8 +462,12 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService
if (type != null && !type.isEmpty()) {
activityPaginationRequest.setType(Operation.Type.valueOf(type.toUpperCase()));
}
- if (status != null && !status.isEmpty()) {
- activityPaginationRequest.setStatus(Operation.Status.valueOf(status.toUpperCase()));
+ if (statuses != null && !statuses.isEmpty()) {
+ List statusEnums = new ArrayList<>();
+ for (String status : statuses) {
+ statusEnums.add(Operation.Status.valueOf(status.toUpperCase()));
+ }
+ activityPaginationRequest.setStatuses(statusEnums);
}
if (timestamp > 0) {
activityPaginationRequest.setSince(timestamp);
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceImpl.java
index 32313062b6..4231ecc41e 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceImpl.java
@@ -21,6 +21,7 @@ import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
+import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
import org.apache.axis2.AxisFault;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -167,7 +168,9 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
DeviceMgtAPIUtils.getDeviceAccessAuthorizationService();
boolean status;
try {
- status = deviceAccessAuthorizationService.isUserAuthorized(new DeviceIdentifier(id, type));
+ String requiredPermission = PermissionManagerServiceImpl.getInstance().getRequiredPermission();
+ String[] requiredPermissions = new String[] {requiredPermission};
+ status = deviceAccessAuthorizationService.isUserAuthorized(new DeviceIdentifier(id, type), requiredPermissions);
} catch (DeviceAccessAuthorizationException e) {
String msg = "Error occurred while modifying enrollment of the Android device that carries the id '" +
id + "'";
@@ -229,8 +232,10 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
String msg = "invalid payload structure";
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} else {
+ String requiredPermission = PermissionManagerServiceImpl.getInstance().getRequiredPermission();
+ String[] requiredPermissions = new String[] {requiredPermission};
boolean authorized = DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized
- (new DeviceIdentifier(type, deviceId));
+ (new DeviceIdentifier(type, deviceId), requiredPermissions);
if (!authorized) {
String msg = "Does not have permission to access the device.";
return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build();
@@ -329,8 +334,10 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
String msg = "Invalid payload structure";
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} else {
+ String requiredPermission = PermissionManagerServiceImpl.getInstance().getRequiredPermission();
+ String[] requiredPermissions = new String[] {requiredPermission};
boolean authorized = DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized
- (new DeviceIdentifier(type, deviceId));
+ (new DeviceIdentifier(type, deviceId), requiredPermissions);
if (!authorized) {
String msg = "Does not have permission to access the device.";
return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build();
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java
index d8f028c928..58259e19c8 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java
@@ -28,6 +28,7 @@ import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionMan
import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil;
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.DisenrollRequest;
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtUtil;
+import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
@@ -580,7 +581,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
String authorizedUser = CarbonContext.getThreadLocalCarbonContext().getUsername();
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(id, type);
// check whether the user is authorized
- if (!deviceAccessAuthorizationService.isUserAuthorized(deviceIdentifier, authorizedUser)) {
+ String requiredPermission = PermissionManagerServiceImpl.getInstance().getRequiredPermission();
+ String[] requiredPermissions = new String[] {requiredPermission};
+ if (!deviceAccessAuthorizationService.isUserAuthorized(deviceIdentifier, authorizedUser, requiredPermissions)) {
String msg = "User '" + authorizedUser + "' is not authorized to retrieve the given device id '" + id + "'";
log.error(msg);
return Response.status(Response.Status.UNAUTHORIZED).entity(
@@ -716,7 +719,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
}
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(id, device.getType());
// check whether the user is authorized
- if (!deviceAccessAuthorizationService.isUserAuthorized(deviceIdentifier, authorizedUser)) {
+ String requiredPermission = PermissionManagerServiceImpl.getInstance().getRequiredPermission();
+ String[] requiredPermissions = new String[] {requiredPermission};
+ if (!deviceAccessAuthorizationService.isUserAuthorized(deviceIdentifier, authorizedUser, requiredPermissions)) {
String message = "User '" + authorizedUser + "' is not authorized to retrieve the given " +
"device id '" + id + "'";
log.error(message);
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/PolicyManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/PolicyManagementServiceImpl.java
index 2a8e6357cc..311b4292a7 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/PolicyManagementServiceImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/PolicyManagementServiceImpl.java
@@ -18,6 +18,7 @@
package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl;
import io.entgra.device.mgt.core.device.mgt.common.PolicyPaginationRequest;
+import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
@@ -85,7 +86,9 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
String username = threadLocalCarbonContext.getUsername();
try {
- if (!deviceAccessAuthorizationService.isUserAuthorized(deviceIdentifier, username)) {
+ String requiredPermission = PermissionManagerServiceImpl.getInstance().getRequiredPermission();
+ String[] requiredPermissions = new String[] {requiredPermission};
+ if (!deviceAccessAuthorizationService.isUserAuthorized(deviceIdentifier, username, requiredPermissions)) {
return Response.status(Response.Status.UNAUTHORIZED).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage
("Current logged in user is not authorized to add policies").build()).build();
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java
index 748989879f..43c98523a5 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java
@@ -574,7 +574,7 @@ public class UserManagementServiceImpl implements UserManagementService {
basicUserInfo.setEmailAddress(getClaimValue(user, Constants.USER_CLAIM_EMAIL_ADDRESS));
basicUserInfo.setFirstname(getClaimValue(user, Constants.USER_CLAIM_FIRST_NAME));
basicUserInfo.setLastname(getClaimValue(user, Constants.USER_CLAIM_LAST_NAME));
- basicUserInfo.setRemovable(isUserRemovable(username));
+ basicUserInfo.setRemovable(isUserRemovable(user));
filteredUserList.add(basicUserInfo);
}
}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java
index fe2b5edd78..ec8c3a65f7 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java
@@ -172,6 +172,9 @@ public class GroupManagementAdminServiceImpl implements GroupManagementAdminServ
if (group == null) {
return Response.status(Response.Status.BAD_REQUEST).build();
}
+ if (StringUtils.isEmpty(group.getOwner())) {
+ group.setOwner(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername());
+ }
group.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE);
try {
DeviceMgtAPIUtils.getGroupManagementProviderService().createGroup(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS);
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java
index 26cd8c4c54..d4f34d8e4a 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java
@@ -17,6 +17,8 @@
*/
package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.admin;
+import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException;
+import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier;
@@ -25,6 +27,11 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.PasswordResetWrapper
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.UserManagementAdminService;
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.CredentialManagementResponseBuilder;
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils;
+import org.wso2.carbon.base.MultitenantConstants;
+import org.wso2.carbon.context.CarbonContext;
+import org.wso2.carbon.stratos.common.exception.StratosException;
+import org.wso2.carbon.tenant.mgt.services.TenantMgtAdminService;
+import org.wso2.carbon.user.api.UserStoreException;
import javax.validation.constraints.Size;
import javax.ws.rs.*;
@@ -81,4 +88,38 @@ public class UserManagementAdminServiceImpl implements UserManagementAdminServic
}
}
+ @DELETE
+ @Path("/domain/{tenantDomain}")
+ @Override
+ public Response deleteTenantByDomain(@PathParam("tenantDomain") String tenantDomain) {
+ try {
+ int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
+ if (tenantId != MultitenantConstants.SUPER_TENANT_ID){
+ String msg = "Only super tenants are allowed to delete tenants";
+ log.error(msg);
+ return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build();
+ } else {
+ DeviceMgtAPIUtils.getApplicationManager().deleteApplicationDataByTenantDomain(tenantDomain);
+ DeviceMgtAPIUtils.getDeviceManagementService().deleteDeviceDataByTenantDomain(tenantDomain);
+ TenantMgtAdminService tenantMgtAdminService = new TenantMgtAdminService();
+ tenantMgtAdminService.deleteTenant(tenantDomain);
+ String msg = "Tenant Deletion process has been initiated for tenant:" + tenantDomain;
+ return Response.status(Response.Status.OK).entity(msg).build();
+ }
+
+ } catch (StratosException | UserStoreException e) {
+ String msg = "Error deleting tenant: " + tenantDomain;
+ log.error(msg, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ } catch (ApplicationManagementException e) {
+ String msg = "Error deleting application data of tenant: " + tenantDomain;
+ log.error(msg, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ } catch (DeviceManagementException e) {
+ String msg = "Error deleting device data of tenant: " + tenantDomain;
+ log.error(msg, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ }
+ }
+
}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java
index 6de5d1d1ca..885d521389 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java
@@ -21,7 +21,9 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util;
import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherService;
import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager;
import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager;
+import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAccessAuthorizationService;
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService;
+import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Options;
import org.apache.axis2.java.security.SSLProtocolSocketFactory;
@@ -342,6 +344,17 @@ public class DeviceMgtAPIUtils {
return deviceAccessAuthorizationService;
}
+ public static GroupAccessAuthorizationService getGroupAccessAuthorizationService() {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ GroupAccessAuthorizationService groupAccessAuthorizationService =
+ (GroupAccessAuthorizationService) ctx.getOSGiService(GroupAccessAuthorizationService.class, null);
+ if (groupAccessAuthorizationService == null) {
+ String msg = "GroupAccessAuthorizationService service has not initialized.";
+ log.error(msg);
+ throw new IllegalStateException(msg);
+ }
+ return groupAccessAuthorizationService;
+ }
public static GroupManagementProviderService getGroupManagementProviderService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
GroupManagementProviderService groupManagementProviderService =
@@ -1111,7 +1124,9 @@ public class DeviceMgtAPIUtils {
RequestValidationUtil.validateDeviceIdentifier(deviceType, identifier);
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(identifier, deviceType);
- if (!getDeviceAccessAuthorizationService().isUserAuthorized(deviceIdentifier, authorizedUser)) {
+ String requiredPermission = PermissionManagerServiceImpl.getInstance().getRequiredPermission();
+ String[] requiredPermissions = new String[] {requiredPermission};
+ if (!getDeviceAccessAuthorizationService().isUserAuthorized(deviceIdentifier, authorizedUser, requiredPermissions)) {
String msg = "User '" + authorizedUser + "' is not authorized to retrieve the given device id '" +
identifier + "'";
log.error(msg);
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImplTest.java
index 5a6d9d0983..59baa18242 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImplTest.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImplTest.java
@@ -132,7 +132,7 @@ public class ActivityProviderServiceImplTest {
activityPaginationRequest.setDeviceType(DEVICE_TYPE_2);
activityPaginationRequest.setOperationId(OPERATION_ID);
activityPaginationRequest.setInitiatedBy(INITIATED_BY);
- activityPaginationRequest.setStatus(STATUS);
+ activityPaginationRequest.setStatuses(Collections.singletonList(STATUS));
activityPaginationRequest.setType(TYPE);
activityPaginationRequest.setStartTimestamp(0);
activityPaginationRequest.setEndTimestamp(0);
@@ -226,7 +226,7 @@ public class ActivityProviderServiceImplTest {
Mockito.when(this.deviceManagementProviderService.getActivities(Mockito.any())).thenReturn(activities);
Response response = this.activityInfoProviderService.getActivities(
OFFSET, LIMIT, SINCE, INITIATED_BY, OPERATION_CODE, OPERATION_ID,
- DEVICE_TYPE_2, Collections.singletonList(DEVICE_ID), TYPE.toString(), STATUS.toString(), null, 0, 0);
+ DEVICE_TYPE_2, Collections.singletonList(DEVICE_ID), TYPE.toString(), Collections.singletonList(STATUS.toString()), null, 0, 0);
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
Assert.assertNotNull(response);
@@ -258,7 +258,7 @@ public class ActivityProviderServiceImplTest {
Mockito.when(this.deviceManagementProviderService.getDeviceActivities(Mockito.any())).thenReturn(deviceActivities);
Response response = this.activityInfoProviderService.getDeviceActivities(
OFFSET, LIMIT, SINCE, INITIATED_BY, OPERATION_CODE, OPERATION_ID,
- DEVICE_TYPE_2, Collections.singletonList(DEVICE_ID), TYPE.toString(), STATUS.toString(), null, 0, 0);
+ DEVICE_TYPE_2, Collections.singletonList(DEVICE_ID), TYPE.toString(), Collections.singletonList(STATUS.toString()), null, 0, 0);
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
Assert.assertNotNull(response);
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java
index e32761b0e6..d7ac8671ee 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java
@@ -285,7 +285,7 @@ public class DeviceAgentServiceTest {
Device testDevice = DeviceMgtAPITestHelper.generateDummyDevice(TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Mockito.when(this.deviceManagementProviderService
.getDevice(Mockito.any(DeviceIdentifier.class), Mockito.any(Boolean.class))).thenReturn(testDevice);
- Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
+ Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class), Mockito.any(String[].class)))
.thenThrow(new DeviceAccessAuthorizationException());
Response response = deviceAgentService.updateDevice(TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER, testDevice);
Assert.assertNotNull(response, "Response should not be null");
@@ -305,7 +305,7 @@ public class DeviceAgentServiceTest {
Device testDevice = DeviceMgtAPITestHelper.generateDummyDevice(TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Mockito.when(this.deviceManagementProviderService
.getDevice(Mockito.any(DeviceIdentifier.class), Mockito.any(Boolean.class))).thenReturn(testDevice);
- Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
+ Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class), Mockito.any(String[].class)))
.thenReturn(false);
Response response = deviceAgentService.updateDevice(TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER, testDevice);
Assert.assertNotNull(response, "Response should not be null");
@@ -327,7 +327,7 @@ public class DeviceAgentServiceTest {
Device testDevice = DeviceMgtAPITestHelper.generateDummyDevice(TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Mockito.when(this.deviceManagementProviderService
.getDevice(Mockito.any(DeviceIdentifier.class), Mockito.any(Boolean.class))).thenReturn(testDevice);
- Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
+ Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class), Mockito.any(String[].class)))
.thenReturn(true);
Mockito.when(this.deviceManagementProviderService.modifyEnrollment(Mockito.any())).thenReturn(false);
Response response = deviceAgentService.updateDevice(TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER, testDevice);
@@ -350,7 +350,7 @@ public class DeviceAgentServiceTest {
Device testDevice = DeviceMgtAPITestHelper.generateDummyDevice(TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Mockito.when(this.deviceManagementProviderService
.getDevice(Mockito.any(DeviceIdentifier.class), Mockito.any(Boolean.class))).thenReturn(testDevice);
- Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
+ Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class), Mockito.any(String[].class)))
.thenReturn(true);
Mockito.when(this.deviceManagementProviderService.modifyEnrollment(Mockito.any()))
.thenThrow(new DeviceManagementException());
@@ -372,7 +372,7 @@ public class DeviceAgentServiceTest {
"getAuthenticatedUser")).toReturn(AUTHENTICATED_USER);
Device testDevice = DeviceMgtAPITestHelper.generateDummyDevice(TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Mockito.when(this.deviceManagementProviderService.getDevice(Mockito.any(DeviceIdentifier.class), Mockito.any(Boolean.class))).thenReturn(testDevice);
- Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
+ Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class), Mockito.any(String[].class)))
.thenReturn(true);
Mockito.when(this.deviceManagementProviderService.modifyEnrollment(Mockito.any())).thenReturn((true));
Response response = deviceAgentService.updateDevice(TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER, testDevice);
@@ -408,7 +408,7 @@ public class DeviceAgentServiceTest {
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
- Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
+ Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class), Mockito.any(String[].class)))
.thenReturn(false);
Mockito.when(this.privilegedCarbonContext.getTenantDomain())
.thenReturn(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
@@ -432,7 +432,7 @@ public class DeviceAgentServiceTest {
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
- Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
+ Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class), Mockito.any(String[].class)))
.thenThrow(new DeviceAccessAuthorizationException());
Mockito.when(this.privilegedCarbonContext.getTenantDomain())
.thenReturn(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
@@ -457,7 +457,7 @@ public class DeviceAgentServiceTest {
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
- Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
+ Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class), Mockito.any(String[].class)))
.thenReturn(true);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventStreamAdminServiceStub"))
.toReturn(this.eventStreamAdminServiceStub);
@@ -485,7 +485,7 @@ public class DeviceAgentServiceTest {
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
- Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
+ Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class), Mockito.any(String[].class)))
.thenReturn(true);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventStreamAdminServiceStub"))
.toThrow(new AxisFault(""));
@@ -511,7 +511,7 @@ public class DeviceAgentServiceTest {
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
- Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
+ Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class), Mockito.any(String[].class)))
.thenReturn(true);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventStreamAdminServiceStub"))
.toThrow(new RemoteException());
@@ -539,7 +539,7 @@ public class DeviceAgentServiceTest {
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
- Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
+ Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class), Mockito.any(String[].class)))
.thenReturn(true);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventStreamAdminServiceStub"))
.toThrow(new JWTClientException());
@@ -567,7 +567,7 @@ public class DeviceAgentServiceTest {
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
- Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
+ Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class), Mockito.any(String[].class)))
.thenReturn(true);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventStreamAdminServiceStub"))
.toThrow(new UserStoreException());
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java
index 2ef62073bd..63bb401d61 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java
@@ -215,7 +215,7 @@ public class DeviceManagementServiceImplTest {
Mockito.when(carbonContext.getTenantId()).thenReturn(-1234);
Mockito.when(carbonContext.getUsername()).thenReturn(DEFAULT_USERNAME);
Mockito.when(deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class),
- Mockito.anyString())).thenReturn(true);
+ Mockito.anyString(), Mockito.any(String[].class))).thenReturn(true);
Response response = this.deviceManagementService
.getDeviceByID(TEST_DEVICE_IDENTIFIER, ifModifiedSince,true);
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml
index 28f10fec95..a472beedad 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/pom.xml
@@ -21,7 +21,7 @@
device-mgt
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/ActivityPaginationRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/ActivityPaginationRequest.java
index 058b82dd2f..77161d7036 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/ActivityPaginationRequest.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/ActivityPaginationRequest.java
@@ -36,7 +36,7 @@ public class ActivityPaginationRequest {
private String initiatedBy;
private long since;
private Operation.Type type;
- private Operation.Status status;
+ private List statuses;
private long startTimestamp;
private long endTimestamp;
@@ -110,12 +110,12 @@ public class ActivityPaginationRequest {
this.type = type;
}
- public Operation.Status getStatus() {
- return status;
+ public List getStatuses() {
+ return statuses;
}
- public void setStatus(Operation.Status status) {
- this.status = status;
+ public void setStatuses(List statuses) {
+ this.statuses = statuses;
}
public long getStartTimestamp() {
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/DeviceAccessAuthorizationService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/DeviceAccessAuthorizationService.java
index 713defbcee..c1d4d50b3f 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/DeviceAccessAuthorizationService.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/DeviceAccessAuthorizationService.java
@@ -28,15 +28,6 @@ import java.util.List;
* accessing the device information and performing MDM operations on devices.
*/
public interface DeviceAccessAuthorizationService {
- /**
- * This method will check whether the currently logged-in user has the access to the device identified by the given
- * DeviceIdentifier.
- *
- * @param deviceIdentifier - DeviceIdentifier of the device to be checked.
- * @return Boolean authorization result.
- * @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization.
- */
- boolean isUserAuthorized(DeviceIdentifier deviceIdentifier) throws DeviceAccessAuthorizationException;
/**
* This method will check whether the currently logged-in user has the access to the device identified by the given
@@ -50,18 +41,6 @@ public interface DeviceAccessAuthorizationService {
boolean isUserAuthorized(DeviceIdentifier deviceIdentifier, String[] groupPermissions)
throws DeviceAccessAuthorizationException;
- /**
- * This method will check whether the currently logged-in user has the access to the devices identified by the given
- * DeviceIdentifier list.
- *
- * @param deviceIdentifiers - List of DeviceIdentifiers to be checked for authorization.
- * @return DeviceAuthorizationResult - Authorization result object including the list of authorized devices and
- * unauthorized devices.
- * @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization.
- */
- DeviceAuthorizationResult isUserAuthorized(List deviceIdentifiers) throws
- DeviceAccessAuthorizationException;
-
/**
* This method will check whether the currently logged-in user has the access to the devices identified by the given
* DeviceIdentifier list.
@@ -103,18 +82,6 @@ public interface DeviceAccessAuthorizationService {
String[] groupPermissions) throws
DeviceAccessAuthorizationException;
- /**
- * This method will check whether the given user has the access to the device identified by the given
- * DeviceIdentifier.
- *
- * @param deviceIdentifier - DeviceIdentifier of the device to be checked.
- * @param username - Username of the user to be checked for authorization.
- * @return Boolean authorization result.
- * @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization.
- */
- boolean isUserAuthorized(DeviceIdentifier deviceIdentifier, String username) throws
- DeviceAccessAuthorizationException;
-
/**
* This method will check whether the authenticated user has the admin permissions.
*
@@ -122,17 +89,4 @@ public interface DeviceAccessAuthorizationService {
* @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization.
*/
boolean isDeviceAdminUser() throws DeviceAccessAuthorizationException;
-
- /**
- * This method will check whether the given user has the access to the devices identified by the given
- * DeviceIdentifier list.
- *
- * @param deviceIdentifiers - List of DeviceIdentifiers to be checked for authorization.
- * @param username - Username of the user to be checked for authorization.
- * @return DeviceAuthorizationResult - Authorization result object including the list of authorized devices and
- * unauthorized devices.
- * @throws DeviceAccessAuthorizationException if something goes wrong when checking the authorization.
- */
- DeviceAuthorizationResult isUserAuthorized(List deviceIdentifiers, String username) throws
- DeviceAccessAuthorizationException;
}
\ No newline at end of file
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/DeviceAuthorizationRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/DeviceAuthorizationRequest.java
new file mode 100644
index 0000000000..92602fe5f4
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/DeviceAuthorizationRequest.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.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 io.entgra.device.mgt.core.device.mgt.common.authorization;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+@ApiModel(value = "DeviceAuthorizationRequest", description = "")
+public class DeviceAuthorizationRequest {
+
+ @ApiModelProperty(name = "type", value = "device type")
+ private String type;
+ @ApiModelProperty(name = "deviceIds", value = "list of device ids")
+ private List deviceIds;
+ @ApiModelProperty(name = "username", value = "user who is accessing the device")
+ private String username;
+ @ApiModelProperty(name = "permissions", value = "list of permissions")
+ private List permissions;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public List getDeviceIds() {
+ return deviceIds;
+ }
+
+ public void setDeviceIds(List deviceIds) {
+ this.deviceIds = deviceIds;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public List getPermissions() {
+ return permissions;
+ }
+
+ public void setPermissions(List permissions) {
+ this.permissions = permissions;
+ }
+}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/GroupAccessAuthorizationException.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/GroupAccessAuthorizationException.java
new file mode 100644
index 0000000000..22ab4eef62
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/GroupAccessAuthorizationException.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.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 io.entgra.device.mgt.core.device.mgt.common.authorization;
+
+/**
+ * Custom exception class which wraps exceptions occurred inside GroupAccessAuthorization service.
+ */
+public class GroupAccessAuthorizationException extends Exception {
+
+ private static final long serialVersionUID = -3151279331929070297L;
+
+ private String errorMessage;
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public GroupAccessAuthorizationException(String msg, Exception nestedEx) {
+ super(msg, nestedEx);
+ setErrorMessage(msg);
+ }
+
+ public GroupAccessAuthorizationException(String message, Throwable cause) {
+ super(message, cause);
+ setErrorMessage(message);
+ }
+
+ public GroupAccessAuthorizationException(String msg) {
+ super(msg);
+ setErrorMessage(msg);
+ }
+
+ public GroupAccessAuthorizationException() {
+ super();
+ }
+
+ public GroupAccessAuthorizationException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/GroupAccessAuthorizationService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/GroupAccessAuthorizationService.java
new file mode 100644
index 0000000000..c9e942cd31
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/GroupAccessAuthorizationService.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.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 io.entgra.device.mgt.core.device.mgt.common.authorization;
+
+import java.util.List;
+
+public interface GroupAccessAuthorizationService {
+
+ public boolean isUserAuthorized(int groupId, String username, String[] groupPermissions)
+ throws GroupAccessAuthorizationException;
+
+ public boolean isUserAuthorized(int groupId, String[] groupPermissions)
+ throws GroupAccessAuthorizationException;
+
+ public GroupAuthorizationResult isUserAuthorized(List groupIds, String username, String[] groupPermission)
+ throws GroupAccessAuthorizationException;
+
+}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/GroupAuthorizationRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/GroupAuthorizationRequest.java
new file mode 100644
index 0000000000..9cda89c591
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/GroupAuthorizationRequest.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.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 io.entgra.device.mgt.core.device.mgt.common.authorization;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+@ApiModel(value = "GroupAuthorizationRequest", description = "")
+public class GroupAuthorizationRequest {
+
+ @ApiModelProperty(name = "groupIds", value = "list of group Ids")
+ private List groupIds;
+ @ApiModelProperty(name = "username", value = "user who is accessing the device")
+ private String username;
+ @ApiModelProperty(name = "permissions", value = "list of permissions")
+ private List permissions;
+
+ public List getGroupIds() {
+ return groupIds;
+ }
+
+ public void setGroupIds(List groupIds) {
+ this.groupIds = groupIds;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public List getPermissions() {
+ return permissions;
+ }
+
+ public void setPermissions(List permissions) {
+ this.permissions = permissions;
+ }
+}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/GroupAuthorizationResult.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/GroupAuthorizationResult.java
new file mode 100644
index 0000000000..93608510ad
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/authorization/GroupAuthorizationResult.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.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 io.entgra.device.mgt.core.device.mgt.common.authorization;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a GroupAuthorizationResult including a list of authorized groups and a list of unauthorized groups.
+ */
+public class GroupAuthorizationResult {
+
+ private List authorizedGroupIds = new ArrayList<>();
+ private List unauthorizedGroupIds= new ArrayList<>();
+
+ public List getAuthorizedGroupIds() {
+ return authorizedGroupIds;
+ }
+
+ public void setAuthorizedGroupIds(List authorizedGroupIds) {
+ this.authorizedGroupIds = authorizedGroupIds;
+ }
+
+ public List getUnauthorizedGroupIds() {
+ return unauthorizedGroupIds;
+ }
+
+ public void setUnauthorizedGroupIds(List unauthorizedGroupIds) {
+ this.unauthorizedGroupIds = unauthorizedGroupIds;
+ }
+
+ public void addAuthorizedGroupId(int groupId) {
+ this.authorizedGroupIds.add(groupId);
+ }
+
+ public void addUnauthorizedGroupId(int groupId) {
+ this.unauthorizedGroupIds.add(groupId);
+ }
+
+}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml
index 735dc54d6d..115bdc04a6 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.config.api/pom.xml
@@ -22,7 +22,7 @@
device-mgt
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml
index 72db2b7d49..9827ec7084 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java
index fec70931a4..368157ca48 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java
@@ -19,6 +19,7 @@
package io.entgra.device.mgt.core.device.mgt.core.app.mgt;
import com.google.gson.Gson;
+import io.entgra.device.mgt.core.device.mgt.core.report.mgt.ReportingPublisherManager;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -286,8 +287,9 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
deviceDetailsWrapper.setTenantId(tenantId);
deviceDetailsWrapper.setDevice(device);
deviceDetailsWrapper.setApplications(newApplications);
- HttpReportingUtil.invokeApi(deviceDetailsWrapper.getJSONString(),
- reportingHost + DeviceManagementConstants.Report.APP_USAGE_ENDPOINT);
+ ReportingPublisherManager reportingManager = new ReportingPublisherManager();
+ reportingManager.publishData(deviceDetailsWrapper, DeviceManagementConstants
+ .Report.APP_USAGE_ENDPOINT);
}
} catch (DeviceManagementDAOException e) {
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/impl/ArchivalDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/impl/ArchivalDAOImpl.java
index 183447be7b..2efe723785 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/impl/ArchivalDAOImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/archival/dao/impl/ArchivalDAOImpl.java
@@ -547,8 +547,9 @@ public class ArchivalDAOImpl implements ArchivalDAO {
String sql = "INSERT INTO " + DESTINATION_DB + ".DM_OPERATION_ARCH " +
"SELECT OPR.ID, OPR.TYPE, OPR.CREATED_TIMESTAMP, OPR.RECEIVED_TIMESTAMP, " +
- "OPR.OPERATION_CODE, OPR.INITIATED_BY, OPR.OPERATION_DETAILS, OPR.ENABLED, NOW() " +
- "FROM " + SOURCE_DB + ".DM_OPERATION OPR " +
+ "OPR.OPERATION_CODE, OPR.INITIATED_BY, OPR.OPERATION_DETAILS, OPR.OPERATION_PROPERTIES, " +
+ "OPR.ENABLED, NOW() " +
+ "FROM " + SOURCE_DB + ".DM_OPERATION OPR " +
"WHERE OPR.ID NOT IN (SELECT DISTINCT OPERATION_ID FROM " + SOURCE_DB + ".DM_ENROLMENT_OP_MAPPING)";
long startTime = System.currentTimeMillis();
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceImpl.java
index 287b794c4c..25120a07e0 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceImpl.java
@@ -63,41 +63,55 @@ public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthori
return !DeviceManagementDataHolder.getInstance().requireDeviceAuthorization(deviceIdentifier.getType());
}
//check for admin and ownership permissions
- if (isAdmin(username, tenantId) || isDeviceOwner(deviceIdentifier, username)) {
+ if (isDeviceAdminUser(username, tenantId) || isDeviceOwner(deviceIdentifier, username)) {
return true;
}
//check for group permissions
- try {
- return isSharedViaGroup(deviceIdentifier, username);
- } catch (GroupManagementException | UserStoreException e) {
- throw new DeviceAccessAuthorizationException("Unable to authorize the access to device : " +
- deviceIdentifier.getId() + " for the user : " +
- username, e);
- }
- }
-
- private boolean isSharedViaGroup(DeviceIdentifier deviceIdentifier, String username)
- throws GroupManagementException, UserStoreException {
- List groupsWithDevice = DeviceManagementDataHolder.getInstance()
- .getGroupManagementProviderService().getGroups(deviceIdentifier, false);
- String[] userRoles = DeviceManagementDataHolder.getInstance().getRealmService()
- .getTenantUserRealm(getTenantId()).getUserStoreManager().getRoleListOfUser(username);
- for (DeviceGroup deviceGroup : groupsWithDevice) {
- List sharingRoles = DeviceManagementDataHolder.getInstance()
- .getGroupManagementProviderService().getRoles(deviceGroup.getGroupId());
- for (String role : userRoles) {
- if (sharingRoles.contains(role)) {
- return true;
+ if (groupPermissions == null || groupPermissions.length == 0) {
+ return false;
+ } else {
+ // if group permissions specified, check whether that permission is available in shared role
+ try {
+ boolean isAuthorized = true;
+ for (String groupPermission : groupPermissions) {
+ if (!isAuthorizedViaSharedGroup(deviceIdentifier, username, groupPermission)) {
+ //if at least one failed, authorizations fails and break the loop
+ isAuthorized = false;
+ break;
+ }
}
+ return isAuthorized;
+ } catch (DeviceAccessAuthorizationException e) {
+ throw new DeviceAccessAuthorizationException("Unable to authorize the access to device : " +
+ deviceIdentifier.getId() + " for the user : " +
+ username, e);
}
}
- return false;
}
- @Override
- public boolean isUserAuthorized(DeviceIdentifier deviceIdentifier, String username)
+
+ private boolean isAuthorizedViaSharedGroup(DeviceIdentifier deviceIdentifier, String username, String groupPermission)
throws DeviceAccessAuthorizationException {
- return isUserAuthorized(deviceIdentifier, username, null);
+ try {
+ List groupsWithDevice = DeviceManagementDataHolder.getInstance()
+ .getGroupManagementProviderService().getGroups(deviceIdentifier, false);
+ UserRealm userRealm = DeviceManagementDataHolder.getInstance().getRealmService()
+ .getTenantUserRealm(getTenantId());
+ String[] userRoles = userRealm.getUserStoreManager().getRoleListOfUser(username);
+ for (DeviceGroup deviceGroup : groupsWithDevice) {
+ List sharingRoles = DeviceManagementDataHolder.getInstance()
+ .getGroupManagementProviderService().getRoles(deviceGroup.getGroupId());
+ for (String role : userRoles) {
+ if (sharingRoles.contains(role) && userRealm.getAuthorizationManager().
+ isRoleAuthorized(role, groupPermission, CarbonConstants.UI_PERMISSION_ACTION)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ } catch (GroupManagementException | UserStoreException e) {
+ throw new DeviceAccessAuthorizationException("unable to authorized via shared role, " + groupPermission);
+ }
}
@Override
@@ -106,18 +120,13 @@ public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthori
return isUserAuthorized(deviceIdentifier, this.getUserName(), groupPermissions);
}
- @Override
- public boolean isUserAuthorized(DeviceIdentifier deviceIdentifier) throws DeviceAccessAuthorizationException {
- return isUserAuthorized(deviceIdentifier, this.getUserName(), null);
- }
-
@Override
public boolean isDeviceAdminUser() throws DeviceAccessAuthorizationException {
String username = this.getUserName();
int tenantId = this.getTenantId();
try {
- return isAdminUser(username, tenantId);
- } catch (UserStoreException e) {
+ return isDeviceAdminUser(username, tenantId);
+ } catch (DeviceAccessAuthorizationException e) {
throw new DeviceAccessAuthorizationException("Unable to check the admin permissions of user : " +
username + " in tenant : " + tenantId, e);
}
@@ -132,7 +141,7 @@ public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthori
return null;
}
DeviceAuthorizationResult deviceAuthorizationResult = new DeviceAuthorizationResult();
- if (isAdmin(username, tenantId)) {
+ if (isDeviceAdminUser(username, tenantId)) {
deviceAuthorizationResult.setAuthorizedDevices(deviceIdentifiers);
return deviceAuthorizationResult;
}
@@ -149,7 +158,7 @@ public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthori
//check for group permissions
boolean isAuthorized = true;
for (String groupPermission : groupPermissions) {
- if (!isAuthorizedViaGroup(username, deviceIdentifier, groupPermission)) {
+ if (!isAuthorizedViaSharedGroup(deviceIdentifier, username, groupPermission)) {
//if at least one failed, authorizations fails and break the loop
isAuthorized = false;
break;
@@ -160,7 +169,7 @@ public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthori
} else {
deviceAuthorizationResult.addUnauthorizedDevice(deviceIdentifier);
}
- } catch (GroupManagementException e) {
+ } catch (DeviceAccessAuthorizationException e) {
throw new DeviceAccessAuthorizationException("Unable to authorize the access to device : " +
deviceIdentifier.getId() + " for the user : " +
username, e);
@@ -170,55 +179,12 @@ public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthori
return deviceAuthorizationResult;
}
- @Override
- public DeviceAuthorizationResult isUserAuthorized(List deviceIdentifiers, String username)
- throws DeviceAccessAuthorizationException {
- return isUserAuthorized(deviceIdentifiers, username, null);
- }
-
- @Override
- public DeviceAuthorizationResult isUserAuthorized(List deviceIdentifiers)
- throws DeviceAccessAuthorizationException {
- return isUserAuthorized(deviceIdentifiers, this.getUserName(), null);
- }
-
@Override
public DeviceAuthorizationResult isUserAuthorized(List deviceIdentifiers, String[] groupPermissions)
throws DeviceAccessAuthorizationException {
return isUserAuthorized(deviceIdentifiers, this.getUserName(), groupPermissions);
}
- private boolean isAdmin(String username, int tenantId)
- throws DeviceAccessAuthorizationException {
- try {
- //Check for admin users. If the user is an admin user we authorize the access to that device.
- return (isAdminUser(username, tenantId));
- } catch (UserStoreException e) {
- throw new DeviceAccessAuthorizationException("Unable to authorize the access for the user : " +
- username, e);
- }
- }
-
- private boolean isAuthorizedViaGroup(String username, DeviceIdentifier deviceIdentifier, String groupPermission)
- throws GroupManagementException {
- List authorizedGroups =
- DeviceManagementDataHolder.getInstance().getGroupManagementProviderService()
- .getGroups(username, groupPermission, false);
- List groupsWithDevice =
- DeviceManagementDataHolder.getInstance().getGroupManagementProviderService()
- .getGroups(deviceIdentifier, false);
- for (DeviceGroup group : authorizedGroups) {
- Iterator groupsWithDeviceIterator = groupsWithDevice.iterator();
- while (groupsWithDeviceIterator.hasNext()) {
- DeviceGroup deviceGroup = groupsWithDeviceIterator.next();
- if (deviceGroup.getGroupId() == group.getGroupId()) {
- return true;
- }
- }
- }
- return false;
- }
-
private boolean isDeviceOwner(DeviceIdentifier deviceIdentifier, String username)
throws DeviceAccessAuthorizationException {
//Check for device ownership. If the user is the owner of the device we allow the access.
@@ -232,15 +198,20 @@ public class DeviceAccessAuthorizationServiceImpl implements DeviceAccessAuthori
}
}
- private boolean isAdminUser(String username, int tenantId) throws UserStoreException {
- UserRealm userRealm = DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId);
- if (userRealm != null && userRealm.getAuthorizationManager() != null) {
- return userRealm.getAuthorizationManager()
- .isUserAuthorized(removeTenantDomain(username),
- PermissionUtils.getAbsolutePermissionPath(CDM_ADMIN_PERMISSION),
- CarbonConstants.UI_PERMISSION_ACTION);
+ private boolean isDeviceAdminUser(String username, int tenantId) throws DeviceAccessAuthorizationException {
+ try {
+ UserRealm userRealm = DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId);
+ if (userRealm != null && userRealm.getAuthorizationManager() != null) {
+ return userRealm.getAuthorizationManager()
+ .isUserAuthorized(removeTenantDomain(username),
+ PermissionUtils.getAbsolutePermissionPath(CDM_ADMIN_PERMISSION),
+ CarbonConstants.UI_PERMISSION_ACTION);
+ }
+ return false;
+ } catch (UserStoreException e) {
+ throw new DeviceAccessAuthorizationException("Unable to authorize the access for the user : " +
+ username, e);
}
- return false;
}
private String getUserName() {
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/GroupAccessAuthorizationServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/GroupAccessAuthorizationServiceImpl.java
new file mode 100644
index 0000000000..acceb466c1
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/authorization/GroupAccessAuthorizationServiceImpl.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.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 io.entgra.device.mgt.core.device.mgt.core.authorization;
+
+import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAccessAuthorizationException;
+import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAccessAuthorizationService;
+import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAuthorizationResult;
+import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup;
+import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException;
+import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.Permission;
+import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionManagementException;
+import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementDataHolder;
+import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.opensaml.xmlsec.signature.G;
+import org.wso2.carbon.CarbonConstants;
+import org.wso2.carbon.context.CarbonContext;
+import org.wso2.carbon.user.api.UserRealm;
+import org.wso2.carbon.user.api.UserStoreException;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import java.util.List;
+
+public class GroupAccessAuthorizationServiceImpl implements GroupAccessAuthorizationService {
+
+ private final static String GROUP_ADMIN_PERMISSION = "/device-mgt/devices/any-group/permitted-actions-under-owning-group";
+ private final static String GROUP_ADMIN = "Group Management Administrator";
+ private static Log log = LogFactory.getLog(DeviceAccessAuthorizationServiceImpl.class);
+
+ public GroupAccessAuthorizationServiceImpl() {
+ try {
+ this.addAdminPermissionToRegistry();
+ } catch (PermissionManagementException e) {
+ log.error("Unable to add the group-admin permission to the registry.", e);
+ }
+ }
+
+ @Override
+ public boolean isUserAuthorized(int groupId, String username, String[] groupPermissions)
+ throws GroupAccessAuthorizationException {
+ int tenantId = this.getTenantId();
+ if (username == null || username.isEmpty()) {
+ username = this.getUserName();
+ }
+ //check for admin and ownership permissions
+ if (isGroupAdminUser(username, tenantId) || isGroupOwner(groupId, username)) {
+ return true;
+ }
+
+ //check for group permissions
+ if (groupPermissions == null || groupPermissions.length == 0) {
+ return false;
+ } else {
+ // if group permissions specified, check whether that permission is available in any user role of the group owner
+ try {
+ UserRealm userRealm = DeviceManagementDataHolder.getInstance().getRealmService()
+ .getTenantUserRealm(getTenantId());
+ String[] userRoles = userRealm.getUserStoreManager().getRoleListOfUser(username);
+ boolean isAuthorized = true;
+ for (String groupPermission : groupPermissions) {
+ for (String role : userRoles) {
+ if (!userRealm.getAuthorizationManager().
+ isRoleAuthorized(role, groupPermission, CarbonConstants.UI_PERMISSION_ACTION)) {
+ isAuthorized = false;
+ break;
+ }
+ }
+ }
+ return isAuthorized;
+ } catch (UserStoreException e) {
+ throw new GroupAccessAuthorizationException("Unable to authorize the access to group : " +
+ groupId + " for the user : " +
+ username, e);
+ }
+ }
+ }
+
+ @Override
+ public GroupAuthorizationResult isUserAuthorized(List groupIds, String username, String[] groupPermission)
+ throws GroupAccessAuthorizationException {
+ GroupAuthorizationResult result = new GroupAuthorizationResult();
+ for (Integer groupId : groupIds) {
+ if (isUserAuthorized(groupId, username, groupPermission)) {
+ result.addAuthorizedGroupId(groupId);
+ } else {
+ result.addUnauthorizedGroupId(groupId);
+ }
+ }
+ return result;
+ }
+
+
+ @Override
+ public boolean isUserAuthorized(int groupId, String[] groupPermissions)
+ throws GroupAccessAuthorizationException {
+ return isUserAuthorized(groupId, this.getUserName(), groupPermissions);
+ }
+
+ private boolean isGroupOwner(int groupId, String username)
+ throws GroupAccessAuthorizationException {
+ //Check for group ownership. If the user is the owner of the group we allow the access.
+ try {
+ DeviceGroup group = DeviceManagementDataHolder.getInstance().
+ getGroupManagementProviderService().getGroup(groupId, false);
+ return username.equals(group.getOwner());
+ } catch (GroupManagementException e) {
+ throw new GroupAccessAuthorizationException("Unable to authorize the access to group : " +
+ groupId + " for the user : " +
+ username, e);
+ }
+ }
+
+ private boolean isGroupAdminUser(String username, int tenantId) throws GroupAccessAuthorizationException {
+ try {
+ UserRealm userRealm = DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId);
+ if (userRealm != null && userRealm.getAuthorizationManager() != null) {
+ return userRealm.getAuthorizationManager()
+ .isUserAuthorized(removeTenantDomain(username),
+ PermissionUtils.getAbsolutePermissionPath(GROUP_ADMIN_PERMISSION),
+ CarbonConstants.UI_PERMISSION_ACTION);
+ }
+ return false;
+ } catch (UserStoreException e) {
+ throw new GroupAccessAuthorizationException("Unable to authorize the access for the user : " +
+ username, e);
+ }
+ }
+
+ private String getUserName() {
+ String username = CarbonContext.getThreadLocalCarbonContext().getUsername();
+ if (username != null && !username.isEmpty()) {
+ return removeTenantDomain(username);
+ }
+ return null;
+ }
+
+ private String removeTenantDomain(String username) {
+ String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
+ if (username.endsWith(tenantDomain)) {
+ return username.substring(0, username.lastIndexOf("@"));
+ }
+ return username;
+ }
+
+ private int getTenantId() {
+ return CarbonContext.getThreadLocalCarbonContext().getTenantId();
+ }
+
+ private boolean addAdminPermissionToRegistry() throws PermissionManagementException {
+ Permission permission = new Permission();
+ permission.setName(GROUP_ADMIN);
+ permission.setPath(PermissionUtils.getAbsolutePermissionPath(GROUP_ADMIN_PERMISSION));
+ return PermissionUtils.putPermission(permission);
+ }
+
+}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java
index 7b105df14d..b7768f9c52 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/DeviceManagementDAOFactory.java
@@ -139,6 +139,22 @@ public class DeviceManagementDAOFactory {
throw new IllegalStateException("Database engine has not initialized properly.");
}
+ public static TenantDAO getTenantDAO() {
+ if (databaseEngine != null) {
+ switch (databaseEngine) {
+ case DeviceManagementConstants.DataBaseTypes.DB_TYPE_POSTGRESQL:
+ case DeviceManagementConstants.DataBaseTypes.DB_TYPE_ORACLE:
+ case DeviceManagementConstants.DataBaseTypes.DB_TYPE_MSSQL:
+ case DeviceManagementConstants.DataBaseTypes.DB_TYPE_H2:
+ case DeviceManagementConstants.DataBaseTypes.DB_TYPE_MYSQL:
+ return new TenantDAOImpl();
+ default:
+ throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
+ }
+ }
+ throw new IllegalStateException("Database engine has not initialized properly.");
+ }
+
public static TrackerDAO getTrackerDAO() {
if (databaseEngine != null) {
switch (databaseEngine) {
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TenantDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TenantDAO.java
new file mode 100644
index 0000000000..372df2583a
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/TenantDAO.java
@@ -0,0 +1,431 @@
+package io.entgra.device.mgt.core.device.mgt.core.dao;
+
+public interface TenantDAO {
+
+ /**
+ * Delete device certificates of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceCertificateByTenantId(int tenantId)throws DeviceManagementDAOException;
+
+ /**
+ * Delete groups of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteGroupByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete role-group mapping data of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteRoleGroupMapByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete devices of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device properties of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDevicePropertiesByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete group properties of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteGroupPropertiesByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device-group mapping details of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceGroupMapByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete operations of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteOperationByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete enrolments of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteEnrolmentByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device statuses of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceStatusByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete enrolment mapping of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteEnrolmentOpMappingByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device operation responses of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceOperationResponseByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete large-device operations responses of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceOperationResponseLargeByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ // Delete policy related tables
+
+ /**
+ * Delete applications of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteApplicationByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete policy compliance features of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deletePolicyComplianceFeaturesByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete policy change management data of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deletePolicyChangeManagementByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete policy compliance statuses of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deletePolicyComplianceStatusByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete policy criteria properties of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deletePolicyCriteriaPropertiesByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete policy criteria of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deletePolicyCriteriaByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete policies of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deletePolicyByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete role policies of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteRolePolicyByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete user policies of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteUserPolicyByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device policies of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDevicePolicyAppliedByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete criteria of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteCriteriaByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device type properties of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceTypePolicyByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device policies of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDevicePolicyByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete profile features of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteProfileFeaturesByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete policy corrective actions of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deletePolicyCorrectiveActionByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete profiles of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteProfileByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete app icons of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteAppIconsByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device group policies of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceGroupPolicyByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete notifications of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteNotificationByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device information of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceInfoByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device location of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceLocationByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device history of last seven days of a tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceHistoryLastSevenDaysByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device details of a tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceDetailByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete metadata of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteMetadataByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete OTP data of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteOTPDataByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete geo fences of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteGeofenceByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete geo fence group mapping data of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteGeofenceGroupMappingByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device events of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceEventByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device event group mapping of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceEventGroupMappingByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete geo fence event mapping of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteGeofenceEventMappingByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete external group mapping of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteExternalGroupMappingByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete External device mapping of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteExternalDeviceMappingByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete external permission mapping of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteExternalPermissionMapping(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete dynamic tasks of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDynamicTaskByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete dynamic task properties of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDynamicTaskPropertiesByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device subtypes of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceSubTypeByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete traccar unsynced devices of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteTraccarUnsyncedDevicesByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete sub operation templates of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteSubOperationTemplate(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete device organizations of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteDeviceOrganizationByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+ /**
+ * Delete CEA policies of tenant
+ *
+ * @param tenantId Tenant ID
+ * @throws DeviceManagementDAOException thrown if there is an error when deleting data
+ */
+ void deleteCEAPoliciesByTenantId(int tenantId) throws DeviceManagementDAOException;
+
+}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/TenantDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/TenantDAOImpl.java
new file mode 100644
index 0000000000..5aec24752b
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/TenantDAOImpl.java
@@ -0,0 +1,939 @@
+package io.entgra.device.mgt.core.device.mgt.core.dao.impl;
+
+import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException;
+import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory;
+import io.entgra.device.mgt.core.device.mgt.core.dao.TenantDAO;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+
+public class TenantDAOImpl implements TenantDAO {
+
+ private static final Log log = LogFactory.getLog(TenantDAOImpl.class);
+
+
+ @Override
+ public void deleteDeviceCertificateByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_CERTIFICATE WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting certificates for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteGroupByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_GROUP WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting groups for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteRoleGroupMapByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_ROLE_GROUP_MAP WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting role group mapping for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting devices for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDevicePropertiesByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_PROPERTIES WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device properties for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+ }
+
+ @Override
+ public void deleteGroupPropertiesByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM GROUP_PROPERTIES WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting group properties for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceGroupMapByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_GROUP_MAP WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device group mapping for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteOperationByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_OPERATION WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting operations for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteEnrolmentByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_ENROLMENT WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting enrolment for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceStatusByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_STATUS WHERE ENROLMENT_ID IN " +
+ "(SELECT ID FROM DM_ENROLMENT WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device status for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteEnrolmentOpMappingByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_ENROLMENT_OP_MAPPING WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting enrolment op mapping for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceOperationResponseByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE EN_OP_MAP_ID IN " +
+ "(SELECT ID FROM DM_ENROLMENT_OP_MAPPING WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device operation response for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceOperationResponseLargeByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE_LARGE WHERE EN_OP_MAP_ID IN "+
+ "(SELECT ID FROM DM_ENROLMENT_OP_MAPPING WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device operation response large for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteApplicationByTenantId(int tenantId) throws DeviceManagementDAOException{
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_APPLICATION WHERE DEVICE_ID IN " +
+ "(SELECT ID FROM DM_DEVICE WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting applications for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+
+ }
+
+ @Override
+ public void deletePolicyComplianceFeaturesByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_POLICY_COMPLIANCE_FEATURES WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting policy compliance features for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deletePolicyChangeManagementByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_POLICY_CHANGE_MGT WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting policy change management for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deletePolicyComplianceStatusByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_POLICY_COMPLIANCE_STATUS WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting policy compliance status for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deletePolicyCriteriaPropertiesByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_POLICY_CRITERIA_PROPERTIES WHERE POLICY_CRITERION_ID IN " +
+ "(SELECT ID FROM DM_POLICY_CRITERIA WHERE POLICY_ID IN " +
+ "(SELECT ID FROM DM_POLICY WHERE TENANT_ID = ?))";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting policy criteria properties for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deletePolicyCriteriaByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_POLICY_CRITERIA WHERE POLICY_ID IN " +
+ "(SELECT ID FROM DM_POLICY WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting policy criteria for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deletePolicyByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_POLICY WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting policy for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteRolePolicyByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_ROLE_POLICY WHERE POLICY_ID IN " +
+ "(SELECT ID FROM DM_POLICY WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting role policy for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteUserPolicyByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_USER_POLICY WHERE POLICY_ID IN " +
+ "(SELECT ID FROM DM_POLICY WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting user policy for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDevicePolicyAppliedByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_POLICY_APPLIED WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting policy applied for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteCriteriaByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_CRITERIA WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting criteria for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceTypePolicyByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_TYPE_POLICY WHERE POLICY_ID IN " +
+ "(SELECT ID FROM DM_POLICY WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device type policy for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+ }
+
+ @Override
+ public void deleteDevicePolicyByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_POLICY WHERE POLICY_ID IN " +
+ "(SELECT ID FROM DM_POLICY WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device policy for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteProfileFeaturesByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_PROFILE_FEATURES WHERE PROFILE_ID IN " +
+ "(SELECT ID FROM DM_PROFILE WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting profile features for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deletePolicyCorrectiveActionByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_POLICY_CORRECTIVE_ACTION WHERE POLICY_ID IN " +
+ "(SELECT ID FROM DM_POLICY WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting policy corrective action for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteProfileByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_PROFILE WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting profile for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteAppIconsByTenantId(int tenantId) throws DeviceManagementDAOException{
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_APP_ICONS WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting App Icons for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceGroupPolicyByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_GROUP_POLICY WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device group policy for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteNotificationByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_NOTIFICATION WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting notifications for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceInfoByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_INFO WHERE ENROLMENT_ID IN " +
+ "(SELECT ID FROM DM_ENROLMENT WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device info for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceLocationByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_LOCATION WHERE ENROLMENT_ID IN " +
+ "(SELECT ID FROM DM_ENROLMENT WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device location for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceHistoryLastSevenDaysByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_HISTORY_LAST_SEVEN_DAYS WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device history for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceDetailByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_DETAIL WHERE ENROLMENT_ID IN " +
+ "(SELECT ID FROM DM_ENROLMENT WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device detail for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteMetadataByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_METADATA WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting metadata for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteOTPDataByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_OTP_DATA WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting OTP data for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteGeofenceByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_GEOFENCE WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting geo fence for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteGeofenceGroupMappingByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_GEOFENCE_GROUP_MAPPING WHERE FENCE_ID IN " +
+ "(SELECT ID FROM DM_GEOFENCE WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting geo fence group mapping for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceEventByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_EVENT WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device event for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceEventGroupMappingByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_EVENT_GROUP_MAPPING WHERE EVENT_ID IN " +
+ "(SELECT ID FROM DM_DEVICE_EVENT WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device event group mapping for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteGeofenceEventMappingByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_GEOFENCE_EVENT_MAPPING WHERE FENCE_ID IN " +
+ "(SELECT ID FROM DM_GEOFENCE WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting geo fence event mapping for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteExternalGroupMappingByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_EXT_GROUP_MAPPING WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting external group mapping for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteExternalDeviceMappingByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_EXT_DEVICE_MAPPING WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting external device mapping for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteExternalPermissionMapping(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_EXT_PERMISSION_MAPPING WHERE TRACCAR_USER_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting ext permission mapping for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+
+ }
+
+ @Override
+ public void deleteDynamicTaskByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DYNAMIC_TASK WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting dynamic task for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDynamicTaskPropertiesByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DYNAMIC_TASK_PROPERTIES WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting dynamic task properties for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceSubTypeByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_SUB_TYPE WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device sub types for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteTraccarUnsyncedDevicesByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_TRACCAR_UNSYNCED_DEVICES WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting Traccar unsynced devices for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteSubOperationTemplate(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM SUB_OPERATION_TEMPLATE WHERE SUB_TYPE_ID IN " +
+ "(SELECT SUB_TYPE_ID FROM DM_DEVICE_SUB_TYPE WHERE TENANT_ID = ?)";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting sub operation template for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteDeviceOrganizationByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_DEVICE_ORGANIZATION WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting device organization for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+
+ @Override
+ public void deleteCEAPoliciesByTenantId(int tenantId) throws DeviceManagementDAOException {
+ try {
+ Connection conn = DeviceManagementDAOFactory.getConnection();
+ String sql = "DELETE FROM DM_CEA_POLICIES WHERE TENANT_ID = ?";
+ try (PreparedStatement stmt = conn.prepareStatement(sql)) {
+ stmt.setInt(1, tenantId);
+ stmt.executeUpdate();
+ }
+ } catch (SQLException e) {
+ String msg = "Error occurred while deleting CEA policies for Tenant ID " + tenantId;
+ log.error(msg, e);
+ throw new DeviceManagementDAOException(msg, e);
+ }
+
+ }
+}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java
index d3681a43c4..ff81879563 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/device/details/mgt/impl/DeviceInformationManagerImpl.java
@@ -18,6 +18,8 @@
package io.entgra.device.mgt.core.device.mgt.core.device.details.mgt.impl;
+import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
+import io.entgra.device.mgt.core.device.mgt.core.report.mgt.ReportingPublisherManager;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -29,7 +31,6 @@ import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceDetailsW
import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo;
import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocation;
import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException;
-import io.entgra.device.mgt.core.device.mgt.common.exceptions.EventPublishingException;
import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException;
import io.entgra.device.mgt.core.device.mgt.common.group.mgt.DeviceGroup;
import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException;
@@ -54,6 +55,8 @@ import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
public class DeviceInformationManagerImpl implements DeviceInformationManager {
@@ -86,6 +89,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
DeviceDetailsWrapper deviceDetailsWrapper = new DeviceDetailsWrapper();
deviceDetailsWrapper.setDeviceInfo(deviceInfo);
+ //Asynchronous call to publish the device information to the reporting service. Hence, response is ignored.
publishEvents(device, deviceDetailsWrapper, DeviceManagementConstants.Report.DEVICE_INFO_PARAM);
DeviceManagementDAOFactory.beginTransaction();
@@ -203,12 +207,34 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
getDeviceManagementProvider().getDevice(deviceIdentifier, false);
DeviceDetailsWrapper deviceDetailsWrapper = new DeviceDetailsWrapper();
deviceDetailsWrapper.setEvents(payload);
- return publishEvents(device, deviceDetailsWrapper, eventType);
+ Future apiCallback = publishEvents(device, deviceDetailsWrapper, eventType);
+ if (null != apiCallback) {
+ boolean isDebugEnabled = log.isDebugEnabled();
+ while(!apiCallback.isDone()) {
+ if (isDebugEnabled) {
+ log.debug("Waiting for the response from the API for the reporting data " +
+ "publishing for the device " + deviceId + ". Event payload: " + payload);
+ }
+ }
+ return apiCallback.get();
+ }
+ return 0; // If the event publishing is disabled.
} catch (DeviceManagementException e) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Event publishing error. Could not get device " + deviceId;
log.error(msg, e);
throw new DeviceDetailsMgtException(msg, e);
+ } catch (ExecutionException e) {
+ //Exceptions thrown in ReportingPublisherManager will be wrapped under this exception
+ String message = "Failed while publishing device information data to the reporting service for the device "
+ + deviceId;
+ log.error(message, e);
+ throw new DeviceDetailsMgtException(message, e);
+ } catch (InterruptedException e) {
+ String message = "Failed while publishing device information data to the reporting service. Thread " +
+ "interrupted while waiting for the response from the API for the Device " + deviceId;
+ log.error(message, e);
+ throw new DeviceDetailsMgtException(message, e);
}
}
@@ -217,7 +243,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
* @param device Device that is sending event
* @param deviceDetailsWrapper Payload to send(example, deviceinfo, applist, raw events)
*/
- private int publishEvents(Device device, DeviceDetailsWrapper deviceDetailsWrapper, String
+ private Future publishEvents(Device device, DeviceDetailsWrapper deviceDetailsWrapper, String
eventType) {
String reportingHost = HttpReportingUtil.getReportingHost();
if (!StringUtils.isBlank(reportingHost)
@@ -235,10 +261,12 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
String username = CarbonContext.getThreadLocalCarbonContext().getUsername();
if (StringUtils.isEmpty(username)) {
+ String requiredPermission = PermissionManagerServiceImpl.getInstance().getRequiredPermission();
+ String[] requiredPermissions = new String[] {requiredPermission};
boolean isUserAuthorized = DeviceManagementDataHolder.getInstance().
getDeviceAccessAuthorizationService().isUserAuthorized(
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()),
- device.getEnrolmentInfo().getOwner()
+ device.getEnrolmentInfo().getOwner(), requiredPermissions
);
if (isUserAuthorized) {
username = device.getEnrolmentInfo().getOwner();
@@ -252,9 +280,8 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
String eventUrl = reportingHost + DeviceManagementConstants.Report
.REPORTING_CONTEXT + DeviceManagementConstants.URL_SEPERATOR + eventType;
- return HttpReportingUtil.invokeApi(deviceDetailsWrapper.getJSONString(), eventUrl);
- } catch (EventPublishingException e) {
- log.error("Error occurred while sending events", e);
+ ReportingPublisherManager reportingManager = new ReportingPublisherManager();
+ return reportingManager.publishData(deviceDetailsWrapper, eventUrl);
} catch (GroupManagementException e) {
log.error("Error occurred while getting group list", e);
} catch (UserStoreException e) {
@@ -270,7 +297,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
+ DeviceManagerUtil.getTenantId());
}
}
- return 0;
+ return null;
}
@Override
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java
index 6736874487..48d573a5fa 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementDataHolder.java
@@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.device.mgt.core.internal;
import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices;
import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServices;
+import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAccessAuthorizationService;
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService;
import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService;
import org.wso2.carbon.context.PrivilegedCarbonContext;
@@ -78,6 +79,7 @@ public class DeviceManagementDataHolder {
private ConfigurationContextService configurationContextService;
private final HashMap requireDeviceAuthorization = new HashMap<>();
private DeviceAccessAuthorizationService deviceAccessAuthorizationService;
+ private GroupAccessAuthorizationService groupAccessAuthorizationService;
private GroupManagementProviderService groupManagementProviderService;
private TaskService taskService;
private EmailSenderService emailSenderService;
@@ -447,4 +449,12 @@ public class DeviceManagementDataHolder {
public void setPublisherRESTAPIServices(PublisherRESTAPIServices publisherRESTAPIServices) {
this.publisherRESTAPIServices = publisherRESTAPIServices;
}
+
+ public GroupAccessAuthorizationService getGroupAccessAuthorizationService() {
+ return groupAccessAuthorizationService;
+ }
+
+ public void setGroupAccessAuthorizationService(GroupAccessAuthorizationService groupAccessAuthorizationService) {
+ this.groupAccessAuthorizationService = groupAccessAuthorizationService;
+ }
}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java
index b36ad79eed..34a07f05b2 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/internal/DeviceManagementServiceComponent.java
@@ -17,7 +17,9 @@
*/
package io.entgra.device.mgt.core.device.mgt.core.internal;
+import io.entgra.device.mgt.core.device.mgt.common.authorization.GroupAccessAuthorizationService;
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService;
+import io.entgra.device.mgt.core.device.mgt.core.authorization.GroupAccessAuthorizationServiceImpl;
import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.DeviceStatusManagementServiceImpl;
import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.TaskConfigurationStartupHandler;
import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService;
@@ -354,6 +356,12 @@ public class DeviceManagementServiceComponent {
bundleContext.registerService(DeviceAccessAuthorizationService.class.getName(),
deviceAccessAuthorizationService, null);
+ /* Registering GroupAccessAuthorization Service */
+ GroupAccessAuthorizationService groupAccessAuthorizationService = new GroupAccessAuthorizationServiceImpl();
+ DeviceManagementDataHolder.getInstance().setGroupAccessAuthorizationService(groupAccessAuthorizationService);
+ bundleContext.registerService(GroupAccessAuthorizationService.class.getName(),
+ groupAccessAuthorizationService, null);
+
/* Registering Geo Service */
GeoLocationProviderService geoService = new GeoLocationProviderServiceImpl();
DeviceManagementDataHolder.getInstance().setGeoLocationProviderService(geoService);
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java
index c7a86bfb82..8cf4630f0a 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/OperationManagerImpl.java
@@ -19,6 +19,7 @@
package io.entgra.device.mgt.core.device.mgt.core.operation.mgt;
import com.google.gson.Gson;
+import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger;
import io.entgra.device.mgt.core.notification.logger.DeviceConnectivityLogContext;
import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceConnectivityLoggerImpl;
@@ -221,7 +222,7 @@ public class OperationManagerImpl implements OperationManager {
if (operationDto.getControl()
== io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Control.NO_REPEAT) {
Map pendingOperationIDs = operationDAO
- .getExistingOperationIDs(enrolments.keySet().toArray(new Integer[0]), operationCode);
+ .getExistingNotExecutedOperationIDs(enrolments.keySet().toArray(new Integer[0]), operationCode);
for (Integer enrolmentId : pendingOperationIDs.keySet()) {
operation.setId(pendingOperationIDs.get(enrolmentId));
device = enrolments.get(enrolmentId);
@@ -293,7 +294,7 @@ public class OperationManagerImpl implements OperationManager {
if (operationDto.getControl() ==
io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Control.NO_REPEAT) {
Map pendingOperationIDs = operationDAO
- .getExistingOperationIDs(enrolments.keySet().toArray(new Integer[0]), operationCode);
+ .getExistingNotExecutedOperationIDs(enrolments.keySet().toArray(new Integer[0]), operationCode);
Device device;
for (Integer enrolmentId : pendingOperationIDs.keySet()) {
operation.setId(pendingOperationIDs.get(enrolmentId));
@@ -367,7 +368,7 @@ public class OperationManagerImpl implements OperationManager {
if (operationDto.getControl() ==
io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Control.NO_REPEAT) {
Map pendingOperationIDs = operationDAO
- .getExistingOperationIDs(enrolments.keySet().toArray(new Integer[0]), operationCode);
+ .getExistingNotExecutedOperationIDs(enrolments.keySet().toArray(new Integer[0]), operationCode);
Device device;
for (Integer enrolmentId : pendingOperationIDs.keySet()) {
operation.setId(pendingOperationIDs.get(enrolmentId));
@@ -561,9 +562,11 @@ public class OperationManagerImpl implements OperationManager {
} else {
boolean isAuthorized;
authorizedDeviceList = new ArrayList<>();
+ String requiredPermission = PermissionManagerServiceImpl.getInstance().getRequiredPermission();
+ String[] requiredPermissions = new String[] {requiredPermission};
for (DeviceIdentifier devId : deviceIds) {
isAuthorized = DeviceManagementDataHolder.getInstance().getDeviceAccessAuthorizationService().
- isUserAuthorized(devId);
+ isUserAuthorized(devId, requiredPermissions);
if (isAuthorized) {
authorizedDeviceList.add(devId);
} else {
@@ -838,23 +841,23 @@ public class OperationManagerImpl implements OperationManager {
}
if (dtoOperation != null) {
- if (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND.equals(dtoOperation.getType()
- )) {
- io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
- commandOperation =
- (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
- getOperation(dtoOperation.getId());
- dtoOperation.setEnabled(commandOperation.isEnabled());
- } else if (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG.equals(dtoOperation.
- getType())) {
- dtoOperation = configOperationDAO.getOperation(dtoOperation.getId());
- } else if (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.PROFILE.equals(dtoOperation.
- getType())) {
- dtoOperation = profileOperationDAO.getOperation(dtoOperation.getId());
- } else if (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.POLICY.equals(dtoOperation.
- getType())) {
- dtoOperation = policyOperationDAO.getOperation(dtoOperation.getId());
- }
+// if (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND.equals(dtoOperation.getType()
+// )) {
+// io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
+// commandOperation =
+// (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
+// getOperation(dtoOperation.getId());
+// dtoOperation.setEnabled(commandOperation.isEnabled());
+// } else if (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG.equals(dtoOperation.
+// getType())) {
+// dtoOperation = configOperationDAO.getOperation(dtoOperation.getId());
+// } else if (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.PROFILE.equals(dtoOperation.
+// getType())) {
+// dtoOperation = profileOperationDAO.getOperation(dtoOperation.getId());
+// } else if (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.POLICY.equals(dtoOperation.
+// getType())) {
+// dtoOperation = policyOperationDAO.getOperation(dtoOperation.getId());
+// }
operation = OperationDAOUtil.convertOperation(dtoOperation);
}
} catch (OperationManagementDAOException e) {
@@ -1047,29 +1050,29 @@ public class OperationManagerImpl implements OperationManager {
io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation deviceSpecificOperation = operationDAO.
getOperationByDeviceAndId(enrolmentInfo.getId(),
operationId);
- io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation dtoOperation = deviceSpecificOperation;
- if (deviceSpecificOperation.getType().
- equals(io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
- io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
- commandOperation =
- (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
- getOperation(deviceSpecificOperation.getId());
- dtoOperation.setEnabled(commandOperation.isEnabled());
- } else if (deviceSpecificOperation.getType().
- equals(io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
- dtoOperation = configOperationDAO.getOperation(deviceSpecificOperation.getId());
- } else if (deviceSpecificOperation.getType().equals(
- io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.PROFILE)) {
- dtoOperation = profileOperationDAO.getOperation(deviceSpecificOperation.getId());
- } else if (deviceSpecificOperation.getType().equals(
- io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.POLICY)) {
- dtoOperation = policyOperationDAO.getOperation(deviceSpecificOperation.getId());
- }
- if (dtoOperation == null) {
- throw new OperationManagementException("Operation not found for operation Id:" + operationId +
- " device id:" + deviceId.getId());
- }
- dtoOperation.setStatus(deviceSpecificOperation.getStatus());
+// io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation dtoOperation = deviceSpecificOperation;
+// if (deviceSpecificOperation.getType().
+// equals(io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
+// io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
+// commandOperation =
+// (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
+// getOperation(deviceSpecificOperation.getId());
+// dtoOperation.setEnabled(commandOperation.isEnabled());
+// } else if (deviceSpecificOperation.getType().
+// equals(io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
+// dtoOperation = configOperationDAO.getOperation(deviceSpecificOperation.getId());
+// } else if (deviceSpecificOperation.getType().equals(
+// io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.PROFILE)) {
+// dtoOperation = profileOperationDAO.getOperation(deviceSpecificOperation.getId());
+// } else if (deviceSpecificOperation.getType().equals(
+// io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.POLICY)) {
+// dtoOperation = policyOperationDAO.getOperation(deviceSpecificOperation.getId());
+// }
+// if (dtoOperation == null) {
+// throw new OperationManagementException("Operation not found for operation Id:" + operationId +
+// " device id:" + deviceId.getId());
+// }
+// dtoOperation.setStatus(deviceSpecificOperation.getStatus());
operation = OperationDAOUtil.convertOperation(deviceSpecificOperation);
} catch (OperationManagementDAOException e) {
throw new OperationManagementException("Error occurred while retrieving the list of " +
@@ -1152,23 +1155,23 @@ public class OperationManagerImpl implements OperationManager {
throw new OperationManagementException("Operation not found for given Id:" + operationId);
}
- if (dtoOperation.getType()
- .equals(io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
- io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
- commandOperation =
- (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
- getOperation(dtoOperation.getId());
- dtoOperation.setEnabled(commandOperation.isEnabled());
- } else if (dtoOperation.getType().
- equals(io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
- dtoOperation = configOperationDAO.getOperation(dtoOperation.getId());
- } else if (dtoOperation.getType().equals(io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.
- PROFILE)) {
- dtoOperation = profileOperationDAO.getOperation(dtoOperation.getId());
- } else if (dtoOperation.getType().equals(io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.
- POLICY)) {
- dtoOperation = policyOperationDAO.getOperation(dtoOperation.getId());
- }
+// if (dtoOperation.getType()
+// .equals(io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
+// io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
+// commandOperation =
+// (io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
+// getOperation(dtoOperation.getId());
+// dtoOperation.setEnabled(commandOperation.isEnabled());
+// } else if (dtoOperation.getType().
+// equals(io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
+// dtoOperation = configOperationDAO.getOperation(dtoOperation.getId());
+// } else if (dtoOperation.getType().equals(io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.
+// PROFILE)) {
+// dtoOperation = profileOperationDAO.getOperation(dtoOperation.getId());
+// } else if (dtoOperation.getType().equals(io.entgra.device.mgt.core.device.mgt.core.dto.operation.mgt.Operation.Type.
+// POLICY)) {
+// dtoOperation = policyOperationDAO.getOperation(dtoOperation.getId());
+// }
operation = OperationDAOUtil.convertOperation(dtoOperation);
} catch (OperationManagementDAOException e) {
throw new OperationManagementException("Error occurred while retrieving the operation with operation Id '" +
@@ -1470,9 +1473,11 @@ public class OperationManagerImpl implements OperationManager {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
String user = this.getUser();
boolean isUserAuthorized;
+ String requiredPermission = PermissionManagerServiceImpl.getInstance().getRequiredPermission();
+ String[] requiredPermissions = new String[] {requiredPermission};
try {
isUserAuthorized = DeviceManagementDataHolder.getInstance()
- .getDeviceAccessAuthorizationService().isUserAuthorized(deviceId, user);
+ .getDeviceAccessAuthorizationService().isUserAuthorized(deviceId, user, requiredPermissions);
} catch (DeviceAccessAuthorizationException e) {
throw new OperationManagementException("Error occurred while checking the device access permissions for '" +
deviceId.getType() + "' device carrying the identifier '" +
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationDAO.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationDAO.java
index 4fe22494c6..4abaf40022 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationDAO.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/OperationDAO.java
@@ -62,7 +62,7 @@ public interface OperationDAO {
void updateEnrollmentOperationsStatus(int enrolmentId, String operationCode, Operation.Status existingStatus,
Operation.Status newStatus) throws OperationManagementDAOException;
- Map getExistingOperationIDs(Integer[] enrolmentIds, String operationCode)
+ Map getExistingNotExecutedOperationIDs(Integer[] enrolmentIds, String operationCode)
throws OperationManagementDAOException;
OperationResponseMeta addOperationResponse(int enrolmentId, io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation operation, String deviceId)
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java
index 319e2d09f8..ddb77a24a4 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java
@@ -59,6 +59,7 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@@ -75,15 +76,16 @@ public class GenericOperationDAOImpl implements OperationDAO {
try {
Connection connection = OperationManagementDAOFactory.getConnection();
String sql = "INSERT INTO DM_OPERATION(TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, " +
- "INITIATED_BY, OPERATION_DETAILS, TENANT_ID) VALUES (?, ?, ?, ?, ?, ?, ?)";
+ "INITIATED_BY, OPERATION_DETAILS, OPERATION_PROPERTIES, TENANT_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
stmt = connection.prepareStatement(sql, new String[]{"id"});
stmt.setString(1, operation.getType().toString());
stmt.setLong(2, DeviceManagementDAOUtil.getCurrentUTCTime());
stmt.setLong(3, 0);
stmt.setString(4, operation.getCode());
stmt.setString(5, operation.getInitiatedBy());
- stmt.setObject(6, operation);
- stmt.setInt(7, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
+ stmt.setObject(6, operation.getPayLoad());
+ stmt.setObject(7, operation.getProperties());
+ stmt.setInt(8, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
stmt.executeUpdate();
rs = stmt.getGeneratedKeys();
@@ -164,7 +166,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
}
@Override
- public Map getExistingOperationIDs(Integer[] enrolmentIds, String operationCode)
+ public Map getExistingNotExecutedOperationIDs(Integer[] enrolmentIds, String operationCode)
throws OperationManagementDAOException {
PreparedStatement stmt = null;
ResultSet rs = null;
@@ -576,7 +578,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
+ "dor.ID AS OP_RES_ID, de.DEVICE_ID, d.DEVICE_IDENTIFICATION, d.DEVICE_TYPE_ID, "
+ "dt.NAME AS DEVICE_TYPE_NAME, eom.STATUS, eom.CREATED_TIMESTAMP, "
+ "eom.UPDATED_TIMESTAMP, op.OPERATION_CODE, op.TYPE AS OPERATION_TYPE, "
- + "dor.OPERATION_RESPONSE, op.INITIATED_BY, dor.RECEIVED_TIMESTAMP, dor.IS_LARGE_RESPONSE FROM "
+ + "dor.OPERATION_RESPONSE, op.INITIATED_BY, dor.RECEIVED_TIMESTAMP, dor.IS_LARGE_RESPONSE FROM "
+ "DM_ENROLMENT_OP_MAPPING eom INNER JOIN DM_OPERATION op "
+ "ON op.ID=eom.OPERATION_ID INNER JOIN DM_ENROLMENT de "
+ "ON de.ID=eom.ENROLMENT_ID INNER JOIN DM_DEVICE d ON d.ID=de.DEVICE_ID "
@@ -1189,24 +1191,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
Operation operation = null;
try {
Connection conn = OperationManagementDAOFactory.getConnection();
- String sql = "SELECT ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, INITIATED_BY FROM " +
- "DM_OPERATION WHERE id = ?";
+ String sql = "SELECT ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, INITIATED_BY, " +
+ "OPERATION_DETAILS, OPERATION_PROPERTIES FROM DM_OPERATION WHERE id = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, id);
rs = stmt.executeQuery();
if (rs.next()) {
- operation = new Operation();
- operation.setId(rs.getInt("ID"));
- operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
- operation.setCreatedTimeStamp(new Timestamp(rs.getLong("CREATED_TIMESTAMP") * 1000L).toString());
- if (rs.getLong("RECEIVED_TIMESTAMP") == 0) {
- operation.setReceivedTimeStamp("");
- } else {
- operation.setReceivedTimeStamp(new Timestamp(rs.getLong("RECEIVED_TIMESTAMP") * 1000L).toString());
- }
- operation.setCode(rs.getString("OPERATION_CODE"));
- operation.setInitiatedBy(rs.getString("INITIATED_BY"));
+ operation = OperationDAOUtil.getOperation(rs);
}
} catch (SQLException e) {
@@ -1219,16 +1211,19 @@ public class GenericOperationDAOImpl implements OperationDAO {
}
@Override
- public Operation getOperationByDeviceAndId(int enrolmentId, int operationId) throws OperationManagementDAOException {
+ public Operation getOperationByDeviceAndId(int enrolmentId, int operationId)
+ throws OperationManagementDAOException {
PreparedStatement stmt = null;
ResultSet rs = null;
Operation operation = null;
try {
Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, om.STATUS, " +
- "o.OPERATION_CODE, o.INITIATED_BY, om.ID AS OM_MAPPING_ID, " +
- "om.UPDATED_TIMESTAMP FROM (SELECT ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP," +
- "OPERATION_CODE, INITIATED_BY FROM DM_OPERATION WHERE id = ?) o INNER JOIN (SELECT * FROM " +
+ "o.OPERATION_CODE, o.INITIATED_BY, o.OPERATION_DETAILS, o.OPERATION_PROPERTIES, " +
+ "om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP, om.STATUS FROM " +
+ "(SELECT ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP," +
+ "OPERATION_CODE, INITIATED_BY, OPERATION_DETAILS, OPERATION_PROPERTIES FROM DM_OPERATION " +
+ "WHERE id = ?) o INNER JOIN (SELECT * FROM " +
"DM_ENROLMENT_OP_MAPPING dm where dm.OPERATION_ID = ? AND dm.ENROLMENT_ID = ?) om " +
"ON o.ID = om.OPERATION_ID ";
stmt = conn.prepareStatement(sql);
@@ -1238,20 +1233,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
rs = stmt.executeQuery();
if (rs.next()) {
- operation = new Operation();
- operation.setId(rs.getInt("ID"));
- operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
- operation.setCreatedTimeStamp(new Timestamp(rs.getLong("CREATED_TIMESTAMP") * 1000L).toString());
- operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
+ operation = OperationDAOUtil.getOperation(rs);
if (rs.getLong("UPDATED_TIMESTAMP") == 0) {
operation.setReceivedTimeStamp("");
} else {
operation.setReceivedTimeStamp(
new Timestamp((rs.getLong("UPDATED_TIMESTAMP") * 1000)).toString());
}
- operation.setCode(rs.getString("OPERATION_CODE"));
- operation.setInitiatedBy(rs.getString("INITIATED_BY"));
- OperationDAOUtil.setActivityId(operation, rs.getInt("ID"));
+ operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
}
} catch (SQLException e) {
throw new OperationManagementDAOException("SQL error occurred while retrieving the operation " +
@@ -1272,7 +1261,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
try {
Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.OPERATION_CODE, " +
- "o.INITIATED_BY, om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
+ "o.INITIATED_BY, o.OPERATION_DETAILS, o.OPERATION_PROPERTIES, om.ID AS OM_MAPPING_ID, " +
+ "om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID ORDER BY o.CREATED_TIMESTAMP DESC";
stmt = conn.prepareStatement(sql);
@@ -1281,20 +1271,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
rs = stmt.executeQuery();
while (rs.next()) {
- operation = new Operation();
- operation.setId(rs.getInt("ID"));
- operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
- operation.setCreatedTimeStamp(new Timestamp(rs.getLong("CREATED_TIMESTAMP") * 1000L).toString());
+ operation = OperationDAOUtil.getOperation(rs);
+ operation.setStatus(status);
if (rs.getLong("UPDATED_TIMESTAMP") == 0) {
operation.setReceivedTimeStamp("");
} else {
operation.setReceivedTimeStamp(
new Timestamp((rs.getLong("UPDATED_TIMESTAMP") * 1000)).toString());
}
- operation.setCode(rs.getString("OPERATION_CODE"));
- operation.setInitiatedBy(rs.getString("INITIATED_BY"));
- operation.setStatus(status);
- OperationDAOUtil.setActivityId(operation, rs.getInt("ID"));
operations.add(operation);
}
} catch (SQLException e) {
@@ -1317,7 +1301,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
try {
Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.OPERATION_CODE, " +
- "o.INITIATED_BY, om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
+ "o.INITIATED_BY, o.OPERATION_DETAILS, o.OPERATION_PROPERTIES, om.ID AS OM_MAPPING_ID, " +
+ "om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID ORDER BY " +
"o.CREATED_TIMESTAMP DESC LIMIT ?,?";
@@ -1329,20 +1314,15 @@ public class GenericOperationDAOImpl implements OperationDAO {
rs = stmt.executeQuery();
while (rs.next()) {
- operation = new Operation();
- operation.setId(rs.getInt("ID"));
- operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
- operation.setCreatedTimeStamp(new Timestamp(rs.getLong("CREATED_TIMESTAMP") * 1000L).toString());
+ operation = OperationDAOUtil.getOperation(rs);
+ operation.setStatus(status);
if (rs.getLong("UPDATED_TIMESTAMP") == 0) {
operation.setReceivedTimeStamp("");
} else {
operation.setReceivedTimeStamp(
new Timestamp((rs.getLong("UPDATED_TIMESTAMP") * 1000)).toString());
}
- operation.setCode(rs.getString("OPERATION_CODE"));
- operation.setInitiatedBy(rs.getString("INITIATED_BY"));
operation.setStatus(status);
- OperationDAOUtil.setActivityId(operation, rs.getInt("OM_MAPPING_ID"));
operations.add(operation);
}
} catch (SQLException e) {
@@ -1364,7 +1344,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
try {
Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, " +
- "o.OPERATION_CODE, o.INITIATED_BY, om.STATUS, om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP " +
+ "o.OPERATION_CODE, o.INITIATED_BY, o.OPERATION_DETAILS, o.OPERATION_PROPERTIES, om.STATUS, " +
+ "om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP " +
"FROM DM_OPERATION o INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"WHERE dm.ENROLMENT_ID = ?) om ON o.ID = om.OPERATION_ID " +
"ORDER BY o.CREATED_TIMESTAMP DESC, o.ID DESC";
@@ -1373,18 +1354,13 @@ public class GenericOperationDAOImpl implements OperationDAO {
rs = stmt.executeQuery();
while (rs.next()) {
- operation = new Operation();
- operation.setId(rs.getInt("ID"));
- operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
- operation.setCreatedTimeStamp(new Timestamp(rs.getLong("CREATED_TIMESTAMP") * 1000L).toString());
+ operation = OperationDAOUtil.getOperation(rs);
if (rs.getLong("UPDATED_TIMESTAMP") == 0) {
operation.setReceivedTimeStamp("");
} else {
operation.setReceivedTimeStamp(
new Timestamp((rs.getLong("UPDATED_TIMESTAMP") * 1000)).toString());
}
- operation.setCode(rs.getString("OPERATION_CODE"));
- operation.setInitiatedBy(rs.getString("INITIATED_BY"));
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
operations.add(operation);
}
@@ -1428,6 +1404,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
"o.OPERATION_CODE, " +
"o.INITIATED_BY, " +
"o.OPERATION_DETAILS, " +
+ "o.OPERATION_PROPERTIES, " +
"om.STATUS, " +
"om.ID AS OM_MAPPING_ID, " +
"om.UPDATED_TIMESTAMP " +
@@ -1514,36 +1491,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
stmt.setInt(paramIndex, request.getRowCount());
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
- operation = new Operation();
- operation.setId(rs.getInt("ID"));
- operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
- operation.setCreatedTimeStamp(new Timestamp(rs.getLong("CREATED_TIMESTAMP") * 1000L).toString());
+ operation = OperationDAOUtil.getOperation(rs);
if (rs.getLong("UPDATED_TIMESTAMP") == 0) {
operation.setReceivedTimeStamp("");
} else {
operation.setReceivedTimeStamp(
new Timestamp((rs.getLong("UPDATED_TIMESTAMP") * 1000)).toString());
}
- operation.setCode(rs.getString("OPERATION_CODE"));
- operation.setInitiatedBy(rs.getString("INITIATED_BY"));
- if (MDMAppConstants.AndroidConstants.UNMANAGED_APP_UNINSTALL.equals(operation.getCode())) {
- byte[] operationDetails = rs.getBytes("OPERATION_DETAILS");
- try (ByteArrayInputStream bais = new ByteArrayInputStream(operationDetails);
- ObjectInputStream ois = new ObjectInputStream(bais)) {
- profileOperation = (ProfileOperation) ois.readObject();
- operation.setPayLoad(profileOperation.getPayLoad());
- } catch (IOException e) {
- String msg = "IO Error occurred while retrieving app data of operation ";
- log.error(msg, e);
- throw new OperationManagementDAOException(msg, e);
- } catch (ClassNotFoundException e) {
- String msg = "Class not found error occurred while retrieving app data of operation ";
- log.error(msg, e);
- throw new OperationManagementDAOException(msg, e);
- }
- }
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
- OperationDAOUtil.setActivityId(operation, rs.getInt("ID"));
operations.add(operation);
}
}
@@ -1562,7 +1517,6 @@ public class GenericOperationDAOImpl implements OperationDAO {
List operations = new ArrayList<>();
String createdTo = null;
String createdFrom = null;
- ProfileOperation profileOperation = null;
DateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
boolean isCreatedDayProvided = false;
boolean isUpdatedDayProvided = false; //updated day = received day
@@ -1586,6 +1540,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
"o.OPERATION_CODE, " +
"o.INITIATED_BY, " +
"o.OPERATION_DETAILS, " +
+ "o.OPERATION_PROPERTIES, " +
"om.STATUS, " +
"om.ID AS OM_MAPPING_ID, " +
"om.UPDATED_TIMESTAMP " +
@@ -1672,36 +1627,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
stmt.setInt(paramIndex, request.getRowCount());
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
- operation = new Operation();
- operation.setId(rs.getInt("ID"));
- operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
- operation.setCreatedTimeStamp(new Timestamp(rs.getLong("CREATED_TIMESTAMP") * 1000L).toString());
+ operation = OperationDAOUtil.getOperation(rs);
if (rs.getLong("UPDATED_TIMESTAMP") == 0) {
operation.setReceivedTimeStamp("");
} else {
operation.setReceivedTimeStamp(
new Timestamp((rs.getLong("UPDATED_TIMESTAMP") * 1000)).toString());
}
- operation.setCode(rs.getString("OPERATION_CODE"));
- operation.setInitiatedBy(rs.getString("INITIATED_BY"));
- if (MDMAppConstants.AndroidConstants.UNMANAGED_APP_UNINSTALL.equals(operation.getCode())) {
- byte[] operationDetails = rs.getBytes("OPERATION_DETAILS");
- try (ByteArrayInputStream bais = new ByteArrayInputStream(operationDetails);
- ObjectInputStream ois = new ObjectInputStream(bais)) {
- profileOperation = (ProfileOperation) ois.readObject();
- operation.setPayLoad(profileOperation.getPayLoad());
- } catch (IOException e) {
- String msg = "IO Error occurred while retrieving app data of operation ";
- log.error(msg, e);
- throw new OperationManagementDAOException(msg, e);
- } catch (ClassNotFoundException e) {
- String msg = "Class not found error occurred while retrieving app data of operation ";
- log.error(msg, e);
- throw new OperationManagementDAOException(msg, e);
- }
- }
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
- OperationDAOUtil.setActivityId(operation, rs.getInt("ID"));
operations.add(operation);
}
}
@@ -1932,7 +1865,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
try {
Connection connection = OperationManagementDAOFactory.getConnection();
stmt = connection.prepareStatement("SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, " +
- "o.OPERATION_CODE, o.INITIATED_BY, om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
+ "o.OPERATION_CODE, o.INITIATED_BY, o.OPERATION_DETAILS, o.OPERATION_PROPERTIES, " +
+ "om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM DM_OPERATION o " +
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID " +
"ORDER BY om.UPDATED_TIMESTAMP ASC, om.ID ASC LIMIT 1");
@@ -1942,21 +1876,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
Operation operation = null;
if (rs.next()) {
- operation = new Operation();
- operation.setType(OperationDAOUtil.getType(rs.getString("TYPE")));
- operation.setId(rs.getInt("ID"));
- operation.setCreatedTimeStamp(new Timestamp(rs.getLong("CREATED_TIMESTAMP") * 1000L).toString());
-
+ operation = OperationDAOUtil.getOperation(rs);
if (rs.getLong("UPDATED_TIMESTAMP") == 0) {
operation.setReceivedTimeStamp("");
} else {
operation.setReceivedTimeStamp(
new Timestamp((rs.getLong("UPDATED_TIMESTAMP") * 1000)).toString());
}
- operation.setCode(rs.getString("OPERATION_CODE"));
- operation.setInitiatedBy(rs.getString("INITIATED_BY"));
operation.setStatus(Operation.Status.PENDING);
- OperationDAOUtil.setActivityId(operation, rs.getInt("ID"));
}
return operation;
} catch (SQLException e) {
@@ -1975,8 +1902,9 @@ public class GenericOperationDAOImpl implements OperationDAO {
List operations = new ArrayList<>();
try {
Connection conn = OperationManagementDAOFactory.getConnection();
- String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, OPERATION_CODE, o.INITIATED_BY," +
- " om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM " +
+ String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, OPERATION_CODE, " +
+ "o.INITIATED_BY, o.OPERATION_DETAILS, o.OPERATION_PROPERTIES, " +
+ "om.ID AS OM_MAPPING_ID, om.UPDATED_TIMESTAMP FROM " +
"(SELECT o.ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, INITIATED_BY " +
"FROM DM_OPERATION o WHERE o.TYPE = ?) o INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm " +
"WHERE dm.ENROLMENT_ID = ? AND dm.STATUS = ?) om ON o.ID = om.OPERATION_ID ORDER BY o.CREATED_TIMESTAMP ASC";
@@ -1988,19 +1916,14 @@ public class GenericOperationDAOImpl implements OperationDAO {
rs = stmt.executeQuery();
while (rs.next()) {
- operation = new Operation();
- operation.setId(rs.getInt("ID"));
- operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
- operation.setCreatedTimeStamp(new Timestamp(rs.getLong("CREATED_TIMESTAMP") * 1000L).toString());
+ operation = OperationDAOUtil.getOperation(rs);
+ operation.setStatus(status);
if (rs.getLong("UPDATED_TIMESTAMP") == 0) {
operation.setReceivedTimeStamp("");
} else {
operation.setReceivedTimeStamp(
new Timestamp((rs.getLong("UPDATED_TIMESTAMP") * 1000)).toString());
}
- operation.setCode(rs.getString("OPERATION_CODE"));
- operation.setInitiatedBy(rs.getString("INITIATED_BY"));
- OperationDAOUtil.setActivityId(operation, rs.getInt("ID"));
operations.add(operation);
}
} catch (SQLException e) {
@@ -2013,7 +1936,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
}
@Override
- public Map> getOperationMappingsByStatus(Operation.Status opStatus, Operation.PushNotificationStatus pushNotificationStatus,
+ public Map> getOperationMappingsByStatus(Operation.Status opStatus,
+ Operation.PushNotificationStatus pushNotificationStatus,
int limit) throws OperationManagementDAOException {
PreparedStatement stmt = null;
ResultSet rs = null;
@@ -2059,7 +1983,8 @@ public class GenericOperationDAOImpl implements OperationDAO {
@Override
public Map> getAllocatedOperationMappingsByStatus(Operation.Status opStatus,
- Operation.PushNotificationStatus pushNotificationStatus, int limit, int activeServerCount, int serverIndex)
+ Operation.PushNotificationStatus pushNotificationStatus,
+ int limit, int activeServerCount, int serverIndex)
throws OperationManagementDAOException {
PreparedStatement stmt = null;
ResultSet rs = null;
@@ -2272,7 +2197,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getDeviceType() != null ||
(activityPaginationRequest.getDeviceIds() != null && !activityPaginationRequest.getDeviceIds().isEmpty()) ||
activityPaginationRequest.getSince() != 0 ||
- activityPaginationRequest.getStatus() != null) {
+ activityPaginationRequest.getStatuses() != null) {
sql.append("(SELECT DISTINCT OPERATION_ID FROM DM_ENROLMENT_OP_MAPPING eom WHERE TENANT_ID = ? ");
@@ -2305,8 +2230,12 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getType() != null) {
sql.append("AND TYPE = ? ");
}
- if (activityPaginationRequest.getStatus() != null) {
- sql.append("AND STATUS = ? ");
+ if (activityPaginationRequest.getStatuses() != null && !activityPaginationRequest.getStatuses().isEmpty()) {
+ sql.append("AND STATUS IN (");
+ for (int i = 0; i < activityPaginationRequest.getStatuses().size() - 1; i++) {
+ sql.append("?, ");
+ }
+ sql.append("?) ");
}
sql.append("ORDER BY OPERATION_ID ASC limit ? , ? ) eom_ordered " +
@@ -2360,8 +2289,12 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getType() != null) {
sql.append("AND eom.TYPE = ? ");
}
- if (activityPaginationRequest.getStatus() != null) {
- sql.append("AND eom.STATUS = ? ");
+ if (activityPaginationRequest.getStatuses() != null && !activityPaginationRequest.getStatuses().isEmpty()) {
+ sql.append("AND eom.STATUS IN (");
+ for (int i = 0; i < activityPaginationRequest.getStatuses().size() - 1; i++) {
+ sql.append("?, ");
+ }
+ sql.append("?) ");
}
sql.append("ORDER BY eom.OPERATION_ID, eom.UPDATED_TIMESTAMP");
@@ -2372,7 +2305,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getDeviceType() != null ||
(activityPaginationRequest.getDeviceIds() != null && !activityPaginationRequest.getDeviceIds().isEmpty()) ||
activityPaginationRequest.getSince() != 0 ||
- activityPaginationRequest.getStatus() != null) {
+ activityPaginationRequest.getStatuses() != null) {
if (activityPaginationRequest.getDeviceType() != null) {
stmt.setString(index++, activityPaginationRequest.getDeviceType());
@@ -2401,8 +2334,10 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getType() != null) {
stmt.setString(index++, activityPaginationRequest.getType().name());
}
- if (activityPaginationRequest.getStatus() != null) {
- stmt.setString(index++, activityPaginationRequest.getStatus().name());
+ if (activityPaginationRequest.getStatuses() != null && !activityPaginationRequest.getStatuses().isEmpty()) {
+ for (io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation.Status status : activityPaginationRequest.getStatuses()) {
+ stmt.setString(index++, status.name());
+ }
}
stmt.setInt(index++, activityPaginationRequest.getOffset());
@@ -2463,8 +2398,10 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getType() != null) {
stmt.setString(index++, activityPaginationRequest.getType().name());
}
- if (activityPaginationRequest.getStatus() != null) {
- stmt.setString(index, activityPaginationRequest.getStatus().name());
+ if (activityPaginationRequest.getStatuses() != null && !activityPaginationRequest.getStatuses().isEmpty()) {
+ for (io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation.Status status : activityPaginationRequest.getStatuses()) {
+ stmt.setString(index++, status.name());
+ }
}
try (ResultSet rs = stmt.executeQuery()) {
@@ -2496,7 +2433,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getDeviceType() != null ||
(activityPaginationRequest.getDeviceIds() != null && !activityPaginationRequest.getDeviceIds().isEmpty()) ||
activityPaginationRequest.getSince() != 0 ||
- activityPaginationRequest.getStatus() != null) {
+ activityPaginationRequest.getStatuses() != null) {
sql.append("SELECT count(DISTINCT OPERATION_ID) AS ACTIVITY_COUNT " +
"FROM DM_ENROLMENT_OP_MAPPING WHERE TENANT_ID = ? ");
@@ -2526,8 +2463,12 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getType() != null) {
sql.append("AND TYPE = ? ");
}
- if (activityPaginationRequest.getStatus() != null) {
- sql.append("AND STATUS = ? ");
+ if (activityPaginationRequest.getStatuses() != null && !activityPaginationRequest.getStatuses().isEmpty()) {
+ sql.append("AND STATUS IN (");
+ for (int i = 0; i < activityPaginationRequest.getStatuses().size() - 1; i++) {
+ sql.append("?, ");
+ }
+ sql.append("?) ");
}
} else {
@@ -2555,7 +2496,7 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getDeviceType() != null ||
(activityPaginationRequest.getDeviceIds() != null && !activityPaginationRequest.getDeviceIds().isEmpty()) ||
activityPaginationRequest.getSince() != 0 ||
- activityPaginationRequest.getStatus() != null) {
+ activityPaginationRequest.getStatuses() != null) {
if (activityPaginationRequest.getDeviceType() != null) {
stmt.setString(index++, activityPaginationRequest.getDeviceType());
}
@@ -2579,8 +2520,10 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getType() != null) {
stmt.setString(index++, activityPaginationRequest.getType().name());
}
- if (activityPaginationRequest.getStatus() != null) {
- stmt.setString(index++, activityPaginationRequest.getStatus().name());
+ if (activityPaginationRequest.getStatuses() != null && !activityPaginationRequest.getStatuses().isEmpty()) {
+ for (io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation.Status status : activityPaginationRequest.getStatuses()) {
+ stmt.setString(index++, status.name());
+ }
}
} else {
if (activityPaginationRequest.getOperationCode() != null) {
@@ -2662,8 +2605,12 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getType() != null) {
sql.append("AND TYPE = ? ");
}
- if (activityPaginationRequest.getStatus() != null) {
- sql.append("AND STATUS = ? ");
+ if (activityPaginationRequest.getStatuses() != null && !activityPaginationRequest.getStatuses().isEmpty()) {
+ sql.append("AND STATUS IN (");
+ for (int i = 0; i < activityPaginationRequest.getStatuses().size() - 1; i++) {
+ sql.append("?, ");
+ }
+ sql.append("?) ");
}
sql.append("ORDER BY ID ASC limit ? , ? ) eom " +
@@ -2700,8 +2647,10 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getType() != null) {
stmt.setString(index++, activityPaginationRequest.getType().name());
}
- if (activityPaginationRequest.getStatus() != null) {
- stmt.setString(index++, activityPaginationRequest.getStatus().name());
+ if (activityPaginationRequest.getStatuses() != null && !activityPaginationRequest.getStatuses().isEmpty()) {
+ for (io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation.Status status : activityPaginationRequest.getStatuses()) {
+ stmt.setString(index++, status.name());
+ }
}
stmt.setInt(index++, activityPaginationRequest.getOffset());
@@ -2744,7 +2693,6 @@ public class GenericOperationDAOImpl implements OperationDAO {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
StringBuilder sql = new StringBuilder();
-
sql.append("SELECT count(DISTINCT ID) AS ACTIVITY_COUNT " +
"FROM DM_ENROLMENT_OP_MAPPING WHERE TENANT_ID = ? ");
@@ -2773,8 +2721,12 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getType() != null) {
sql.append("AND TYPE = ? ");
}
- if (activityPaginationRequest.getStatus() != null) {
- sql.append("AND STATUS = ? ");
+ if (activityPaginationRequest.getStatuses() != null && !activityPaginationRequest.getStatuses().isEmpty()) {
+ sql.append("AND STATUS IN (");
+ for (int i = 0; i < activityPaginationRequest.getStatuses().size() - 1; i++) {
+ sql.append("?, ");
+ }
+ sql.append("?) ");
}
if (activityPaginationRequest.getStartTimestamp() > 0 && activityPaginationRequest.getEndTimestamp() > 0) {
@@ -2808,8 +2760,10 @@ public class GenericOperationDAOImpl implements OperationDAO {
if (activityPaginationRequest.getType() != null) {
stmt.setString(index++, activityPaginationRequest.getType().name());
}
- if (activityPaginationRequest.getStatus() != null) {
- stmt.setString(index++, activityPaginationRequest.getStatus().name());
+ if (activityPaginationRequest.getStatuses() != null && !activityPaginationRequest.getStatuses().isEmpty()) {
+ for (io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation.Status status : activityPaginationRequest.getStatuses()) {
+ stmt.setString(index++, status.name());
+ }
}
if (isTimeDurationFilteringProvided) {
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java
index e36828233f..6561868060 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java
@@ -44,6 +44,7 @@ import java.util.Date;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.TreeMap;
public class OperationDAOUtil {
@@ -330,4 +331,60 @@ public class OperationDAOUtil {
deviceActivity.setUpdatedTimestamp(new Date(rs.getLong(("UPDATED_TIMESTAMP")) * 1000).toString());
return deviceActivity;
}
+
+ public static Operation getOperation(ResultSet rs) throws OperationManagementDAOException, SQLException {
+ Operation operation = new Operation();
+ operation.setId(rs.getInt("ID"));
+ operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
+ operation.setCreatedTimeStamp(new Timestamp(rs.getLong("CREATED_TIMESTAMP") * 1000L).toString());
+ if (rs.getLong("RECEIVED_TIMESTAMP") == 0) {
+ operation.setReceivedTimeStamp("");
+ } else {
+ operation.setReceivedTimeStamp(
+ new Timestamp((rs.getLong("RECEIVED_TIMESTAMP") * 1000)).toString());
+ }
+ operation.setCode(rs.getString("OPERATION_CODE"));
+ operation.setInitiatedBy(rs.getString("INITIATED_BY"));
+ byte[] operationDetails = rs.getBytes("OPERATION_DETAILS");
+ if (!rs.wasNull()) {
+ try (ByteArrayInputStream bais = new ByteArrayInputStream(operationDetails);
+ ObjectInputStream ois = new ObjectInputStream(bais)) {
+ operation.setPayLoad(ois.readObject());
+ } catch (IOException e) {
+ String msg = "IO Error occurred while retrieving operation details";
+ log.error(msg, e);
+ throw new OperationManagementDAOException(msg, e);
+ } catch (ClassNotFoundException e) {
+ String msg = "Class not found error occurred while retrieving operation details";
+ log.error(msg, e);
+ throw new OperationManagementDAOException(msg, e);
+ } catch (Exception e) {
+ String msg = "Error occurred while retrieving operation details";
+ log.error(msg, e);
+ throw new OperationManagementDAOException(msg, e);
+ }
+ }
+ byte[] operationProperties = rs.getBytes("OPERATION_PROPERTIES");
+ if (!rs.wasNull()) {
+ try (ByteArrayInputStream bais = new ByteArrayInputStream(operationProperties);
+ ObjectInputStream ois = new ObjectInputStream(bais)) {
+ operation.setProperties((Properties) ois.readObject());
+ } catch (IOException e) {
+ String msg = "IO Error occurred while retrieving operation properties";
+ log.error(msg, e);
+ throw new OperationManagementDAOException(msg, e);
+ } catch (ClassNotFoundException e) {
+ String msg = "Class not found error occurred while retrieving operation properties";
+ log.error(msg, e);
+ throw new OperationManagementDAOException(msg, e);
+ } catch (Exception e) {
+ String msg = "Error occurred while retrieving operation properties";
+ log.error(msg, e);
+ throw new OperationManagementDAOException(msg, e);
+ }
+ }
+ OperationDAOUtil.setActivityId(operation, rs.getInt("ID"));
+ return operation;
+ }
+
}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceImpl.java
index 7de2a3a9c9..8b7c9244ad 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceImpl.java
@@ -32,6 +32,7 @@ public class PermissionManagerServiceImpl implements PermissionManagerService {
private static PermissionManagerServiceImpl registryBasedPermissionManager;
private static APIResourcePermissions apiResourcePermissions;
+ private ThreadLocal requiredPermission = null;
private PermissionManagerServiceImpl() {
}
@@ -64,4 +65,16 @@ public class PermissionManagerServiceImpl implements PermissionManagerService {
public List getPermission(String context) throws PermissionManagementException {
return apiResourcePermissions.getPermissions(context);
}
+
+ public String getRequiredPermission() {
+ if (requiredPermission == null) {
+ requiredPermission = new ThreadLocal<>();
+ }
+ return requiredPermission.get();
+ }
+
+ public void setRequiredPermission(String permission) {
+ requiredPermission = new ThreadLocal<>();
+ requiredPermission.set(permission);
+ }
}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/ReportingPublisherManager.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/ReportingPublisherManager.java
new file mode 100644
index 0000000000..b6e3bf5ae1
--- /dev/null
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/report/mgt/ReportingPublisherManager.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.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 io.entgra.device.mgt.core.device.mgt.core.report.mgt;
+
+import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceDetailsWrapper;
+import io.entgra.device.mgt.core.device.mgt.common.exceptions.EventPublishingException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.protocol.HTTP;
+
+import java.io.IOException;
+import java.net.ConnectException;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+public class ReportingPublisherManager {
+
+ private static final Log log = LogFactory.getLog(ReportingPublisherManager.class);
+ private final static ExecutorService executorService;
+ private DeviceDetailsWrapper payload;
+ private String endpoint;
+ private static final PoolingHttpClientConnectionManager poolingManager;
+
+ static {
+ executorService = Executors.newFixedThreadPool(10); //todo make this configurable
+ poolingManager = new PoolingHttpClientConnectionManager();
+ poolingManager.setMaxTotal(10); //todo make this configurable
+ poolingManager.setDefaultMaxPerRoute(10);
+ }
+
+ public Future publishData(DeviceDetailsWrapper deviceDetailsWrapper, String eventUrl) {
+ this.payload = deviceDetailsWrapper;
+ this.endpoint = eventUrl;
+ return executorService.submit(new ReportingPublisher());
+ }
+
+ private class ReportingPublisher implements Callable {
+ @Override
+ public Integer call() throws EventPublishingException {
+ try (CloseableHttpClient client = HttpClients.custom().setConnectionManager(poolingManager).build()) {
+ HttpPost apiEndpoint = new HttpPost(endpoint);
+ apiEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
+ StringEntity requestEntity = new StringEntity(payload.getJSONString(), ContentType.APPLICATION_JSON);
+ apiEndpoint.setEntity(requestEntity);
+ HttpResponse response = client.execute(apiEndpoint);
+ int statusCode = response.getStatusLine().getStatusCode();
+ if (log.isDebugEnabled()) {
+ log.debug("Published data to the reporting backend: " + endpoint + ", Response code: " + statusCode);
+ }
+ return statusCode;
+ } catch (ConnectException e) {
+ String message = "Connection refused while publishing reporting data to the API: " + endpoint;
+ log.error(message, e);
+ throw new EventPublishingException(message, e);
+ } catch (IOException e) {
+ String message = "Error occurred when publishing reporting data to the API: " + endpoint;
+ log.error(message, e);
+ throw new EventPublishingException(message, e);
+ }
+ }
+ }
+}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java
index 44f6fe15dd..683971472b 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderService.java
@@ -1070,4 +1070,5 @@ public interface DeviceManagementProviderService {
List getInstalledApplicationsOnDevice(Device device) throws DeviceManagementException;
List getEnrolledDevicesSince(Date since) throws DeviceManagementException;
List getEnrolledDevicesPriorTo(Date before) throws DeviceManagementException;
+ void deleteDeviceDataByTenantDomain(String tenantDomain) throws DeviceManagementException;
}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
index 5c8a8eb28e..7aad6f8f2e 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
@@ -21,6 +21,7 @@ package io.entgra.device.mgt.core.device.mgt.core.service;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService;
+import io.entgra.device.mgt.core.device.mgt.core.dao.TenantDAO;
import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger;
import io.entgra.device.mgt.core.notification.logger.DeviceEnrolmentLogContext;
import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceEnrolmentLoggerImpl;
@@ -160,7 +161,6 @@ import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
-import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
public class DeviceManagementProviderServiceImpl implements DeviceManagementProviderService,
@@ -178,6 +178,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
private final ApplicationDAO applicationDAO;
private MetadataDAO metadataDAO;
private final DeviceStatusDAO deviceStatusDAO;
+ private final TenantDAO tenantDao;
int count = 0;
public DeviceManagementProviderServiceImpl() {
@@ -188,6 +189,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
this.enrollmentDAO = DeviceManagementDAOFactory.getEnrollmentDAO();
this.metadataDAO = MetadataManagementDAOFactory.getMetadataDAO();
this.deviceStatusDAO = DeviceManagementDAOFactory.getDeviceStatusDAO();
+ this.tenantDao = DeviceManagementDAOFactory.getTenantDAO();
/* Registering a listener to retrieve events when some device management service plugin is installed after
* the component is done getting initialized */
@@ -5187,4 +5189,94 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
}
return devices;
}
+
+ @Override
+ public void deleteDeviceDataByTenantDomain(String tenantDomain) throws DeviceManagementException {
+ int tenantId;
+ try{
+ TenantMgtAdminService tenantMgtAdminService = new TenantMgtAdminService();
+ TenantInfoBean tenantInfoBean = tenantMgtAdminService.getTenant(tenantDomain);
+ tenantId = tenantInfoBean.getTenantId();
+
+ } catch (Exception e) {
+ String msg = "Error getting tenant ID from domain: "
+ + tenantDomain;
+ log.error(msg);
+ throw new DeviceManagementException(msg, e);
+ }
+
+ try {
+ DeviceManagementDAOFactory.beginTransaction();
+
+ tenantDao.deleteExternalPermissionMapping(tenantId);
+ tenantDao.deleteExternalDeviceMappingByTenantId(tenantId);
+ tenantDao.deleteExternalGroupMappingByTenantId(tenantId);
+ // TODO: Check whether deleting DM_DEVICE_ORGANIZATION table data is necessary
+// tenantDao.deleteDeviceOrganizationByTenantId(tenantId);
+ tenantDao.deleteDeviceHistoryLastSevenDaysByTenantId(tenantId);
+ tenantDao.deleteDeviceDetailByTenantId(tenantId);
+ tenantDao.deleteDeviceLocationByTenantId(tenantId);
+ tenantDao.deleteDeviceInfoByTenantId(tenantId);
+ tenantDao.deleteNotificationByTenantId(tenantId);
+ tenantDao.deleteAppIconsByTenantId(tenantId);
+ tenantDao.deleteTraccarUnsyncedDevicesByTenantId(tenantId);
+ tenantDao.deleteDeviceEventGroupMappingByTenantId(tenantId);
+ tenantDao.deleteGeofenceEventMappingByTenantId(tenantId);
+ tenantDao.deleteDeviceEventByTenantId(tenantId);
+ tenantDao.deleteGeofenceGroupMappingByTenantId(tenantId);
+ tenantDao.deleteGeofenceByTenantId(tenantId);
+ tenantDao.deleteDeviceGroupPolicyByTenantId(tenantId);
+ tenantDao.deleteDynamicTaskPropertiesByTenantId(tenantId);
+ tenantDao.deleteDynamicTaskByTenantId(tenantId);
+ tenantDao.deleteMetadataByTenantId(tenantId);
+ tenantDao.deleteOTPDataByTenantId(tenantId);
+ tenantDao.deleteSubOperationTemplate(tenantId);
+ tenantDao.deleteDeviceSubTypeByTenantId(tenantId);
+ tenantDao.deleteCEAPoliciesByTenantId(tenantId);
+
+ tenantDao.deleteApplicationByTenantId(tenantId);
+ tenantDao.deletePolicyCriteriaPropertiesByTenantId(tenantId);
+ tenantDao.deletePolicyCriteriaByTenantId(tenantId);
+ tenantDao.deleteCriteriaByTenantId(tenantId);
+ tenantDao.deletePolicyChangeManagementByTenantId(tenantId);
+ tenantDao.deletePolicyComplianceFeaturesByTenantId(tenantId);
+ tenantDao.deletePolicyComplianceStatusByTenantId(tenantId);
+ tenantDao.deleteRolePolicyByTenantId(tenantId);
+ tenantDao.deleteUserPolicyByTenantId(tenantId);
+ tenantDao.deleteDeviceTypePolicyByTenantId(tenantId);
+ tenantDao.deleteDevicePolicyAppliedByTenantId(tenantId);
+ tenantDao.deleteDevicePolicyByTenantId(tenantId);
+ tenantDao.deletePolicyCorrectiveActionByTenantId(tenantId);
+ tenantDao.deletePolicyByTenantId(tenantId);
+ tenantDao.deleteProfileFeaturesByTenantId(tenantId);
+ tenantDao.deleteProfileByTenantId(tenantId);
+
+ tenantDao.deleteDeviceOperationResponseLargeByTenantId(tenantId);
+ tenantDao.deleteDeviceOperationResponseByTenantId(tenantId);
+ tenantDao.deleteEnrolmentOpMappingByTenantId(tenantId);
+ tenantDao.deleteDeviceStatusByTenantId(tenantId);
+ tenantDao.deleteEnrolmentByTenantId(tenantId);
+ tenantDao.deleteOperationByTenantId(tenantId);
+ tenantDao.deleteDeviceGroupMapByTenantId(tenantId);
+ tenantDao.deleteGroupPropertiesByTenantId(tenantId);
+ tenantDao.deleteDevicePropertiesByTenantId(tenantId);
+ tenantDao.deleteDeviceByTenantId(tenantId);
+ tenantDao.deleteRoleGroupMapByTenantId(tenantId);
+ tenantDao.deleteGroupByTenantId(tenantId);
+ tenantDao.deleteDeviceCertificateByTenantId(tenantId);
+
+ DeviceManagementDAOFactory.commitTransaction();
+ } catch (DeviceManagementDAOException e) {
+ DeviceManagementDAOFactory.rollbackTransaction();
+ String msg = "Error deleting data of tenant of ID: '" + tenantId + "'";
+ log.error(msg);
+ throw new DeviceManagementException(msg, e);
+ } catch (TransactionManagementException e) {
+ String msg = "Error while initiating transaction when trying to delete tenant info of '" + tenantId + "'";
+ log.error(msg);
+ throw new DeviceManagementException(msg, e);
+ } finally {
+ DeviceManagementDAOFactory.closeConnection();
+ }
+ }
}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java
index 0941d3d3a1..88aad71dcd 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/GroupManagementProviderServiceImpl.java
@@ -32,6 +32,7 @@ import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory;
import io.entgra.device.mgt.core.device.mgt.core.dao.GroupDAO;
import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOException;
import io.entgra.device.mgt.core.device.mgt.core.dao.GroupManagementDAOFactory;
+import io.entgra.device.mgt.core.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -593,10 +594,24 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
} else {
List allDeviceGroupIdsOfUser = getGroupIds(username);
rootGroups = this.getGroups(allDeviceGroupIdsOfUser, tenantId);
- if (requireGroupProps) {
+ try {
+ GroupManagementDAOFactory.openConnection();
for (DeviceGroup rootGroup : rootGroups) {
- populateGroupProperties(rootGroup, tenantId);
+ parentPath = DeviceManagerUtil.createParentPath(rootGroup);
+ childrenGroups = groupDAO.getChildrenGroups(parentPath, tenantId);
+ createGroupWithChildren(
+ rootGroup, childrenGroups, requireGroupProps, tenantId, request.getDepth(), 0);
+ if (requireGroupProps) {
+ populateGroupProperties(rootGroup, tenantId);
+ }
}
+ } catch (SQLException e) {
+ String msg = "Error occurred while opening a connection to the data source to retrieve all groups "
+ + "with hierarchy when username is provided";
+ log.error(msg, e);
+ throw new GroupManagementException(msg, e);
+ } finally {
+ GroupManagementDAOFactory.closeConnection();
}
}
} catch (GroupManagementDAOException e) {
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DynamicPartitionedScheduleTask.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DynamicPartitionedScheduleTask.java
index 6ca728cd13..65379945e4 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DynamicPartitionedScheduleTask.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/task/impl/DynamicPartitionedScheduleTask.java
@@ -86,13 +86,13 @@ public abstract class DynamicPartitionedScheduleTask implements Task {
if (localHashIndex.equals(String.valueOf(taskContext.getServerHashIndex()))) {
if (log.isDebugEnabled()) {
log.debug("Executing dynamically scheduled task (" + getTaskName() +
- ") for current server hash index: " + localHashIndex);
+ ") for current server hash index: " + taskContext.getServerHashIndex());
}
executeDynamicTask();
} else {
if (log.isDebugEnabled()) {
log.debug("Ignoring execution of task (" + getTaskName() +
- ") not belonging to current serer hash index: " + localHashIndex);
+ ") not belonging to current server hash index: " + taskContext.getServerHashIndex());
}
}
} else {
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/HttpReportingUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/HttpReportingUtil.java
index 288d0c0fc5..ad7a7bf67d 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/HttpReportingUtil.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/HttpReportingUtil.java
@@ -27,6 +27,7 @@ import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.protocol.HTTP;
import org.json.JSONObject;
import io.entgra.device.mgt.core.device.mgt.common.exceptions.EventPublishingException;
@@ -49,24 +50,6 @@ public class HttpReportingUtil {
return System.getProperty(DeviceManagementConstants.Report.REPORTING_EVENT_HOST);
}
- public static int invokeApi(String payload, String endpoint) throws EventPublishingException {
- try (CloseableHttpClient client = HttpClients.createDefault()) {
- HttpPost apiEndpoint = new HttpPost(endpoint);
- apiEndpoint.setHeader(HTTP.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
- StringEntity requestEntity = new StringEntity(
- payload, ContentType.APPLICATION_JSON);
- apiEndpoint.setEntity(requestEntity);
- HttpResponse response = client.execute(apiEndpoint);
- return response.getStatusLine().getStatusCode();
- } catch (ConnectException e) {
- log.error("Connection refused to API endpoint: " + endpoint, e);
- return HttpStatus.SC_SERVICE_UNAVAILABLE;
- } catch (IOException e) {
- throw new EventPublishingException("Error occurred when " +
- "invoking API. API endpoint: " + endpoint, e);
- }
- }
-
public static boolean isPublishingEnabledForTenant() {
Object configuration = DeviceManagerUtil.getConfiguration(IS_EVENT_PUBLISHING_ENABLED);
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceTest.java
index 6565a4b029..0e31232a03 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceTest.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/authorization/DeviceAccessAuthorizationServiceTest.java
@@ -193,7 +193,7 @@ public class DeviceAccessAuthorizationServiceTest {
public void userAuthDevIdUserName() throws Exception {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(ADMIN_USER);
for (DeviceIdentifier deviceId : deviceIds) {
- Assert.assertTrue(deviceAccessAuthorizationService.isUserAuthorized(deviceId, ADMIN_USER),
+ Assert.assertTrue(deviceAccessAuthorizationService.isUserAuthorized(deviceId, ADMIN_USER, new String[]{NON_ADMIN_PERMISSION}),
"Device access authorization for admin user failed");
}
}
@@ -202,7 +202,7 @@ public class DeviceAccessAuthorizationServiceTest {
public void userAuthDevIdUserNameResult() throws DeviceAccessAuthorizationException {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(ADMIN_USER);
DeviceAuthorizationResult deviceAuthorizationResult = deviceAccessAuthorizationService.
- isUserAuthorized(deviceIds, ADMIN_USER);
+ isUserAuthorized(deviceIds, ADMIN_USER, new String[]{NON_ADMIN_PERMISSION});
Assert.assertEquals(deviceAuthorizationResult.getAuthorizedDevices().size(), 5,
"Expected 5 authorized devices for admin user");
Assert.assertEquals(deviceAuthorizationResult.getUnauthorizedDevices().size(), 0,
@@ -213,7 +213,7 @@ public class DeviceAccessAuthorizationServiceTest {
public void userAuthDevId() throws Exception {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(ADMIN_USER);
for (DeviceIdentifier deviceId : deviceIds) {
- Assert.assertTrue(deviceAccessAuthorizationService.isUserAuthorized(deviceId),
+ Assert.assertTrue(deviceAccessAuthorizationService.isUserAuthorized(deviceId, new String[]{NON_ADMIN_PERMISSION}),
"Authorize user from device identifier failed");
}
}
@@ -222,7 +222,7 @@ public class DeviceAccessAuthorizationServiceTest {
public void userAuthDevIdResult() throws Exception {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(ADMIN_USER);
DeviceAuthorizationResult deviceAuthorizationResult = deviceAccessAuthorizationService.
- isUserAuthorized(deviceIds);
+ isUserAuthorized(deviceIds, new String[]{NON_ADMIN_PERMISSION});
Assert.assertEquals(deviceAuthorizationResult.getAuthorizedDevices().size(), 5,
"Expected 5 authorized devices for admin user");
Assert.assertEquals(deviceAuthorizationResult.getUnauthorizedDevices().size(), 0,
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql
index 94c94106b5..00c3c804a2 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql
@@ -140,6 +140,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
OPERATION_CODE VARCHAR(1000) NOT NULL,
INITIATED_BY VARCHAR(100) NULL,
OPERATION_DETAILS BLOB DEFAULT NULL,
+ OPERATION_PROPERTIES BLOB DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID)
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml
index 3a254255a2..5d5d3d252f 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml
@@ -22,7 +22,7 @@
device-mgt
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql
index b282aa59ce..3dae0cb261 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql
@@ -70,46 +70,12 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
OPERATION_CODE VARCHAR(1000) NOT NULL,
INITIATED_BY VARCHAR(100) NULL,
OPERATION_DETAILS BLOB DEFAULT NULL,
+ OPERATION_PROPERTIES BLOB DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID)
);
-CREATE TABLE IF NOT EXISTS DM_CONFIG_OPERATION (
- OPERATION_ID INTEGER NOT NULL,
- OPERATION_CONFIG BLOB DEFAULT NULL,
- ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
- PRIMARY KEY (OPERATION_ID),
- CONSTRAINT fk_dm_operation_config FOREIGN KEY (OPERATION_ID) REFERENCES
- DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
-);
-
-CREATE TABLE IF NOT EXISTS DM_COMMAND_OPERATION (
- OPERATION_ID INTEGER NOT NULL,
- ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
- PRIMARY KEY (OPERATION_ID),
- CONSTRAINT fk_dm_operation_command FOREIGN KEY (OPERATION_ID) REFERENCES
- DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
-);
-
-CREATE TABLE IF NOT EXISTS DM_POLICY_OPERATION (
- OPERATION_ID INTEGER NOT NULL,
- ENABLED INTEGER NOT NULL DEFAULT 0,
- OPERATION_DETAILS BLOB DEFAULT NULL,
- PRIMARY KEY (OPERATION_ID),
- CONSTRAINT fk_dm_operation_policy FOREIGN KEY (OPERATION_ID) REFERENCES
- DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
-);
-
-CREATE TABLE IF NOT EXISTS DM_PROFILE_OPERATION (
- OPERATION_ID INTEGER NOT NULL,
- ENABLED INTEGER NOT NULL DEFAULT 0,
- OPERATION_DETAILS BLOB DEFAULT NULL,
- PRIMARY KEY (OPERATION_ID),
- CONSTRAINT fk_dm_operation_profile FOREIGN KEY (OPERATION_ID) REFERENCES
- DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
-);
-
CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
ID INTEGER AUTO_INCREMENT NOT NULL,
DEVICE_ID INTEGER NOT NULL,
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml
index d2f58a949d..a99497bcb7 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.url.printer/pom.xml
@@ -23,7 +23,7 @@
device-mgt
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml
index 118fc75e51..e3ff16a185 100644
--- a/components/device-mgt/pom.xml
+++ b/components/device-mgt/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml
index ac400e3630..d4a1423579 100644
--- a/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml
+++ b/components/heartbeat-management/io.entgra.device.mgt.core.server.bootup.heartbeat.beacon/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
heartbeat-management
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml
index d30eddcd04..144a391a6f 100644
--- a/components/heartbeat-management/pom.xml
+++ b/components/heartbeat-management/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml
index 62440f8010..f9e469335b 100644
--- a/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml
+++ b/components/identity-extensions/io.entgra.device.mgt.core.device.mgt.oauth.extensions/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
identity-extensions
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml
index 751ebbd569..3c44fc89af 100644
--- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml
+++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
identity-extensions
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml
index 1af80b96bc..9d9d13a9eb 100644
--- a/components/identity-extensions/pom.xml
+++ b/components/identity-extensions/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml
index a3514dc270..26e29d584d 100644
--- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml
+++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml
@@ -23,7 +23,7 @@
io.entgra.device.mgt.core
logger
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
io.entgra.device.mgt.core.notification.logger
diff --git a/components/logger/pom.xml b/components/logger/pom.xml
index 7bc7f8cb87..28f050bcd1 100644
--- a/components/logger/pom.xml
+++ b/components/logger/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core.parent
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml
index e17f7f4e0a..a1f8fd8ca1 100644
--- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml
+++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
operation-template-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql
index c2f33227b7..0c547b11a4 100644
--- a/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql
+++ b/components/operation-template-mgt/io.entgra.device.mgt.core.operation.template/src/test/resources/carbon-home/dbscripts/dm-db-h2.sql
@@ -89,6 +89,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
OPERATION_CODE VARCHAR(1000) NOT NULL,
INITIATED_BY VARCHAR(100) NULL,
OPERATION_DETAILS BLOB DEFAULT NULL,
+ OPERATION_PROPERTIES BLOB DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID)
diff --git a/components/operation-template-mgt/pom.xml b/components/operation-template-mgt/pom.xml
index f0b861c909..57d6048b31 100644
--- a/components/operation-template-mgt/pom.xml
+++ b/components/operation-template-mgt/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml
index 06ae599d6e..e979327e53 100644
--- a/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml
+++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.decision.point/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
policy-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml
index 8b5a83ec5c..f9d89bdcab 100644
--- a/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml
+++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.information.point/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
policy-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml
index 3a3a6db097..7e6c53db05 100644
--- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml
+++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.common/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
policy-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml
index 3c0fabec4b..1b25b8d1d1 100644
--- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml
+++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
policy-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql
index 2570e7dd7f..2a2d497eb8 100644
--- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql
+++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql
@@ -89,6 +89,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
OPERATION_CODE VARCHAR(1000) NOT NULL,
INITIATED_BY VARCHAR(100) NULL,
OPERATION_DETAILS BLOB DEFAULT NULL,
+ OPERATION_PROPERTIES BLOB DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID)
diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml
index 77d6d7d101..44c54eddd7 100644
--- a/components/policy-mgt/pom.xml
+++ b/components/policy-mgt/pom.xml
@@ -23,7 +23,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml
index 6dd2cd8a2f..69bce27091 100644
--- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml
+++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/pom.xml
@@ -20,7 +20,7 @@
io.entgra.device.mgt.core
subtype-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/subtype-mgt/pom.xml b/components/subtype-mgt/pom.xml
index 492d35162c..51dc884b45 100644
--- a/components/subtype-mgt/pom.xml
+++ b/components/subtype-mgt/pom.xml
@@ -20,7 +20,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml
index f6e60da0e1..4b447f0e38 100755
--- a/components/task-mgt/pom.xml
+++ b/components/task-mgt/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml
index 22778ee388..3f47201bf8 100755
--- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml
+++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.common/pom.xml
@@ -20,7 +20,7 @@
task-manager
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml
index 09bcea13b7..583e05bfeb 100755
--- a/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml
+++ b/components/task-mgt/task-manager/io.entgra.device.mgt.core.task.mgt.core/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
task-manager
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml
index a74dafdd10..6904bc1898 100755
--- a/components/task-mgt/task-manager/pom.xml
+++ b/components/task-mgt/task-manager/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
task-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml
index 7cf2dfd1af..9b3679a880 100755
--- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml
+++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
task-watcher
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/src/main/java/io/entgra/device/mgt/core/task/mgt/watcher/IoTSStartupHandler.java b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/src/main/java/io/entgra/device/mgt/core/task/mgt/watcher/IoTSStartupHandler.java
index 5b1945e686..aed0d3dc8b 100755
--- a/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/src/main/java/io/entgra/device/mgt/core/task/mgt/watcher/IoTSStartupHandler.java
+++ b/components/task-mgt/task-watcher/io.entgra.device.mgt.core.task.mgt.watcher/src/main/java/io/entgra/device/mgt/core/task/mgt/watcher/IoTSStartupHandler.java
@@ -45,8 +45,11 @@ import java.util.Timer;
import java.util.TimerTask;
public class IoTSStartupHandler implements ServerStartupObserver {
+
private static final Log log = LogFactory.getLog(IoTSStartupHandler.class);
+ private static int lastHashIndex = -1;
+
@Override
public void completingServerStartup() {
}
@@ -80,6 +83,22 @@ public class IoTSStartupHandler implements ServerStartupObserver {
Map> tenantedDynamicTasks = TaskWatcherDataHolder.getInstance()
.getTaskManagementService().getDynamicTasksForAllTenants();
+ int serverHashIdx;
+ try {
+ serverHashIdx = TaskWatcherDataHolder.getInstance().getHeartBeatService()
+ .getServerCtxInfo().getLocalServerHashIdx();
+ } catch (HeartBeatManagementException e) {
+ String msg = "Failed to get server hash index.";
+ log.error(msg, e);
+ throw new TaskManagementException(msg, e);
+ }
+
+ if (serverHashIdx != lastHashIndex) {
+ log.info("Server hash index changed. Old: " + lastHashIndex + ", new: " + serverHashIdx);
+ deleteAllDynamicNTasks(nTaskService, tenantedDynamicTasks, serverHashIdx);
+ lastHashIndex = serverHashIdx;
+ }
+
scheduleMissingTasks(nTaskService, tenantedDynamicTasks);
deleteObsoleteTasks(nTaskService, tenantedDynamicTasks);
@@ -96,7 +115,45 @@ public class IoTSStartupHandler implements ServerStartupObserver {
}
- private static void scheduleMissingTasks(TaskService nTaskService, Map> tenantedDynamicTasks, int serverHashIdx) throws TaskException {
+ List tenants = getAllTenants();
+
+ TaskManager taskManager;
+
+ for (Tenant tenant : tenants) {
+ if (tenantedDynamicTasks.get(tenant.getId()) == null) {
+ if (log.isTraceEnabled()) {
+ log.trace("Dynamic tasks not running for tenant: [" + tenant.getId() + "] "
+ + tenant.getDomain());
+ }
+ continue;
+ }
+ PrivilegedCarbonContext.startTenantFlow();
+ PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenant.getId(), true);
+ if (!nTaskService.getRegisteredTaskTypes().contains(TaskMgtConstants.Task.DYNAMIC_TASK_TYPE)) {
+ nTaskService.registerTaskType(TaskMgtConstants.Task.DYNAMIC_TASK_TYPE);
+ }
+ taskManager = nTaskService.getTaskManager(TaskMgtConstants.Task.DYNAMIC_TASK_TYPE);
+ List tasks = taskManager.getAllTasks();
+ // Remove all applicable dynamic tasks from the nTask core
+ for (TaskInfo taskInfo : tasks) {
+ for (DynamicTask dt : tenantedDynamicTasks.get(tenant.getId())) {
+ if (tenant.getId() == dt.getTenantId()
+ && taskInfo.getName()
+ .equals(TaskManagementUtil.generateNTaskName(dt.getDynamicTaskId(), serverHashIdx))) {
+ taskManager.deleteTask(taskInfo.getName());
+ if (log.isDebugEnabled()) {
+ log.debug("Task '" + taskInfo.getName() + "' deleted as server hash changed.");
+ }
+ }
+ }
+ }
+ PrivilegedCarbonContext.endTenantFlow();
+ }
+ }
+
+ private void scheduleMissingTasks(TaskService nTaskService, Map> tenantedDynamicTasks)
throws TaskException, TaskManagementException {
@@ -187,26 +244,10 @@ public class IoTSStartupHandler implements ServerStartupObserver {
}
}
- private static void deleteObsoleteTasks(TaskService nTaskService,
- Map> tenantedDynamicTasks)
+ private void deleteObsoleteTasks(TaskService nTaskService,
+ Map> tenantedDynamicTasks)
throws TaskManagementException, TaskException {
- List tenants = new ArrayList<>();
- try {
- RealmService realmService = TaskWatcherDataHolder.getInstance().getRealmService();
- Tenant[] tenantArray = realmService.getTenantManager().getAllTenants();
- if (tenantArray != null && tenantArray.length != 0) {
- tenants.addAll(Arrays.asList(tenantArray));
- }
- Tenant superTenant = new Tenant();
- superTenant.setId(-1234);
- tenants.add(superTenant);
- } catch (UserStoreException e) {
- String msg = "Unable to load tenants";
- log.error(msg, e);
- return;
- }
-
TaskManager taskManager;
Set hashIds;
try {
@@ -217,6 +258,8 @@ public class IoTSStartupHandler implements ServerStartupObserver {
throw new TaskManagementException(msg, e);
}
+ List tenants = getAllTenants();
+
for (Tenant tenant : tenants) {
if (tenantedDynamicTasks.get(tenant.getId()) == null) {
if (log.isTraceEnabled()) {
@@ -258,4 +301,23 @@ public class IoTSStartupHandler implements ServerStartupObserver {
}
}
+ private List getAllTenants() {
+ List tenants = new ArrayList<>();
+ try {
+ RealmService realmService = TaskWatcherDataHolder.getInstance().getRealmService();
+ Tenant[] tenantArray = realmService.getTenantManager().getAllTenants();
+ if (tenantArray != null && tenantArray.length != 0) {
+ tenants.addAll(Arrays.asList(tenantArray));
+ }
+ Tenant superTenant = new Tenant();
+ superTenant.setId(-1234);
+ tenants.add(superTenant);
+ return tenants;
+ } catch (UserStoreException e) {
+ String msg = "Unable to load tenants";
+ log.error(msg, e);
+ return new ArrayList<>();
+ }
+ }
+
}
diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml
index f075b06b9c..9fe0b11e7c 100755
--- a/components/task-mgt/task-watcher/pom.xml
+++ b/components/task-mgt/task-watcher/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
task-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml
index 0fe678ebb1..2dd5078116 100644
--- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml
+++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/pom.xml
@@ -20,7 +20,7 @@
tenant-mgt
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/src/main/java/io/entgra/device/mgt/core/tenant/mgt/common/spi/TenantManagerService.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/src/main/java/io/entgra/device/mgt/core/tenant/mgt/common/spi/TenantManagerService.java
index 5577ef4368..9f459412b4 100644
--- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/src/main/java/io/entgra/device/mgt/core/tenant/mgt/common/spi/TenantManagerService.java
+++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.common/src/main/java/io/entgra/device/mgt/core/tenant/mgt/common/spi/TenantManagerService.java
@@ -27,4 +27,6 @@ public interface TenantManagerService {
void addDefaultDeviceStatusFilters(TenantInfoBean tenantInfoBean) throws TenantMgtException;
void addDefaultDeviceTaskConfiguration(TenantInfoBean tenantInfoBean) throws TenantMgtException;
+ void deleteTenantApplicationData(int tenantId) throws TenantMgtException;
+ void deleteTenantDeviceData(int tenantId) throws TenantMgtException;
}
\ No newline at end of file
diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml
index 413d88d949..7eafae8b99 100644
--- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml
+++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/pom.xml
@@ -20,7 +20,7 @@
tenant-mgt
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
@@ -66,6 +66,7 @@
io.entgra.device.mgt.core.device.mgt.common.roles.config,
io.entgra.device.mgt.core.device.mgt.core.metadata.mgt,
io.entgra.device.mgt.core.device.mgt.core.config,
+ io.entgra.device.mgt.core.device.mgt.core.dao.*,
org.wso2.carbon.user.core.service,
org.wso2.carbon.context
diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/TenantManager.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/TenantManager.java
index 3cf7e7fc62..dce4d36e28 100644
--- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/TenantManager.java
+++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/TenantManager.java
@@ -50,4 +50,18 @@ public interface TenantManager {
* @throws TenantMgtException Throws when error occurred while adding default TaskFrequency
*/
void addDefaultDeviceTaskConfiguration(TenantInfoBean tenantInfoBean) throws TenantMgtException;
+
+ /**
+ * Delete Application related details of a tenant
+ * @param tenantId ID of the tenant
+ * @throws TenantMgtException Throws when deleting Tenant related application data
+ */
+ void deleteTenantApplicationData(int tenantId) throws TenantMgtException;
+
+ /**
+ * Delete Device related details of a tenant
+ * @param tenantId ID of the tenant
+ * @throws TenantMgtException Throws when deleting Tenant related device data
+ */
+ void deleteTenantDeviceData(int tenantId) throws TenantMgtException;
}
diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerImpl.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerImpl.java
index e3212ab769..76e6058f68 100644
--- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerImpl.java
+++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerImpl.java
@@ -20,6 +20,10 @@ package io.entgra.device.mgt.core.tenant.mgt.core.impl;
import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException;
import io.entgra.device.mgt.core.application.mgt.core.config.ConfigurationManager;
import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager;
+import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException;
+import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOException;
+import io.entgra.device.mgt.core.device.mgt.core.dao.DeviceManagementDAOFactory;
+import io.entgra.device.mgt.core.device.mgt.core.dao.TenantDAO;
import io.entgra.device.mgt.core.tenant.mgt.core.TenantManager;
import io.entgra.device.mgt.core.tenant.mgt.common.exception.TenantMgtException;
import io.entgra.device.mgt.core.tenant.mgt.core.internal.TenantMgtDataHolder;
@@ -38,6 +42,7 @@ import io.entgra.device.mgt.core.device.mgt.common.roles.config.Role;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.api.UserStoreManager;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -46,6 +51,11 @@ import java.util.Map;
public class TenantManagerImpl implements TenantManager {
private static final Log log = LogFactory.getLog(TenantManagerImpl.class);
private static final String PERMISSION_ACTION = "ui.execute";
+ TenantDAO tenantDao;
+
+ public TenantManagerImpl() {
+ this.tenantDao = DeviceManagementDAOFactory.getTenantDAO();
+ }
@Override
public void addDefaultRoles(TenantInfoBean tenantInfoBean) throws TenantMgtException {
@@ -127,6 +137,100 @@ public class TenantManagerImpl implements TenantManager {
}
}
+ @Override
+ public void deleteTenantApplicationData(int tenantId) throws TenantMgtException {
+ try {
+ TenantMgtDataHolder.getInstance().getApplicationManager().
+ deleteApplicationDataOfTenant(tenantId);
+ } catch (ApplicationManagementException e) {
+ String msg = "Error occurred while deleting Application related data of Tenant of " +
+ "tenant Id" + tenantId;
+ log.error(msg, e);
+ throw new TenantMgtException(msg, e);
+ }
+ }
+
+ @Override
+ public void deleteTenantDeviceData(int tenantId) throws TenantMgtException {
+ if (log.isDebugEnabled()) {
+ log.debug("Request is received to delete Device related data of tenant with ID: " + tenantId);
+ }
+ try {
+ DeviceManagementDAOFactory.beginTransaction();
+
+ tenantDao.deleteExternalPermissionMapping(tenantId);
+ tenantDao.deleteExternalDeviceMappingByTenantId(tenantId);
+ tenantDao.deleteExternalGroupMappingByTenantId(tenantId);
+ // TODO: Check whether deleting DM_DEVICE_ORGANIZATION table data is necessary
+// tenantDao.deleteDeviceOrganizationByTenantId(tenantId);
+ tenantDao.deleteDeviceHistoryLastSevenDaysByTenantId(tenantId);
+ tenantDao.deleteDeviceDetailByTenantId(tenantId);
+ tenantDao.deleteDeviceLocationByTenantId(tenantId);
+ tenantDao.deleteDeviceInfoByTenantId(tenantId);
+ tenantDao.deleteNotificationByTenantId(tenantId);
+ tenantDao.deleteAppIconsByTenantId(tenantId);
+ tenantDao.deleteTraccarUnsyncedDevicesByTenantId(tenantId);
+ tenantDao.deleteDeviceEventGroupMappingByTenantId(tenantId);
+ tenantDao.deleteGeofenceEventMappingByTenantId(tenantId);
+ tenantDao.deleteDeviceEventByTenantId(tenantId);
+ tenantDao.deleteGeofenceGroupMappingByTenantId(tenantId);
+ tenantDao.deleteGeofenceByTenantId(tenantId);
+ tenantDao.deleteDeviceGroupPolicyByTenantId(tenantId);
+ tenantDao.deleteDynamicTaskPropertiesByTenantId(tenantId);
+ tenantDao.deleteDynamicTaskByTenantId(tenantId);
+ tenantDao.deleteMetadataByTenantId(tenantId);
+ tenantDao.deleteOTPDataByTenantId(tenantId);
+ tenantDao.deleteSubOperationTemplate(tenantId);
+ tenantDao.deleteDeviceSubTypeByTenantId(tenantId);
+ tenantDao.deleteCEAPoliciesByTenantId(tenantId);
+
+ tenantDao.deleteApplicationByTenantId(tenantId);
+ tenantDao.deletePolicyCriteriaPropertiesByTenantId(tenantId);
+ tenantDao.deletePolicyCriteriaByTenantId(tenantId);
+ tenantDao.deleteCriteriaByTenantId(tenantId);
+ tenantDao.deletePolicyChangeManagementByTenantId(tenantId);
+ tenantDao.deletePolicyComplianceFeaturesByTenantId(tenantId);
+ tenantDao.deletePolicyComplianceStatusByTenantId(tenantId);
+ tenantDao.deleteRolePolicyByTenantId(tenantId);
+ tenantDao.deleteUserPolicyByTenantId(tenantId);
+ tenantDao.deleteDeviceTypePolicyByTenantId(tenantId);
+ tenantDao.deleteDevicePolicyAppliedByTenantId(tenantId);
+ tenantDao.deleteDevicePolicyByTenantId(tenantId);
+ tenantDao.deletePolicyCorrectiveActionByTenantId(tenantId);
+ tenantDao.deletePolicyByTenantId(tenantId);
+ tenantDao.deleteProfileFeaturesByTenantId(tenantId);
+ tenantDao.deleteProfileByTenantId(tenantId);
+
+ tenantDao.deleteDeviceOperationResponseLargeByTenantId(tenantId);
+ tenantDao.deleteDeviceOperationResponseByTenantId(tenantId);
+ tenantDao.deleteEnrolmentOpMappingByTenantId(tenantId);
+ tenantDao.deleteDeviceStatusByTenantId(tenantId);
+ tenantDao.deleteEnrolmentByTenantId(tenantId);
+ tenantDao.deleteOperationByTenantId(tenantId);
+ tenantDao.deleteDeviceGroupMapByTenantId(tenantId);
+ tenantDao.deleteGroupPropertiesByTenantId(tenantId);
+ tenantDao.deleteDevicePropertiesByTenantId(tenantId);
+ tenantDao.deleteDeviceByTenantId(tenantId);
+ tenantDao.deleteRoleGroupMapByTenantId(tenantId);
+ tenantDao.deleteGroupByTenantId(tenantId);
+ tenantDao.deleteDeviceCertificateByTenantId(tenantId);
+
+ DeviceManagementDAOFactory.commitTransaction();
+ } catch (DeviceManagementDAOException e) {
+ DeviceManagementDAOFactory.rollbackTransaction();
+ String msg = "Error deleting data of tenant of ID: '" + tenantId + "'";
+ log.error(msg);
+ throw new TenantMgtException(msg, e);
+ } catch (TransactionManagementException e) {
+ String msg = "Error initializing transaction when trying to delete tenant info of '" + tenantId + "'";
+ log.error(msg);
+ throw new TenantMgtException(msg, e);
+ } finally {
+ DeviceManagementDAOFactory.closeConnection();
+ }
+
+ }
+
private void initTenantFlow(TenantInfoBean tenantInfoBean) {
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerServiceImpl.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerServiceImpl.java
index 21d0350e66..848e7ed3a6 100644
--- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerServiceImpl.java
+++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/impl/TenantManagerServiceImpl.java
@@ -43,4 +43,14 @@ public class TenantManagerServiceImpl implements TenantManagerService {
public void addDefaultDeviceTaskConfiguration(TenantInfoBean tenantInfoBean) throws TenantMgtException {
TenantMgtDataHolder.getInstance().getTenantManager().addDefaultDeviceTaskConfiguration(tenantInfoBean);
}
+
+ @Override
+ public void deleteTenantApplicationData(int tenantId) throws TenantMgtException {
+ TenantMgtDataHolder.getInstance().getTenantManager().deleteTenantApplicationData(tenantId);
+ }
+
+ @Override
+ public void deleteTenantDeviceData(int tenantId) throws TenantMgtException {
+ TenantMgtDataHolder.getInstance().getTenantManager().deleteTenantDeviceData(tenantId);
+ }
}
diff --git a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/listener/DeviceMgtTenantListener.java b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/listener/DeviceMgtTenantListener.java
index 69437fc84b..e2e9c88864 100644
--- a/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/listener/DeviceMgtTenantListener.java
+++ b/components/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.core/src/main/java/io/entgra/device/mgt/core/tenant/mgt/core/listener/DeviceMgtTenantListener.java
@@ -89,5 +89,13 @@ public class DeviceMgtTenantListener implements TenantMgtListener {
@Override
public void onPreDelete(int i) throws StratosException {
// Any work to be performed before a tenant is deleted
+ TenantManager tenantManager = TenantMgtDataHolder.getInstance().getTenantManager();
+ try{
+ tenantManager.deleteTenantDeviceData(i);
+ tenantManager.deleteTenantApplicationData(i);
+ } catch (TenantMgtException e) {
+ String msg = "Error occurred while deleting tenant data";
+ log.error(msg, e);
+ }
}
}
diff --git a/components/tenant-mgt/pom.xml b/components/tenant-mgt/pom.xml
index b5addd2794..b4e13f6292 100644
--- a/components/tenant-mgt/pom.xml
+++ b/components/tenant-mgt/pom.xml
@@ -20,7 +20,7 @@
io.entgra.device.mgt.core.parent
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml
index 685fab620e..7e2afe4f69 100644
--- a/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml
+++ b/components/transport-mgt/email-sender/io.entgra.device.mgt.core.transport.mgt.email.sender.core/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
email-sender
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml
index 24d0866e4e..1b663db64e 100644
--- a/components/transport-mgt/email-sender/pom.xml
+++ b/components/transport-mgt/email-sender/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
transport-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml
index cf83a5a86d..e28aeb6f30 100644
--- a/components/transport-mgt/pom.xml
+++ b/components/transport-mgt/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core.parent
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml
index cb9826b78e..c911c571a4 100644
--- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml
+++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
sms-handler
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml
index 15190aee11..eec782a9aa 100644
--- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml
+++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.common/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
sms-handler
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml
index 9deac3dc50..740d1b7ae5 100644
--- a/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml
+++ b/components/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.core/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
sms-handler
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml
index 10c48a75ec..63db59b599 100644
--- a/components/transport-mgt/sms-handler/pom.xml
+++ b/components/transport-mgt/sms-handler/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
transport-mgt
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml
index 1cef468e96..83f664e143 100644
--- a/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml
+++ b/components/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor/pom.xml
@@ -21,7 +21,7 @@
ui-request-interceptor
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
4.0.0
diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml
index 0c6244c963..cc51666724 100644
--- a/components/ui-request-interceptor/pom.xml
+++ b/components/ui-request-interceptor/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core.parent
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml
index 3da7785970..b52526e02a 100644
--- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml
+++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
webapp-authenticator-framework
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/PermissionAuthorizer.java b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/PermissionAuthorizer.java
index 0d509200e4..aed1ecf836 100644
--- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/PermissionAuthorizer.java
+++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/main/java/io/entgra/device/mgt/core/webapp/authenticator/framework/authorizer/PermissionAuthorizer.java
@@ -134,6 +134,7 @@ public class PermissionAuthorizer {
}
if (isUserAuthorized) {
+ PermissionManagerServiceImpl.getInstance().setRequiredPermission(requiredPermission);
return WebappAuthenticator.Status.SUCCESS;
} else {
return WebappAuthenticator.Status.FAILURE;
diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml
index 8cd92c6bd3..0ede892b7f 100644
--- a/components/webapp-authenticator-framework/pom.xml
+++ b/components/webapp-authenticator-framework/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml
index 5ee2379a0c..8f1745bb78 100644
--- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml
+++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
grafana-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml
index 22396e9043..4b128c1cb3 100644
--- a/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml
+++ b/features/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.server.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
grafana-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml
index f8dffca5f7..46349cd1ae 100644
--- a/features/analytics-mgt/grafana-mgt/pom.xml
+++ b/features/analytics-mgt/grafana-mgt/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
analytics-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml
index 28c032bfc2..569422c9de 100644
--- a/features/analytics-mgt/pom.xml
+++ b/features/analytics-mgt/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core.parent
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml
index 77a6b7c55c..3f06938008 100644
--- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml
+++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml
@@ -20,7 +20,7 @@
io.entgra.device.mgt.core
apimgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml
index 96c0fcf364..ea792fb1f6 100644
--- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml
+++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.feature/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
apimgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml
index 7e97d37e80..ca37184ea3 100644
--- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml
+++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
apimgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml
index 0735dde1b8..f96d462b4e 100644
--- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml
+++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.feature/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
apimgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml
index 201259a689..2f015d97d3 100644
--- a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml
+++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher.feature/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
apimgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml
index e8445e248b..ef44e37db0 100644
--- a/features/apimgt-extensions/pom.xml
+++ b/features/apimgt-extensions/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml
index 5e023a221d..514dfdd2f4 100644
--- a/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml
+++ b/features/application-mgt/io.entgra.device.mgt.core.application.mgt.server.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
application-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml
index cc19155edf..f639dbdaf4 100644
--- a/features/application-mgt/pom.xml
+++ b/features/application-mgt/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml
index ec1828cb6c..14e01f52b4 100644
--- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml
+++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
cea-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml
index fa0608b760..8d8397ae01 100644
--- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml
+++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
cea-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/cea-mgt-feature/pom.xml b/features/cea-mgt-feature/pom.xml
index 5641cfe43c..ddfd8381c9 100644
--- a/features/cea-mgt-feature/pom.xml
+++ b/features/cea-mgt-feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml
index db8d9a6ab3..54dec9a0a7 100644
--- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml
+++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.api.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
certificate-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml
index 9b995d1f34..a4cd54ecb8 100644
--- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml
+++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.cert.admin.api.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
certificate-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml
index ce1b6b9059..c29d15d221 100644
--- a/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml
+++ b/features/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.server.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
certificate-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml
index 8b0656bdb5..3ed731f10e 100644
--- a/features/certificate-mgt/pom.xml
+++ b/features/certificate-mgt/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml
index 76b1f58f1e..d9b0d5fedc 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml
index 028e2d7249..49509d8695 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
4.0.0
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml
index 4486e06cdd..37e9e2ac4a 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml
index dfedede26e..94d691700b 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.type.deployer.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml
index fd6bd72c73..a8ea392725 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.logger.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml
index 28a3b66da2..d4ba060b68 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml
index 0983252c6a..399761b3f0 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.http.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml
index 26c03188a9..2e9351f5ca 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml
index fb348ee8d3..a04e0a0933 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml
index 0eb091bfc9..66ac3b6eb8 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.stateengine.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml
index b15e6b8148..bc35f8e7c1 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.userstore.role.mapper/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-extensions-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml
index d0d4ccd68c..240077996f 100644
--- a/features/device-mgt-extensions/pom.xml
+++ b/features/device-mgt-extensions/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml
index d8f24a9759..3baff87eb1 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.api.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml
index b862a19654..6f21b990a7 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml
index 7ddc51b95e..8303fc6402 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml
@@ -289,6 +289,7 @@
um:users:update
um:users:invite
um:admin:users:view
+ um:admin:tenants:remove
dm:admin:enrollment:update
gm:devices:view
gm:groups:update
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/archival/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/archival/mysql.sql
index 7854ee1181..d7cf6837bc 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/archival/mysql.sql
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/archival/mysql.sql
@@ -7,6 +7,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION_ARCH (
OPERATION_CODE VARCHAR(50) NOT NULL,
INITIATED_BY VARCHAR(100) NULL,
OPERATION_DETAILS BLOB DEFAULT NULL,
+ OPERATION_PROPERTIES BLOB DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
ARCHIVED_AT TIMESTAMP DEFAULT NOW()
)ENGINE = InnoDB;
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/archival/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/archival/postgresql.sql
index 726f5b9a7c..ec4513bf5b 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/archival/postgresql.sql
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/archival/postgresql.sql
@@ -6,6 +6,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION_ARCH (
OPERATION_CODE VARCHAR(50) NOT NULL,
INITIATED_BY VARCHAR(100) NULL,
OPERATION_DETAILS BYTEA DEFAULT NULL,
+ OPERATION_PROPERTIES BYTEA DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
ARCHIVED_AT TIMESTAMP(0) DEFAULT NOW()
);
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql
index b6dcb7d5be..072ce0a81d 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql
@@ -91,6 +91,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
OPERATION_CODE VARCHAR(1000) NOT NULL,
INITIATED_BY VARCHAR(100) NULL,
OPERATION_DETAILS BLOB DEFAULT NULL,
+ OPERATION_PROPERTIES BLOB DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
TENANT_ID INT NOT NULL,
PRIMARY KEY (ID)
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql
index cee731c034..6c7aa649fd 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql
@@ -125,6 +125,7 @@ CREATE TABLE DM_OPERATION (
OPERATION_CODE VARCHAR(50) NOT NULL,
INITIATED_BY VARCHAR(100) NULL,
OPERATION_DETAILS VARBINARY(MAX) DEFAULT NULL,
+ OPERATION_PROPERTIES VARBINARY(MAX) DEFAULT NULL,
ENABLED BIT NOT NULL DEFAULT 0,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID)
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql
index 7ddaf22af6..065862a36b 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql
@@ -106,6 +106,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
OPERATION_CODE VARCHAR(50) NOT NULL,
INITIATED_BY VARCHAR(100) NULL,
OPERATION_DETAILS BLOB DEFAULT NULL,
+ OPERATION_PROPERTIES BLOB DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
TENANT_ID INT NOT NULL,
PRIMARY KEY (ID)
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql
index 6e99bb43ee..eccc831141 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql
@@ -181,6 +181,7 @@ CREATE TABLE DM_OPERATION (
INITIATED_BY VARCHAR2(100) NULL,
ENABLED NUMBER(10) DEFAULT 0 NOT NULL,
OPERATION_DETAILS BLOB DEFAULT NULL,
+ OPERATION_PROPERTIES BLOB DEFAULT NULL,
TENANT_ID INTEGER NOT NULL,
CONSTRAINT PK_DM_OPERATION PRIMARY KEY (ID)
)
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql
index 5d5c7446e6..371baa0763 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql
@@ -99,6 +99,7 @@ CREATE TABLE IF NOT EXISTS DM_OPERATION (
OPERATION_CODE VARCHAR(50) NOT NULL,
INITIATED_BY VARCHAR(100) NULL,
OPERATION_DETAILS BYTEA DEFAULT NULL,
+ OPERATION_PROPERTIES BYTEA DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID)
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cleanup-scripts/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cleanup-scripts/mysql.sql
index df58b1cf84..5a43717800 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cleanup-scripts/mysql.sql
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cleanup-scripts/mysql.sql
@@ -157,6 +157,7 @@ CREATE TABLE NEW_DM_OPERATION (
OPERATION_CODE VARCHAR(50) NOT NULL,
INITIATED_BY VARCHAR(100) NULL,
OPERATION_DETAILS BLOB DEFAULT NULL,
+ OPERATION_PROPERTIES BLOB DEFAULT NULL,
ENABLED BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (ID)
);
@@ -218,8 +219,8 @@ SELECT CONCAT(NOW(), ': Inserted ', ROW_COUNT(),' records to DM_ENROLMENT_OP_MAP
Insert data into NEW_DM_OPERATION from DM_OPERATION only with the OPERATION_IDs from DM_ENROLMENT_OP_MAPPING
*/
SELECT CONCAT(NOW(), ': Inserting data into DM_OPERATION FROM OLD_DM_OPERATION.') AS '';
-INSERT INTO DM_OPERATION (ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, INITIATED_BY, OPERATION_DETAILS, ENABLED)
-SELECT ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, INITIATED_BY, OPERATION_DETAILS, ENABLED
+INSERT INTO DM_OPERATION (ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, INITIATED_BY, OPERATION_DETAILS, OPERATION_PROPERTIES, ENABLED)
+SELECT ID, TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, INITIATED_BY, OPERATION_DETAILS, OPERATION_PROPERTIES, ENABLED
FROM OLD_DM_OPERATION
WHERE ID IN(SELECT OPERATION_ID FROM DM_ENROLMENT_OP_MAPPING);
SELECT CONCAT(NOW(), ': Inserted ', ROW_COUNT(),' records to DM_OPERATION.') AS '';
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml
index 9ff456a387..2e69e4991e 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml
index e8835dddd0..ca7591b012 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml
index efd9801efd..fecbd4b026 100644
--- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml
+++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.server.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
device-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml
index 2149f050ef..dd09fa4aae 100644
--- a/features/device-mgt/pom.xml
+++ b/features/device-mgt/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml
index 89cf0a2a10..92cc4ed0a6 100644
--- a/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml
+++ b/features/heartbeat-management/io.entgra.device.mgt.core.server.heart.beat.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
heart-beat-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml
index 52bf889e4c..77db508369 100644
--- a/features/heartbeat-management/pom.xml
+++ b/features/heartbeat-management/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml
index 9072639ce2..47d3eba794 100644
--- a/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml
+++ b/features/jwt-client/io.entgra.device.mgt.core.identity.jwt.client.extension.feature/pom.xml
@@ -23,7 +23,7 @@
io.entgra.device.mgt.core
jwt-client-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml
index 38b5dd52af..13352c3ac9 100644
--- a/features/jwt-client/pom.xml
+++ b/features/jwt-client/pom.xml
@@ -23,7 +23,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml
index 5062f0ddb1..13dfee7c04 100644
--- a/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml
+++ b/features/logger/io.entgra.device.mgt.core.notification.logger.feature/pom.xml
@@ -23,7 +23,7 @@
io.entgra.device.mgt.core
logger-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/logger/pom.xml b/features/logger/pom.xml
index ddf8e91e8d..d618a48143 100644
--- a/features/logger/pom.xml
+++ b/features/logger/pom.xml
@@ -23,7 +23,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml
index 15ba6a9c06..51e22389d6 100644
--- a/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml
+++ b/features/operation-template-mgt-plugin-feature/io.entgra.device.mgt.core.operation.template.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
operation-template-mgt-plugin-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/operation-template-mgt-plugin-feature/pom.xml b/features/operation-template-mgt-plugin-feature/pom.xml
index 3a29bf350c..6eaf76b03a 100644
--- a/features/operation-template-mgt-plugin-feature/pom.xml
+++ b/features/operation-template-mgt-plugin-feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core.parent
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml
index 233a27afd3..27e6f9f338 100644
--- a/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml
+++ b/features/policy-mgt/io.entgra.device.mgt.core.policy.mgt.server.feature/pom.xml
@@ -23,7 +23,7 @@
io.entgra.device.mgt.core
policy-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml
index 4980bdcc92..b8ad61c8c1 100644
--- a/features/policy-mgt/pom.xml
+++ b/features/policy-mgt/pom.xml
@@ -23,7 +23,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml
index d5acfbbeb0..545cbf5983 100644
--- a/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml
+++ b/features/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../../pom.xml
diff --git a/features/subtype-mgt/pom.xml b/features/subtype-mgt/pom.xml
index 7c8b555c8a..1d9a686b44 100644
--- a/features/subtype-mgt/pom.xml
+++ b/features/subtype-mgt/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core.parent
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml
index c2de0d9937..910eb1dd01 100755
--- a/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml
+++ b/features/task-mgt/io.entgra.device.mgt.core.task.mgt.feature/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../../pom.xml
diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml
index 16b841f8dc..847891c371 100755
--- a/features/task-mgt/pom.xml
+++ b/features/task-mgt/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core.parent
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml
index a72d9174fd..11c9910d26 100644
--- a/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml
+++ b/features/tenant-mgt/io.entgra.device.mgt.core.tenant.mgt.server.feature/pom.xml
@@ -20,7 +20,7 @@
tenant-mgt-feature
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/tenant-mgt/pom.xml b/features/tenant-mgt/pom.xml
index 28e985f832..1905e1c77f 100644
--- a/features/tenant-mgt/pom.xml
+++ b/features/tenant-mgt/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core.parent
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml
index 2841cacaf2..5fdfd06406 100644
--- a/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml
+++ b/features/transport-mgt/email-sender/io.entgra.device.mgt.core.email.sender.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
email-sender-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml
index 42659ed683..3a8cad8254 100644
--- a/features/transport-mgt/email-sender/pom.xml
+++ b/features/transport-mgt/email-sender/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
transport-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml
index cf5f83d5c3..d8ef07065e 100644
--- a/features/transport-mgt/pom.xml
+++ b/features/transport-mgt/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core.parent
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml
index c6204f96eb..ba79eec348 100644
--- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml
+++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.api.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
sms-handler-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml
index cbe26f3040..8a8d12575f 100644
--- a/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml
+++ b/features/transport-mgt/sms-handler/io.entgra.device.mgt.core.transport.mgt.sms.handler.server.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
sms-handler-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml
index 52c2807727..29a6377f7a 100644
--- a/features/transport-mgt/sms-handler/pom.xml
+++ b/features/transport-mgt/sms-handler/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
transport-mgt-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml
index ac3a9b3cf9..4695bfd1a7 100644
--- a/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml
+++ b/features/ui-request-interceptor/io.entgra.device.mgt.core.ui.request.interceptor.feature/pom.xml
@@ -21,7 +21,7 @@
ui-request-interceptor-feature
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
4.0.0
diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml
index 0628bc0b09..af85499d51 100644
--- a/features/ui-request-interceptor/pom.xml
+++ b/features/ui-request-interceptor/pom.xml
@@ -21,7 +21,7 @@
io.entgra.device.mgt.core.parent
io.entgra.device.mgt.core
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml
index bd6e9a7fdd..ad5a36dc35 100644
--- a/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml
+++ b/features/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework.server.feature/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
webapp-authenticator-framework-feature
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../pom.xml
diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml
index 40ff6344e8..b790add82e 100644
--- a/features/webapp-authenticator-framework/pom.xml
+++ b/features/webapp-authenticator-framework/pom.xml
@@ -22,7 +22,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
../../pom.xml
diff --git a/pom.xml b/pom.xml
index 5c3be7d83f..680a4ced22 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
io.entgra.device.mgt.core
io.entgra.device.mgt.core.parent
pom
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
WSO2 Carbon - Device Management - Parent
http://wso2.org
WSO2 Connected Device Manager Components
@@ -2128,7 +2128,7 @@
1.2.11.wso2v10
- 5.0.41-SNAPSHOT
+ 5.0.42-SNAPSHOT
4.7.35