IOUtils.copy(new FileInputStream(tempFile), exchange.getOutputStream());
exchange.endExchange();
}
else {
logger.log(Level.WARNING, "Invalid request received; Cannot find file token " + tempFileToken);
eventBus.post(new BadRequestResponse(-1, "Invalid request."));
}
}
else {
String message = IOUtils.toString(exchange.getInputStream()); // TODO [high] Read entire file to memory. Dangerous!
logger.log(Level.INFO, "REST message received: " + message);
try {
Request request = MessageFactory.toRequest(message);
daemonWebServer.putCacheRestRequest(request.getId(), exchange);
eventBus.post(request);
}
catch (Exception e) {
logger.log(Level.WARNING, "Invalid request received; cannot serialize to Request.", e);
eventBus.post(new BadRequestResponse(-1, "Invalid request."));
}
}
}