Add minor fixes in APP subscription flow

merge-requests/102/head
lasanthaDLPDS 6 years ago
parent efa17d2e51
commit 7b8e68220f

@ -129,9 +129,10 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
applicationInstallResponse.setActivity(activity); applicationInstallResponse.setActivity(activity);
applicationInstallResponse.setAlreadyInstalledDevices(installedDeviceIdentifiers); applicationInstallResponse.setAlreadyInstalledDevices(installedDeviceIdentifiers);
int operationId = Integer // int operationId = Integer
.parseInt(activity.getActivityId().split(DeviceManagementConstants.OperationAttributes.ACTIVITY)[1]); // .parseInt(activity.getActivityId().split(DeviceManagementConstants.OperationAttributes.ACTIVITY)[1]);
addDeviceSubscriptionForUser(applicationDTO.getApplicationReleaseDTOs().get(0).getId(), int operationId = Integer.parseInt(activity.getActivityId().split("ACTIVITY_")[1]);
addDeviceSubscriptions(applicationDTO.getApplicationReleaseDTOs().get(0).getId(),
operationTriggeredDeviceIds, new ArrayList<>(deviceSubscriptions.keySet()), null, operationId, operationTriggeredDeviceIds, new ArrayList<>(deviceSubscriptions.keySet()), null, operationId,
SubsciptionType.DEVICE.toString()); SubsciptionType.DEVICE.toString());
return applicationInstallResponse; return applicationInstallResponse;
@ -271,15 +272,17 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
applicationInstallResponse.setActivity(activity); applicationInstallResponse.setActivity(activity);
applicationInstallResponse.setAlreadyInstalledDevices(installedDeviceIdentifiers); applicationInstallResponse.setAlreadyInstalledDevices(installedDeviceIdentifiers);
int operationId = Integer // int operationId = Integer
.parseInt(activity.getActivityId().split(DeviceManagementConstants.OperationAttributes.ACTIVITY)[1]); // .parseInt(activity.getActivityId().split(DeviceManagementConstants.OperationAttributes.ACTIVITY)[1]);
addDeviceSubscriptionForUser(applicationDTO.getApplicationReleaseDTOs().get(0).getId(), int operationId = Integer.parseInt(activity.getActivityId().split("ACTIVITY_")[1]);
addDeviceSubscriptions(applicationDTO.getApplicationReleaseDTOs().get(0).getId(),
operationTriggeredDeviceIds, new ArrayList<>(deviceSubscriptions.keySet()), userList, operationId, SubsciptionType.USER.toString()); operationTriggeredDeviceIds, new ArrayList<>(deviceSubscriptions.keySet()), userList, operationId, SubsciptionType.USER.toString());
return applicationInstallResponse; return applicationInstallResponse;
} }
private void addDeviceSubscriptionForUser(int applicationReleaseId, List<Integer> deviceIds, private void addDeviceSubscriptions(int applicationReleaseId, List<Integer> deviceIds,
List<Integer> subDeviceIds, List<String> userList, int operationId, String subType) List<Integer> subDeviceIds, List<String> subscribers, int operationId, String subType)
throws ApplicationManagementException { throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String subscriber = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); String subscriber = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
@ -289,13 +292,13 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
List<Integer> deviceSubscriptingIds; List<Integer> deviceSubscriptingIds;
if (SubsciptionType.USER.toString().equals(subType)){ if (SubsciptionType.USER.toString().equals(subType)){
List<String> subscribedUsers = subscriptionDAO.getSubscribedUsernames(userList, tenantId); List<String> subscribedUsers = subscriptionDAO.getSubscribedUsernames(subscribers, tenantId);
if (!subscribedUsers.isEmpty()) { if (!subscribedUsers.isEmpty()) {
subscriptionDAO subscriptionDAO
.updateUserSubscription(tenantId, subscriber, false, subscribedUsers, applicationReleaseId); .updateUserSubscription(tenantId, subscriber, false, subscribedUsers, applicationReleaseId);
userList.removeAll(subscribedUsers); subscribers.removeAll(subscribedUsers);
} }
subscriptionDAO.subscribeUserToApplication(tenantId, subscriber, userList, applicationReleaseId); subscriptionDAO.subscribeUserToApplication(tenantId, subscriber, subscribers, applicationReleaseId);
} }
if (!subDeviceIds.isEmpty()) { if (!subDeviceIds.isEmpty()) {

Loading…
Cancel
Save