diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java index c8ef600e7d1..497b361b868 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java @@ -254,13 +254,16 @@ public interface ApplicationManager { String getInstallableLifecycleState() throws ApplicationManagementException; - /** - * Get plist content to download and install the application. - * - * @param uuid Release UUID of the application. - * @return plist string - * @throws ApplicationManagementException Application management exception - */ + void updateSubsStatus (int operationId, String status) throws ApplicationManagementException; + + + /** + * Get plist content to download and install the application. + * + * @param uuid Release UUID of the application. + * @return plist string + * @throws ApplicationManagementException Application management exception + */ String getPlistArtifact(String uuid) throws ApplicationManagementException; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java index e0280c3d75f..f1400cc115e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java @@ -81,6 +81,6 @@ public interface SubscriptionDAO { List getSubscribedDeviceIds(List deviceIds, int tenantId) throws ApplicationManagementDAOException; - void updateDeviceSubStatus (int operationId, String status, int tenantcId) throws ApplicationManagementDAOException; + boolean updateDeviceSubStatus (int operationId, String status, int tenantcId) throws ApplicationManagementDAOException; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index 365c05fca9e..21d88cb53c2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -577,7 +577,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } @Override - public void updateDeviceSubStatus (int operationId, String status, int tenantId) throws ApplicationManagementDAOException { + public boolean updateDeviceSubStatus (int operationId, String status, int tenantId) throws ApplicationManagementDAOException { Connection conn; try { conn = this.getDBConnection(); @@ -590,7 +590,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc stmt.setString(1, status); stmt.setInt(2, operationId); stmt.setInt(3, tenantId); - stmt.executeUpdate(); + return stmt.executeUpdate() != 0; } } catch (DBConnectionException e) { String msg = "Error occurred while obtaining the DB connection to update the subscription status of the " diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java index 2763eb616d6..3de23e03b32 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java @@ -2660,6 +2660,21 @@ public class ApplicationManagerImpl implements ApplicationManager { } } + public void updateSubsStatus (int operationId, String status) throws ApplicationManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + try { + if (!subscriptionDAO.updateDeviceSubStatus(operationId, status, tenantId)){ + String msg = "Didn't update an any app subscription of device for operation Id: " + operationId; + log.error(msg); + throw new ApplicationManagementException(msg); + } + } catch (ApplicationManagementDAOException e) { + String msg = "Error occured while updating app subscription status of the device."; + log.error(msg); + throw new ApplicationManagementException(msg); + } + } + public String getPlistArtifact(String releaseUuid) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); try {