class FileConnection implements ObjectStoreConnection {

    @Override
    public List<String> lookupDomainByRole(String roleMember, String roleName) {

        boolean memberPresent = (roleMember != null && !roleMember.isEmpty());
        boolean rolePresent = (roleName != null && !roleName.isEmpty());

        // first get the list of domains

        Set<String> uniqueDomains = new HashSet<>();
        List<String> domainNames = listDomains(null, 0);
        for (String domainName : domainNames) {
            DomainStruct domainStruct = getDomainStruct(domainName);
            if (domainStruct == null) {
                continue;
            }
            if (rolePresent || memberPresent) {
                if (rolePresent) {
                    Role role = getRoleObject(domainStruct, roleName);
                    if (role == null) {
                        continue;
                    }
                    if (memberPresent) {
                        List<RoleMember> roleMembers = role.getRoleMembers();
                        if (roleMembers != null) {
                            for (RoleMember member: roleMembers) {
                                if (member.getMemberName().equalsIgnoreCase(roleMember)) {
                                    uniqueDomains.add(domainName);
                                    break;
                                }
                            }
                        }
                    } else {
                        uniqueDomains.add(domainName);
                    }
                } else {
                    HashMap<String, Role> roles = domainStruct.getRoles();
                    if (roles != null) {
                        for (Role role : roles.values()) {
                            boolean roleMemberFound = false;
                            if (role.getRoleMembers() != null) {
                                for (RoleMember member: role.getRoleMembers()) {
                                    if (member.getMemberName().equals(roleMember)) {
                                        uniqueDomains.add(domainName);
                                        roleMemberFound = true;
                                        break;
                                    }
                                }
                                if (roleMemberFound) {
                                    break;
                                }
                            }
                        }
                    }

                }
            } else {
                uniqueDomains.add(domainName);
            }
        }

        List<String> matchedDomains = new ArrayList<>(uniqueDomains);
        Collections.sort(matchedDomains);
        return matchedDomains;
    }

    public  FileConnection(File rootDir, File quotaDir);

}