use of org.opentripplanner.api.model.alertpatch.AlertPatchCreationResponse in project OpenTripPlanner by opentripplanner.
the class AlertPatcher method createPatches.
@RolesAllowed("user")
@POST
@Path("/patch")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML + Q, MediaType.TEXT_XML + Q })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
public AlertPatchCreationResponse createPatches(AlertPatchSet alertPatches) {
AlertPatchCreationResponse response = new AlertPatchCreationResponse();
for (AlertPatch alertPatch : alertPatches.alertPatches) {
if (alertPatch.getId() == null) {
response.status = "Every patch must have an id";
return response;
}
final AgencyAndId route = alertPatch.getRoute();
if (route != null && route.getId().equals("")) {
response.status = "Every route patch must have a route id";
return response;
}
}
for (AlertPatch alertPatch : alertPatches.alertPatches) {
alertPatchService.apply(alertPatch);
}
response.status = "OK";
return response;
}
Aggregations