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/SubscriptionManager.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/SubscriptionManager.java index 1cbeda5f08..de9f2977e6 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/SubscriptionManager.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/SubscriptionManager.java @@ -293,12 +293,10 @@ public interface SubscriptionManager { * * @param deviceId the deviceId of the device that need to get operation details. * @param uuid the UUID of the application release. - * @param offset the offset for the data set - * @param limit the limit for the data set * @return {@link DeviceOperationDTO} which contains the details of device subscriptions. * @throws SubscriptionManagementException if there is an error while fetching the details. */ - List getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid, int offset, int limit) + List getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid) throws ApplicationManagementException; /** 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 88465a4533..3bc8918fcc 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 @@ -378,12 +378,10 @@ public interface SubscriptionDAO { * @param appReleaseId the appReleaseId of the application release. * @param deviceId the deviceId of the device that need to get operation details. * @param tenantId id of the current tenant. - * @param offset the offset for the data set - * @param limit the limit for the data set * @return {@link DeviceOperationDTO} which contains the details of device subscriptions. * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. */ - List getSubscriptionOperationsByAppReleaseIDAndDeviceID(int appReleaseId, int deviceId, int tenantId, int offset, int limit) + List getSubscriptionOperationsByAppReleaseIDAndDeviceID(int appReleaseId, int deviceId, 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/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 8737c99d7c..fb2e2cffd6 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 @@ -1857,7 +1857,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc @Override public List getSubscriptionOperationsByAppReleaseIDAndDeviceID( - int appReleaseId, int deviceId, int tenantId, int offset, int limit) throws ApplicationManagementDAOException { + int appReleaseId, int deviceId, int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to get device subscriptions related to the given AppReleaseID and DeviceID."); } @@ -1877,13 +1877,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc "WHERE ads.AP_APP_RELEASE_ID = ? " + "AND ads.DM_DEVICE_ID = ? " + "AND ads.TENANT_ID = ? " + - "LIMIT ? OFFSET ?"; + "ORDER BY aasom.OPERATION_ID DESC " + + "LIMIT 1"; try (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setInt(1, appReleaseId); ps.setInt(2, deviceId); ps.setInt(3, tenantId); - ps.setInt(4, limit); - ps.setInt(5, offset); try (ResultSet rs = ps.executeQuery()) { DeviceOperationDTO deviceSubscription; while (rs.next()) { 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/SubscriptionManagerImpl.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/SubscriptionManagerImpl.java index 669cdb7745..498abe0b02 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/SubscriptionManagerImpl.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/SubscriptionManagerImpl.java @@ -2612,7 +2612,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public List getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid, int offset, int limit) + public List getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); if (uuid == null || uuid.isEmpty()) { @@ -2631,7 +2631,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); List deviceSubscriptions = - subscriptionDAO.getSubscriptionOperationsByAppReleaseIDAndDeviceID(appReleaseId, deviceId, tenantId, offset, limit); + subscriptionDAO.getSubscriptionOperationsByAppReleaseIDAndDeviceID(appReleaseId, deviceId, tenantId); for (DeviceOperationDTO deviceSubscription : deviceSubscriptions) { Integer operationId = deviceSubscription.getOperationId(); if (operationId != null) {