mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
improve uninstall API for Google EMM APIs
This commit is contained in:
parent
5d08e98b8a
commit
5a3d9c455a
@ -92,13 +92,14 @@ public interface SubscriptionManager {
|
|||||||
* @param subType subscription type. E.g. <code>DEVICE, USER, ROLE, GROUP</code> {@see {
|
* @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 action subscription action. E.g. <code>INSTALL/UNINSTALL</code> {@see {
|
||||||
* @param <T> generic type of the method.
|
* @param <T> generic type of the method.
|
||||||
|
* @param requiresUpdatingExternal should an external server be updated. Such as Google EMM APIs
|
||||||
* @return {@link ApplicationInstallResponse}
|
* @return {@link ApplicationInstallResponse}
|
||||||
* @throws ApplicationManagementException ApplicationManagementException if error occurs when subscribing to the
|
* @throws ApplicationManagementException ApplicationManagementException if error occurs when subscribing to the
|
||||||
* given application
|
* given application
|
||||||
* @link org.wso2.carbon.device.application.mgt.common.SubscriptionType}}
|
* @link org.wso2.carbon.device.application.mgt.common.SubscriptionType}}
|
||||||
*/
|
*/
|
||||||
<T> void performEntAppSubscription(String applicationUUID, List<T> params, String subType, String action)
|
<T> void performEntAppSubscription(String applicationUUID, List<T> params, String subType, String action,
|
||||||
throws ApplicationManagementException;
|
boolean requiresUpdatingExternal) throws ApplicationManagementException;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* This method used to get the app id ,device ids and pass them to DM service method.
|
* 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
|
@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 {
|
throws ApplicationManagementException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Google Ent app Install operation is received to application which has UUID "
|
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());
|
List<String> categories = getApplicationCategories(applicationDTO.getId());
|
||||||
if (!categories.contains("GooglePlaySyncedApp")) {
|
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.";
|
+ "installation.";
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
throw new BadRequestException(msg);
|
throw new BadRequestException(msg);
|
||||||
@ -424,12 +425,14 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//Installing the application
|
if (requiresUpdatingExternal) {
|
||||||
ApplicationPolicyDTO applicationPolicyDTO = new ApplicationPolicyDTO();
|
//Installing the application
|
||||||
applicationPolicyDTO.setApplicationDTO(applicationDTO);
|
ApplicationPolicyDTO applicationPolicyDTO = new ApplicationPolicyDTO();
|
||||||
applicationPolicyDTO.setDeviceIdentifierList(deviceIdentifiers);
|
applicationPolicyDTO.setApplicationDTO(applicationDTO);
|
||||||
applicationPolicyDTO.setAction(action);
|
applicationPolicyDTO.setDeviceIdentifierList(deviceIdentifiers);
|
||||||
installEnrollmentApplications(applicationPolicyDTO);
|
applicationPolicyDTO.setAction(action.toUpperCase());
|
||||||
|
installEnrollmentApplications(applicationPolicyDTO);
|
||||||
|
}
|
||||||
|
|
||||||
appSubscribingDeviceIds = devices.stream().map(Device::getId).collect(Collectors.toList());
|
appSubscribingDeviceIds = devices.stream().map(Device::getId).collect(Collectors.toList());
|
||||||
Map<Integer, DeviceSubscriptionDTO> deviceSubscriptions = getDeviceSubscriptions(appSubscribingDeviceIds,
|
Map<Integer, DeviceSubscriptionDTO> deviceSubscriptions = getDeviceSubscriptions(appSubscribingDeviceIds,
|
||||||
@ -972,6 +975,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.put(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP, true);
|
properties.put(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP, true);
|
||||||
properties.put(MDMAppConstants.IOSConstants.IS_REMOVE_APP, true);
|
properties.put(MDMAppConstants.IOSConstants.IS_REMOVE_APP, true);
|
||||||
|
properties.put(MDMAppConstants.IOSConstants.I_TUNES_ID, application.getPackageName());
|
||||||
app.setProperties(properties);
|
app.setProperties(properties);
|
||||||
return MDMIOSOperationUtil.createInstallAppOperation(app);
|
return MDMIOSOperationUtil.createInstallAppOperation(app);
|
||||||
} else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
} else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
||||||
|
|||||||
@ -229,7 +229,12 @@ public interface SubscriptionManagementAPI {
|
|||||||
name = "timestamp",
|
name = "timestamp",
|
||||||
value = "Timestamp of scheduled ent. install operation"
|
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
|
@POST
|
||||||
@ -282,7 +287,12 @@ public interface SubscriptionManagementAPI {
|
|||||||
name = "timestamp",
|
name = "timestamp",
|
||||||
value = "Timestamp of scheduled ent app install operation"
|
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
|
@GET
|
||||||
|
|||||||
@ -155,12 +155,14 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
|
|||||||
@PathParam("uuid") String uuid,
|
@PathParam("uuid") String uuid,
|
||||||
@PathParam("action") String action,
|
@PathParam("action") String action,
|
||||||
@Valid List<DeviceIdentifier> deviceIdentifiers,
|
@Valid List<DeviceIdentifier> deviceIdentifiers,
|
||||||
@QueryParam("timestamp") String timestamp) {
|
@QueryParam("timestamp") String timestamp,
|
||||||
|
@QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal) {
|
||||||
try {
|
try {
|
||||||
if (StringUtils.isEmpty(timestamp)) {
|
if (StringUtils.isEmpty(timestamp)) {
|
||||||
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
|
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
|
||||||
subscriptionManager
|
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 "
|
String msg = "Application release which has UUID " + uuid + " is installed to given valid device "
|
||||||
+ "identifiers.";
|
+ "identifiers.";
|
||||||
return Response.status(Response.Status.OK).entity(msg).build();
|
return Response.status(Response.Status.OK).entity(msg).build();
|
||||||
@ -200,11 +202,12 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
|
|||||||
@PathParam("subType") String subType,
|
@PathParam("subType") String subType,
|
||||||
@PathParam("action") String action,
|
@PathParam("action") String action,
|
||||||
@Valid List<String> subscribers,
|
@Valid List<String> subscribers,
|
||||||
@QueryParam("timestamp") String timestamp) {
|
@QueryParam("timestamp") String timestamp,
|
||||||
|
@QueryParam("requiresUpdatingExternal") boolean requiresUpdatingExternal) {
|
||||||
try {
|
try {
|
||||||
if (StringUtils.isEmpty(timestamp)) {
|
if (StringUtils.isEmpty(timestamp)) {
|
||||||
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
|
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"
|
String msg = "Application release which has UUID " + uuid + " is installed to subscriber's valid device"
|
||||||
+ " identifiers.";
|
+ " identifiers.";
|
||||||
return Response.status(Response.Status.OK).entity(msg).build();
|
return Response.status(Response.Status.OK).entity(msg).build();
|
||||||
|
|||||||
@ -67,8 +67,8 @@ public class MDMIOSOperationUtil {
|
|||||||
appStoreApplication.setPreventBackupOfAppData((Boolean) application.getProperties().
|
appStoreApplication.setPreventBackupOfAppData((Boolean) application.getProperties().
|
||||||
get(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP));
|
get(MDMAppConstants.IOSConstants.IS_PREVENT_BACKUP));
|
||||||
appStoreApplication.setBundleId(application.getId());
|
appStoreApplication.setBundleId(application.getId());
|
||||||
appStoreApplication.setiTunesStoreID((Integer) application.getProperties().
|
appStoreApplication.setiTunesStoreID(Integer.parseInt(application.getProperties().
|
||||||
get(MDMAppConstants.IOSConstants.I_TUNES_ID));
|
get(MDMAppConstants.IOSConstants.I_TUNES_ID).toString()));
|
||||||
operation.setCode(MDMAppConstants.IOSConstants.OPCODE_INSTALL_STORE_APPLICATION);
|
operation.setCode(MDMAppConstants.IOSConstants.OPCODE_INSTALL_STORE_APPLICATION);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
operation.setPayLoad(appStoreApplication.toJSON());
|
operation.setPayLoad(appStoreApplication.toJSON());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user