@GET
@Path("available.xml")
@Produces(MediaType.TEXT_XML)
@RestQuery(name = "availableasxml", description = "Lists available services by service type identifier, ordered by load.", returnDescription = "The services list as XML", restParameters = { @RestParameter(name = "serviceType", isRequired = false, type = Type.STRING, description = "The service type identifier") }, reponses = {
@RestResponse(responseCode = SC_OK, description = "Returned the available services."),
@RestResponse(responseCode = SC_BAD_REQUEST, description = "No service type specified, bad request.") })
public Response getAvailableServicesAsXml(@QueryParam("serviceType") String serviceType) {
if (isBlank(serviceType))
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity("Service type must be specified")
.build());
JaxbServiceRegistrationList registrations = new JaxbServiceRegistrationList();
try {
for (ServiceRegistration reg : serviceRegistry.getServiceRegistrationsByLoad(serviceType)) {
registrations.add(new JaxbServiceRegistration(reg));
}
return Response.ok(registrations).build();
} catch (ServiceRegistryException e) {
throw new WebApplicationException(e);
}
}