Enforcing uniqueness?

11 views
Skip to first unread message

Rick Mann

unread,
Oct 12, 2016, 11:44:04 PM10/12/16
to Baratine
Okay, my Auction-derived app is starting to work. I can register a new user. Now I'd like to add the ability to throw an exception in UserImpl.create if another User already exists with the supplied login. But in my UserImpl class, I don't directly have access to all the existing users.

My AbstractSession has a "UserAbstractVault<User> mUsers", but it seems best to put the logic down in UserImpl, or at least in the UserAbstractVault, because that publishes the /User Service. But it's not clear to me how to do that enforcement.

https://github.com/JetForMe/hoa

Thanks,

--
Rick Mann
rm...@latencyzero.com


Alex Rojkov

unread,
Oct 13, 2016, 12:23:18 AM10/13/16
to Rick Mann, Baratine
In a session I'd have a Set<String> of logins that are currently
trying to register.
Upon user finishing typing in the login I'd pass that login to
session's reserve() method which should do the following
– check that the login is not in the Set<String>
– check that the login is not associated with any User by calling the
findByLogin method on a vault.
– put the login into the Set<String> if above passes.

Alex
> --
> You received this message because you are subscribed to the Google Groups "Baratine" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to baratine-io...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages