use of org.onebusaway.admin.bundle.model.Bundle in project onebusaway-application-modules by camsys.
the class DirectoryBundleSource method checkIsValidBundleFile.
@Override
public boolean checkIsValidBundleFile(String bundleId, String relativeFilePath) {
init();
boolean isValid = false;
Bundle requestedBundle;
try {
requestedBundle = loadBundleDirectory(bundleId);
if (requestedBundle != null) {
if (requestedBundle.containsFile(relativeFilePath)) {
isValid = true;
}
}
} catch (IOException e) {
isValid = false;
}
return isValid;
}
use of org.onebusaway.admin.bundle.model.Bundle 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;
}
use of org.onebusaway.admin.bundle.model.Bundle in project onebusaway-application-modules by camsys.
the class LocalBundleDeployerServiceImpl method getLatestBundle.
/**
* displays the latest active bundle.
*/
@Override
public Response getLatestBundle() {
_log.info("Starting getLatestBundle.");
Bundle latestBundle = getLatestBundleAsBundle();
if (latestBundle != null) {
try {
JSONObject response = new JSONObject();
response.put("id", latestBundle.getId());
response.put("dataset", latestBundle.getDataset());
response.put("name", latestBundle.getName());
return Response.ok(response.toString()).build();
} catch (Exception e) {
_log.error("Error reading latest bundle: " + e);
}
}
return Response.ok("Error: No bundles deployed.").build();
}
use of org.onebusaway.admin.bundle.model.Bundle in project onebusaway-application-modules by camsys.
the class LocalBundleDeployerServiceImpl method getLatestBundleAsBundle.
private Bundle getLatestBundleAsBundle() {
List<Bundle> bundles = bundleProvider.getBundles();
Bundle latestBundle = null;
for (Bundle bundle : bundles) {
// make sure bundle is active
if (bundle.getServiceDateFrom().isBefore(new LocalDate()) || bundle.getServiceDateFrom().isEqual(new LocalDate())) {
if (latestBundle == null || bundle.getCreated().isAfter(latestBundle.getCreated())) {
latestBundle = bundle;
}
}
}
return latestBundle;
}
use of org.onebusaway.admin.bundle.model.Bundle in project onebusaway-application-modules by camsys.
the class DirectoryBundleSource method loadBundleMetadata.
private Bundle loadBundleMetadata(File metadataFile) throws FileNotFoundException {
FileReader metadataReader = null;
Bundle resultBundle = null;
try {
metadataReader = new FileReader(metadataFile);
if (jsonTool == null) {
// we have an issue with the spring configuration
throw new RuntimeException("Configuration Error: jsonTool not configured!");
}
resultBundle = jsonTool.readJson(metadataReader, Bundle.class);
} catch (RuntimeException re) {
_log.error("fatal configuration error!", re);
} catch (Exception e) {
// our bundle is corrupt or we have permissions/configuration issue
// give up on this bundle and hope that others exist!
_log.error("Configuration Exception: Unable to load file " + metadataFile, e);
return null;
} finally {
if (metadataReader != null)
try {
metadataReader.close();
} catch (IOException e) {
}
}
return resultBundle;
}
Aggregations