mirror of
https://github.com/google/nomulus.git
synced 2025-05-01 04:27:51 +02:00
This changes ResourceStatusProhibitsOperationException so that we print out the list of StatusValues using their XML names rather than the literal enum name, i.e. we use "pendingDelete" rather than "PENDING_DELETE". This seems more correct given that EPP clients will be used to seeing the status values in the XML representation, and it also matches the existing ResourceHasClientUpdateProhibitedException that hardcodes "clientUpdateProhibited": http://[]/third_party/java_src/gtld/java/google/registry/flows/exceptions/ResourceHasClientUpdateProhibitedException.java?l=22&rcl=146111211 Also reorganized related test methods and added some missing tests, including for ContactTransferRequestFlow which previously had none. I also renamed the "clientProhibitedStatusValue" tests to instead say "statusValueNotClientSettable" to be clearer about what's being tested, and that it's not related to the "clientXXProhibited" statuses. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=150248562
38 lines
1.6 KiB
Java
38 lines
1.6 KiB
Java
// Copyright 2017 The Nomulus 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 google.registry.flows.exceptions;
|
|
|
|
import com.google.common.base.Joiner;
|
|
import com.google.common.collect.ImmutableSet;
|
|
import google.registry.flows.EppException.StatusProhibitsOperationException;
|
|
import google.registry.model.eppcommon.StatusValue;
|
|
import java.util.Set;
|
|
|
|
/** Resource status prohibits this operation. */
|
|
public class ResourceStatusProhibitsOperationException
|
|
extends StatusProhibitsOperationException {
|
|
public ResourceStatusProhibitsOperationException(Set<StatusValue> statuses) {
|
|
super("Operation disallowed by status: " + formatStatusValues(statuses));
|
|
}
|
|
|
|
/** Returns a human-readable string listing the XML names of the given status values. */
|
|
private static String formatStatusValues(Set<StatusValue> statuses) {
|
|
ImmutableSet.Builder<String> statusXmlNames = new ImmutableSet.Builder<>();
|
|
for (StatusValue status : statuses) {
|
|
statusXmlNames.add(status.getXmlName());
|
|
}
|
|
return Joiner.on(", ").join(statusXmlNames.build());
|
|
}
|
|
}
|