class ZMSFileChangeLogStoreCommon {

    List<SignedDomain> getSignedDomainList(ZMSClient zmsClient, SignedDomains domainList) {

        List<SignedDomain> domains = new ArrayList<>();
        for (SignedDomain domain : domainList.getDomains()) {

            final String domainName = domain.getDomain().getName();

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("getSignedDomainList: fetching domain {}", domainName);
            }

            while (true) {
                try {
                    SignedDomains singleDomain = zmsClient.getSignedDomains(domainName,
                            null, null, null);

                    if (singleDomain != null && !singleDomain.getDomains().isEmpty()) {
                        domains.addAll(singleDomain.getDomains());
                    }

                    break;

                } catch (ZMSClientException ex) {

                    LOGGER.error("Error fetching domain {} from ZMS: {}", domainName,
                            ex.getMessage());

                    // if we get a rate limiting failure, we're going to sleep
                    // for a second and retry our operation again

                    if (ex.getCode() != ZMSClientException.TOO_MANY_REQUESTS) {
                        break;
                    }

                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException ignored) {
                    }
                }
            }
        }
        return domains;
    }

    public  ZMSFileChangeLogStoreCommon(final String rootDirectory);

}