|
|
@ -177,23 +177,26 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// Only for iOS devices
|
|
|
|
// Only for iOS devices
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
|
|
|
if (DeviceTypes.IOS.toString().equalsIgnoreCase(APIUtil.getDeviceTypeData(applicationDTO
|
|
|
|
// Ignore checking device type if app is a web clip
|
|
|
|
.getDeviceTypeId()).getName())) {
|
|
|
|
if(!applicationDTO.getType().equals("WEB_CLIP")){
|
|
|
|
// TODO: replace getAssetByAppId with the correct one in DAO
|
|
|
|
if (DeviceTypes.IOS.toString().equalsIgnoreCase(APIUtil.getDeviceTypeData(applicationDTO
|
|
|
|
// Check if the app trying to subscribe is a VPP asset.
|
|
|
|
.getDeviceTypeId()).getName())) {
|
|
|
|
VppAssetDTO storedAsset = vppApplicationDAO.getAssetByAppId(applicationDTO.getId(), tenantId);
|
|
|
|
// TODO: replace getAssetByAppId with the correct one in DAO
|
|
|
|
if (storedAsset != null) { // This is a VPP asset
|
|
|
|
// Check if the app trying to subscribe is a VPP asset.
|
|
|
|
List<VppUserDTO> users = new ArrayList<>();
|
|
|
|
VppAssetDTO storedAsset = vppApplicationDAO.getAssetByAppId(applicationDTO.getId(), tenantId);
|
|
|
|
List<Device> devices = applicationSubscriptionInfo.getDevices();// get
|
|
|
|
if (storedAsset != null) { // This is a VPP asset
|
|
|
|
// subscribed device list, so that we can extract the users of those devices.
|
|
|
|
List<VppUserDTO> users = new ArrayList<>();
|
|
|
|
for (Device device : devices) {
|
|
|
|
List<Device> devices = applicationSubscriptionInfo.getDevices();// get
|
|
|
|
VppUserDTO user = vppApplicationDAO.getUserByDMUsername(device.getEnrolmentInfo()
|
|
|
|
// subscribed device list, so that we can extract the users of those devices.
|
|
|
|
.getOwner(), PrivilegedCarbonContext.getThreadLocalCarbonContext()
|
|
|
|
for (Device device : devices) {
|
|
|
|
.getTenantId(true));
|
|
|
|
VppUserDTO user = vppApplicationDAO.getUserByDMUsername(device.getEnrolmentInfo()
|
|
|
|
users.add(user);
|
|
|
|
.getOwner(), PrivilegedCarbonContext.getThreadLocalCarbonContext()
|
|
|
|
|
|
|
|
.getTenantId(true));
|
|
|
|
|
|
|
|
users.add(user);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
VPPApplicationManager vppManager = APIUtil.getVPPManager();
|
|
|
|
|
|
|
|
vppManager.addAssociation(storedAsset, users);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
VPPApplicationManager vppManager = APIUtil.getVPPManager();
|
|
|
|
|
|
|
|
vppManager.addAssociation(storedAsset, users);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (BadRequestException e) {
|
|
|
|
} catch (BadRequestException e) {
|
|
|
|