|
|
@ -138,17 +138,17 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
.isEmpty(deviceIdentifier.getType())) {
|
|
|
|
.isEmpty(deviceIdentifier.getType())) {
|
|
|
|
log.warn("Found a device identifier which has either empty identity of the device or empty"
|
|
|
|
log.warn("Found a device identifier which has either empty identity of the device or empty"
|
|
|
|
+ " device type. Hence ignoring the device identifier. ");
|
|
|
|
+ " device type. Hence ignoring the device identifier. ");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!ApplicationType.WEB_CLIP.toString().equals(applicationDTO.getType())) {
|
|
|
|
if (!ApplicationType.WEB_CLIP.toString().equals(applicationDTO.getType())) {
|
|
|
|
DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
|
|
|
DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
|
|
|
if (!deviceType.getName().equals(deviceIdentifier.getType())) {
|
|
|
|
if (!deviceType.getName().equals(deviceIdentifier.getType())) {
|
|
|
|
String msg =
|
|
|
|
log.warn("Found a device identifier which is not matched with the supported device type "
|
|
|
|
"Found a device identifier which is not matched with the application device Type. "
|
|
|
|
+ "of the application release which has UUID " + applicationUUID + " Application "
|
|
|
|
+ "Application device type is " + deviceType.getName() + " and the "
|
|
|
|
+ "supported device type is " + deviceType.getName() + " and the "
|
|
|
|
+ "identifier of which has a " + "different device type is "
|
|
|
|
+ "identifier of which has a different device type is " + deviceIdentifier.getId());
|
|
|
|
+ deviceIdentifier.getId();
|
|
|
|
|
|
|
|
log.warn(msg);
|
|
|
|
|
|
|
|
errorDeviceIdentifiers.add(deviceIdentifier);
|
|
|
|
errorDeviceIdentifiers.add(deviceIdentifier);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
devices.add(deviceManagementProviderService.getDevice(deviceIdentifier, false));
|
|
|
|
devices.add(deviceManagementProviderService.getDevice(deviceIdentifier, false));
|
|
|
@ -188,7 +188,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
applicationInstallResponse = performActionOnDevices(null, devices, applicationDTO, subType,
|
|
|
|
applicationInstallResponse = performActionOnDevices(null, devices, applicationDTO, subType,
|
|
|
|
subscribers, action);
|
|
|
|
subscribers, action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
applicationInstallResponse.setErrorDevices(errorDeviceIdentifiers);
|
|
|
|
applicationInstallResponse.setErrorDeviceIdentifiers(errorDeviceIdentifiers);
|
|
|
|
return applicationInstallResponse;
|
|
|
|
return applicationInstallResponse;
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
String msg = "Error occurred while getting devices of given users or given roles.";
|
|
|
|
String msg = "Error occurred while getting devices of given users or given roles.";
|
|
|
@ -400,21 +400,23 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
entry.getKey(), action);
|
|
|
|
entry.getKey(), action);
|
|
|
|
activityList.add(activity);
|
|
|
|
activityList.add(activity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else if (applicationDTO.getType().equals(ApplicationType.PUBLIC.toString())) {
|
|
|
|
if (applicationDTO.getType().equals(ApplicationType.PUBLIC.toString())) {
|
|
|
|
List<String> categories = getApplicationCategories(applicationDTO.getId());
|
|
|
|
List<String> categories = getApplicationCategories(applicationDTO.getId());
|
|
|
|
if (categories.contains("GooglePlaySyncedApp")) {
|
|
|
|
if (categories.contains("GooglePlaySyncedApp")) {
|
|
|
|
ApplicationPolicyDTO applicationPolicyDTO = new ApplicationPolicyDTO();
|
|
|
|
ApplicationPolicyDTO applicationPolicyDTO = new ApplicationPolicyDTO();
|
|
|
|
applicationPolicyDTO.setApplicationDTO(applicationDTO);
|
|
|
|
applicationPolicyDTO.setApplicationDTO(applicationDTO);
|
|
|
|
applicationPolicyDTO.setDeviceIdentifierList(deviceIdentifiers);
|
|
|
|
applicationPolicyDTO.setDeviceIdentifierList(deviceIdentifiers);
|
|
|
|
applicationPolicyDTO.setAction(action);
|
|
|
|
applicationPolicyDTO.setAction(action);
|
|
|
|
installEnrollmentApplications(applicationPolicyDTO);
|
|
|
|
installEnrollmentApplications(applicationPolicyDTO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Activity activity = addAppOperationOnDevices(applicationDTO, deviceIdentifiers, deviceType, action);
|
|
|
|
Activity activity = addAppOperationOnDevices(applicationDTO, deviceIdentifiers, deviceType, action);
|
|
|
|
activityList.add(activity);
|
|
|
|
activityList.add(activity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Activity activity = addAppOperationOnDevices(applicationDTO, deviceIdentifiers, deviceType, action);
|
|
|
|
|
|
|
|
activityList.add(activity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationInstallResponse applicationInstallResponse = new ApplicationInstallResponse();
|
|
|
|
ApplicationInstallResponse applicationInstallResponse = new ApplicationInstallResponse();
|
|
|
|
applicationInstallResponse.setActivities(activityList);
|
|
|
|
applicationInstallResponse.setActivities(activityList);
|
|
|
|
applicationInstallResponse.setIgnoredDeviceIdentifiers(ignoredDeviceIdentifiers);
|
|
|
|
applicationInstallResponse.setIgnoredDeviceIdentifiers(ignoredDeviceIdentifiers);
|
|
|
@ -600,16 +602,20 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<Integer> getOperationAddedDeviceIds(Activity activity, Map<DeviceIdentifier, Integer> deviceMap) {
|
|
|
|
private List<Integer> getOperationAddedDeviceIds(Activity activity, Map<DeviceIdentifier, Integer> deviceMap) {
|
|
|
|
List<Integer> deviceIds = new ArrayList<>();
|
|
|
|
|
|
|
|
List<ActivityStatus> activityStatuses = activity.getActivityStatus();
|
|
|
|
List<ActivityStatus> activityStatuses = activity.getActivityStatus();
|
|
|
|
for (ActivityStatus status : activityStatuses) {
|
|
|
|
return activityStatuses.stream().map(status -> deviceMap.get(status.getDeviceIdentifier()))
|
|
|
|
if (status.getStatus().equals(ActivityStatus.Status.PENDING)) {
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
deviceIds.add(deviceMap.get(status.getDeviceIdentifier()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return deviceIds;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* This method is responsible to get device subscription of particular application releasee for given set of devices.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param deviceIds Set of device Ids
|
|
|
|
|
|
|
|
* @param appReleaseId Application release Id
|
|
|
|
|
|
|
|
* @return {@link HashMap} with key as device id and value as {@link DeviceSubscriptionDTO}
|
|
|
|
|
|
|
|
* @throws ApplicationManagementException if error occured while executing SQL query or if more than one data found
|
|
|
|
|
|
|
|
* for a device id.
|
|
|
|
|
|
|
|
*/
|
|
|
|
private Map<Integer, DeviceSubscriptionDTO> getDeviceSubscriptions(List<Integer> deviceIds, int appReleaseId)
|
|
|
|
private Map<Integer, DeviceSubscriptionDTO> getDeviceSubscriptions(List<Integer> deviceIds, int appReleaseId)
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|