use of org.onebusaway.admin.model.BundleBuildResponse in project onebusaway-application-modules by camsys.
the class BuildResource method build.
@Path("create")
@POST
@Produces("application/json")
public Response build(@FormParam("bundleDirectory") String bundleDirectory, @FormParam("bundleName") String bundleName, @FormParam("email") String email, @FormParam("bundleStartDate") String bundleStartDate, @FormParam("bundleEndDate") String bundleEndDate, @FormParam("bundleComment") String bundleComment, @FormParam("archive") boolean archiveFlag, @FormParam("consolidate") boolean consolidateFlag, @FormParam("predate") boolean predateFlag) {
Response response = null;
directoryName = bundleDirectory;
this.bundleName = bundleName;
startDate = bundleStartDate;
endDate = bundleEndDate;
emailTo = email;
comment = bundleComment;
archive = archiveFlag;
consolidate = consolidateFlag;
predate = predateFlag;
if (!isAuthorized()) {
return Response.noContent().build();
}
BundleBuildResponse buildResponse = null;
try {
validateDates(bundleStartDate, bundleEndDate);
} catch (DateValidationException e) {
try {
buildResponse = new BundleBuildResponse();
buildResponse.setException(e);
response = constructResponse(buildResponse);
} catch (Exception any) {
_log.error("exception in build:", any);
response = Response.serverError().build();
}
}
// Proceed only if date validation passes
if (response == null) {
BundleBuildRequest buildRequest = new BundleBuildRequest();
buildRequest.setBundleDirectory(bundleDirectory);
buildRequest.setBundleName(bundleName);
buildRequest.setEmailAddress(email);
buildRequest.setBundleStartDate(bundleStartDate);
buildRequest.setBundleEndDate(bundleEndDate);
buildRequest.setBundleComment(bundleComment);
buildRequest.setArchiveFlag(archive);
buildRequest.setConsolidateFlag(consolidate);
buildRequest.setPredate(predate);
String session = RequestContextHolder.currentRequestAttributes().getSessionId();
buildRequest.setSessionId(session);
try {
String message = "Starting bundle building process for bundle '" + buildRequest.getBundleName() + "' initiated by user : " + _currentUserService.getCurrentUserDetails().getUsername();
String component = System.getProperty("admin.chefRole");
loggingService.log(component, Level.INFO, message);
buildResponse = _bundleService.build(buildRequest);
buildResponse = _bundleService.buildBundleResultURL(buildResponse.getId());
response = constructResponse(buildResponse);
} catch (Exception any) {
_log.error("exception in build:", any);
response = Response.serverError().build();
}
}
return response;
}
use of org.onebusaway.admin.model.BundleBuildResponse in project onebusaway-application-modules by camsys.
the class BuildResource method url.
@Path("/{id}/url")
@GET
@Produces("application/json")
public Response url(@PathParam("id") String id) {
Response response = null;
if (!isAuthorized()) {
return Response.noContent().build();
}
BundleBuildResponse buildResponse = _bundleService.lookupBuildRequest(id);
try {
response = constructResponse(buildResponse);
} catch (Exception any) {
_log.error("exception looking up build:", any);
response = Response.serverError().build();
}
return response;
}
use of org.onebusaway.admin.model.BundleBuildResponse in project onebusaway-application-modules by camsys.
the class BuildRemoteResource method list.
@Path("/{id}/list")
@GET
@Produces("application/json")
public Response list(@PathParam("id") String id) {
Response response = null;
if (!isAuthorized()) {
return Response.noContent().build();
}
try {
final StringWriter sw = new StringWriter();
final MappingJsonFactory jsonFactory = new MappingJsonFactory();
final JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(sw);
BundleBuildResponse bbr = _buildMap.get(id);
if (bbr == null) {
bbr = _bundleService.getBundleBuildResponseForId(id);
}
if (bbr != null && bbr.getException() != null) {
_log.error("id=" + id + " has exception=" + bbr.getException());
}
_mapper.writeValue(jsonGenerator, bbr);
response = Response.ok(sw.toString()).build();
} catch (Exception any) {
response = Response.serverError().build();
}
return response;
}
Aggregations