|
|
@ -19,13 +19,42 @@
|
|
|
|
package io.entgra.device.mgt.core.application.mgt.core.impl;
|
|
|
|
package io.entgra.device.mgt.core.application.mgt.core.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.*;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.ApplicationInstallResponse;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.dto.*;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.ApplicationSubscriptionInfo;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.ApplicationType;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionResult;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscription;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionData;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionFilterCriteria;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.SubAction;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.SubscribingDeviceIdHolder;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionEntity;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionMetadata;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionResponse;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionStatistics;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationPolicyDTO;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.dto.CategorizedSubscriptionCountsDTO;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionStatisticDTO;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.dto.VppAssetDTO;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.dto.VppUserDTO;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.services.VPPApplicationManager;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.services.VPPApplicationManager;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationReleaseDAO;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.ApplicationReleaseDAO;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.VppApplicationDAO;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.dao.VppApplicationDAO;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.exception.BadRequestException;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.util.SubscriptionManagementHelperUtil;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.util.SubscriptionManagementHelperUtil;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.Device;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.MDMAppConstants;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.PaginationResult;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.PaginationResult;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants;
|
|
|
@ -70,7 +99,6 @@ import io.entgra.device.mgt.core.application.mgt.core.util.ConnectionManagerUtil
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.util.Constants;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.util.Constants;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.util.OAuthUtils;
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.util.OAuthUtils;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.*;
|
|
|
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.App;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.MobileAppTypes;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.MobileAppTypes;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.android.CustomApplication;
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.android.CustomApplication;
|
|
|
@ -103,7 +131,16 @@ import java.net.URL;
|
|
|
|
import java.security.KeyManagementException;
|
|
|
|
import java.security.KeyManagementException;
|
|
|
|
import java.security.KeyStoreException;
|
|
|
|
import java.security.KeyStoreException;
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
@ -1217,6 +1254,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Get the bundle id of the iOS public application.
|
|
|
|
* Get the bundle id of the iOS public application.
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param appId Application Id
|
|
|
|
* @param appId Application Id
|
|
|
|
* @return {@link String} bundle Id
|
|
|
|
* @return {@link String} bundle Id
|
|
|
|
* @throws ApplicationManagementException if error occurred while getting the bundle if of the requesting public
|
|
|
|
* @throws ApplicationManagementException if error occurred while getting the bundle if of the requesting public
|
|
|
@ -1674,17 +1712,18 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Get subscription data describes by {@link SubscriptionInfo} entity
|
|
|
|
* Get subscription data describes by {@link SubscriptionInfo} entity
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param subscriptionInfo {@link SubscriptionInfo}
|
|
|
|
* @param subscriptionInfo {@link SubscriptionInfo}
|
|
|
|
* @param limit Limit value
|
|
|
|
* @param limit Limit value
|
|
|
|
* @param offset Offset value
|
|
|
|
* @param offset Offset value
|
|
|
|
* @return {@link SubscriptionResponse}
|
|
|
|
* @return {@link SubscriptionResponse}
|
|
|
|
* @throws ApplicationManagementException Throws when error encountered while getting subscription data
|
|
|
|
* @throws ApplicationManagementException Throws when error encountered while getting subscription data
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public SubscriptionResponse getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset)
|
|
|
|
public SubscriptionResponse getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset)
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus());
|
|
|
|
final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED,
|
|
|
|
|
|
|
|
subscriptionInfo.getSubscriptionStatus());
|
|
|
|
final int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
final int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
@ -1702,13 +1741,15 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
int subscriptionCount = isUnsubscribe ? subscriptionDAO.getGroupUnsubscriptionCount(applicationReleaseDTO.getId(), tenantId) :
|
|
|
|
int subscriptionCount = isUnsubscribe ? subscriptionDAO.getGroupUnsubscriptionCount(applicationReleaseDTO.getId(), tenantId) :
|
|
|
|
subscriptionDAO.getGroupSubscriptionCount(applicationReleaseDTO.getId(), tenantId);
|
|
|
|
subscriptionDAO.getGroupSubscriptionCount(applicationReleaseDTO.getId(), tenantId);
|
|
|
|
return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), subscriptionCount, subscriptionEntities);
|
|
|
|
return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), subscriptionCount, subscriptionEntities);
|
|
|
|
} if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.ROLE)){
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.ROLE)) {
|
|
|
|
List<SubscriptionEntity> subscriptionEntities = subscriptionDAO.
|
|
|
|
List<SubscriptionEntity> subscriptionEntities = subscriptionDAO.
|
|
|
|
getRoleSubscriptionsByAppReleaseID(applicationReleaseDTO.getId(), isUnsubscribe, tenantId, offset, limit);
|
|
|
|
getRoleSubscriptionsByAppReleaseID(applicationReleaseDTO.getId(), isUnsubscribe, tenantId, offset, limit);
|
|
|
|
int subscriptionCount = isUnsubscribe ? subscriptionDAO.getRoleUnsubscriptionCount(applicationReleaseDTO.getId(), tenantId) :
|
|
|
|
int subscriptionCount = isUnsubscribe ? subscriptionDAO.getRoleUnsubscriptionCount(applicationReleaseDTO.getId(), tenantId) :
|
|
|
|
subscriptionDAO.getRoleSubscriptionCount(applicationReleaseDTO.getId(), tenantId);
|
|
|
|
subscriptionDAO.getRoleSubscriptionCount(applicationReleaseDTO.getId(), tenantId);
|
|
|
|
return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), subscriptionCount, subscriptionEntities);
|
|
|
|
return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), subscriptionCount, subscriptionEntities);
|
|
|
|
} if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.USER)){
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.USER)) {
|
|
|
|
List<SubscriptionEntity> subscriptionEntities = subscriptionDAO.
|
|
|
|
List<SubscriptionEntity> subscriptionEntities = subscriptionDAO.
|
|
|
|
getUserSubscriptionsByAppReleaseID(applicationReleaseDTO.getId(), isUnsubscribe, tenantId, offset, limit);
|
|
|
|
getUserSubscriptionsByAppReleaseID(applicationReleaseDTO.getId(), isUnsubscribe, tenantId, offset, limit);
|
|
|
|
int subscriptionCount = isUnsubscribe ? subscriptionDAO.getUserUnsubscriptionCount(applicationReleaseDTO.getId(), tenantId) :
|
|
|
|
int subscriptionCount = isUnsubscribe ? subscriptionDAO.getUserUnsubscriptionCount(applicationReleaseDTO.getId(), tenantId) :
|
|
|
@ -1728,17 +1769,18 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Retrieves subscription statistics described by the {@link SubscriptionInfo} entity.
|
|
|
|
* Retrieves subscription statistics described by the {@link SubscriptionInfo} entity.
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param subscriptionInfo The {@link SubscriptionInfo} containing details about the subscription type and identifier.
|
|
|
|
* @param subscriptionInfo The {@link SubscriptionInfo} containing details about the subscription type and identifier.
|
|
|
|
* @return {@link SubscriptionStatistics} The subscription statistics for the specified subscription type and identifier.
|
|
|
|
* @return {@link SubscriptionStatistics} The subscription statistics for the specified subscription type and identifier.
|
|
|
|
* @throws ApplicationManagementException Throws when an error is encountered while getting subscription statistics.
|
|
|
|
* @throws ApplicationManagementException Throws when an error is encountered while getting subscription statistics.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
public SubscriptionStatistics getSubscriptionStatistics(SubscriptionInfo subscriptionInfo)
|
|
|
|
public SubscriptionStatistics getSubscriptionStatistics(SubscriptionInfo subscriptionInfo)
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.DEVICE)) {
|
|
|
|
if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.DEVICE)) {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus());
|
|
|
|
final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED,
|
|
|
|
|
|
|
|
subscriptionInfo.getSubscriptionStatus());
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
|
ConnectionManagerUtil.openDBConnection();
|
|
|
@ -1751,25 +1793,27 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
throw new NotFoundException(msg);
|
|
|
|
throw new NotFoundException(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.GROUP)) {
|
|
|
|
if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.GROUP)) {
|
|
|
|
List<Device> devices = HelperUtil.getGroupManagementProviderService().
|
|
|
|
return SubscriptionManagementHelperUtil.getSubscriptionStatistics(
|
|
|
|
getAllDevicesOfGroup(subscriptionInfo.getIdentifier(), false);
|
|
|
|
subscriptionDAO.getSubscriptionStatistic(
|
|
|
|
List<Integer> deviceIdsOwnByGroup = devices.stream().map(Device::getId).collect(Collectors.toList());
|
|
|
|
HelperUtil.getGroupManagementProviderService()
|
|
|
|
SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO.
|
|
|
|
.getAllDevicesOfGroup(subscriptionInfo.getIdentifier(), false)
|
|
|
|
getSubscriptionStatistic(deviceIdsOwnByGroup, isUnsubscribe, tenantId, applicationReleaseDTO.getId());
|
|
|
|
.stream().map(Device::getId).collect(Collectors.toList()),
|
|
|
|
int allDeviceCount = HelperUtil.getGroupManagementProviderService().getDeviceCount(subscriptionInfo.getIdentifier());
|
|
|
|
isUnsubscribe, tenantId, applicationReleaseDTO.getId()),
|
|
|
|
return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount);
|
|
|
|
HelperUtil.getGroupManagementProviderService().getDeviceCount(subscriptionInfo.getIdentifier())
|
|
|
|
} if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.ROLE)){
|
|
|
|
);
|
|
|
|
List<Integer> deviceIdsOwnByRole = getDeviceIdsOwnByRole(subscriptionInfo.getIdentifier(), tenantId);
|
|
|
|
}
|
|
|
|
SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO.
|
|
|
|
if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.ROLE)) {
|
|
|
|
getSubscriptionStatistic(deviceIdsOwnByRole, isUnsubscribe, tenantId, applicationReleaseDTO.getId());
|
|
|
|
return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionDAO.getSubscriptionStatistic(
|
|
|
|
int allDeviceCount = deviceIdsOwnByRole.size();
|
|
|
|
getDeviceIdsOwnByRole(subscriptionInfo.getIdentifier(), tenantId), isUnsubscribe, tenantId,
|
|
|
|
return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount);
|
|
|
|
applicationReleaseDTO.getId()
|
|
|
|
} if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.USER)){
|
|
|
|
), getDeviceIdsOwnByRole(subscriptionInfo.getIdentifier(), tenantId).size());
|
|
|
|
List<Integer> deviceIdsOwnByUser = getDeviceIdsOwnByUser(subscriptionInfo.getIdentifier());
|
|
|
|
}
|
|
|
|
SubscriptionStatisticDTO subscriptionStatisticDTO = subscriptionDAO.
|
|
|
|
if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.USER)) {
|
|
|
|
getSubscriptionStatistic(deviceIdsOwnByUser, isUnsubscribe, tenantId, applicationReleaseDTO.getId());
|
|
|
|
return SubscriptionManagementHelperUtil.getSubscriptionStatistics(
|
|
|
|
int allDeviceCount = deviceIdsOwnByUser.size();
|
|
|
|
subscriptionDAO.getSubscriptionStatistic(getDeviceIdsOwnByUser(subscriptionInfo.getIdentifier()),
|
|
|
|
return SubscriptionManagementHelperUtil.getSubscriptionStatistics(subscriptionStatisticDTO, allDeviceCount);
|
|
|
|
isUnsubscribe, tenantId, applicationReleaseDTO.getId()),
|
|
|
|
|
|
|
|
getDeviceIdsOwnByUser(subscriptionInfo.getIdentifier()).size()
|
|
|
|
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1796,13 +1840,14 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Get status based subscription data describes by {@link SubscriptionInfo} entity
|
|
|
|
* Get status based subscription data describes by {@link SubscriptionInfo} entity
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param subscriptionInfo {@link SubscriptionInfo}
|
|
|
|
* @param subscriptionInfo {@link SubscriptionInfo}
|
|
|
|
* @param limit Limit value
|
|
|
|
* @param limit Limit value
|
|
|
|
* @param offset Offset value
|
|
|
|
* @param offset Offset value
|
|
|
|
* @return {@link SubscriptionResponse}
|
|
|
|
* @return {@link SubscriptionResponse}
|
|
|
|
* @throws ApplicationManagementException Throws when error encountered while getting subscription data
|
|
|
|
* @throws ApplicationManagementException Throws when error encountered while getting subscription data
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset)
|
|
|
|
public SubscriptionResponse getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset)
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.DEVICE)) {
|
|
|
|
if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.DEVICE)) {
|
|
|
@ -1810,14 +1855,14 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
} else if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.GROUP)) {
|
|
|
|
} else if (Objects.equals(subscriptionInfo.getSubscriptionType(), SubscriptionMetadata.SubscriptionTypes.GROUP)) {
|
|
|
|
return getStatusBaseSubscriptionsGroup(subscriptionInfo, limit, offset);
|
|
|
|
return getStatusBaseSubscriptionsGroup(subscriptionInfo, limit, offset);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return getStatusBaseSubscriptionsRoleUser(subscriptionInfo, limit, offset);
|
|
|
|
return getStatusBaseSubscriptionsRoleAndUser(subscriptionInfo, limit, offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SubscriptionResponse getStatusBaseSubscriptionsDevice(SubscriptionInfo subscriptionInfo, int limit, int offset)
|
|
|
|
public SubscriptionResponse getStatusBaseSubscriptionsDevice(SubscriptionInfo subscriptionInfo, int limit, int offset)
|
|
|
|
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus());
|
|
|
|
final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED,
|
|
|
|
|
|
|
|
subscriptionInfo.getSubscriptionStatus());
|
|
|
|
List<DeviceSubscriptionDTO> deviceSubscriptionDTOS;
|
|
|
|
List<DeviceSubscriptionDTO> deviceSubscriptionDTOS;
|
|
|
|
int deviceCount = 0;
|
|
|
|
int deviceCount = 0;
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
@ -1843,7 +1888,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
String deviceSubscriptionStatus = SubscriptionManagementHelperUtil.getDeviceSubscriptionStatus(subscriptionInfo);
|
|
|
|
String deviceSubscriptionStatus = SubscriptionManagementHelperUtil.getDeviceSubscriptionStatus(subscriptionInfo);
|
|
|
|
DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria = subscriptionInfo.getDeviceSubscriptionFilterCriteria();
|
|
|
|
DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria = subscriptionInfo.getDeviceSubscriptionFilterCriteria();
|
|
|
|
DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService();
|
|
|
|
DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService();
|
|
|
|
List<String> dbSubscriptionStatus = SubscriptionManagementHelperUtil.getDBSubscriptionStatus(subscriptionInfo.getDeviceSubscriptionStatus());
|
|
|
|
List<String> dbSubscriptionStatus = SubscriptionManagementHelperUtil.getDBSubscriptionStatus
|
|
|
|
|
|
|
|
(subscriptionInfo.getDeviceSubscriptionStatus());
|
|
|
|
|
|
|
|
|
|
|
|
if (Objects.equals(SubscriptionMetadata.DeviceSubscriptionStatus.NEW, deviceSubscriptionStatus)) {
|
|
|
|
if (Objects.equals(SubscriptionMetadata.DeviceSubscriptionStatus.NEW, deviceSubscriptionStatus)) {
|
|
|
|
deviceSubscriptionDTOS = subscriptionDAO.getAllSubscriptionsDetails(applicationReleaseDTO.
|
|
|
|
deviceSubscriptionDTOS = subscriptionDAO.getAllSubscriptionsDetails(applicationReleaseDTO.
|
|
|
@ -1862,7 +1908,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1);
|
|
|
|
deviceSubscriptionFilterCriteria.getTriggeredBy(), -1, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<DeviceSubscription> deviceSubscriptions = SubscriptionManagementHelperUtil.getDeviceSubscriptionData(deviceSubscriptionDTOS,
|
|
|
|
List<DeviceSubscription> deviceSubscriptions = SubscriptionManagementHelperUtil.getDeviceSubscriptionData(deviceSubscriptionDTOS,
|
|
|
|
subscriptionInfo.getDeviceSubscriptionFilterCriteria(), isUnsubscribe, applicationDTO.getDeviceTypeId(), limit, offset);
|
|
|
|
subscriptionInfo.getDeviceSubscriptionFilterCriteria(), isUnsubscribe, applicationDTO.getDeviceTypeId(), limit, offset);
|
|
|
|
return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), deviceCount, deviceSubscriptions);
|
|
|
|
return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), deviceCount, deviceSubscriptions);
|
|
|
@ -1879,10 +1924,11 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public SubscriptionResponse getStatusBaseSubscriptionsGroup(SubscriptionInfo subscriptionInfo, int limit, int offset)
|
|
|
|
private SubscriptionResponse getStatusBaseSubscriptionsGroup(SubscriptionInfo subscriptionInfo, int limit, int offset)
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus());
|
|
|
|
final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED,
|
|
|
|
|
|
|
|
subscriptionInfo.getSubscriptionStatus());
|
|
|
|
List<DeviceSubscriptionDTO> deviceSubscriptionDTOS;
|
|
|
|
List<DeviceSubscriptionDTO> deviceSubscriptionDTOS;
|
|
|
|
int deviceCount = 0;
|
|
|
|
int deviceCount = 0;
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
@ -1912,11 +1958,14 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
|
|
|
|
|
|
|
|
GroupManagementProviderService groupManagementProviderService = HelperUtil.getGroupManagementProviderService();
|
|
|
|
GroupManagementProviderService groupManagementProviderService = HelperUtil.getGroupManagementProviderService();
|
|
|
|
GroupDetailsDTO groupDetailsDTO;
|
|
|
|
GroupDetailsDTO groupDetailsDTO;
|
|
|
|
List<String> dbSubscriptionStatus = SubscriptionManagementHelperUtil.getDBSubscriptionStatus(subscriptionInfo.getDeviceSubscriptionStatus());
|
|
|
|
List<String> dbSubscriptionStatus = SubscriptionManagementHelperUtil.getDBSubscriptionStatus
|
|
|
|
|
|
|
|
(subscriptionInfo.getDeviceSubscriptionStatus());
|
|
|
|
|
|
|
|
|
|
|
|
if (Objects.equals(SubscriptionMetadata.DeviceSubscriptionStatus.NEW, deviceSubscriptionStatus)) {
|
|
|
|
if (Objects.equals(SubscriptionMetadata.DeviceSubscriptionStatus.NEW, deviceSubscriptionStatus)) {
|
|
|
|
List<Integer> allDeviceIdsOwnByGroup = groupManagementProviderService.getGroupDetailsWithDevices(subscriptionInfo.getIdentifier(),
|
|
|
|
List<Integer> allDeviceIdsOwnByGroup = groupManagementProviderService.getGroupDetailsWithDevices
|
|
|
|
applicationDTO.getDeviceTypeId(), deviceSubscriptionFilterCriteria.getOwner(), deviceSubscriptionFilterCriteria.getName(),
|
|
|
|
(subscriptionInfo.getIdentifier(),
|
|
|
|
|
|
|
|
applicationDTO.getDeviceTypeId(), deviceSubscriptionFilterCriteria.getOwner(),
|
|
|
|
|
|
|
|
deviceSubscriptionFilterCriteria.getName(),
|
|
|
|
deviceSubscriptionFilterCriteria.getDeviceStatus(), -1, -1).getDeviceIds();
|
|
|
|
deviceSubscriptionFilterCriteria.getDeviceStatus(), -1, -1).getDeviceIds();
|
|
|
|
|
|
|
|
|
|
|
|
deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(),
|
|
|
|
deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(),
|
|
|
@ -1964,10 +2013,10 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SubscriptionResponse getStatusBaseSubscriptionsRoleAndUser(SubscriptionInfo subscriptionInfo, int limit, int offset)
|
|
|
|
public SubscriptionResponse getStatusBaseSubscriptionsRoleUser(SubscriptionInfo subscriptionInfo, int limit, int offset)
|
|
|
|
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED, subscriptionInfo.getSubscriptionStatus());
|
|
|
|
final boolean isUnsubscribe = Objects.equals(SubscriptionMetadata.SUBSCRIPTION_STATUS_UNSUBSCRIBED,
|
|
|
|
|
|
|
|
subscriptionInfo.getSubscriptionStatus());
|
|
|
|
List<DeviceSubscriptionDTO> deviceSubscriptionDTOS;
|
|
|
|
List<DeviceSubscriptionDTO> deviceSubscriptionDTOS;
|
|
|
|
int deviceCount = 0;
|
|
|
|
int deviceCount = 0;
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
@ -1995,7 +2044,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
String deviceSubscriptionStatus = SubscriptionManagementHelperUtil.getDeviceSubscriptionStatus(subscriptionInfo);
|
|
|
|
String deviceSubscriptionStatus = SubscriptionManagementHelperUtil.getDeviceSubscriptionStatus(subscriptionInfo);
|
|
|
|
DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria = subscriptionInfo.getDeviceSubscriptionFilterCriteria();
|
|
|
|
DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria = subscriptionInfo.getDeviceSubscriptionFilterCriteria();
|
|
|
|
DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService();
|
|
|
|
DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService();
|
|
|
|
List<String> dbSubscriptionStatus = SubscriptionManagementHelperUtil.getDBSubscriptionStatus(subscriptionInfo.getDeviceSubscriptionStatus());
|
|
|
|
List<String> dbSubscriptionStatus = SubscriptionManagementHelperUtil.getDBSubscriptionStatus
|
|
|
|
|
|
|
|
(subscriptionInfo.getDeviceSubscriptionStatus());
|
|
|
|
|
|
|
|
|
|
|
|
if (Objects.equals(SubscriptionMetadata.DeviceSubscriptionStatus.NEW, deviceSubscriptionStatus)) {
|
|
|
|
if (Objects.equals(SubscriptionMetadata.DeviceSubscriptionStatus.NEW, deviceSubscriptionStatus)) {
|
|
|
|
deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(),
|
|
|
|
deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(),
|
|
|
@ -2021,7 +2071,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
|
|
|
|
|
|
|
|
List<DeviceSubscription> deviceSubscriptions = SubscriptionManagementHelperUtil.
|
|
|
|
List<DeviceSubscription> deviceSubscriptions = SubscriptionManagementHelperUtil.
|
|
|
|
getDeviceSubscriptionData(deviceSubscriptionDTOS,
|
|
|
|
getDeviceSubscriptionData(deviceSubscriptionDTOS,
|
|
|
|
subscriptionInfo.getDeviceSubscriptionFilterCriteria(), isUnsubscribe, applicationDTO.getDeviceTypeId(), limit, offset);
|
|
|
|
subscriptionInfo.getDeviceSubscriptionFilterCriteria(), isUnsubscribe,
|
|
|
|
|
|
|
|
applicationDTO.getDeviceTypeId(), limit, offset);
|
|
|
|
return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), deviceCount, deviceSubscriptions);
|
|
|
|
return new SubscriptionResponse(subscriptionInfo.getApplicationUUID(), deviceCount, deviceSubscriptions);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
@ -2041,7 +2092,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
private List<Integer> getDeviceIdsOwnByRole(String roleName, int tenantId) throws UserStoreException, DeviceManagementException {
|
|
|
|
private List<Integer> getDeviceIdsOwnByRole(String roleName, int tenantId) throws UserStoreException, DeviceManagementException {
|
|
|
|
UserStoreManager userStoreManager = DataHolder.getInstance().getRealmService().
|
|
|
|
UserStoreManager userStoreManager = DataHolder.getInstance().getRealmService().
|
|
|
@ -2076,6 +2126,15 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
return deviceListOwnByUser.stream().map(Device::getId).collect(Collectors.toList());
|
|
|
|
return deviceListOwnByUser.stream().map(Device::getId).collect(Collectors.toList());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Retrieves a list of device IDs associated with the subscription described by the {@link SubscriptionInfo}.
|
|
|
|
|
|
|
|
* The device IDs are determined based on the subscription type, which could be either a role or a user.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param subscriptionInfo {@link SubscriptionInfo} containing the subscription details.
|
|
|
|
|
|
|
|
* @return A {@link List} of device IDs corresponding to the subscription type, or {@code null} if the type is not recognized.
|
|
|
|
|
|
|
|
* @throws DeviceManagementException Thrown when an error occurs while retrieving device IDs.
|
|
|
|
|
|
|
|
* @throws UserStoreException Thrown when an error occurs while accessing the user store.
|
|
|
|
|
|
|
|
*/
|
|
|
|
private List<Integer> getAllDeviceIds(SubscriptionInfo subscriptionInfo) throws DeviceManagementException, UserStoreException {
|
|
|
|
private List<Integer> getAllDeviceIds(SubscriptionInfo subscriptionInfo) throws DeviceManagementException, UserStoreException {
|
|
|
|
String type = subscriptionInfo.getSubscriptionType();
|
|
|
|
String type = subscriptionInfo.getSubscriptionType();
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
@ -2084,13 +2143,14 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Objects.equals(type, SubscriptionMetadata.SubscriptionTypes.USER)) {
|
|
|
|
if (Objects.equals(type, SubscriptionMetadata.SubscriptionTypes.USER)) {
|
|
|
|
return getDeviceIdsOwnByUser(subscriptionInfo.getIdentifier());
|
|
|
|
return getDeviceIdsOwnByUser(subscriptionInfo.getIdentifier());
|
|
|
|
}else
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Get subscription statistics related data describes by the {@link SubscriptionInfo}
|
|
|
|
* Get subscription statistics related data describes by the {@link SubscriptionInfo}
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param subscriptionInfo {@link SubscriptionInfo}
|
|
|
|
* @param subscriptionInfo {@link SubscriptionInfo}
|
|
|
|
* @return {@link SubscriptionStatistics}
|
|
|
|
* @return {@link SubscriptionStatistics}
|
|
|
|
* @throws ApplicationManagementException Throws when error encountered while getting statistics
|
|
|
|
* @throws ApplicationManagementException Throws when error encountered while getting statistics
|
|
|
@ -2100,7 +2160,6 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|
|
|
return getSubscriptionStatistics(subscriptionInfo);
|
|
|
|
return getSubscriptionStatistics(subscriptionInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<DeviceOperationDTO> getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid)
|
|
|
|
public List<DeviceOperationDTO> getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid)
|
|
|
|
throws ApplicationManagementException {
|
|
|
|
throws ApplicationManagementException {
|
|
|
|