|
|
@ -121,7 +121,16 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public <T> ApplicationInstallResponse performBulkAppOperation(String applicationUUID, List<T> params,
|
|
|
|
public <T> ApplicationInstallResponse performBulkAppOperation(String applicationUUID, List<T> params,
|
|
|
|
String subType, String action, Properties properties) throws ApplicationManagementException {
|
|
|
|
String subType, String action, Properties properties)
|
|
|
|
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
|
|
|
|
return performBulkAppOperation(applicationUUID, params, subType, action, properties, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public <T> ApplicationInstallResponse performBulkAppOperation(String applicationUUID, List<T> params,
|
|
|
|
|
|
|
|
String subType, String action, Properties properties,
|
|
|
|
|
|
|
|
boolean isOperationReExecutingDisabled)
|
|
|
|
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Install application release which has UUID " + applicationUUID + " to " + params.size()
|
|
|
|
log.debug("Install application release which has UUID " + applicationUUID + " to " + params.size()
|
|
|
|
+ " users.");
|
|
|
|
+ " users.");
|
|
|
@ -134,7 +143,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
params);
|
|
|
|
params);
|
|
|
|
ApplicationInstallResponse applicationInstallResponse = performActionOnDevices(
|
|
|
|
ApplicationInstallResponse applicationInstallResponse = performActionOnDevices(
|
|
|
|
applicationSubscriptionInfo.getAppSupportingDeviceTypeName(), applicationSubscriptionInfo.getDevices(),
|
|
|
|
applicationSubscriptionInfo.getAppSupportingDeviceTypeName(), applicationSubscriptionInfo.getDevices(),
|
|
|
|
applicationDTO, subType, applicationSubscriptionInfo.getSubscribers(), action, properties);
|
|
|
|
applicationDTO, subType, applicationSubscriptionInfo.getSubscribers(), action, properties, isOperationReExecutingDisabled);
|
|
|
|
|
|
|
|
|
|
|
|
applicationInstallResponse.setErrorDeviceIdentifiers(applicationSubscriptionInfo.getErrorDeviceIdentifiers());
|
|
|
|
applicationInstallResponse.setErrorDeviceIdentifiers(applicationSubscriptionInfo.getErrorDeviceIdentifiers());
|
|
|
|
return applicationInstallResponse;
|
|
|
|
return applicationInstallResponse;
|
|
|
@ -617,12 +626,17 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
* @param subType Subscription type (i.e USER, ROLE, GROUP or DEVICE)
|
|
|
|
* @param subType Subscription type (i.e USER, ROLE, GROUP or DEVICE)
|
|
|
|
* @param subscribers Subscribers
|
|
|
|
* @param subscribers Subscribers
|
|
|
|
* @param action Performing action. (i.e INSTALL or UNINSTALL)
|
|
|
|
* @param action Performing action. (i.e INSTALL or UNINSTALL)
|
|
|
|
|
|
|
|
* @param isOperationReExecutingDisabled To prevent adding the application subscribing operation to devices that are
|
|
|
|
|
|
|
|
* already subscribed application successfully.
|
|
|
|
* @return {@link ApplicationInstallResponse}
|
|
|
|
* @return {@link ApplicationInstallResponse}
|
|
|
|
* @throws ApplicationManagementException if error occured when adding operation on device or updating subscription
|
|
|
|
* @throws ApplicationManagementException if error occurred when adding operation on device or updating subscription
|
|
|
|
* data.
|
|
|
|
* data.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private ApplicationInstallResponse performActionOnDevices(String deviceType, List<Device> devices,
|
|
|
|
private ApplicationInstallResponse performActionOnDevices(String deviceType, List<Device> devices,
|
|
|
|
ApplicationDTO applicationDTO, String subType, List<String> subscribers, String action, Properties properties)
|
|
|
|
ApplicationDTO applicationDTO, String subType,
|
|
|
|
|
|
|
|
List<String> subscribers, String action,
|
|
|
|
|
|
|
|
Properties properties,
|
|
|
|
|
|
|
|
boolean isOperationReExecutingDisabled)
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
//Get app subscribing info of each device
|
|
|
|
//Get app subscribing info of each device
|
|
|
@ -637,15 +651,19 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
|
|
|
|
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
|
|
|
|
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppInstallableDevices().keySet()));
|
|
|
|
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppInstallableDevices().keySet()));
|
|
|
|
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppReInstallableDevices().keySet()));
|
|
|
|
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppReInstallableDevices().keySet()));
|
|
|
|
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppInstalledDevices().keySet()));
|
|
|
|
if (!isOperationReExecutingDisabled) {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
|
|
|
|
|
|
|
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppInstalledDevices().keySet()));
|
|
|
|
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppInstalledDevices().keySet()));
|
|
|
|
deviceIdentifiers
|
|
|
|
|
|
|
|
.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppReUnInstallableDevices().keySet()));
|
|
|
|
|
|
|
|
ignoredDeviceIdentifiers
|
|
|
|
|
|
|
|
.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppInstallableDevices().keySet()));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
|
|
|
|
|
|
|
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppInstalledDevices().keySet()));
|
|
|
|
|
|
|
|
deviceIdentifiers
|
|
|
|
|
|
|
|
.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppReUnInstallableDevices().keySet()));
|
|
|
|
|
|
|
|
ignoredDeviceIdentifiers
|
|
|
|
|
|
|
|
.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppInstallableDevices().keySet()));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
String msg = "Found invalid Action: " + action + ". Hence, terminating the application subscribing.";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new ApplicationManagementException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (deviceIdentifiers.isEmpty()) {
|
|
|
|
if (deviceIdentifiers.isEmpty()) {
|
|
|
@ -717,15 +735,14 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (deviceSubscriptionDTO.isUnsubscribed()) {
|
|
|
|
if (deviceSubscriptionDTO.isUnsubscribed()) {
|
|
|
|
if (!Operation.Status.COMPLETED.toString().equals(deviceSubscriptionDTO.getStatus())) {
|
|
|
|
if (!Operation.Status.COMPLETED.toString().equals(deviceSubscriptionDTO.getStatus())) {
|
|
|
|
/*We can't ensure whether app is uninstalled successfully or not hence allow to perform both
|
|
|
|
/*If the uninstalling operation has failed, we can't ensure whether the app is uninstalled
|
|
|
|
install and uninstall operations*/
|
|
|
|
successfully or not. Therefore, allowing to perform both install and uninstall operations*/
|
|
|
|
subscribingDeviceIdHolder.getAppReUnInstallableDevices()
|
|
|
|
subscribingDeviceIdHolder.getAppReUnInstallableDevices()
|
|
|
|
.put(deviceIdentifier, device.getId());
|
|
|
|
.put(deviceIdentifier, device.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
subscribingDeviceIdHolder.getAppReInstallableDevices().put(deviceIdentifier, device.getId());
|
|
|
|
subscribingDeviceIdHolder.getAppReInstallableDevices().put(deviceIdentifier, device.getId());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (!deviceSubscriptionDTO.isUnsubscribed() && Operation.Status.COMPLETED.toString()
|
|
|
|
if (Operation.Status.COMPLETED.toString().equals(deviceSubscriptionDTO.getStatus())) {
|
|
|
|
.equals(deviceSubscriptionDTO.getStatus())) {
|
|
|
|
|
|
|
|
subscribingDeviceIdHolder.getAppInstalledDevices().put(deviceIdentifier, device.getId());
|
|
|
|
subscribingDeviceIdHolder.getAppInstalledDevices().put(deviceIdentifier, device.getId());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
subscribingDeviceIdHolder.getAppReInstallableDevices()
|
|
|
|
subscribingDeviceIdHolder.getAppReInstallableDevices()
|
|
|
@ -960,11 +977,11 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
return this.subscriptionDAO.getDeviceSubscriptions(deviceIds, appReleaseId, tenantId);
|
|
|
|
return this.subscriptionDAO.getDeviceSubscriptions(deviceIds, appReleaseId, tenantId);
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
} catch (ApplicationManagementDAOException e) {
|
|
|
|
String msg = "Error occured when getting device subscriptions for given device IDs";
|
|
|
|
String msg = "Error occurred when getting device subscriptions for given device IDs";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
} catch (DBConnectionException e) {
|
|
|
|
String msg = "Error occured while getting database connection for getting device subscriptions.";
|
|
|
|
String msg = "Error occurred while getting database connection for getting device subscriptions.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
throw new ApplicationManagementException(msg, e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|