use of org.codehaus.jackson.map.MappingJsonFactory in project onebusaway-application-modules by camsys.
the class ValidateRemoteResource 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);
BundleResponse bundleResponse = _validationMap.get(id);
_log.debug("found bundleResponse=" + bundleResponse + " for id=" + id);
_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 LocalBundleStagerServiceImpl method jsonSerializer.
/*private String getBundleDirectory() {
return bundleStager.getStagedBundleDirectory();
}*/
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 UserResource method constructResponse.
private Response constructResponse(Object result) {
final StringWriter sw = new StringWriter();
final MappingJsonFactory jsonFactory = new MappingJsonFactory();
Response response = null;
try {
final JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(sw);
mapper.writeValue(jsonGenerator, result);
response = Response.ok(sw.toString()).build();
} catch (JsonGenerationException e) {
log.error("Error generating response JSON");
response = Response.serverError().build();
e.printStackTrace();
} catch (JsonMappingException e) {
log.error("Error mapping response to JSON");
response = Response.serverError().build();
e.printStackTrace();
} catch (IOException e) {
log.error("I/O error while creating response JSON");
response = Response.serverError().build();
e.printStackTrace();
}
return response;
}
use of org.codehaus.jackson.map.MappingJsonFactory in project onebusaway-application-modules by camsys.
the class BuildResource method constructResponse.
private Response constructResponse(BundleBuildResponse buildResponse) throws IOException, JsonGenerationException, JsonMappingException {
final StringWriter sw = new StringWriter();
final MappingJsonFactory jsonFactory = new MappingJsonFactory();
final JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(sw);
_mapper.writeValue(jsonGenerator, buildResponse);
return Response.ok(sw.toString()).build();
}
use of org.codehaus.jackson.map.MappingJsonFactory in project onebusaway-application-modules by camsys.
the class BuildResource 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();
}
BundleBuildResponse buildResponse = _bundleService.lookupBuildRequest(id);
String dirName = buildResponse.getBundleDirectoryName();
if (dirName == null || dirName.isEmpty()) {
buildResponse.setBundleBuildName(bundleName);
buildResponse.setBundleDirectoryName(directoryName);
buildResponse.setBundleEmailTo(emailTo);
buildResponse.setBundleStartDate(startDate);
buildResponse.setBundleEndDate(endDate);
buildResponse.setBundleComment(comment);
}
try {
final StringWriter sw = new StringWriter();
final MappingJsonFactory jsonFactory = new MappingJsonFactory();
final JsonGenerator jsonGenerator = jsonFactory.createJsonGenerator(sw);
_mapper.writeValue(jsonGenerator, buildResponse);
response = Response.ok(sw.toString()).build();
} catch (Exception any) {
_log.error("exception looking up build:", any);
response = Response.serverError().build();
}
return response;
}
Aggregations