mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Refactored Android APIs
This commit is contained in:
parent
af8905069d
commit
814dcf9c8f
@ -152,7 +152,7 @@ public interface DeviceTypeConfigurationService {
|
|||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 200,
|
code = 200,
|
||||||
message = "OK. \n Successfully fetched Android license configuration.",
|
message = "OK. \n Successfully fetched Android license configuration.",
|
||||||
response = PlatformConfiguration.class,
|
response = String.class,
|
||||||
responseHeaders = {
|
responseHeaders = {
|
||||||
@ResponseHeader(
|
@ResponseHeader(
|
||||||
name = "Content-Type",
|
name = "Content-Type",
|
||||||
|
|||||||
@ -52,15 +52,15 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
|
|||||||
public Response getConfiguration(
|
public Response getConfiguration(
|
||||||
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
||||||
String msg;
|
String msg;
|
||||||
PlatformConfiguration PlatformConfiguration;
|
PlatformConfiguration platformConfiguration;
|
||||||
List<ConfigurationEntry> configs;
|
List<ConfigurationEntry> configs;
|
||||||
try {
|
try {
|
||||||
PlatformConfiguration = AndroidAPIUtils.getDeviceManagementService().
|
platformConfiguration = AndroidAPIUtils.getDeviceManagementService().
|
||||||
getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||||
if (PlatformConfiguration != null) {
|
if (platformConfiguration != null) {
|
||||||
configs = PlatformConfiguration.getConfiguration();
|
configs = platformConfiguration.getConfiguration();
|
||||||
} else {
|
} else {
|
||||||
PlatformConfiguration = new PlatformConfiguration();
|
platformConfiguration = new PlatformConfiguration();
|
||||||
configs = new ArrayList<>();
|
configs = new ArrayList<>();
|
||||||
}
|
}
|
||||||
ConfigurationEntry entry = new ConfigurationEntry();
|
ConfigurationEntry entry = new ConfigurationEntry();
|
||||||
@ -73,7 +73,7 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
|
|||||||
entry.setName(AndroidConstants.TenantConfigProperties.LICENSE_KEY);
|
entry.setName(AndroidConstants.TenantConfigProperties.LICENSE_KEY);
|
||||||
entry.setValue(license.getText());
|
entry.setValue(license.getText());
|
||||||
configs.add(entry);
|
configs.add(entry);
|
||||||
PlatformConfiguration.setConfiguration(configs);
|
platformConfiguration.setConfiguration(configs);
|
||||||
}
|
}
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
msg = "Error occurred while retrieving the Android tenant configuration";
|
msg = "Error occurred while retrieving the Android tenant configuration";
|
||||||
@ -81,14 +81,13 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
|
|||||||
throw new UnexpectedServerErrorException(
|
throw new UnexpectedServerErrorException(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(PlatformConfiguration).build();
|
return Response.status(Response.Status.OK).entity(platformConfiguration).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Override
|
@Override
|
||||||
public Response updateConfiguration(@Valid AndroidPlatformConfiguration androidPlatformConfiguration) {
|
public Response updateConfiguration(@Valid AndroidPlatformConfiguration androidPlatformConfiguration) {
|
||||||
String msg;
|
String msg;
|
||||||
Message responseMsg = new Message();
|
|
||||||
ConfigurationEntry licenseEntry = null;
|
ConfigurationEntry licenseEntry = null;
|
||||||
PlatformConfiguration configuration = new PlatformConfiguration();
|
PlatformConfiguration configuration = new PlatformConfiguration();
|
||||||
if (androidPlatformConfiguration == null) {
|
if (androidPlatformConfiguration == null) {
|
||||||
@ -120,16 +119,13 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
|
|||||||
configuration.setConfiguration(configs);
|
configuration.setConfiguration(configs);
|
||||||
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
|
||||||
//AndroidAPIUtils.getGCMService().resetTenantConfigCache();
|
//AndroidAPIUtils.getGCMService().resetTenantConfigCache();
|
||||||
Response.status(Response.Status.ACCEPTED);
|
|
||||||
responseMsg.setResponseMessage("Android platform configuration has been updated successfully.");
|
|
||||||
responseMsg.setResponseCode(Response.Status.ACCEPTED.toString());
|
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
msg = "Error occurred while modifying configuration settings of Android platform";
|
msg = "Error occurred while modifying configuration settings of Android platform";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new UnexpectedServerErrorException(
|
throw new UnexpectedServerErrorException(
|
||||||
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
||||||
}
|
}
|
||||||
return Response.status(Response.Status.CREATED).entity(responseMsg).build();
|
return Response.status(Response.Status.OK).entity("Android platform configuration has been updated successfully.").build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -123,17 +123,15 @@ public class AndroidAPIUtils {
|
|||||||
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
||||||
}
|
}
|
||||||
DeviceIdentifier deviceIdentifier;
|
DeviceIdentifier deviceIdentifier;
|
||||||
List<DeviceIdentifier> deviceids = new ArrayList<>();
|
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
|
||||||
for (String deviceId : deviceIDs) {
|
for (String deviceId : deviceIDs) {
|
||||||
deviceIdentifier = new DeviceIdentifier();
|
deviceIdentifier = new DeviceIdentifier();
|
||||||
deviceIdentifier.setId(deviceId);
|
deviceIdentifier.setId(deviceId);
|
||||||
deviceIdentifier.setType(AndroidConstants.DEVICE_TYPE_ANDROID);
|
deviceIdentifier.setType(AndroidConstants.DEVICE_TYPE_ANDROID);
|
||||||
deviceids.add(deviceIdentifier);
|
deviceIdentifiers.add(deviceIdentifier);
|
||||||
}
|
}
|
||||||
Activity activity = null;
|
Activity activity = getDeviceManagementService().addOperation(
|
||||||
activity = getDeviceManagementService().addOperation(
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, deviceIdentifiers);
|
||||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, deviceids);
|
|
||||||
|
|
||||||
// if (activity != null) {
|
// if (activity != null) {
|
||||||
// GCMService gcmService = getGCMService();
|
// GCMService gcmService = getGCMService();
|
||||||
// if (gcmService.isGCMEnabled()) {
|
// if (gcmService.isGCMEnabled()) {
|
||||||
@ -145,7 +143,6 @@ public class AndroidAPIUtils {
|
|||||||
// getGCMService().sendNotification(operation.getCode(), devices);
|
// getGCMService().sendNotification(operation.getCode(), devices);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return Response.status(Response.Status.CREATED).entity(activity).build();
|
return Response.status(Response.Status.CREATED).entity(activity).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user