Java Code Examples for com.google.common.collect.BiMap#isEmpty()

The following examples show how to use com.google.common.collect.BiMap#isEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ManagementServiceImpl.java    From usergrid with Apache License 2.0 5 votes vote down vote up
@Override
public boolean deleteAdminUser( UUID userId ) throws Exception {

    // make sure user is not attached to any orgs
    BiMap<UUID, String> orgMap = getOrganizationsForAdminUser(userId);
    if (!orgMap.isEmpty()) {
        // cannot delete admin user that is attached to orgs
        logger.info("Cannot delete admin user {} -- admin user is attached to {} orgs", userId, orgMap.size());
        return false;
    }

    EntityRef userRef = new SimpleEntityRef(User.ENTITY_TYPE, userId);

    // delete mongo password
    deleteUserMongoPassword(smf.getManagementAppId(), userRef);

    // delete user password
    deleteUserPassword(smf.getManagementAppId(), userRef);

    // delete user token
    deleteUserToken(smf.getManagementAppId(), userRef);

    // delete user entity
    emf.getEntityManager(smf.getManagementAppId()).delete(userRef);

    return true;
}