// TODO at this point the server will expect a response per-file. The simplistic error responses may not be handled well
Optional<Long> accountId = getAccountId();
if (accountId.isPresent()) {
UserFileUploadTracker tracker = ServiceLocator.instance().getInstance(
UserFileUploadTracker.class);
boolean registeredForUpload = tracker.tryToRegisterUserForFileUpload(accountId.get());
if (!registeredForUpload) {
log.error("User with id {} is already uploading something.", accountId.get());
respondWithError(response, "already uploading");
} else {
try {
processMultipartPost(request, response);
} finally {
tracker.deRegisterUserForFileUpload(accountId.get());
}
}
} else {
log.error("User attempted upload when not logged in.");
respondWithError(response, "not logged in");