public static boolean canSetAsCurrent(ModelKey accountRef, ModelKey parentAccountRef) throws IllegalArgumentException {
if(accountRef == null || !accountRef.isSet()) throw new IllegalArgumentException("Null or unset account ref");
final AdminContext ac = getAdminContextCmd().getAdminContext();
final AdminRole role = ac.getUserRole();
final SmbizEntityType targetAccountType = (SmbizEntityType) accountRef.getEntityType();
final ModelKey userAcntRef = ac.getUserAccount().getKey();
assert userAcntRef != null;
switch(targetAccountType) {
case ASP:
case ISP:
return (role == AdminRole.ASP);
case MERCHANT:
switch(role) {
case ASP:
return true;
case ISP:
// verify the user is parent to the given merchant
return userAcntRef.equals(parentAccountRef);
}
}
// default
return false;
}