throws WebApplicationException {
if(emailAddress == null) {
throw new MissingRequiredParameterException("emailAddress");
}
DataManager dataManager = getDataManager();
UnverifiedAccount newAccount = null;
try {
UnverifiedAccount unverifiedAccount = dataManager
.getUnverifiedAccount(emailAddress);
throw new WebApplicationException(
Response.status(Status.BAD_REQUEST)
.entity("The submitted email address '"
+ emailAddress
+ "' results already registered (but not yet verified!) since "
+ unverifiedAccount.getRegistrationDate())
.build());
} catch (UnknownUnverifiedAccountException e1) {
try {
VerifiedAccount verifiedAccount = dataManager
.getVerifiedAccount(emailAddress);
throw new WebApplicationException(Response
.status(Status.BAD_REQUEST)
.entity("The submitted email address '" + emailAddress
+ "' results already registered since "
+ verifiedAccount.getRegistrationDate())
.build());
} catch (UnknownVerifiedAccountException e) {
/*
* All right, that is how we like it ;-)
*/
try {
newAccount = dataManager
.createUnverifiedAccount(emailAddress);
performSendConfirmation(context, newAccount);
URI accountURI = uriInfo.getBaseUri().resolve(
"/resources/unverifiedAccounts/"
+ newAccount.getEmailAddress());
return Response.created(accountURI).build();
} catch (WebApplicationException e2) {
dataManager.removeAccount(newAccount);
throw e2;
}
}
} finally {
dataManager.close();
}
}