Add appm device subscription update feature

feature/appm-store/pbac
lasanthaDLPDS 5 years ago
parent 76050a1aaf
commit 46f39c0918

@ -254,13 +254,16 @@ public interface ApplicationManager {
String getInstallableLifecycleState() throws ApplicationManagementException; String getInstallableLifecycleState() throws ApplicationManagementException;
/** 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 * Get plist content to download and install the application.
* @throws ApplicationManagementException Application management exception *
*/ * @param uuid Release UUID of the application.
* @return plist string
* @throws ApplicationManagementException Application management exception
*/
String getPlistArtifact(String uuid) throws ApplicationManagementException; String getPlistArtifact(String uuid) throws ApplicationManagementException;
} }

@ -81,6 +81,6 @@ public interface SubscriptionDAO {
List<Integer> getSubscribedDeviceIds(List<Integer> deviceIds, int tenantId) throws ApplicationManagementDAOException; List<Integer> getSubscribedDeviceIds(List<Integer> 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;
} }

@ -577,7 +577,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
} }
@Override @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; Connection conn;
try { try {
conn = this.getDBConnection(); conn = this.getDBConnection();
@ -590,7 +590,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
stmt.setString(1, status); stmt.setString(1, status);
stmt.setInt(2, operationId); stmt.setInt(2, operationId);
stmt.setInt(3, tenantId); stmt.setInt(3, tenantId);
stmt.executeUpdate(); return stmt.executeUpdate() != 0;
} }
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
String msg = "Error occurred while obtaining the DB connection to update the subscription status of the " String msg = "Error occurred while obtaining the DB connection to update the subscription status of the "

@ -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 { public String getPlistArtifact(String releaseUuid) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
try { try {

Loading…
Cancel
Save