Merge branch 'application-mgt-new' into 'application-mgt-new'

Add appm device subscription update feature

See merge request entgra/carbon-device-mgt!155
feature/appm-store/pbac
Dharmakeerthi Lasantha 5 years ago
commit c3a5fbbeb1

@ -254,6 +254,9 @@ public interface ApplicationManager {
String getInstallableLifecycleState() throws ApplicationManagementException;
void updateSubsStatus (int operationId, String status) throws ApplicationManagementException;
/**
* Get plist content to download and install the application.
*

@ -81,6 +81,6 @@ public interface SubscriptionDAO {
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
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 "

@ -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 {

Loading…
Cancel
Save