public MaxDomainMessageCount(Domain domain, Long value) { this.domain = domain.asString(); this.value = value; }
/** * Use this simple constructor to create a new Domain. * * @param name * the name of the Domain */ public JPADomain(Domain name) { this.name = name.asString(); }
/** * Use this simple constructor to create a new RecipientRewriteTable. * * @param user * , domain and their associated targetAddress */ public JPARecipientRewrite(String user, Domain domain, String targetAddress) { this.user = user; this.domain = domain.asString(); this.targetAddress = targetAddress; }
@Override public String asAggregateKey() { return PREFIX + SEPARATOR + domain.asString(); }
/** * Returns the host part. * * @return the host part of this email address. If the host is of the * dotNum form (e.g. [yyy.yyy.yyy.yyy]), then strip the braces first. * @deprecated use {@link #getDomain()}, whose name was changed to * align with RFC2822 3.4.1. addr-spec specification */ @Deprecated public String getHost() { return domain.asString(); }
/** * Returns the host part. * * @return the host part of this email address. If the host is of the * dotNum form (e.g. [yyy.yyy.yyy.yyy]), then strip the braces first. * @deprecated use {@link #getDomain()}, whose name was changed to * align with RFC2822 3.4.1. addr-spec specification */ @Deprecated public String getHost() { return domain.asString(); }
public String asString() { return domainPart.map(domain -> localPart + "@" + domain.asString()) .orElse(localPart); }
private boolean containsDomainInternal(Domain domain, EntityManager entityManager) { try { return entityManager.createNamedQuery("findDomainByName") .setParameter("name", domain.asString()) .getSingleResult() != null; } catch (NoResultException e) { LOGGER.debug("No domain found", e); return false; } }
@Override public Collection<String> getMailServers(Domain host) { try { return dns.findMXRecords(host.asString()); } catch (TemporaryResolutionException e) { // TODO: We only do this to not break backward compatiblity. Should // fixed later return ImmutableSet.of(); } }
public Optional<QuotaSize> getDomainMaxStorage(Domain domain) { EntityManager entityManager = entityManagerFactory.createEntityManager(); MaxDomainStorage storedValue = entityManager.find(MaxDomainStorage.class, domain.asString()); if (storedValue == null) { return Optional.empty(); } return longToQuotaSize(storedValue.getValue()); }
public Optional<QuotaCount> getDomainMaxMessage(Domain domain) { EntityManager entityManager = entityManagerFactory.createEntityManager(); MaxDomainMessageCount storedValue = entityManager.find(MaxDomainMessageCount.class, domain.asString()); if (storedValue == null) { return Optional.empty(); } return longToQuotaCount(storedValue.getValue()); }
@Override public void serialize(QuotaRoot value, JsonGenerator generator, SerializerProvider serializers) throws IOException, JsonProcessingException { generator.writeStartObject(); generator.writeStringField(QUOTA_ROOT_VALUE_FIELD, value.getValue()); value.getDomain() .ifPresent(Throwing.consumer(domain -> generator.writeStringField(QUOTA_ROOT_DOMAIN_FIELD, domain.asString()))); generator.writeEndObject(); }
public void setMaxMessage(Domain domain, QuotaCount maxMessageCount) { session.execute(setMaxMessageStatement.bind(domain.asString(), QuotaCodec.quotaValueToLong(maxMessageCount))); }
@Override protected boolean containsDomainInternal(Domain domain) throws DomainListException { return executor.executeSingleRow(readStatement.bind() .setString(DOMAIN, domain.asString())) .join() .isPresent(); }
private MaxDomainMessageCount getMaxDomainMessageEntity(EntityManager entityManager, Domain domain, Optional<QuotaCount> maxMessageQuota) { MaxDomainMessageCount storedValue = entityManager.find(MaxDomainMessageCount.class, domain.asString()); Long value = quotaValueToLong(maxMessageQuota); if (storedValue == null) { return new MaxDomainMessageCount(domain, value); } storedValue.setValue(value); return storedValue; }
private MaxDomainStorage getMaxDomainStorageEntity(EntityManager entityManager, Domain domain, Optional<QuotaSize> maxStorageQuota) { MaxDomainStorage storedValue = entityManager.find(MaxDomainStorage.class, domain.asString()); Long value = quotaValueToLong(maxStorageQuota); if (storedValue == null) { return new MaxDomainStorage(domain, value); } storedValue.setValue(value); return storedValue; }
public Optional<QuotaCount> getMaxMessage(Domain domain) { ResultSet resultSet = session.execute(getMaxMessageStatement.bind(domain.asString())); if (resultSet.isExhausted()) { return Optional.empty(); } Long maxMessages = resultSet.one().get(CassandraDomainMaxQuota.MESSAGE_COUNT, Long.class); return QuotaCodec.longToQuotaCount(maxMessages); }
public Optional<QuotaSize> getMaxStorage(Domain domain) { ResultSet resultSet = session.execute(getMaxStorageStatement.bind(domain.asString())); if (resultSet.isExhausted()) { return Optional.empty(); } Long maxStorage = resultSet.one().get(CassandraDomainMaxQuota.STORAGE, Long.class); return QuotaCodec.longToQuotaSize(maxStorage); }
@Override public void addDomain(Domain domain) throws DomainListException { boolean executed = executor.executeReturnApplied(insertStatement.bind() .setString(DOMAIN, domain.asString())) .join(); if (!executed) { throw new DomainListException(domain.name() + " already exists."); } }
@Override public void removeDomain(Domain domain) throws DomainListException { boolean executed = executor.executeReturnApplied(removeStatement.bind() .setString(DOMAIN, domain.asString())) .join(); if (!executed) { throw new DomainListException(domain.name() + " was not found"); } }