|
|
@@ -31,9 +31,15 @@ import static org.cobbzilla.wizard.resources.ResourceUtil.invalidEx; |
|
|
|
public class AccountContact implements Serializable { |
|
|
|
|
|
|
|
public static final int MAX_NICK_LENGTH = 100; |
|
|
|
public static final String[] UPDATE_EXCLUDE_FIELDS = {"uuid", "type", "info"}; |
|
|
|
|
|
|
|
public AccountContact(AccountContact other) { copy(this, other); } |
|
|
|
|
|
|
|
public AccountContact update(AccountContact other) { |
|
|
|
copy(this, other, null, UPDATE_EXCLUDE_FIELDS); |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
@Getter @Setter private String uuid = randomUUID().toString(); |
|
|
|
public boolean hasUuid () { return !empty(uuid); } |
|
|
|
public AccountContact initUuid () { uuid = randomUUID().toString(); return this; } |
|
|
@@ -78,11 +84,6 @@ public class AccountContact implements Serializable { |
|
|
|
final List<ConstraintViolationBean> errors = c.getType().validate(c.getInfo()); |
|
|
|
if (errors != null && !errors.isEmpty()) throw invalidEx(errors); |
|
|
|
|
|
|
|
// there must be at least one contact that can be used to unlock the network |
|
|
|
if (!c.requiredForNetworkUnlock() && (contacts == null || Arrays.stream(contacts).noneMatch(AccountContact::requiredForNetworkUnlock))) { |
|
|
|
throw invalidEx("err.requiredForNetworkUnlock.atLeastOneNetworkUnlockContactRequired"); |
|
|
|
} |
|
|
|
|
|
|
|
if (c.isAuthenticator()) { |
|
|
|
final AccountContact auth = findAuthenticator(contacts); |
|
|
|
if (auth != null && !auth.getUuid().equals(c.getUuid())) { |
|
|
|