mirror of
https://github.com/google/nomulus.git
synced 2025-06-28 23:33:36 +02:00
Run automatic Java 8 conversion over codebase
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=171174380
This commit is contained in:
parent
44df5da771
commit
5edb7935ed
190 changed files with 2312 additions and 3096 deletions
|
@ -14,15 +14,12 @@
|
|||
|
||||
package google.registry.flows;
|
||||
|
||||
import static com.google.common.collect.Iterables.any;
|
||||
import static com.google.common.collect.Sets.difference;
|
||||
import static com.google.common.collect.Sets.intersection;
|
||||
import static google.registry.model.domain.fee.Fee.FEE_EXTENSION_URIS;
|
||||
import static google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension.getCommandExtensionUri;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.flows.EppException.CommandUseErrorException;
|
||||
|
@ -130,7 +127,13 @@ public final class ExtensionManager {
|
|||
ImmutableSet<Class<? extends CommandExtension>> implementedExtensions)
|
||||
throws UnsupportedRepeatedExtensionException {
|
||||
for (Class<? extends CommandExtension> implemented : implementedExtensions) {
|
||||
if (FluentIterable.from(suppliedExtensionInstances).filter(implemented).size() > 1) {
|
||||
if ((int)
|
||||
suppliedExtensionInstances
|
||||
.stream()
|
||||
.filter(implemented::isInstance)
|
||||
.map(implemented::cast)
|
||||
.count()
|
||||
> 1) {
|
||||
throw new UnsupportedRepeatedExtensionException();
|
||||
}
|
||||
}
|
||||
|
@ -143,13 +146,9 @@ public final class ExtensionManager {
|
|||
ImmutableSet.Builder<Class<? extends CommandExtension>> unimplementedExtensionsBuilder =
|
||||
new ImmutableSet.Builder<>();
|
||||
for (final CommandExtension instance : suppliedExtensionInstances) {
|
||||
if (!any(
|
||||
implementedExtensionClasses,
|
||||
new Predicate<Class<? extends CommandExtension>>() {
|
||||
@Override
|
||||
public boolean apply(Class<? extends CommandExtension> implementedExtensionClass) {
|
||||
return implementedExtensionClass.isInstance(instance);
|
||||
}})) {
|
||||
if (implementedExtensionClasses
|
||||
.stream()
|
||||
.noneMatch(implementedExtensionClass -> implementedExtensionClass.isInstance(instance))) {
|
||||
unimplementedExtensionsBuilder.add(instance.getClass());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import com.google.common.base.Optional;
|
|||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Work;
|
||||
|
@ -178,29 +177,35 @@ public final class ResourceFlowUtils {
|
|||
final Class<R> resourceClass,
|
||||
final Function<DomainBase, ImmutableSet<?>> getPotentialReferences) throws EppException {
|
||||
// Enter a transactionless context briefly.
|
||||
EppException failfastException = ofy().doTransactionless(new Work<EppException>() {
|
||||
@Override
|
||||
public EppException run() {
|
||||
final ForeignKeyIndex<R> fki = ForeignKeyIndex.load(resourceClass, targetId, now);
|
||||
if (fki == null) {
|
||||
return new ResourceDoesNotExistException(resourceClass, targetId);
|
||||
}
|
||||
// Query for the first few linked domains, and if found, actually load them. The query is
|
||||
// eventually consistent and so might be very stale, but the direct load will not be stale,
|
||||
// just non-transactional. If we find at least one actual reference then we can reliably
|
||||
// fail. If we don't find any, we can't trust the query and need to do the full mapreduce.
|
||||
Iterable<Key<DomainBase>> keys =
|
||||
queryForLinkedDomains(fki.getResourceKey(), now).limit(FAILFAST_CHECK_COUNT).keys();
|
||||
Predicate<DomainBase> predicate = new Predicate<DomainBase>() {
|
||||
@Override
|
||||
public boolean apply(DomainBase domain) {
|
||||
return getPotentialReferences.apply(domain).contains(fki.getResourceKey());
|
||||
}};
|
||||
return Iterables.any(ofy().load().keys(keys).values(), predicate)
|
||||
? new ResourceToDeleteIsReferencedException()
|
||||
: null;
|
||||
}
|
||||
});
|
||||
EppException failfastException =
|
||||
ofy()
|
||||
.doTransactionless(
|
||||
new Work<EppException>() {
|
||||
@Override
|
||||
public EppException run() {
|
||||
final ForeignKeyIndex<R> fki =
|
||||
ForeignKeyIndex.load(resourceClass, targetId, now);
|
||||
if (fki == null) {
|
||||
return new ResourceDoesNotExistException(resourceClass, targetId);
|
||||
}
|
||||
/* Query for the first few linked domains, and if found, actually load them. The
|
||||
* query is eventually consistent and so might be very stale, but the direct
|
||||
* load will not be stale, just non-transactional. If we find at least one
|
||||
* actual reference then we can reliably fail. If we don't find any, we can't
|
||||
* trust the query and need to do the full mapreduce.
|
||||
*/
|
||||
Iterable<Key<DomainBase>> keys =
|
||||
queryForLinkedDomains(fki.getResourceKey(), now)
|
||||
.limit(FAILFAST_CHECK_COUNT)
|
||||
.keys();
|
||||
Predicate<DomainBase> predicate =
|
||||
domain ->
|
||||
getPotentialReferences.apply(domain).contains(fki.getResourceKey());
|
||||
return ofy().load().keys(keys).values().stream().anyMatch(predicate)
|
||||
? new ResourceToDeleteIsReferencedException()
|
||||
: null;
|
||||
}
|
||||
});
|
||||
if (failfastException != null) {
|
||||
throw failfastException;
|
||||
}
|
||||
|
@ -339,13 +344,8 @@ public final class ResourceFlowUtils {
|
|||
return;
|
||||
}
|
||||
// The roid should match one of the contacts.
|
||||
Optional<Key<ContactResource>> foundContact = tryFind(
|
||||
domain.getReferencedContacts(),
|
||||
new Predicate<Key<ContactResource>>() {
|
||||
@Override
|
||||
public boolean apply(Key<ContactResource> key) {
|
||||
return key.getName().equals(authRepoId);
|
||||
}});
|
||||
Optional<Key<ContactResource>> foundContact =
|
||||
tryFind(domain.getReferencedContacts(), key -> key.getName().equals(authRepoId));
|
||||
if (!foundContact.isPresent()) {
|
||||
throw new BadAuthInfoForResourceException();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import google.registry.model.eppcommon.Trid;
|
|||
import google.registry.model.host.HostResource;
|
||||
import google.registry.util.FormattingLogger;
|
||||
import google.registry.util.Retrier;
|
||||
import java.util.concurrent.Callable;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -107,11 +106,11 @@ public final class AsyncFlowEnqueuer {
|
|||
* enqueuing a task.
|
||||
*/
|
||||
private void addTaskToQueueWithRetry(final Queue queue, final TaskOptions task) {
|
||||
retrier.callWithRetry(new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
queue.add(task);
|
||||
return null;
|
||||
}}, TransientFailureException.class);
|
||||
retrier.callWithRetry(
|
||||
() -> {
|
||||
queue.add(task);
|
||||
return null;
|
||||
},
|
||||
TransientFailureException.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import static google.registry.flows.ResourceFlowUtils.verifyResourceOwnership;
|
|||
import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
|
@ -69,13 +68,6 @@ public final class ContactDeleteFlow implements TransactionalFlow {
|
|||
StatusValue.PENDING_DELETE,
|
||||
StatusValue.SERVER_DELETE_PROHIBITED);
|
||||
|
||||
private static final Function<DomainBase, ImmutableSet<?>> GET_REFERENCED_CONTACTS =
|
||||
new Function<DomainBase, ImmutableSet<?>>() {
|
||||
@Override
|
||||
public ImmutableSet<?> apply(DomainBase domain) {
|
||||
return domain.getReferencedContacts();
|
||||
}};
|
||||
|
||||
@Inject ExtensionManager extensionManager;
|
||||
@Inject @ClientId String clientId;
|
||||
@Inject @TargetId String targetId;
|
||||
|
@ -93,7 +85,7 @@ public final class ContactDeleteFlow implements TransactionalFlow {
|
|||
extensionManager.validate();
|
||||
validateClientIsLoggedIn(clientId);
|
||||
DateTime now = ofy().getTransactionTime();
|
||||
failfastForAsyncDelete(targetId, now, ContactResource.class, GET_REFERENCED_CONTACTS);
|
||||
failfastForAsyncDelete(targetId, now, ContactResource.class, DomainBase::getReferencedContacts);
|
||||
ContactResource existingContact = loadAndVerifyExistence(ContactResource.class, targetId, now);
|
||||
verifyNoDisallowedStatuses(existingContact, DISALLOWED_STATUSES);
|
||||
verifyOptionalAuthInfo(authInfo, existingContact);
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
package google.registry.flows.domain;
|
||||
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static com.google.common.collect.MoreCollectors.onlyElement;
|
||||
import static google.registry.flows.FlowUtils.validateClientIsLoggedIn;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyResourceDoesNotExist;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.cloneAndLinkReferences;
|
||||
|
@ -39,6 +38,7 @@ import static google.registry.util.DateTimeUtils.leapSafeAddYears;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import com.googlecode.objectify.Key;
|
||||
import dagger.Lazy;
|
||||
|
@ -212,7 +212,10 @@ public class DomainAllocateFlow implements TransactionalFlow {
|
|||
|
||||
private <T extends ImmutableObject> T getOnly(
|
||||
Iterable<? extends ImmutableObject> objects, Class<T> clazz) {
|
||||
return getOnlyElement(filter(objects, clazz));
|
||||
return Streams.stream(objects)
|
||||
.filter(clazz::isInstance)
|
||||
.map(clazz::cast)
|
||||
.collect(onlyElement());
|
||||
}
|
||||
|
||||
private void verifyIsSuperuser() throws OnlySuperuserCanAllocateException {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.flows.domain;
|
||||
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static google.registry.flows.FlowUtils.persistEntityChanges;
|
||||
import static google.registry.flows.FlowUtils.validateClientIsLoggedIn;
|
||||
|
@ -43,8 +44,6 @@ import static google.registry.model.index.DomainApplicationIndex.loadActiveAppli
|
|||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.label.ReservedList.matchesAnchorTenantReservation;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
|
@ -94,7 +93,6 @@ import google.registry.model.registry.Registry;
|
|||
import google.registry.model.registry.Registry.TldState;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
|
||||
import google.registry.model.smd.AbstractSignedMark;
|
||||
import google.registry.model.smd.EncodedSignedMark;
|
||||
import javax.inject.Inject;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -244,32 +242,31 @@ public final class DomainApplicationCreateFlow implements TransactionalFlow {
|
|||
.setDomainName(domainName)
|
||||
.setYears(years)
|
||||
.build());
|
||||
DomainApplication newApplication = new DomainApplication.Builder()
|
||||
.setCreationTrid(trid)
|
||||
.setCreationClientId(clientId)
|
||||
.setPersistedCurrentSponsorClientId(clientId)
|
||||
.setRepoId(createDomainRepoId(ObjectifyService.allocateId(), tld))
|
||||
.setLaunchNotice(launchCreate == null ? null : launchCreate.getNotice())
|
||||
.setIdnTableName(idnTableName)
|
||||
.setPhase(launchCreate.getPhase())
|
||||
.setPeriod(command.getPeriod())
|
||||
.setApplicationStatus(ApplicationStatus.VALIDATED)
|
||||
.addStatusValue(StatusValue.PENDING_CREATE)
|
||||
.setDsData(secDnsCreate == null ? null : secDnsCreate.getDsData())
|
||||
.setRegistrant(command.getRegistrant())
|
||||
.setAuthInfo(command.getAuthInfo())
|
||||
.setFullyQualifiedDomainName(targetId)
|
||||
.setNameservers(command.getNameservers())
|
||||
.setContacts(command.getContacts())
|
||||
.setEncodedSignedMarks(FluentIterable
|
||||
.from(launchCreate.getSignedMarks())
|
||||
.transform(new Function<AbstractSignedMark, EncodedSignedMark>() {
|
||||
@Override
|
||||
public EncodedSignedMark apply(AbstractSignedMark abstractSignedMark) {
|
||||
return (EncodedSignedMark) abstractSignedMark;
|
||||
}})
|
||||
.toList())
|
||||
.build();
|
||||
DomainApplication newApplication =
|
||||
new DomainApplication.Builder()
|
||||
.setCreationTrid(trid)
|
||||
.setCreationClientId(clientId)
|
||||
.setPersistedCurrentSponsorClientId(clientId)
|
||||
.setRepoId(createDomainRepoId(ObjectifyService.allocateId(), tld))
|
||||
.setLaunchNotice(launchCreate == null ? null : launchCreate.getNotice())
|
||||
.setIdnTableName(idnTableName)
|
||||
.setPhase(launchCreate.getPhase())
|
||||
.setPeriod(command.getPeriod())
|
||||
.setApplicationStatus(ApplicationStatus.VALIDATED)
|
||||
.addStatusValue(StatusValue.PENDING_CREATE)
|
||||
.setDsData(secDnsCreate == null ? null : secDnsCreate.getDsData())
|
||||
.setRegistrant(command.getRegistrant())
|
||||
.setAuthInfo(command.getAuthInfo())
|
||||
.setFullyQualifiedDomainName(targetId)
|
||||
.setNameservers(command.getNameservers())
|
||||
.setContacts(command.getContacts())
|
||||
.setEncodedSignedMarks(
|
||||
launchCreate
|
||||
.getSignedMarks()
|
||||
.stream()
|
||||
.map(abstractSignedMark -> (EncodedSignedMark) abstractSignedMark)
|
||||
.collect(toImmutableList()))
|
||||
.build();
|
||||
HistoryEntry historyEntry =
|
||||
buildHistoryEntry(newApplication.getRepoId(), command.getPeriod(), now);
|
||||
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
|
||||
|
|
|
@ -28,8 +28,6 @@ import static google.registry.model.registry.label.ReservationType.getTypeOfHigh
|
|||
import static google.registry.pricing.PricingEngineProxy.isDomainPremium;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -46,7 +44,6 @@ import google.registry.flows.annotations.ReportingSpec;
|
|||
import google.registry.flows.custom.DomainCheckFlowCustomLogic;
|
||||
import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseParameters;
|
||||
import google.registry.flows.custom.DomainCheckFlowCustomLogic.BeforeResponseReturnData;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.DomainCommand.Check;
|
||||
import google.registry.model.domain.DomainResource;
|
||||
import google.registry.model.domain.fee.FeeCheckCommandExtension;
|
||||
|
@ -176,12 +173,9 @@ public final class DomainCheckFlow implements Flow {
|
|||
}
|
||||
Registry registry = Registry.get(domainName.parent().toString());
|
||||
if (PENDING_ALLOCATION_TLD_STATES.contains(registry.getTldState(now))
|
||||
&& FluentIterable.from(loadActiveApplicationsByDomainName(domainName.toString(), now))
|
||||
.anyMatch(new Predicate<DomainApplication>() {
|
||||
@Override
|
||||
public boolean apply(DomainApplication input) {
|
||||
return !input.getApplicationStatus().isFinalStatus();
|
||||
}})) {
|
||||
&& loadActiveApplicationsByDomainName(domainName.toString(), now)
|
||||
.stream()
|
||||
.anyMatch(input -> !input.getApplicationStatus().isFinalStatus())) {
|
||||
return Optional.of("Pending allocation");
|
||||
}
|
||||
ImmutableSet<ReservationType> reservationTypes = getReservationTypes(domainName);
|
||||
|
|
|
@ -41,13 +41,12 @@ import static google.registry.util.DomainNameUtils.ACE_PREFIX;
|
|||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.EppException;
|
||||
|
@ -940,24 +939,22 @@ public class DomainFlowUtils {
|
|||
.order("modificationTime")
|
||||
.list();
|
||||
Optional<HistoryEntry> entryToCancel =
|
||||
FluentIterable.from(recentHistoryEntries)
|
||||
.filter(
|
||||
new Predicate<HistoryEntry>() {
|
||||
@Override
|
||||
public boolean apply(HistoryEntry historyEntry) {
|
||||
// Look for add and renew transaction records that have yet to be reported
|
||||
for (DomainTransactionRecord record :
|
||||
historyEntry.getDomainTransactionRecords()) {
|
||||
if (cancelableFields.contains(record.getReportField())
|
||||
&& record.getReportingTime().isAfter(now)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
})
|
||||
// We only want to cancel out the most recent add or renewal
|
||||
.last();
|
||||
Optional.fromJavaUtil(
|
||||
Streams.findLast(
|
||||
recentHistoryEntries
|
||||
.stream()
|
||||
.filter(
|
||||
historyEntry -> {
|
||||
// Look for add and renew transaction records that have yet to be reported
|
||||
for (DomainTransactionRecord record :
|
||||
historyEntry.getDomainTransactionRecords()) {
|
||||
if (cancelableFields.contains(record.getReportField())
|
||||
&& record.getReportingTime().isAfter(now)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})));
|
||||
ImmutableSet.Builder<DomainTransactionRecord> recordsBuilder = new ImmutableSet.Builder<>();
|
||||
if (entryToCancel.isPresent()) {
|
||||
for (DomainTransactionRecord record : entryToCancel.get().getDomainTransactionRecords()) {
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
package google.registry.flows.domain;
|
||||
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static com.google.common.collect.MoreCollectors.onlyElement;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
@ -61,14 +61,29 @@ public final class DomainTransferUtils {
|
|||
if (transferPeriod.getValue() != 0) {
|
||||
// Unless superuser sets period to 0, add a transfer billing event.
|
||||
transferDataBuilder.setServerApproveBillingEvent(
|
||||
Key.create(getOnlyElement(filter(serverApproveEntities, BillingEvent.OneTime.class))));
|
||||
Key.create(
|
||||
serverApproveEntities
|
||||
.stream()
|
||||
.filter(BillingEvent.OneTime.class::isInstance)
|
||||
.map(BillingEvent.OneTime.class::cast)
|
||||
.collect(onlyElement())));
|
||||
}
|
||||
return transferDataBuilder
|
||||
.setTransferStatus(TransferStatus.PENDING)
|
||||
.setServerApproveAutorenewEvent(Key.create(
|
||||
getOnlyElement(filter(serverApproveEntities, BillingEvent.Recurring.class))))
|
||||
.setServerApproveAutorenewPollMessage(Key.create(
|
||||
getOnlyElement(filter(serverApproveEntities, PollMessage.Autorenew.class))))
|
||||
.setServerApproveAutorenewEvent(
|
||||
Key.create(
|
||||
serverApproveEntities
|
||||
.stream()
|
||||
.filter(BillingEvent.Recurring.class::isInstance)
|
||||
.map(BillingEvent.Recurring.class::cast)
|
||||
.collect(onlyElement())))
|
||||
.setServerApproveAutorenewPollMessage(
|
||||
Key.create(
|
||||
serverApproveEntities
|
||||
.stream()
|
||||
.filter(PollMessage.Autorenew.class::isInstance)
|
||||
.map(PollMessage.Autorenew.class::cast)
|
||||
.collect(onlyElement())))
|
||||
.setServerApproveEntities(serverApproveEntityKeys.build())
|
||||
.setTransferPeriod(transferPeriod)
|
||||
.build();
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
package google.registry.flows.domain;
|
||||
|
||||
import static com.google.common.collect.Iterables.concat;
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static google.registry.util.CollectionUtils.nullToEmpty;
|
||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
@ -26,6 +26,7 @@ import google.registry.model.domain.fee.BaseFee;
|
|||
import google.registry.model.domain.fee.BaseFee.FeeType;
|
||||
import google.registry.model.domain.fee.Credit;
|
||||
import google.registry.model.domain.fee.Fee;
|
||||
import java.util.stream.Stream;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
|
||||
|
@ -102,7 +103,7 @@ public class FeesAndCredits extends ImmutableObject implements Buildable {
|
|||
|
||||
/** Returns all fees and credits for the event. */
|
||||
public ImmutableList<BaseFee> getFeesAndCredits() {
|
||||
return ImmutableList.copyOf(concat(getFees(), getCredits()));
|
||||
return Stream.concat(getFees().stream(), getCredits().stream()).collect(toImmutableList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,6 @@ import static google.registry.flows.host.HostFlowUtils.validateHostName;
|
|||
import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.EppException;
|
||||
|
@ -71,13 +70,6 @@ public final class HostDeleteFlow implements TransactionalFlow {
|
|||
StatusValue.PENDING_DELETE,
|
||||
StatusValue.SERVER_DELETE_PROHIBITED);
|
||||
|
||||
private static final Function<DomainBase, ImmutableSet<?>> GET_NAMESERVERS =
|
||||
new Function<DomainBase, ImmutableSet<?>>() {
|
||||
@Override
|
||||
public ImmutableSet<?> apply(DomainBase domain) {
|
||||
return domain.getNameservers();
|
||||
}};
|
||||
|
||||
@Inject ExtensionManager extensionManager;
|
||||
@Inject @ClientId String clientId;
|
||||
@Inject @TargetId String targetId;
|
||||
|
@ -95,7 +87,7 @@ public final class HostDeleteFlow implements TransactionalFlow {
|
|||
validateClientIsLoggedIn(clientId);
|
||||
DateTime now = ofy().getTransactionTime();
|
||||
validateHostName(targetId);
|
||||
failfastForAsyncDelete(targetId, now, HostResource.class, GET_NAMESERVERS);
|
||||
failfastForAsyncDelete(targetId, now, HostResource.class, DomainBase::getNameservers);
|
||||
HostResource existingHost = loadAndVerifyExistence(HostResource.class, targetId, now);
|
||||
verifyNoDisallowedStatuses(existingHost, DISALLOWED_STATUSES);
|
||||
if (!isSuperuser) {
|
||||
|
|
|
@ -18,11 +18,10 @@ import static google.registry.model.EppResourceUtils.isActive;
|
|||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.model.registry.Registries.findTldForName;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.AuthorizationErrorException;
|
||||
|
@ -98,8 +97,12 @@ public class HostFlowUtils {
|
|||
return Optional.absent();
|
||||
}
|
||||
// This is a subordinate host
|
||||
String domainName = Joiner.on('.').join(Iterables.skip(
|
||||
hostName.parts(), hostName.parts().size() - (tld.get().parts().size() + 1)));
|
||||
String domainName =
|
||||
hostName
|
||||
.parts()
|
||||
.stream()
|
||||
.skip(hostName.parts().size() - (tld.get().parts().size() + 1))
|
||||
.collect(joining("."));
|
||||
DomainResource superordinateDomain = loadByForeignKey(DomainResource.class, domainName, now);
|
||||
if (superordinateDomain == null || !isActive(superordinateDomain, now)) {
|
||||
throw new SuperordinateDomainDoesNotExistException(domainName);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue