@GET
@Path("/take/snapshot")
@Produces({"application/xml", "application/json"})
public Response takeSnapshot() {
DarkstarRunner runner = getRunner();
if(runner == null || runner.getStatus() != Status.NOT_RUNNING) {
return Response.status(Response.Status.BAD_REQUEST).cacheControl(NO_CACHE).build();
}
// use a default name based on the current data
DateFormat df = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss.SS");
String snapshotName = df.format(new Date());
try {
runner.createSnapshot(snapshotName);
} catch (RunnerException re) {
LOGGER.warning("Error creating snapshot!");
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).cacheControl(NO_CACHE).build();
}