}
@Override
protected URL doPost(Path path, Object value) throws QueryException {
if (value == null) {
throw new QueryException(Query.Status.BAD_REQUEST);
}
Expense expense = (Expense)value;
// Add the expense to the list/map
int id;
synchronized (this) {
id = nextID++;
expense.setID(id);
expenses.add(expense);
expenseMap.put(id, expense);
}
// Return the location of the newly-created resource
URL location = getLocation();
try {
location = new URL(location, Integer.toString(id));
} catch (MalformedURLException exception) {
throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
}
return location;
}