From 1a050554fe02353bbf6b7ad24009c482bc6d7698 Mon Sep 17 00:00:00 2001 From: mountford Date: Tue, 13 Sep 2016 13:36:05 -0700 Subject: [PATCH] Move flags extension exceptions to separate classes The exceptions created for generic problems with the flags extension (invalid flag, etc.) should be in a common location, so they can be used by all interested TLDs. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=133040831 --- ...tensionFlagDomainPolicyErrorException.java | 24 ++++++++++++++++ .../flags/ExtensionFlagMissingException.java | 28 +++++++++++++++++++ ...sionFlagRegistrarPolicyErrorException.java | 24 ++++++++++++++++ ...sionFlagSetDomainPolicyErrorException.java | 24 ++++++++++++++++ .../flags/InvalidExtensionFlagException.java | 24 ++++++++++++++++ ...uallyExclusiveExtensionFlagsException.java | 24 ++++++++++++++++ .../domain/flags/NonClientFlagException.java | 24 ++++++++++++++++ .../SameFlagAddedAndRemovedException.java | 24 ++++++++++++++++ 8 files changed, 196 insertions(+) create mode 100644 java/google/registry/flows/domain/flags/ExtensionFlagDomainPolicyErrorException.java create mode 100644 java/google/registry/flows/domain/flags/ExtensionFlagMissingException.java create mode 100644 java/google/registry/flows/domain/flags/ExtensionFlagRegistrarPolicyErrorException.java create mode 100644 java/google/registry/flows/domain/flags/ExtensionFlagSetDomainPolicyErrorException.java create mode 100644 java/google/registry/flows/domain/flags/InvalidExtensionFlagException.java create mode 100644 java/google/registry/flows/domain/flags/MutuallyExclusiveExtensionFlagsException.java create mode 100644 java/google/registry/flows/domain/flags/NonClientFlagException.java create mode 100644 java/google/registry/flows/domain/flags/SameFlagAddedAndRemovedException.java diff --git a/java/google/registry/flows/domain/flags/ExtensionFlagDomainPolicyErrorException.java b/java/google/registry/flows/domain/flags/ExtensionFlagDomainPolicyErrorException.java new file mode 100644 index 000000000..2c95ea2af --- /dev/null +++ b/java/google/registry/flows/domain/flags/ExtensionFlagDomainPolicyErrorException.java @@ -0,0 +1,24 @@ +// 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 google.registry.flows.domain.flags; + +import google.registry.flows.EppException.StatusProhibitsOperationException; + +/** Extension flag is not currently valid for this domain. */ +public class ExtensionFlagDomainPolicyErrorException extends StatusProhibitsOperationException { + public ExtensionFlagDomainPolicyErrorException(String flag) { + super(String.format("Extension flag %s is not valid for this domain", flag)); + } +} diff --git a/java/google/registry/flows/domain/flags/ExtensionFlagMissingException.java b/java/google/registry/flows/domain/flags/ExtensionFlagMissingException.java new file mode 100644 index 000000000..ca593b53e --- /dev/null +++ b/java/google/registry/flows/domain/flags/ExtensionFlagMissingException.java @@ -0,0 +1,28 @@ +// 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 google.registry.flows.domain.flags; + +import google.registry.flows.EppException.RequiredParameterMissingException; + +/** Required extension flag missing. */ +public class ExtensionFlagMissingException extends RequiredParameterMissingException { + public ExtensionFlagMissingException(String flag) { + super(String.format("Flag %s must be specified", flag)); + } + + public ExtensionFlagMissingException(String flag1, String flag2) { + super(String.format("Either %s or %s must be specified", flag1, flag2)); + } +} diff --git a/java/google/registry/flows/domain/flags/ExtensionFlagRegistrarPolicyErrorException.java b/java/google/registry/flows/domain/flags/ExtensionFlagRegistrarPolicyErrorException.java new file mode 100644 index 000000000..933eaf16d --- /dev/null +++ b/java/google/registry/flows/domain/flags/ExtensionFlagRegistrarPolicyErrorException.java @@ -0,0 +1,24 @@ +// 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 google.registry.flows.domain.flags; + +import google.registry.flows.EppException.ParameterValuePolicyErrorException; + +/** Extension flag is not currently valid for this registrar. */ +public class ExtensionFlagRegistrarPolicyErrorException extends ParameterValuePolicyErrorException { + public ExtensionFlagRegistrarPolicyErrorException(String flag) { + super(String.format("Extension flag %s is not valid for this registrar", flag)); + } +} diff --git a/java/google/registry/flows/domain/flags/ExtensionFlagSetDomainPolicyErrorException.java b/java/google/registry/flows/domain/flags/ExtensionFlagSetDomainPolicyErrorException.java new file mode 100644 index 000000000..1c53d8307 --- /dev/null +++ b/java/google/registry/flows/domain/flags/ExtensionFlagSetDomainPolicyErrorException.java @@ -0,0 +1,24 @@ +// 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 google.registry.flows.domain.flags; + +import google.registry.flows.EppException.StatusProhibitsOperationException; + +/** Extension flag cannot currently be set for this domain. */ +public class ExtensionFlagSetDomainPolicyErrorException extends StatusProhibitsOperationException { + public ExtensionFlagSetDomainPolicyErrorException(String flag) { + super(String.format("Extension flag %s cannot be set for this domain", flag)); + } +} diff --git a/java/google/registry/flows/domain/flags/InvalidExtensionFlagException.java b/java/google/registry/flows/domain/flags/InvalidExtensionFlagException.java new file mode 100644 index 000000000..abfcd3f0b --- /dev/null +++ b/java/google/registry/flows/domain/flags/InvalidExtensionFlagException.java @@ -0,0 +1,24 @@ +// 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 google.registry.flows.domain.flags; + +import google.registry.flows.EppException.ParameterValueRangeErrorException; + +/** Extension flag is not valid. */ +public class InvalidExtensionFlagException extends ParameterValueRangeErrorException { + public InvalidExtensionFlagException(String flag) { + super(String.format("Extension flag %s is not defined", flag)); + } +} diff --git a/java/google/registry/flows/domain/flags/MutuallyExclusiveExtensionFlagsException.java b/java/google/registry/flows/domain/flags/MutuallyExclusiveExtensionFlagsException.java new file mode 100644 index 000000000..bd302969d --- /dev/null +++ b/java/google/registry/flows/domain/flags/MutuallyExclusiveExtensionFlagsException.java @@ -0,0 +1,24 @@ +// 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 google.registry.flows.domain.flags; + +import google.registry.flows.EppException.ParameterValuePolicyErrorException; + +/** Specified extension flags are mutually exclusive. */ +public class MutuallyExclusiveExtensionFlagsException extends ParameterValuePolicyErrorException { + public MutuallyExclusiveExtensionFlagsException(String flag1, String flag2) { + super(String.format("Extension flags %s and %s are mutually exclusive", flag1, flag2)); + } +} diff --git a/java/google/registry/flows/domain/flags/NonClientFlagException.java b/java/google/registry/flows/domain/flags/NonClientFlagException.java new file mode 100644 index 000000000..f6c9a572e --- /dev/null +++ b/java/google/registry/flows/domain/flags/NonClientFlagException.java @@ -0,0 +1,24 @@ +// 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 google.registry.flows.domain.flags; + +import google.registry.flows.EppException.ParameterValuePolicyErrorException; + +/** Only client flags can be updated. */ +public class NonClientFlagException extends ParameterValuePolicyErrorException { + public NonClientFlagException() { + super("Non-client flags cannot be added or removed"); + } +} diff --git a/java/google/registry/flows/domain/flags/SameFlagAddedAndRemovedException.java b/java/google/registry/flows/domain/flags/SameFlagAddedAndRemovedException.java new file mode 100644 index 000000000..b13f391f6 --- /dev/null +++ b/java/google/registry/flows/domain/flags/SameFlagAddedAndRemovedException.java @@ -0,0 +1,24 @@ +// 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 google.registry.flows.domain.flags; + +import google.registry.flows.EppException.ParameterValuePolicyErrorException; + +/** The same flag was specified in both add and remove lists. */ +public class SameFlagAddedAndRemovedException extends ParameterValuePolicyErrorException { + public SameFlagAddedAndRemovedException() { + super("An extension flag cannot be both added and removed in the same command"); + } +}