|
|
|
@ -707,6 +707,18 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private <T> void validatePendingAppSubscription(List<Device> devices, SubscribingDeviceIdHolder subscribingDeviceIdHolder) throws BadRequestException{
|
|
|
|
|
Set<DeviceIdentifier> deviceIdentifiers = devices.stream()
|
|
|
|
|
.map(device -> new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()))
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
Set<DeviceIdentifier> skippedDevices = subscribingDeviceIdHolder.getSkippedDevices().keySet();
|
|
|
|
|
if (skippedDevices.containsAll(deviceIdentifiers) && deviceIdentifiers.containsAll(skippedDevices)) {
|
|
|
|
|
String msg = "All devices in the subscription have pending operations for this application.";
|
|
|
|
|
log.error(msg);
|
|
|
|
|
throw new BadRequestException(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This method perform given action (i.e APP INSTALL or APP UNINSTALL) on given set of devices.
|
|
|
|
|
*
|
|
|
|
@ -741,6 +753,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
|
Map<String, List<DeviceIdentifier>> deviceIdentifierMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
|
|
|
|
|
validatePendingAppSubscription(devices, subscribingDeviceIdHolder);
|
|
|
|
|
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppInstallableDevices().keySet()));
|
|
|
|
|
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppReInstallableDevices().keySet()));
|
|
|
|
|
if (!isOperationReExecutingDisabled) {
|
|
|
|
|