mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
mv com/google/domain/registry google/registry
This change renames directories in preparation for the great package rename. The repository is now in a broken state because the code itself hasn't been updated. However this should ensure that git correctly preserves history for each file.
This commit is contained in:
parent
a41677aea1
commit
5012893c1d
2396 changed files with 0 additions and 0 deletions
128
java/google/registry/flows/domain/DomainCheckFlow.java
Normal file
128
java/google/registry/flows/domain/DomainCheckFlow.java
Normal file
|
@ -0,0 +1,128 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.domain.registry.flows.domain;
|
||||
|
||||
import static com.google.domain.registry.flows.domain.DomainFlowUtils.getReservationType;
|
||||
import static com.google.domain.registry.flows.domain.DomainFlowUtils.handleFeeRequest;
|
||||
import static com.google.domain.registry.model.EppResourceUtils.checkResourcesExist;
|
||||
import static com.google.domain.registry.model.registry.label.ReservationType.UNRESERVED;
|
||||
import static com.google.domain.registry.util.CollectionUtils.nullToEmpty;
|
||||
import static com.google.domain.registry.util.DomainNameUtils.getTldFromDomainName;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.net.InternetDomainName;
|
||||
import com.google.domain.registry.flows.EppException;
|
||||
import com.google.domain.registry.flows.EppException.ParameterValuePolicyErrorException;
|
||||
import com.google.domain.registry.model.domain.fee.FeeCheckExtension;
|
||||
import com.google.domain.registry.model.domain.fee.FeeCheckResponseExtension;
|
||||
import com.google.domain.registry.model.domain.fee.FeeCheckResponseExtension.FeeCheck;
|
||||
import com.google.domain.registry.model.domain.launch.LaunchCheckExtension;
|
||||
import com.google.domain.registry.model.eppcommon.ProtocolDefinition.ServiceExtension;
|
||||
import com.google.domain.registry.model.eppoutput.CheckData;
|
||||
import com.google.domain.registry.model.eppoutput.CheckData.DomainCheck;
|
||||
import com.google.domain.registry.model.eppoutput.CheckData.DomainCheckData;
|
||||
import com.google.domain.registry.model.eppoutput.Response.ResponseExtension;
|
||||
import com.google.domain.registry.model.registry.Registry;
|
||||
import com.google.domain.registry.model.registry.label.ReservationType;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* An EPP flow that checks whether a domain can be provisioned.
|
||||
*
|
||||
* @error {@link com.google.domain.registry.flows.ResourceCheckFlow.TooManyResourceChecksException}
|
||||
* @error {@link com.google.domain.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException}
|
||||
* @error {@link DomainFlowUtils.BadDomainNameCharacterException}
|
||||
* @error {@link DomainFlowUtils.BadDomainNamePartsCountException}
|
||||
* @error {@link DomainFlowUtils.BadPeriodUnitException}
|
||||
* @error {@link DomainFlowUtils.CurrencyUnitMismatchException}
|
||||
* @error {@link DomainFlowUtils.DashesInThirdAndFourthException}
|
||||
* @error {@link DomainFlowUtils.DomainLabelTooLongException}
|
||||
* @error {@link DomainFlowUtils.EmptyDomainNamePartException}
|
||||
* @error {@link DomainFlowUtils.FeeChecksDontSupportPhasesException}
|
||||
* @error {@link DomainFlowUtils.InvalidIdnDomainLabelException}
|
||||
* @error {@link DomainFlowUtils.InvalidPunycodeException}
|
||||
* @error {@link DomainFlowUtils.LeadingDashException}
|
||||
* @error {@link DomainFlowUtils.RestoresAreAlwaysForOneYearException}
|
||||
* @error {@link DomainFlowUtils.TldDoesNotExistException}
|
||||
* @error {@link DomainFlowUtils.TrailingDashException}
|
||||
* @error {@link DomainFlowUtils.UnknownFeeCommandException}
|
||||
* @error {@link DomainCheckFlow.OnlyCheckedNamesCanBeFeeCheckedException}
|
||||
*/
|
||||
public class DomainCheckFlow extends BaseDomainCheckFlow {
|
||||
|
||||
@Override
|
||||
protected void initDomainCheckFlow() throws EppException {
|
||||
registerExtensions(LaunchCheckExtension.class, FeeCheckExtension.class);
|
||||
}
|
||||
|
||||
private String getMessageForCheck(String targetId, Set<String> existingIds) {
|
||||
if (existingIds.contains(targetId)) {
|
||||
return "In use";
|
||||
}
|
||||
InternetDomainName domainName = domainNames.get(targetId);
|
||||
ReservationType reservationType = getReservationType(domainName);
|
||||
Registry registry = Registry.get(domainName.parent().toString());
|
||||
if (reservationType == UNRESERVED
|
||||
&& registry.isPremiumName(domainName)
|
||||
&& registry.getPremiumPriceAckRequired()
|
||||
&& !nullToEmpty(sessionMetadata.getServiceExtensionUris()).contains(
|
||||
ServiceExtension.FEE_0_6.getUri())) {
|
||||
return "Premium names require EPP ext.";
|
||||
}
|
||||
return reservationType.getMessageForCheck();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CheckData getCheckData() {
|
||||
Set<String> existingIds = checkResourcesExist(resourceClass, targetIds, now);
|
||||
ImmutableList.Builder<DomainCheck> checks = new ImmutableList.Builder<>();
|
||||
for (String id : targetIds) {
|
||||
String message = getMessageForCheck(id, existingIds);
|
||||
checks.add(DomainCheck.create(message == null, id, message));
|
||||
}
|
||||
return DomainCheckData.create(checks.build());
|
||||
}
|
||||
|
||||
/** Handle the fee check extension. */
|
||||
@Override
|
||||
protected ImmutableList<? extends ResponseExtension> getResponseExtensions() throws EppException {
|
||||
FeeCheckExtension feeCheck = eppInput.getSingleExtension(FeeCheckExtension.class);
|
||||
if (feeCheck == null) {
|
||||
return null; // No fee checks were requested.
|
||||
}
|
||||
ImmutableList.Builder<FeeCheck> feeChecksBuilder = new ImmutableList.Builder<>();
|
||||
for (FeeCheckExtension.DomainCheck domainCheck : feeCheck.getDomains()) {
|
||||
String domainName = domainCheck.getName();
|
||||
if (!domainNames.containsKey(domainName)) {
|
||||
// Although the fee extension explicitly says it's ok to fee check a domain name that you
|
||||
// aren't also availability checking, we forbid it. This makes the experience simpler and
|
||||
// also means we can assume any domain names in the fee checks have been validated.
|
||||
throw new OnlyCheckedNamesCanBeFeeCheckedException();
|
||||
}
|
||||
FeeCheck.Builder builder = new FeeCheck.Builder();
|
||||
handleFeeRequest(domainCheck, builder, domainName, getTldFromDomainName(domainName), now);
|
||||
feeChecksBuilder.add(builder.setName(domainName).build());
|
||||
}
|
||||
return ImmutableList.of(FeeCheckResponseExtension.create(feeChecksBuilder.build()));
|
||||
}
|
||||
|
||||
/** By server policy, fee check names must be listed in the availability check. */
|
||||
static class OnlyCheckedNamesCanBeFeeCheckedException extends ParameterValuePolicyErrorException {
|
||||
OnlyCheckedNamesCanBeFeeCheckedException() {
|
||||
super("By server policy, fee check names must be listed in the availability check");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue