Fix app-install operation adding issue for custom apps

feature/appm-store/pbac
lasanthaDLPDS 5 years ago
parent a3e0eb031c
commit 34f1b25c84

@ -463,68 +463,94 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
throws ApplicationManagementException { throws ApplicationManagementException {
try { try {
//todo rethink and modify the {@link App} usage //todo rethink and modify the {@link App} usage
App app = new App(); if (ApplicationType.CUSTOM.toString().equalsIgnoreCase(application.getType())) {
MobileAppTypes mobileAppType = MobileAppTypes.valueOf(application.getType()); ProfileOperation operation = new ProfileOperation();
if (DeviceTypes.ANDROID.toString().equalsIgnoreCase(deviceType)) {
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
app.setType(mobileAppType); operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_INSTALL_APPLICATION);
app.setLocation(application.getApplicationReleases().get(0).getInstallerPath()); operation.setType(Operation.Type.PROFILE);
return MDMAndroidOperationUtil.createInstallAppOperation(app); CustomApplication customApplication = new CustomApplication();
customApplication.setType(application.getType());
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)) {
return MDMAndroidOperationUtil.createAppUninstallOperation(app); operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_UNINSTALL_APPLICATION);
} else { operation.setType(Operation.Type.PROFILE);
String msg = "Invalid Action is found. Action: " + action; CustomApplication customApplication = new CustomApplication();
log.error(msg); customApplication.setType(application.getType());
throw new ApplicationManagementException(msg); //todo get application package name and set
} operation.setPayLoad(customApplication.toJSON());
} else if (DeviceTypes.IOS.toString().equalsIgnoreCase(deviceType)) { return operation;
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
String plistDownloadEndpoint = APIUtil.getArtifactDownloadBaseURL()
+ MDMAppConstants.IOSConstants.PLIST + Constants.FORWARD_SLASH
+ application.getApplicationReleases().get(0).getUuid();
app.setType(mobileAppType);
app.setLocation(plistDownloadEndpoint);
Properties properties = new Properties();
properties.put(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP, true);
properties.put(MDMAppConstants.IOSConstants.IS_REMOVE_APP, true);
app.setProperties(properties);
return MDMIOSOperationUtil.createInstallAppOperation(app);
} else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
return MDMIOSOperationUtil.createAppUninstallOperation(app);
} else { } else {
String msg = "Invalid Action is found. Action: " + action; String msg = "Invalid Action is found. Action: " + action;
log.error(msg); log.error(msg);
throw new ApplicationManagementException(msg); throw new ApplicationManagementException(msg);
} }
} else { } else {
if (ApplicationType.CUSTOM.toString().equalsIgnoreCase(application.getType())) { App app = new App();
MobileAppTypes mobileAppType = MobileAppTypes.valueOf(application.getType());
if (DeviceTypes.ANDROID.toString().equalsIgnoreCase(deviceType)) {
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
ProfileOperation operation = new ProfileOperation(); app.setType(mobileAppType);
operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_INSTALL_APPLICATION); app.setLocation(application.getApplicationReleases().get(0).getInstallerPath());
operation.setType(Operation.Type.PROFILE); return MDMAndroidOperationUtil.createInstallAppOperation(app);
CustomApplication customApplication = new CustomApplication();
customApplication.setType(application.getType());
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)) {
ProfileOperation operation = new ProfileOperation();
operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_UNINSTALL_APPLICATION);
operation.setType(Operation.Type.PROFILE);
CustomApplication customApplication = new CustomApplication();
customApplication.setType(application.getType());
//todo get application package name and set
operation.setPayLoad(customApplication.toJSON());
return MDMAndroidOperationUtil.createAppUninstallOperation(app); return MDMAndroidOperationUtil.createAppUninstallOperation(app);
} else { } else {
String msg = "Invalid Action is found. Action: " + action; String msg = "Invalid Action is found. Action: " + action;
log.error(msg); log.error(msg);
throw new ApplicationManagementException(msg); throw new ApplicationManagementException(msg);
} }
} else if (DeviceTypes.IOS.toString().equalsIgnoreCase(deviceType)) {
if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
String plistDownloadEndpoint =
APIUtil.getArtifactDownloadBaseURL() + MDMAppConstants.IOSConstants.PLIST
+ Constants.FORWARD_SLASH + application.getApplicationReleases().get(0)
.getUuid();
app.setType(mobileAppType);
app.setLocation(plistDownloadEndpoint);
Properties properties = new Properties();
properties.put(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP, true);
properties.put(MDMAppConstants.IOSConstants.IS_REMOVE_APP, true);
app.setProperties(properties);
return MDMIOSOperationUtil.createInstallAppOperation(app);
} else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
return MDMIOSOperationUtil.createAppUninstallOperation(app);
} else {
String msg = "Invalid Action is found. Action: " + action;
log.error(msg);
throw new ApplicationManagementException(msg);
}
} else { } else {
String msg = "Invalid device type is found. Device Type: " + deviceType; if (ApplicationType.CUSTOM.toString().equalsIgnoreCase(application.getType())) {
log.error(msg); if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
throw new ApplicationManagementException(msg); ProfileOperation operation = new ProfileOperation();
operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_INSTALL_APPLICATION);
operation.setType(Operation.Type.PROFILE);
CustomApplication customApplication = new CustomApplication();
customApplication.setType(application.getType());
customApplication.setUrl(application.getApplicationReleases().get(0).getInstallerPath());
operation.setPayLoad(customApplication.toJSON());
return operation;
} else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
ProfileOperation operation = new ProfileOperation();
operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_UNINSTALL_APPLICATION);
operation.setType(Operation.Type.PROFILE);
CustomApplication customApplication = new CustomApplication();
customApplication.setType(application.getType());
//todo get application package name and set
operation.setPayLoad(customApplication.toJSON());
return MDMAndroidOperationUtil.createAppUninstallOperation(app);
} else {
String msg = "Invalid Action is found. Action: " + action;
log.error(msg);
throw new ApplicationManagementException(msg);
}
} else {
String msg = "Invalid device type is found. Device Type: " + deviceType;
log.error(msg);
throw new ApplicationManagementException(msg);
}
} }
} }
} catch (UnknownApplicationTypeException e) { } catch (UnknownApplicationTypeException e) {

Loading…
Cancel
Save