Package io.fathom.cloud.protobuf.DnsModel

Examples of io.fathom.cloud.protobuf.DnsModel.DnsSuffixData


        while (true) {
            if (Strings.isNullOrEmpty(domain)) {
                return null;
            }

            DnsSuffixData data = store.find(domain);
            if (data != null) {
                return data;
            }

            int dotIndex = domain.indexOf('.');
View Full Code Here


        // TODO: Caching

        NamedItemCollection<DnsSuffixData> store = repository.getDnsSuffixes();
        domain = domain.toLowerCase();

        DnsSuffixData data = store.find(domain);
        if (data != null) {
            return data.hasTld() && data.getTld();
        }

        return false;

        // tlds.add("com");
View Full Code Here

        while (tld.startsWith(".")) {
            tld = tld.substring(1);
        }
        tld = tld.toLowerCase();

        DnsSuffixData data = store.find(tld);
        if (data != null) {
            if (!data.getTld()) {
                throw new IllegalArgumentException("Suffix is not marked as TLD: " + tld);
            }
            return data;
        }
View Full Code Here

        return store.create(b);
    }

    public DnsSuffixData deleteTld(String tld) throws CloudException {
        NamedItemCollection<DnsSuffixData> store = repository.getDnsSuffixes();
        DnsSuffixData ret = store.find(tld);

        store.delete(tld);

        return ret;
    }
View Full Code Here

    @Override
    public DnsZone createZone(Project project, DnsZoneSpec spec) throws CloudException, DuplicateValueException {
        String zoneName = spec.name;
        zoneName = zoneName.toLowerCase();

        DnsSuffixData suffixData = findMaximalSuffix(zoneName);
        if (suffixData == null) {
            throw new IllegalArgumentException("Unsupported suffix: " + zoneName);
        }

        if (suffixData.getTld() && !canCreateInTld) {
            throw new IllegalArgumentException("Creation of domains blocked (under TLDs)");
        }

        String backendKey = null;
        String zone;

        // TODO: Is there any point in allowing a shared domain but then
        // blocking creation under it?
        // if (suffixData.getSharedDomain() && !canCreateInShared) {
        // throw new
        // IllegalArgumentException("Creation of domains blocked (under shared domains)");
        // }

        String suffix = suffixData.getKey();
        String prefix = zoneName.substring(0, zoneName.length() - suffix.length());
        prefix = CharMatcher.is('.').trimTrailingFrom(prefix);

        if (prefix.isEmpty()) {
            throw new IllegalArgumentException("Unsupported domain (TLD or marked as shared): " + zoneName);
        } else {
            int dotIndex = prefix.indexOf('.');
            String prefixTail;
            if (dotIndex != -1) {
                prefixTail = prefix.substring(dotIndex + 1);
            } else {
                prefixTail = prefix;
            }

            // If this is a shared domain, try to assign it to the user
            if (suffixData.getSharedDomain()) {
                NamedItemCollection<DnsSuffixData> store = repository.getSharedSubdomains(suffixData.getKey());
                DnsSuffixData allocation = store.find(prefixTail);
                if (allocation == null) {
                    DnsSuffixData.Builder b = DnsSuffixData.newBuilder();
                    b.setKey(prefixTail);
                    b.setOwnerProject(project.getId());

                    allocation = store.create(b);
                } else {
                    if (allocation.getOwnerProject() != project.getId()) {
                        // Already assigned to someone else
                        throw new DuplicateValueException();
                    }
                }
            }
View Full Code Here

TOP

Related Classes of io.fathom.cloud.protobuf.DnsModel.DnsSuffixData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.