Merge branch 'application-mgt-new' into 'master'

Uninstall related fixes for Google EMM APIs

See merge request entgra/carbon-device-mgt!364
feature/appm-store/pbac
Inosh Perara 5 years ago
commit e7ccff1f69

@ -92,13 +92,14 @@ public interface SubscriptionManager {
* @param subType subscription type. E.g. <code>DEVICE, USER, ROLE, GROUP</code> {@see {
* @param action subscription action. E.g. <code>INSTALL/UNINSTALL</code> {@see {
* @param <T> generic type of the method.
* @param requiresUpdatingExternal should an external server be updated. Such as Google EMM APIs
* @return {@link ApplicationInstallResponse}
* @throws ApplicationManagementException ApplicationManagementException if error occurs when subscribing to the
* given application
* @link org.wso2.carbon.device.application.mgt.common.SubscriptionType}}
*/
<T> void performEntAppSubscription(String applicationUUID, List<T> params, String subType, String action)
throws ApplicationManagementException;
<T> void performEntAppSubscription(String applicationUUID, List<T> params, String subType, String action,
boolean requiresUpdatingExternal) throws ApplicationManagementException;
/***
* This method used to get the app id ,device ids and pass them to DM service method.

@ -319,7 +319,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
@Override
public <T> void performEntAppSubscription(String applicationUUID, List<T> params, String subType, String action)
public <T> void performEntAppSubscription(String applicationUUID, List<T> params, String subType, String action,
boolean requiresUpdatingExternal)
throws ApplicationManagementException {
if (log.isDebugEnabled()) {
log.debug("Google Ent app Install operation is received to application which has UUID "
@ -347,7 +348,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
List<String> categories = getApplicationCategories(applicationDTO.getId());
if (!categories.contains("GooglePlaySyncedApp")) {
String msg = "This is not google play store synced application. Hence can't perform enteprise app "
String msg = "This is not google play store synced application. Hence can't perform enterprise app "
+ "installation.";
log.error(msg);
throw new BadRequestException(msg);
@ -424,12 +425,14 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
});
}
//Installing the application
ApplicationPolicyDTO applicationPolicyDTO = new ApplicationPolicyDTO();
applicationPolicyDTO.setApplicationDTO(applicationDTO);
applicationPolicyDTO.setDeviceIdentifierList(deviceIdentifiers);
applicationPolicyDTO.setAction(action);
installEnrollmentApplications(applicationPolicyDTO);
if (requiresUpdatingExternal) {
//Installing the application
ApplicationPolicyDTO applicationPolicyDTO = new ApplicationPolicyDTO();
applicationPolicyDTO.setApplicationDTO(applicationDTO);
applicationPolicyDTO.setDeviceIdentifierList(deviceIdentifiers);
applicationPolicyDTO.setAction(action.toUpperCase());
installEnrollmentApplications(applicationPolicyDTO);
}
appSubscribingDeviceIds = devices.stream().map(Device::getId).collect(Collectors.toList());
Map<Integer, DeviceSubscriptionDTO> deviceSubscriptions = getDeviceSubscriptions(appSubscribingDeviceIds,
@ -972,6 +975,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
Properties properties = new Properties();
properties.put(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP, true);
properties.put(MDMAppConstants.IOSConstants.IS_REMOVE_APP, true);
properties.put(MDMAppConstants.IOSConstants.I_TUNES_ID, application.getPackageName());
app.setProperties(properties);
return MDMIOSOperationUtil.createInstallAppOperation(app);
} else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {

@ -229,7 +229,12 @@ public interface SubscriptionManagementAPI {
name = "timestamp",
value = "Timestamp of scheduled ent. install operation"
)
@QueryParam("timestamp") String timestamp
@QueryParam("timestamp") String timestamp,
@ApiParam(
name = "requiresUpdatingExternal",
value = "Should external system such as Google EMM APIs need to be updated."
)
@QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal
);
@POST
@ -282,7 +287,12 @@ public interface SubscriptionManagementAPI {
name = "timestamp",
value = "Timestamp of scheduled ent app install operation"
)
@QueryParam("timestamp") String timestamp
@QueryParam("timestamp") String timestamp,
@ApiParam(
name = "requiresUpdatingExternal",
value = "Should external system such as Google EMM APIs need to be updated."
)
@QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal
);
@GET

@ -155,12 +155,14 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
@PathParam("uuid") String uuid,
@PathParam("action") String action,
@Valid List<DeviceIdentifier> deviceIdentifiers,
@QueryParam("timestamp") String timestamp) {
@QueryParam("timestamp") String timestamp,
@QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal) {
try {
if (StringUtils.isEmpty(timestamp)) {
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
subscriptionManager
.performEntAppSubscription(uuid, deviceIdentifiers, SubscriptionType.DEVICE.toString(), action);
.performEntAppSubscription(uuid, deviceIdentifiers, SubscriptionType.DEVICE.toString(),
action, requiresUpdatingExternal);
String msg = "Application release which has UUID " + uuid + " is installed to given valid device "
+ "identifiers.";
return Response.status(Response.Status.OK).entity(msg).build();
@ -200,11 +202,12 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
@PathParam("subType") String subType,
@PathParam("action") String action,
@Valid List<String> subscribers,
@QueryParam("timestamp") String timestamp) {
@QueryParam("timestamp") String timestamp,
@QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal) {
try {
if (StringUtils.isEmpty(timestamp)) {
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
subscriptionManager.performEntAppSubscription(uuid, subscribers, subType, action);
subscriptionManager.performEntAppSubscription(uuid, subscribers, subType, action, requiresUpdatingExternal);
String msg = "Application release which has UUID " + uuid + " is installed to subscriber's valid device"
+ " identifiers.";
return Response.status(Response.Status.OK).entity(msg).build();

@ -67,8 +67,8 @@ public class MDMIOSOperationUtil {
appStoreApplication.setPreventBackupOfAppData((Boolean) application.getProperties().
get(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP));
appStoreApplication.setBundleId(application.getId());
appStoreApplication.setiTunesStoreID((Integer) application.getProperties().
get(MDMAppConstants.IOSConstants.I_TUNES_ID));
appStoreApplication.setiTunesStoreID(Integer.parseInt(application.getProperties().
get(MDMAppConstants.IOSConstants.I_TUNES_ID).toString()));
operation.setCode(MDMAppConstants.IOSConstants.OPCODE_INSTALL_STORE_APPLICATION);
operation.setType(Operation.Type.COMMAND);
operation.setPayLoad(appStoreApplication.toJSON());

Loading…
Cancel
Save