Improving HTTP status code handling and the resource implementations

4.x.x
prabathabey 9 years ago
parent a23f44e682
commit 624e7df688

@ -68,13 +68,14 @@ public interface ConfigurationManagementService {
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
message = "Not Modified. \n Empty body because the client has already the latest version of " +
"the requested resource."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the general " +
message = "Internal Server Error. \n Server error occurred while fetching the general " +
"platform configuration.",
response = ErrorResponse.class)
})
@ -100,9 +101,6 @@ public interface ConfigurationManagementService {
code = 200,
message = "OK. \n General platform configuration has been updated successfully",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "URL of the updated general platform configuration."),
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ -122,7 +120,7 @@ public interface ConfigurationManagementService {
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server ErrorResponse. \n " +
message = "Internal Server Error. \n " +
"Server error occurred while modifying general platform configuration.",
response = ErrorResponse.class)
})

@ -308,9 +308,6 @@ public interface RoleManagementService {
code = 200,
message = "OK. \n Role has been updated successfully",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "URL of the updated role."),
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@ -404,9 +401,6 @@ public interface RoleManagementService {
code = 200,
message = "OK. \n User list of the role has been updated successfully",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "URL of the updated user list."),
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),

@ -162,9 +162,6 @@ public interface UserManagementService {
code = 200,
message = "OK. \n User has been updated successfully",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "URL of the updated user."),
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@ -190,7 +187,7 @@ public interface UserManagementService {
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server ErrorResponse. \n " +
message = "Internal Server Error. \n " +
"Server error occurred while updating the user.",
response = ErrorResponse.class)
})
@ -224,7 +221,7 @@ public interface UserManagementService {
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server ErrorResponse. \n " +
message = "Internal Server Error. \n " +
"Server error occurred while removing the user.",
response = ErrorResponse.class
)
@ -274,7 +271,7 @@ public interface UserManagementService {
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the role list" +
message = "Internal Server Error. \n Server error occurred while fetching the role list" +
" assigned to the user.",
response = ErrorResponse.class)
})
@ -318,7 +315,7 @@ public interface UserManagementService {
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the user list.",
message = "Internal Server Error. \n Server error occurred while fetching the user list.",
response = ErrorResponse.class)
})
@Permission(scope = "user-view", permissions = {"/permission/admin/device-mgt/admin/user/list"})
@ -384,7 +381,7 @@ public interface UserManagementService {
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the username " +
message = "Internal Server Error. \n Server error occurred while fetching the username " +
"list that matches the given filter.",
response = ErrorResponse.class)
})
@ -438,7 +435,7 @@ public interface UserManagementService {
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server ErrorResponse. \n " +
message = "Internal Server Error. \n " +
"Server error occurred while updating credentials of the user.",
response = ErrorResponse.class)
})

@ -55,19 +55,19 @@ public class ConfigurationServiceImpl implements ConfigurationManagementService
ConfigurationEntry configurationEntry = new ConfigurationEntry();
configurationEntry.setContentType("text");
configurationEntry.setName("notifierFrequency");
configurationEntry.setValue(PolicyManagerUtil.getMonitoringFequency());
configurationEntry.setValue(PolicyManagerUtil.getMonitoringFrequency());
List<ConfigurationEntry> configList = config.getConfiguration();
if (configList == null) {
configList = new ArrayList<>();
configList.add(configurationEntry);
}
config.setConfiguration(configList);
return Response.status(Response.Status.OK).entity(config).build();
return Response.ok().entity(config).build();
} catch (ConfigurationManagementException | PolicyManagementException e) {
msg = "ErrorResponse occurred while retrieving the configurations.";
msg = "Error occurred while retrieving the general platform configuration";
log.error(msg, e);
throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
}
}
@ -80,13 +80,15 @@ public class ConfigurationServiceImpl implements ConfigurationManagementService
MDMAppConstants.RegistryConstants.GENERAL_CONFIG_RESOURCE_PATH);
//Schedule the task service
DeviceMgtAPIUtils.scheduleTaskService(DeviceMgtAPIUtils.getNotifierFrequency(config));
return Response.status(Response.Status.CREATED)
.entity("Configuration has successfully been updated").build();
PlatformConfiguration updatedConfig = DeviceMgtAPIUtils.getPlatformConfigurationManagementService().
getConfiguration(MDMAppConstants.RegistryConstants.GENERAL_CONFIG_RESOURCE_PATH);
return Response.ok().entity(updatedConfig).build();
} catch (ConfigurationManagementException e) {
String msg = "ErrorResponse occurred while updating the configuration.";
String msg = "Error occurred while updating the general platform configuration";
log.error(msg, e);
throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
}
}

@ -91,7 +91,7 @@ public class PolicyManagementServiceComponent {
DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration();
if(policyConfiguration.getMonitoringEnable()) {
TaskScheduleService taskScheduleService = new TaskScheduleServiceImpl();
taskScheduleService.startTask(PolicyManagerUtil.getMonitoringFequency());
taskScheduleService.startTask(PolicyManagerUtil.getMonitoringFrequency());
}
} catch (Throwable t) {

@ -196,7 +196,7 @@ public class PolicyManagerUtil {
}
public static int getMonitoringFequency() throws PolicyManagementException {
public static int getMonitoringFrequency() throws PolicyManagementException {
PlatformConfigurationManagementService configMgtService = new PlatformConfigurationManagementServiceImpl();
PlatformConfiguration tenantConfiguration;

Loading…
Cancel
Save