Search in sources :

Example 1 with BundlesListMessage

use of org.onebusaway.admin.bundle.BundlesListMessage in project onebusaway-application-modules by camsys.

the class LocalBundleDeployerServiceImpl method getBundleList.

@Override
public Response getBundleList() {
    _log.info("Starting getBundleList.");
    List<Bundle> bundles = bundleProvider.getBundles();
    Response response;
    if (bundles != null) {
        BundlesListMessage bundlesMessage = new BundlesListMessage();
        bundlesMessage.setBundles(bundles);
        bundlesMessage.setStatus("OK");
        final BundlesListMessage bundlesMessageToWrite = bundlesMessage;
        StreamingOutput output = new StreamingOutput() {

            @Override
            public void write(OutputStream out) throws IOException, WebApplicationException {
                BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
                jsonTool.writeJson(writer, bundlesMessageToWrite);
                writer.close();
                out.close();
            }
        };
        response = Response.ok(output, "application/json").build();
    } else {
        response = Response.serverError().build();
    }
    _log.info("Returning Response in getBundleList.");
    return response;
}
Also used : Response(javax.ws.rs.core.Response) Bundle(org.onebusaway.admin.bundle.model.Bundle) BundlesListMessage(org.onebusaway.admin.bundle.BundlesListMessage) OutputStream(java.io.OutputStream) StreamingOutput(javax.ws.rs.core.StreamingOutput) OutputStreamWriter(java.io.OutputStreamWriter) BufferedWriter(java.io.BufferedWriter)

Example 2 with BundlesListMessage

use of org.onebusaway.admin.bundle.BundlesListMessage in project onebusaway-application-modules by camsys.

the class LocalBundleStagerServiceImpl method getBundleList.

@Override
public Response getBundleList() {
    _log.info("Starting getBundleList.");
    List<Bundle> bundles = bundleProvider.getBundles();
    Response response;
    if (bundles != null) {
        BundlesListMessage bundlesMessage = new BundlesListMessage();
        bundlesMessage.setBundles(bundles);
        bundlesMessage.setStatus("OK");
        final BundlesListMessage bundlesMessageToWrite = bundlesMessage;
        StreamingOutput output = new StreamingOutput() {

            @Override
            public void write(OutputStream out) throws IOException, WebApplicationException {
                BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
                jsonTool.writeJson(writer, bundlesMessageToWrite);
                writer.close();
                out.close();
            }
        };
        response = Response.ok(output, "application/json").build();
    } else {
        response = Response.serverError().build();
    }
    _log.info("Returning Response in getBundleList.");
    return response;
}
Also used : Response(javax.ws.rs.core.Response) Bundle(org.onebusaway.admin.bundle.model.Bundle) BundlesListMessage(org.onebusaway.admin.bundle.BundlesListMessage) OutputStream(java.io.OutputStream) StreamingOutput(javax.ws.rs.core.StreamingOutput) OutputStreamWriter(java.io.OutputStreamWriter) BufferedWriter(java.io.BufferedWriter)

Aggregations

BufferedWriter (java.io.BufferedWriter)2 OutputStream (java.io.OutputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2 Response (javax.ws.rs.core.Response)2 StreamingOutput (javax.ws.rs.core.StreamingOutput)2 BundlesListMessage (org.onebusaway.admin.bundle.BundlesListMessage)2 Bundle (org.onebusaway.admin.bundle.model.Bundle)2