@POST
	@Consumes("application/json") // We expect the newUser to be passed as json info.
	public CreateUserResult createUser( CreateUserCommand createUserCommand ) {
		logger.info("Entered createUser()");
		// See if we have a record already for the given email.
		User loadedUser = null ;
		try {
			loadedUser = txFindUser(createUserCommand.getEmail());
		} catch (DuplicateUserEmailDetected e) {
			// We'll use the error-level of logging as a flag to ops that there's interventions needed.
			logger.error("We got multiple user accounts with this email, can't continue processing this request.", e);
		}
		
		// Already got someone with this email?
		if( loadedUser != null ) {
			// Credentials checks.
			boolean checksOut = loadedUser.getPassword().equals(createUserCommand.getPassword());
			
			CreateUserResult exists = new CreateUserResult();
			// If the credentials are good, return our result.
			if( checksOut ) {
				long elapsed = new Date().getTime() - loadedUser.getLastEmailCheck().getTime();
				
				double daysElapsed = (elapsed/1000.0) / 60 / 60 / 24 ;
				if( !loadedUser.getConfirmed() && daysElapsed > UNCONFIRMED_MAX_DAYS ) {
					exists.setResultCode(CreateUserResult.Code.EXISTS_UNCONFIRMED_EMAIL_DUE);
				} else {
					exists.setResultCode(CreateUserResult.Code.EXISTS_GOOD_CREDS);
				}
				
			} else {
				exists.setResultCode(CreateUserResult.Code.EXISTS_BAD_CREDS);
			}
			
			return exists ;
		} 
		
		// Do a validation check before attempting a creation.
		ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
		Validator validator = factory.getValidator();
		
		// The command knows how to build user from received parameters.
		User newUser = createUserCommand.buildUser();
		
		// We only validate on email and password for this operation.
		HashSet<ConstraintViolation<User>> constraintViolations = new HashSet<ConstraintViolation<User>>();
		constraintViolations.addAll(validator.validateProperty(newUser, "email"));
		constraintViolations.addAll(validator.validateProperty(newUser, "password"));

		// Builds the user response if we failed to respect constraints. 
		if( constraintViolations.size() > 0 ) {
			CreateUserResult createUserResult = new CreateUserResult();
			createUserResult.setResultCode(CreateUserResult.Code.VALIDATION_FAILED);
			
			List<ValidationResult> results = new ArrayList<ValidationResult>(constraintViolations.size());
			for( ConstraintViolation<User> current : constraintViolations ) {
				ValidationResult validationResult = new ValidationResult();
				// FIXME: need to check how to extract attribute name, JSR docs fuzzy on this subject.
				validationResult.setFieldName(current.getPropertyPath().toString());
				validationResult.setMessage(current.getMessage());
				results.add(validationResult);
			}
			createUserResult.setValidationResults(results);
			
			return createUserResult ;
		}
		
		// User doesn't exist, validation was good, create the user.
		txSaveUser(newUser);

		// Prepare answer for our clients.
		CreateUserResult createUserResult = new CreateUserResult();
		createUserResult.setResultCode(CreateUserResult.Code.USER_CREATED);
		
		return createUserResult;
	}