if (person.getUsername() == null)
if (person.getUsername() == null || person.getUsername().length() == 0)
    public Integer run(InfoGrantOwner infoGrantOwner) throws FenixServiceException, ExcepcaoPersistencia {        ISuportePersistente sp = null;        IPersistentGrantOwner pGrantOwner = null;                try {            sp = PersistenceSupportFactory.getDefaultPersistenceSupport();        } catch (ExcepcaoPersistencia e) {            e.printStackTrace();            throw new FenixServiceException("Unable to dao factory!", e);        }        pGrantOwner = sp.getIPersistentGrantOwner();                IPerson person = null;        IGrantOwner grantOwner = null;        ICountry country = null;                if (infoGrantOwner.getPersonInfo().getInfoPais() != null) {            country = (ICountry) sp.getIPersistentCountry().readByOID(Country.class, infoGrantOwner.getPersonInfo().getInfoPais().getIdInternal());        } else {            //If the person country is undefined it is set to default "PORTUGUESA NATURAL DO CONTINENTE"             //In a not distance future this will not be needed since the coutry can never be null            country = (ICountry) sp.getIPersistentCountry().readCountryByNationality("PORTUGUESA NATURAL DO CONTINENTE");        }                //create or edit person information        if (infoGrantOwner.getPersonInfo().getIdInternal() == null) {            person = DomainFactory.makePerson(infoGrantOwner.getPersonInfo(), country);        }        else {            person = (IPerson) sp.getIPessoaPersistente().readByOID(Person.class, infoGrantOwner.getPersonInfo().getIdInternal());            person.edit(infoGrantOwner.getPersonInfo(), country);        }        //verify if person is new        if (person.getUsername() != null)            grantOwner = checkIfGrantOwnerExists(infoGrantOwner.getGrantOwnerNumber(), pGrantOwner);        //create or edit grantOwner information        if (grantOwner == null) {                        grantOwner = DomainFactory.makeGrantOwner();            IPersistentRole persistentRole = sp.getIPersistentRole();            person.getPersonRoles().add(persistentRole.readByRoleType(RoleType.GRANT_OWNER));        }        grantOwner = prepareGrantOwner(grantOwner, person, infoGrantOwner, pGrantOwner);        //Generate the GrantOwner's Person Username        if (person.getUsername() == null)            person.changeUsername(generateGrantOwnerPersonUsername(grantOwner.getNumber()), (List<IPerson>) sp.getIPessoaPersistente().readAll(Person.class));        return grantOwner.getIdInternal();    }