Merge branch 'master' into 'master'

Add bundle Id getting method for iOS public apps

See merge request entgra/carbon-device-mgt!727
revert-70ac1926
Inosh Perara 4 years ago
commit bcff3f46ad

@ -25,6 +25,8 @@ import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONObject;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException;
import org.wso2.carbon.context.PrivilegedCarbonContext;
@ -88,7 +90,13 @@ import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import javax.ws.rs.core.MediaType;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -125,9 +133,11 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
validateRequest(params, subType, action);
//todo validate users, groups and roles
ApplicationDTO applicationDTO = getApplicationDTO(applicationUUID);
ApplicationSubscriptionInfo applicationSubscriptionInfo = getAppSubscriptionInfo(applicationDTO, subType, params);
ApplicationInstallResponse applicationInstallResponse = performActionOnDevices(applicationSubscriptionInfo.getAppSupportingDeviceTypeName(),
applicationSubscriptionInfo.getDevices(), applicationDTO, subType, applicationSubscriptionInfo.getSubscribers(), action);
ApplicationSubscriptionInfo applicationSubscriptionInfo = getAppSubscriptionInfo(applicationDTO, subType,
params);
ApplicationInstallResponse applicationInstallResponse = performActionOnDevices(
applicationSubscriptionInfo.getAppSupportingDeviceTypeName(), applicationSubscriptionInfo.getDevices(),
applicationDTO, subType, applicationSubscriptionInfo.getSubscribers(), action);
applicationInstallResponse.setErrorDeviceIdentifiers(applicationSubscriptionInfo.getErrorDeviceIdentifiers());
return applicationInstallResponse;
@ -138,14 +148,15 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
throws SubscriptionManagementException {
try {
ConnectionManagerUtil.beginDBTransaction();
ScheduledSubscriptionDTO existingEntry = subscriptionDAO.getPendingScheduledSubscriptionByTaskName(
subscriptionDTO.getTaskName());
ScheduledSubscriptionDTO existingEntry = subscriptionDAO
.getPendingScheduledSubscriptionByTaskName(subscriptionDTO.getTaskName());
boolean transactionStatus;
if (existingEntry == null) {
transactionStatus = subscriptionDAO.createScheduledSubscription(subscriptionDTO);
} else {
transactionStatus = subscriptionDAO.updateScheduledSubscription(existingEntry.getId(),
subscriptionDTO.getScheduledAt(), subscriptionDTO.getScheduledBy());
transactionStatus = subscriptionDAO
.updateScheduledSubscription(existingEntry.getId(), subscriptionDTO.getScheduledAt(),
subscriptionDTO.getScheduledBy());
}
if (!transactionStatus) {
ConnectionManagerUtil.rollbackDBTransaction();
@ -175,13 +186,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
ConnectionManagerUtil.openDBConnection();
return subscriptionDAO.getUUID(id, packageName);
} catch (ApplicationManagementDAOException e) {
String msg = "Error occurred while checking the application is " +
"subscribed one or not";
String msg = "Error occurred while checking the application is " + "subscribed one or not";
log.error(msg, e);
throw new SubscriptionManagementException(msg, e);
} catch (DBConnectionException e) {
String msg = "Error occurred while observing the database connection while checking the application is " +
"subscribed one or not";
String msg = "Error occurred while observing the database connection while checking the application is "
+ "subscribed one or not";
log.error(msg, e);
throw new SubscriptionManagementException(msg, e);
} finally {
@ -194,12 +204,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
try {
// Cleaning up already executed, missed and failed tasks
ConnectionManagerUtil.beginDBTransaction();
List<ScheduledSubscriptionDTO> taskList = subscriptionDAO.getScheduledSubscriptionByStatus(
ExecutionStatus.EXECUTED, false);
List<ScheduledSubscriptionDTO> taskList = subscriptionDAO
.getScheduledSubscriptionByStatus(ExecutionStatus.EXECUTED, false);
taskList.addAll(subscriptionDAO.getNonExecutedSubscriptions());
taskList.addAll(subscriptionDAO.getScheduledSubscriptionByStatus(ExecutionStatus.FAILED, false));
List<Integer> tasksToClean = taskList.stream().map(ScheduledSubscriptionDTO::getId).collect(
Collectors.toList());
List<Integer> tasksToClean = taskList.stream().map(ScheduledSubscriptionDTO::getId)
.collect(Collectors.toList());
if (!subscriptionDAO.deleteScheduledSubscription(tasksToClean)) {
ConnectionManagerUtil.rollbackDBTransaction();
}
@ -374,9 +384,10 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
AtomicBoolean isAppSubscribable = new AtomicBoolean(true);
for (DeviceSubscriptionDTO deviceSubscriptionDTO : deviceSubscriptionDTOS) {
if (device.getId() == deviceSubscriptionDTO.getDeviceId() &&
(Operation.Status.PENDING.toString().equals(deviceSubscriptionDTO.getStatus())
|| Operation.Status.IN_PROGRESS.toString().equals(deviceSubscriptionDTO.getStatus()))) {
if (device.getId() == deviceSubscriptionDTO.getDeviceId() && (
Operation.Status.PENDING.toString().equals(deviceSubscriptionDTO.getStatus())
|| Operation.Status.IN_PROGRESS.toString()
.equals(deviceSubscriptionDTO.getStatus()))) {
isAppSubscribable.set(false);
break;
}
@ -456,29 +467,36 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
devices.add(deviceManagementProviderService.getDevice(deviceIdentifier, false));
}
} else if (SubscriptionType.USER.toString().equalsIgnoreCase(subType)) {
} else {
if (SubscriptionType.USER.toString().equalsIgnoreCase(subType)) {
for (T param : params) {
String username = (String) param;
subscribers.add(username);
devices.addAll(deviceManagementProviderService.getDevicesOfUser(username));
}
} else if (SubscriptionType.ROLE.toString().equalsIgnoreCase(subType)) {
} else {
if (SubscriptionType.ROLE.toString().equalsIgnoreCase(subType)) {
for (T param : params) {
String roleName = (String) param;
subscribers.add(roleName);
devices.addAll(deviceManagementProviderService.getAllDevicesOfRole(roleName));
}
} else if (SubscriptionType.GROUP.toString().equalsIgnoreCase(subType)) {
} else {
if (SubscriptionType.GROUP.toString().equalsIgnoreCase(subType)) {
for (T param : params) {
String groupName = (String) param;
subscribers.add(groupName);
devices.addAll(groupManagementProviderService.getAllDevicesOfGroup(groupName, true));
}
} else {
String msg = "Found invalid subscription type " + subType+ " to install application release" ;
String msg =
"Found invalid subscription type " + subType + " to install application release";
log.error(msg);
throw new BadRequestException(msg);
}
}
}
}
if (!ApplicationType.WEB_CLIP.toString().equals(applicationDTO.getType()) && !SubscriptionType.DEVICE
.toString().equals(subType)) {
@ -576,8 +594,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
log.error(msg);
throw new BadRequestException(msg);
}
boolean isValidAction = Arrays.stream(SubAction.values())
.anyMatch(sub -> sub.name().equalsIgnoreCase(action));
boolean isValidAction = Arrays.stream(SubAction.values()).anyMatch(sub -> sub.name().equalsIgnoreCase(action));
if (!isValidAction) {
String msg = "Found invalid action " + action + " to perform on application release";
log.error(msg);
@ -615,13 +632,15 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppInstallableDevices().keySet()));
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppReInstallableDevices().keySet()));
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppInstalledDevices().keySet()));
} else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
} else {
if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
deviceIdentifiers.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppInstalledDevices().keySet()));
deviceIdentifiers
.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppReUnInstallableDevices().keySet()));
ignoredDeviceIdentifiers
.addAll(new ArrayList<>(subscribingDeviceIdHolder.getAppInstallableDevices().keySet()));
}
}
if (deviceIdentifiers.isEmpty()) {
ApplicationInstallResponse applicationInstallResponse = new ApplicationInstallResponse();
@ -689,18 +708,24 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
if (Operation.Status.PENDING.toString().equals(deviceSubscriptionDTO.getStatus())
|| Operation.Status.IN_PROGRESS.toString().equals(deviceSubscriptionDTO.getStatus())) {
subscribingDeviceIdHolder.getSkippedDevices().put(deviceIdentifier, device.getId());
} else if (deviceSubscriptionDTO.isUnsubscribed()) {
} else {
if (deviceSubscriptionDTO.isUnsubscribed()) {
if (!Operation.Status.COMPLETED.toString().equals(deviceSubscriptionDTO.getStatus())) {
/*We can't ensure whether app is uninstalled successfully or not hence allow to perform both
install and uninstall operations*/
subscribingDeviceIdHolder.getAppReUnInstallableDevices().put(deviceIdentifier, device.getId());
subscribingDeviceIdHolder.getAppReUnInstallableDevices()
.put(deviceIdentifier, device.getId());
}
subscribingDeviceIdHolder.getAppReInstallableDevices().put(deviceIdentifier, device.getId());
} else if (!deviceSubscriptionDTO.isUnsubscribed() && Operation.Status.COMPLETED.toString()
} else {
if (!deviceSubscriptionDTO.isUnsubscribed() && Operation.Status.COMPLETED.toString()
.equals(deviceSubscriptionDTO.getStatus())) {
subscribingDeviceIdHolder.getAppInstalledDevices().put(deviceIdentifier, device.getId());
} else {
subscribingDeviceIdHolder.getAppReInstallableDevices().put(deviceIdentifier, device.getId());
subscribingDeviceIdHolder.getAppReInstallableDevices()
.put(deviceIdentifier, device.getId());
}
}
}
} else {
subscribingDeviceIdHolder.getAppInstallableDevices().put(deviceIdentifier, device.getId());
@ -790,8 +815,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
* @throws ApplicationManagementException if error occurred while getting or updating subscription data.
*/
private void updateSubscriptions(int applicationReleaseId, List<Activity> activities,
SubscribingDeviceIdHolder subscribingDeviceIdHolder, List<String> params, String subType,
String action) throws ApplicationManagementException {
SubscribingDeviceIdHolder subscribingDeviceIdHolder, List<String> params, String subType, String action)
throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
try {
@ -809,12 +834,14 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
subscribingDeviceIdHolder.getAppInstalledDevices()));
subInsertingDeviceIds.addAll(getOperationAddedDeviceIds(activity,
subscribingDeviceIdHolder.getAppInstallableDevices()));
} else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
} else {
if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
subUpdatingDeviceIds.addAll(getOperationAddedDeviceIds(activity,
subscribingDeviceIdHolder.getAppInstalledDevices()));
subUpdatingDeviceIds.addAll(getOperationAddedDeviceIds(activity,
subscribingDeviceIdHolder.getAppReUnInstallableDevices()));
}
}
subscriptionDAO.addDeviceSubscription(username, subInsertingDeviceIds, subType,
Operation.Status.PENDING.toString(), applicationReleaseId, tenantId);
@ -832,8 +859,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
ConnectionManagerUtil.commitDBTransaction();
} catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
String msg = "Error occurred when adding subscription data for application release ID: "
+ applicationReleaseId;
String msg =
"Error occurred when adding subscription data for application release ID: " + applicationReleaseId;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException e) {
@ -872,19 +899,24 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
if (!params.isEmpty()) {
subscriptionDAO.addUserSubscriptions(tenantId, username, params, applicationReleaseId, action);
}
} else if (SubscriptionType.ROLE.toString().equalsIgnoreCase(subType)) {
} else {
if (SubscriptionType.ROLE.toString().equalsIgnoreCase(subType)) {
subscribedEntities = subscriptionDAO.getAppSubscribedRoleNames(params, applicationReleaseId, tenantId);
params.removeAll(subscribedEntities);
if (!params.isEmpty()) {
subscriptionDAO.addRoleSubscriptions(tenantId, username, params, applicationReleaseId, action);
}
} else if (SubscriptionType.GROUP.toString().equalsIgnoreCase(subType)) {
subscribedEntities = subscriptionDAO.getAppSubscribedGroupNames(params, applicationReleaseId, tenantId);
} else {
if (SubscriptionType.GROUP.toString().equalsIgnoreCase(subType)) {
subscribedEntities = subscriptionDAO
.getAppSubscribedGroupNames(params, applicationReleaseId, tenantId);
params.removeAll(subscribedEntities);
if (!params.isEmpty()) {
subscriptionDAO.addGroupSubscriptions(tenantId, username, params, applicationReleaseId, action);
}
}
}
}
if (!subscribedEntities.isEmpty()) {
subscriptionDAO
@ -901,8 +933,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
*/
private List<Integer> getOperationAddedDeviceIds(Activity activity, Map<DeviceIdentifier, Integer> deviceMap) {
List<ActivityStatus> activityStatuses = activity.getActivityStatus();
return activityStatuses.stream()
.filter(status -> deviceMap.get(status.getDeviceIdentifier()) != null)
return activityStatuses.stream().filter(status -> deviceMap.get(status.getDeviceIdentifier()) != null)
.map(status -> deviceMap.get(status.getDeviceIdentifier())).collect(Collectors.toList());
}
@ -987,7 +1018,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
customApplication.setUrl(application.getApplicationReleases().get(0).getInstallerPath());
operation.setPayLoad(customApplication.toJSON());
return operation;
} else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
} else {
if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_UNINSTALL_APPLICATION);
operation.setType(Operation.Type.PROFILE);
CustomApplication customApplication = new CustomApplication();
@ -1000,6 +1032,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
log.error(msg);
throw new ApplicationManagementException(msg);
}
}
} else {
App app = new App();
MobileAppTypes mobileAppType = MobileAppTypes.valueOf(application.getType());
@ -1010,14 +1043,17 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
app.setName(application.getName());
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
return MDMAndroidOperationUtil.createInstallAppOperation(app);
} else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
} else {
if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
return MDMAndroidOperationUtil.createAppUninstallOperation(app);
} else {
String msg = "Invalid Action is found. Action: " + action;
log.error(msg);
throw new ApplicationManagementException(msg);
}
} else if (DeviceTypes.IOS.toString().equalsIgnoreCase(deviceType)) {
}
} else {
if (DeviceTypes.IOS.toString().equalsIgnoreCase(deviceType)) {
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
String plistDownloadEndpoint =
APIUtil.getArtifactDownloadBaseURL() + MDMAppConstants.IOSConstants.PLIST
@ -1035,7 +1071,18 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
application.getApplicationReleases().get(0).getInstallerPath());
app.setProperties(properties);
return MDMIOSOperationUtil.createInstallAppOperation(app);
} else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
} else {
if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
if (ApplicationType.PUBLIC.toString().equals(mobileAppType.toString())) {
String bundleId = getBundleId(application.getPackageName());
if (bundleId == null) {
String msg = "Couldn't find the bundle Id for iOS public app uninstallation";
log.error(msg);
throw new ApplicationManagementException(msg);
}
application.setPackageName(bundleId);
}
app.setType(mobileAppType);
app.setIdentifier(application.getPackageName());
app.setLocation(application.getApplicationReleases().get(0).getInstallerPath());
@ -1045,7 +1092,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
log.error(msg);
throw new ApplicationManagementException(msg);
}
} else if (DeviceTypes.WINDOWS.toString().equalsIgnoreCase(deviceType)) {
}
} else {
if (DeviceTypes.WINDOWS.toString().equalsIgnoreCase(deviceType)) {
app.setType(mobileAppType);
app.setIdentifier(application.getPackageName());
app.setMetaData(application.getApplicationReleases().get(0).getMetaData());
@ -1063,6 +1112,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
throw new ApplicationManagementException(msg);
}
}
}
}
} catch (UnknownApplicationTypeException e) {
String msg = "Unknown Application type is found.";
log.error(msg, e);
@ -1070,6 +1121,47 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
}
/**
* Get the bundle id of the iOS public application.
* @param appId Application Id
* @return {@link String} bundle Id
* @throws ApplicationManagementException if error occurred while getting the bundle if of the requesting public
* application
*/
private String getBundleId(String appId) throws ApplicationManagementException {
try {
URL url = new URL(Constants.APPLE_LOOKUP_URL + appId);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
InputStream responseStream = connection.getInputStream();
try (BufferedReader in = new BufferedReader(new InputStreamReader(responseStream))) {
StringBuilder response = new StringBuilder();
String readLine;
while ((readLine = in.readLine()) != null) {
response.append(readLine);
}
JSONObject obj = new JSONObject(response.toString());
JSONArray results = obj.getJSONArray("results");
for (int i = 0; i < results.length(); ++i) {
JSONObject result = results.getJSONObject(i);
if (StringUtils.isNotBlank(result.getString("bundleId"))) {
return result.getString("bundleId");
}
}
return null;
}
} catch (MalformedURLException e) {
String msg = "Error occurred while constructing to get iOS public app bundle Id.";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (IOException e) {
String msg = "Error occurred while getting bundle Id of the iOS public app.";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
}
}
public int installEnrollmentApplications(ApplicationPolicyDTO applicationPolicyDTO)
throws ApplicationManagementException {
@ -1078,23 +1170,23 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
try {
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
ApiApplicationKey apiApplicationKey = OAuthUtils.getClientCredentials(tenantDomain);
String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm()
.getRealmConfiguration().getAdminUserName() + Constants.ApplicationInstall.AT + tenantDomain;
String username =
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration()
.getAdminUserName() + Constants.ApplicationInstall.AT + tenantDomain;
AccessTokenInfo tokenInfo = OAuthUtils.getOAuthCredentials(apiApplicationKey, username);
String requestUrl = Constants.ApplicationInstall.ENROLLMENT_APP_INSTALL_PROTOCOL +
System.getProperty(Constants.ApplicationInstall.IOT_CORE_HOST) +
Constants.ApplicationInstall.COLON +
System.getProperty(Constants.ApplicationInstall.IOT_CORE_PORT) +
Constants.ApplicationInstall.GOOGLE_APP_INSTALL_URL;
String requestUrl = Constants.ApplicationInstall.ENROLLMENT_APP_INSTALL_PROTOCOL + System
.getProperty(Constants.ApplicationInstall.IOT_CORE_HOST) + Constants.ApplicationInstall.COLON
+ System.getProperty(Constants.ApplicationInstall.IOT_CORE_PORT)
+ Constants.ApplicationInstall.GOOGLE_APP_INSTALL_URL;
Gson gson = new Gson();
String payload = gson.toJson(applicationPolicyDTO);
StringRequestEntity requestEntity = new StringRequestEntity(payload, MediaType.APPLICATION_JSON
, Constants.ApplicationInstall.ENCODING);
StringRequestEntity requestEntity = new StringRequestEntity(payload, MediaType.APPLICATION_JSON,
Constants.ApplicationInstall.ENCODING);
httpClient = new HttpClient();
request = new PostMethod(requestUrl);
request.addRequestHeader(Constants.ApplicationInstall.AUTHORIZATION
, Constants.ApplicationInstall.AUTHORIZATION_HEADER_VALUE + tokenInfo.getAccessToken());
request.addRequestHeader(Constants.ApplicationInstall.AUTHORIZATION,
Constants.ApplicationInstall.AUTHORIZATION_HEADER_VALUE + tokenInfo.getAccessToken());
request.setRequestEntity(requestEntity);
httpClient.executeMethod(request);
return request.getStatusCode();
@ -1108,13 +1200,13 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (HttpException e) {
String msg = "Error while calling the app store to install enrollment app with id: " +
applicationPolicyDTO.getApplicationDTO().getId() +
" on device";
String msg = "Error while calling the app store to install enrollment app with id: " + applicationPolicyDTO
.getApplicationDTO().getId() + " on device";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (IOException e) {
String msg = "Error while installing the enrollment with id: " + applicationPolicyDTO.getApplicationDTO().getId()
String msg =
"Error while installing the enrollment with id: " + applicationPolicyDTO.getApplicationDTO().getId()
+ " on device";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
@ -1165,8 +1257,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
.getAppSubscribedDevices(offsetValue, limitValue, deviceIdList, status);
if (deviceDetails == null) {
String msg = "Couldn't found an subscribed devices details for device ids: "
+ deviceIdList;
String msg = "Couldn't found an subscribed devices details for device ids: " + deviceIdList;
log.error(msg);
throw new NotFoundException(msg);
}
@ -1178,13 +1269,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
throw new ApplicationManagementException(msg, e);
}
} catch (ApplicationManagementDAOException e) {
String msg = "Error occurred when get application release data for application" +
" release UUID: " + appUUID;
String msg =
"Error occurred when get application release data for application" + " release UUID: " + appUUID;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException e) {
String msg = "DB Connection error occurred while getting device details that " +
"given application id";
String msg = "DB Connection error occurred while getting device details that " + "given application id";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} finally {
@ -1200,8 +1290,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
PaginationResult paginationResult = new PaginationResult();
try {
ConnectionManagerUtil.openDBConnection();
ApplicationDTO applicationDTO = this.applicationDAO
.getAppWithRelatedRelease(appUUID, tenantId);
ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(appUUID, tenantId);
int applicationReleaseId = applicationDTO.getApplicationReleaseDTOs().get(0).getId();
List<String> subscriptionList = new ArrayList<>();
@ -1211,28 +1300,31 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
subscriptionList = subscriptionDAO
.getAppSubscribedUsers(offsetValue, limitValue, applicationReleaseId, tenantId);
count = subscriptionDAO.getSubscribedUserCount(applicationReleaseId, tenantId);
} else if (SubscriptionType.ROLE.toString().equalsIgnoreCase(subType)) {
} else {
if (SubscriptionType.ROLE.toString().equalsIgnoreCase(subType)) {
subscriptionList = subscriptionDAO
.getAppSubscribedRoles(offsetValue, limitValue, applicationReleaseId, tenantId);
count = subscriptionDAO.getSubscribedRoleCount(applicationReleaseId, tenantId);
} else if (SubscriptionType.GROUP.toString().equalsIgnoreCase(subType)) {
} else {
if (SubscriptionType.GROUP.toString().equalsIgnoreCase(subType)) {
subscriptionList = subscriptionDAO
.getAppSubscribedGroups(offsetValue, limitValue, applicationReleaseId, tenantId);
count = subscriptionDAO.getSubscribedGroupCount(applicationReleaseId, tenantId);
}
}
}
paginationResult.setData(subscriptionList);
paginationResult.setRecordsFiltered(count);
paginationResult.setRecordsTotal(count);
return paginationResult;
} catch (ApplicationManagementDAOException e) {
String msg = "Error occurred when get application release data for application" +
" release UUID: " + appUUID;
String msg =
"Error occurred when get application release data for application" + " release UUID: " + appUUID;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException e) {
String msg = "DB Connection error occurred while getting category details that " +
"given application id";
String msg = "DB Connection error occurred while getting category details that " + "given application id";
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} finally {
@ -1315,8 +1407,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
throw new ApplicationManagementException(msg, e);
}
} catch (ApplicationManagementDAOException e) {
String msg = "Error occurred when getting application release data for application release UUID: "
+ appUUID;
String msg =
"Error occurred when getting application release data for application release UUID: " + appUUID;
log.error(msg, e);
throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException e) {

@ -64,6 +64,7 @@ public class Constants {
public static final String TASK_NAME = "TASK_NAME";
public static final String SUBSCRIBED = "SUBSCRIBED";
public static final String UNSUBSCRIBED = "UNSUBSCRIBED";
public static final String APPLE_LOOKUP_URL = "https://itunes.apple.com/us/lookup?id=";
//App type constants related to window device type
public static final String MSI = "MSI";

Loading…
Cancel
Save