Refactored Android APIs

merge-requests/1/head
harshanl 8 years ago
parent af8905069d
commit 814dcf9c8f

@ -152,7 +152,7 @@ public interface DeviceTypeConfigurationService {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched Android license configuration.",
response = PlatformConfiguration.class,
response = String.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",

@ -52,15 +52,15 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
public Response getConfiguration(
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
String msg;
PlatformConfiguration PlatformConfiguration;
PlatformConfiguration platformConfiguration;
List<ConfigurationEntry> configs;
try {
PlatformConfiguration = AndroidAPIUtils.getDeviceManagementService().
platformConfiguration = AndroidAPIUtils.getDeviceManagementService().
getConfiguration(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
if (PlatformConfiguration != null) {
configs = PlatformConfiguration.getConfiguration();
if (platformConfiguration != null) {
configs = platformConfiguration.getConfiguration();
} else {
PlatformConfiguration = new PlatformConfiguration();
platformConfiguration = new PlatformConfiguration();
configs = new ArrayList<>();
}
ConfigurationEntry entry = new ConfigurationEntry();
@ -73,7 +73,7 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
entry.setName(AndroidConstants.TenantConfigProperties.LICENSE_KEY);
entry.setValue(license.getText());
configs.add(entry);
PlatformConfiguration.setConfiguration(configs);
platformConfiguration.setConfiguration(configs);
}
} catch (DeviceManagementException e) {
msg = "Error occurred while retrieving the Android tenant configuration";
@ -81,14 +81,13 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
throw new UnexpectedServerErrorException(
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
@Override
public Response updateConfiguration(@Valid AndroidPlatformConfiguration androidPlatformConfiguration) {
String msg;
Message responseMsg = new Message();
ConfigurationEntry licenseEntry = null;
PlatformConfiguration configuration = new PlatformConfiguration();
if (androidPlatformConfiguration == null) {
@ -120,16 +119,13 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
configuration.setConfiguration(configs);
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
//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) {
msg = "Error occurred while modifying configuration settings of Android platform";
log.error(msg, e);
throw new UnexpectedServerErrorException(
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());
}
DeviceIdentifier deviceIdentifier;
List<DeviceIdentifier> deviceids = new ArrayList<>();
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
for (String deviceId : deviceIDs) {
deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setId(deviceId);
deviceIdentifier.setType(AndroidConstants.DEVICE_TYPE_ANDROID);
deviceids.add(deviceIdentifier);
deviceIdentifiers.add(deviceIdentifier);
}
Activity activity = null;
activity = getDeviceManagementService().addOperation(
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, deviceids);
Activity activity = getDeviceManagementService().addOperation(
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, deviceIdentifiers);
// if (activity != null) {
// GCMService gcmService = getGCMService();
// if (gcmService.isGCMEnabled()) {
@ -145,7 +143,6 @@ public class AndroidAPIUtils {
// getGCMService().sendNotification(operation.getCode(), devices);
// }
// }
return Response.status(Response.Status.CREATED).entity(activity).build();
}

Loading…
Cancel
Save