use of org.codehaus.jackson.map.MappingJsonFactory in project onebusaway-application-modules by camsys.
the class LocalBundleDeployerServiceImpl method jsonSerializer.
private String jsonSerializer(Object object) throws IOException {
// serialize the status object and send to client -- it contains an id for querying
final StringWriter sw = new StringWriter();
final MappingJsonFactory jsonFactory = new MappingJsonFactory();
final JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(sw);
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(jsonGenerator, object);
return sw.toString();
}
use of org.codehaus.jackson.map.MappingJsonFactory in project onebusaway-application-modules by camsys.
the class ValidateRemoteResource method validate.
@Path("/{bundleDirectory}/{bundleName}/{id}/create")
@GET
@Produces("application/json")
public Response validate(@PathParam("bundleDirectory") String bundleDirectory, @PathParam("bundleName") String bundleName, @PathParam("id") String id) {
Response response = null;
if (!isAuthorized()) {
return Response.noContent().build();
}
BundleRequest bundleRequest = new BundleRequest();
_log.debug("bundleName=" + bundleName + ", bundleDirectory=" + bundleDirectory);
bundleRequest.setBundleBuildName(bundleName);
bundleRequest.setBundleDirectory(bundleDirectory);
bundleRequest.setId(id);
BundleResponse bundleResponse = new BundleResponse(id);
try {
bundleResponse.addStatusMessage("server started");
bundleResponse.addStatusMessage("queueing");
// place execution in its own thread
_executorService.execute(new ValidateThread(bundleRequest, bundleResponse));
// place handle to response in map
_validationMap.put(id, bundleResponse);
final StringWriter sw = new StringWriter();
final MappingJsonFactory jsonFactory = new MappingJsonFactory();
final JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(sw);
// write back response
_log.debug("returning id=" + bundleResponse.getId() + " for bundleResponse=" + bundleResponse);
_mapper.writeValue(jsonGenerator, bundleResponse);
response = Response.ok(sw.toString()).build();
} catch (Exception any) {
_log.error("validate resource caught exception:" + any);
response = Response.serverError().build();
}
return response;
}
use of org.codehaus.jackson.map.MappingJsonFactory in project onebusaway-application-modules by camsys.
the class ValidateResource 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();
}
BundleResponse bundleResponse = null;
try {
bundleResponse = _bundleService.lookupValidationRequest(id);
bundleResponse.setBuildName(bundleName);
bundleResponse.setDirectoryName(directoryName);
final StringWriter sw = new StringWriter();
final MappingJsonFactory jsonFactory = new MappingJsonFactory();
final JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(sw);
_mapper.writeValue(jsonGenerator, bundleResponse);
response = Response.ok(sw.toString()).build();
} catch (Exception any) {
response = Response.serverError().build();
}
return response;
}
use of org.codehaus.jackson.map.MappingJsonFactory 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