@Override
protected URL doPost(Path path, Object value) throws QueryException {
if (path.getLength() > 0
|| value == null) {
throw new QueryException(Query.Status.BAD_REQUEST);
}
// Write the value to a temp file
File directory = new File(System.getProperty("java.io.tmpdir"));
File file;
try {
file = File.createTempFile(getClass().getName(), null, directory);
JSONSerializer jsonSerializer = new JSONSerializer();
jsonSerializer.writeObject(value, new FileOutputStream(file));
} catch (IOException exception) {
throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
} catch (SerializationException exception) {
throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
}
// Return the location of the resource
URL location;
try {
location = new URL(getLocation(), file.getName());
} catch (MalformedURLException exception) {
throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
}
return location;
}