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:
Justine Tunney 2016-05-13 18:55:08 -04:00
parent a41677aea1
commit 5012893c1d
2396 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,167 @@
// 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.model.eppoutput;
import com.google.common.collect.ImmutableList;
import com.google.domain.registry.model.ImmutableObject;
import com.google.domain.registry.model.eppoutput.Response.ResponseData;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;
/** The "chkDataType" complex type. */
@XmlTransient
public abstract class CheckData extends ImmutableObject implements ResponseData {
/** The check responses. We must explicitly list the namespaced versions of {@link Check}. */
@XmlElements({
@XmlElement(
name = "cd", namespace = "urn:ietf:params:xml:ns:contact-1.0", type = ContactCheck.class),
@XmlElement(
name = "cd", namespace = "urn:ietf:params:xml:ns:domain-1.0", type = DomainCheck.class),
@XmlElement(
name = "cd", namespace = "urn:ietf:params:xml:ns:host-1.0", type = HostCheck.class)})
ImmutableList<? extends Check> checks;
protected static <T extends CheckData> T init(T instance, ImmutableList<? extends Check> checks) {
instance.checks = checks;
return instance;
}
public ImmutableList<? extends Check> getChecks() {
return checks;
}
/** The response for a check on a single resource. */
@XmlTransient
public static class Check extends ImmutableObject {
/** An element containing the name or id and availability of a resource. */
@XmlElements({
@XmlElement(name = "name", type = CheckName.class),
@XmlElement(name = "id", type = CheckID.class)})
CheckNameOrID nameOrId;
/** A message explaining the availability of this resource. */
String reason;
protected static <T extends Check> T init(T instance, CheckNameOrID nameOrId, String reason) {
instance.nameOrId = nameOrId;
instance.reason = reason;
return instance;
}
}
/**
* The "checkNameType" and "checkIDType" types.
* <p>
* Although these are specified in the Epp extension RFCs and not in RFC 5730, which implies that
* they should be implemented per-extension, all of RFCs 5731, 5732 and 5733 define them
* identically except for the namespace and some slightly renamed fields, allowing us to share
* some code between the different extensions.
*/
public abstract static class CheckNameOrID extends ImmutableObject {
/** Whether the resource is available. */
@XmlAttribute
boolean avail;
/** The name of the resource being checked. */
@XmlValue
String value;
public boolean getAvail() {
return avail;
}
protected static <T extends CheckNameOrID> T init(T instance, boolean avail, String value) {
instance.avail = avail;
instance.value = value;
return instance;
}
}
/** The name for a resource in a check response. */
public static class CheckName extends CheckNameOrID {
protected static CheckName create(boolean avail, String name) {
return init(new CheckName(), avail, name);
}
}
/** The id for a resource in a check response. */
public static class CheckID extends CheckNameOrID {
protected static CheckID create(boolean avail, String id) {
return init(new CheckID(), avail, id);
}
}
/** A version with contact namespacing. */
@XmlType(namespace = "urn:ietf:params:xml:ns:contact-1.0")
public static class ContactCheck extends Check {
public static ContactCheck create(boolean avail, String id, String reason) {
return init(new ContactCheck(), CheckID.create(avail, id), reason);
}
}
/** A version with domain namespacing. */
@XmlType(namespace = "urn:ietf:params:xml:ns:domain-1.0")
public static class DomainCheck extends Check {
public static DomainCheck create(boolean avail, String name, String reason) {
return init(new DomainCheck(), CheckName.create(avail, name), reason);
}
public CheckName getName() {
return (CheckName) nameOrId;
}
public String getReason() {
return reason;
}
}
/** A version with host namespacing. */
@XmlType(namespace = "urn:ietf:params:xml:ns:host-1.0")
public static class HostCheck extends Check {
public static HostCheck create(boolean avail, String name, String reason) {
return init(new HostCheck(), CheckName.create(avail, name), reason);
}
}
/** A version with contact namespacing. */
@XmlRootElement(name = "chkData", namespace = "urn:ietf:params:xml:ns:contact-1.0")
public static class ContactCheckData extends CheckData {
public static ContactCheckData create(ImmutableList<ContactCheck> checks) {
return init(new ContactCheckData(), checks);
}
}
/** A version with domain namespacing. */
@XmlRootElement(name = "chkData", namespace = "urn:ietf:params:xml:ns:domain-1.0")
public static class DomainCheckData extends CheckData {
public static DomainCheckData create(ImmutableList<DomainCheck> checks) {
return init(new DomainCheckData(), checks);
}
}
/** A version with host namespacing. */
@XmlRootElement(name = "chkData", namespace = "urn:ietf:params:xml:ns:host-1.0")
public static class HostCheckData extends CheckData {
public static HostCheckData create(ImmutableList<HostCheck> checks) {
return init(new HostCheckData(), checks);
}
}
}

View file

@ -0,0 +1,84 @@
// 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.model.eppoutput;
import com.google.domain.registry.model.eppoutput.Response.ResponseData;
import org.joda.time.DateTime;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
/** The {@link ResponseData} returned when creating a resource. */
@XmlTransient
public abstract class CreateData implements ResponseData {
@XmlElement(name = "crDate")
protected DateTime creationDate;
/** An acknowledgment message indicating that a contact was created. */
@XmlRootElement(name = "creData", namespace = "urn:ietf:params:xml:ns:contact-1.0")
@XmlType(propOrder = {"id", "creationDate"}, namespace = "urn:ietf:params:xml:ns:contact-1.0")
public static class ContactCreateData extends CreateData {
String id;
public static ContactCreateData create(String id, DateTime creationDate) {
ContactCreateData instance = new ContactCreateData();
instance.id = id;
instance.creationDate = creationDate;
return instance;
}
}
/** An acknowledgment message indicating that a domain was created. */
@XmlRootElement(name = "creData", namespace = "urn:ietf:params:xml:ns:domain-1.0")
@XmlType(
propOrder = {"name", "creationDate", "expirationDate"},
namespace = "urn:ietf:params:xml:ns:domain-1.0")
public static class DomainCreateData extends CreateData {
String name;
@XmlElement(name = "exDate")
DateTime expirationDate;
public static DomainCreateData create(
String name, DateTime creationDate, DateTime expirationDate) {
DomainCreateData instance = new DomainCreateData();
instance.name = name;
instance.creationDate = creationDate;
instance.expirationDate = expirationDate;
return instance;
}
}
/** An acknowledgment message indicating that a host was created. */
@XmlRootElement(name = "creData", namespace = "urn:ietf:params:xml:ns:host-1.0")
@XmlType(propOrder = {"name", "creationDate"}, namespace = "urn:ietf:params:xml:ns:host-1.0")
public static class HostCreateData extends CreateData {
String name;
public static HostCreateData create(String name, DateTime creationDate) {
HostCreateData instance = new HostCreateData();
instance.name = name;
instance.creationDate = creationDate;
return instance;
}
}
}

View file

@ -0,0 +1,53 @@
// 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.model.eppoutput;
import com.google.common.annotations.VisibleForTesting;
import com.google.domain.registry.model.ImmutableObject;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
/** This class represents the root EPP XML element for output. */
@XmlRootElement(name = "epp")
public class EppOutput extends ImmutableObject {
@XmlElements({
@XmlElement(name = "response", type = Response.class),
@XmlElement(name = "greeting", type = Greeting.class) })
ResponseOrGreeting responseOrGreeting;
public static EppOutput create(ResponseOrGreeting responseOrGreeting) {
EppOutput instance = new EppOutput();
instance.responseOrGreeting = responseOrGreeting;
return instance;
}
@VisibleForTesting
public boolean isSuccess() {
return ((Response) responseOrGreeting).result.getCode().isSuccess();
}
public Response getResponse() {
return (Response) responseOrGreeting;
}
public boolean isResponse() {
return responseOrGreeting instanceof Response;
}
/** Marker interface for types allowed inside of an {@link EppOutput}. */
public interface ResponseOrGreeting {}
}

View file

@ -0,0 +1,88 @@
// 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.model.eppoutput;
import static org.joda.time.DateTimeZone.UTC;
import com.google.domain.registry.model.ImmutableObject;
import com.google.domain.registry.model.eppcommon.PresenceMarker;
import com.google.domain.registry.model.eppcommon.ProtocolDefinition;
import com.google.domain.registry.model.eppoutput.EppOutput.ResponseOrGreeting;
import org.joda.time.DateTime;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
/**
* A greeting, defined in {@link "http://tools.ietf.org/html/rfc5730"}.
* <p>
* It would be nice to make this a singleton, but we need the {@link #svDate} field to stay current.
*/
public class Greeting extends ImmutableObject implements ResponseOrGreeting {
String svID = "Charleston Road Registry";
DateTime svDate = DateTime.now(UTC);
/** This is never changed, so it might as well be static for efficiency. */
@XmlElement
static SvcMenu svcMenu = new SvcMenu();
/** This is never changed, so it might as well be static for efficiency. */
@XmlElement
static Dcp dcp = new Dcp();
static class SvcMenu extends ImmutableObject {
String version = ProtocolDefinition.VERSION;
String lang = ProtocolDefinition.LANGUAGE;
Set<String> objURI = ProtocolDefinition.SUPPORTED_OBJECT_SERVICES;
@XmlElementWrapper(name = "svcExtension")
Set<String> extURI = ProtocolDefinition.getVisibleServiceExtensionUris();
}
static class Dcp extends ImmutableObject {
Access access = new Access();
Statement statement = new Statement();
}
static class Access extends ImmutableObject {
PresenceMarker all = new PresenceMarker();
}
static class Statement extends ImmutableObject {
Purpose purpose = new Purpose();
Recipient recipient = new Recipient();
Retention retention = new Retention();
}
static class Purpose extends ImmutableObject {
PresenceMarker admin = new PresenceMarker();
PresenceMarker prov = new PresenceMarker();
}
static class Recipient extends ImmutableObject {
PresenceMarker ours = new PresenceMarker();
@XmlElement(name = "public")
PresenceMarker publicObj = new PresenceMarker();
}
static class Retention extends ImmutableObject {
PresenceMarker indefinite = new PresenceMarker();
}
}

View file

@ -0,0 +1,202 @@
// 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.model.eppoutput;
import com.google.common.collect.ImmutableList;
import com.google.domain.registry.model.Buildable;
import com.google.domain.registry.model.ImmutableObject;
import com.google.domain.registry.model.contact.ContactResource;
import com.google.domain.registry.model.domain.DomainApplication;
import com.google.domain.registry.model.domain.DomainRenewData;
import com.google.domain.registry.model.domain.DomainResource;
import com.google.domain.registry.model.domain.fee.FeeCheckResponseExtension;
import com.google.domain.registry.model.domain.fee.FeeCreateResponseExtension;
import com.google.domain.registry.model.domain.fee.FeeDeleteResponseExtension;
import com.google.domain.registry.model.domain.fee.FeeInfoResponseExtension;
import com.google.domain.registry.model.domain.fee.FeeRenewResponseExtension;
import com.google.domain.registry.model.domain.fee.FeeTransferResponseExtension;
import com.google.domain.registry.model.domain.fee.FeeUpdateResponseExtension;
import com.google.domain.registry.model.domain.launch.LaunchCheckResponseExtension;
import com.google.domain.registry.model.domain.launch.LaunchCreateResponseExtension;
import com.google.domain.registry.model.domain.launch.LaunchInfoResponseExtension;
import com.google.domain.registry.model.domain.rgp.RgpInfoExtension;
import com.google.domain.registry.model.domain.secdns.SecDnsInfoExtension;
import com.google.domain.registry.model.eppcommon.Trid;
import com.google.domain.registry.model.eppoutput.CheckData.ContactCheckData;
import com.google.domain.registry.model.eppoutput.CheckData.DomainCheckData;
import com.google.domain.registry.model.eppoutput.CheckData.HostCheckData;
import com.google.domain.registry.model.eppoutput.CreateData.ContactCreateData;
import com.google.domain.registry.model.eppoutput.CreateData.DomainCreateData;
import com.google.domain.registry.model.eppoutput.CreateData.HostCreateData;
import com.google.domain.registry.model.eppoutput.EppOutput.ResponseOrGreeting;
import com.google.domain.registry.model.host.HostResource;
import com.google.domain.registry.model.poll.MessageQueueInfo;
import com.google.domain.registry.model.poll.PendingActionNotificationResponse.ContactPendingActionNotificationResponse;
import com.google.domain.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse;
import com.google.domain.registry.model.transfer.TransferResponse.ContactTransferResponse;
import com.google.domain.registry.model.transfer.TransferResponse.DomainTransferResponse;
import org.joda.time.DateTime;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
/**
* The Response class represents an EPP response message.
*
* <p>From the RFC: "An EPP server responds to a client command by returning a response to the
* client. EPP commands are atomic, so a command will either succeed completely or fail completely.
* Success and failure results MUST NOT be mixed."
*
* @see "http://tools.ietf.org/html/rfc5730#section-2.6"
*/
@XmlType(propOrder = {"result", "messageQueueInfo", "resData", "extensions", "trid"})
public class Response extends ImmutableObject implements ResponseOrGreeting {
/** The TRID associated with this response. */
@XmlElement(name = "trID")
Trid trid;
/** The command result. The RFC allows multiple failure results, but we always return one. */
Result result;
/**
* The time the command that created this response was executed.
* <p>
* This is for logging purposes only and is not returned to the user.
*/
@XmlTransient
DateTime executionTime;
/**
* The repository id of a new object if this is a create response, or null.
* <p>
* This is for logging purposes only and is not returned to the user.
*/
@XmlTransient
String createdRepoId;
/**
* Information about messages queued for retrieval. This may appear in response to any EPP message
* (if messages are queued), but in practice this will only be set in response to a poll request.
*/
@XmlElement(name = "msgQ")
MessageQueueInfo messageQueueInfo;
/** Zero or more response "resData" results. */
@XmlElementRefs({
@XmlElementRef(type = ContactResource.class),
@XmlElementRef(type = DomainApplication.class),
@XmlElementRef(type = DomainResource.class),
@XmlElementRef(type = HostResource.class),
@XmlElementRef(type = ContactCheckData.class),
@XmlElementRef(type = ContactCreateData.class),
@XmlElementRef(type = ContactPendingActionNotificationResponse.class),
@XmlElementRef(type = ContactTransferResponse.class),
@XmlElementRef(type = DomainCheckData.class),
@XmlElementRef(type = DomainCreateData.class),
@XmlElementRef(type = DomainPendingActionNotificationResponse.class),
@XmlElementRef(type = DomainRenewData.class),
@XmlElementRef(type = DomainTransferResponse.class),
@XmlElementRef(type = HostCheckData.class),
@XmlElementRef(type = HostCreateData.class)})
@XmlElementWrapper
ImmutableList<? extends ResponseData> resData;
/** Zero or more response extensions. */
@XmlElementRefs({
@XmlElementRef(type = FeeCheckResponseExtension.class),
@XmlElementRef(type = FeeCreateResponseExtension.class),
@XmlElementRef(type = FeeDeleteResponseExtension.class),
@XmlElementRef(type = FeeInfoResponseExtension.class),
@XmlElementRef(type = FeeRenewResponseExtension.class),
@XmlElementRef(type = FeeTransferResponseExtension.class),
@XmlElementRef(type = FeeUpdateResponseExtension.class),
@XmlElementRef(type = LaunchCheckResponseExtension.class),
@XmlElementRef(type = LaunchCreateResponseExtension.class),
@XmlElementRef(type = LaunchInfoResponseExtension.class),
@XmlElementRef(type = RgpInfoExtension.class),
@XmlElementRef(type = SecDnsInfoExtension.class) })
@XmlElementWrapper(name = "extension")
ImmutableList<? extends ResponseExtension> extensions;
public DateTime getExecutionTime() {
return executionTime;
}
public String getCreatedRepoId() {
return createdRepoId;
}
public ImmutableList<? extends ResponseData> getResponseData() {
return resData;
}
public ImmutableList<? extends ResponseExtension> getExtensions() {
return extensions;
}
public Result getResult() {
return result;
}
/** Marker interface for types that can go in the {@link #resData} field. */
public interface ResponseData {}
/** Marker interface for types that can go in the {@link #extensions} field. */
public interface ResponseExtension {}
/** Builder for {@link Response} because it is immutable. */
public static class Builder extends Buildable.Builder<Response> {
public Builder setTrid(Trid trid) {
getInstance().trid = trid;
return this;
}
public Builder setResult(Result result) {
getInstance().result = result;
return this;
}
public Builder setMessageQueueInfo(MessageQueueInfo messageQueueInfo) {
getInstance().messageQueueInfo = messageQueueInfo;
return this;
}
public Builder setExecutionTime(DateTime executionTime) {
getInstance().executionTime = executionTime;
return this;
}
public Builder setCreatedRepoId(String createdRepoId) {
getInstance().createdRepoId = createdRepoId;
return this;
}
public Builder setResData(ImmutableList<? extends ResponseData> resData) {
getInstance().resData = resData;
return this;
}
public Builder setExtensions(ImmutableList<? extends ResponseExtension> extensions) {
getInstance().extensions = extensions;
return this;
}
}
}

View file

@ -0,0 +1,190 @@
// 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.model.eppoutput;
import static com.google.domain.registry.util.XmlEnumUtils.enumToXml;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.domain.registry.model.ImmutableObject;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlEnumValue;
/**
* "If the command was processed successfully, only one {@code Result} element MUST be returned. If
* the command was not processed successfully, multiple {@code Result} elements MAY be returned to
* document failure conditions."
*/
public class Result extends ImmutableObject {
/**
* "EPP result codes are based on the theory of reply codes described in section 4.2.1 of
* [RFC5321]. EPP uses four decimal digits to describe the success or failure of each EPP command.
* Each of the digits of the reply have special significance."
*
* "The first digit denotes command success or failure. The second digit denotes the response
* category, such as command syntax or security. The third and fourth digits provide explicit
* response detail within each response category."
*/
public enum Code {
@XmlEnumValue("1000")
Success("Command completed successfully"),
@XmlEnumValue("1001")
SuccessWithActionPending("Command completed successfully; action pending"),
@XmlEnumValue("1300")
SuccessWithNoMessages("Command completed successfully; no messages"),
@XmlEnumValue("1301")
SuccessWithAckMessage("Command completed successfully; ack to dequeue"),
@XmlEnumValue("1500")
SuccessAndClose("Command completed successfully; ending session"),
@XmlEnumValue("2000")
UnknownCommand("Unknown command"),
@XmlEnumValue("2001")
SyntaxError("Command syntax error"),
@XmlEnumValue("2002")
CommandUseError("Command use error"),
@XmlEnumValue("2003")
RequiredParameterMissing("Required parameter missing"),
@XmlEnumValue("2004")
ParameterValueRangeError("Parameter value range error"),
@XmlEnumValue("2005")
ParameterValueSyntaxError("Parameter value syntax error"),
@XmlEnumValue("2100")
UnimplementedProtocolVersion("Unimplemented protocol version"),
@XmlEnumValue("2101")
UnimplementedCommand("Unimplemented command"),
@XmlEnumValue("2102")
UnimplementedOption("Unimplemented option"),
@XmlEnumValue("2103")
UnimplementedExtension("Unimplemented extension"),
@XmlEnumValue("2200")
AuthenticationError("Authentication error"),
@XmlEnumValue("2201")
AuthorizationError("Authorization error"),
@XmlEnumValue("2202")
InvalidAuthorizationInformationError("Invalid authorization information"),
@XmlEnumValue("2300")
ObjectPendingTransfer("Object pending transfer"),
@XmlEnumValue("2301")
ObjectNotPendingTransfer("Object not pending transfer"),
@XmlEnumValue("2302")
ObjectExists("Object exists"),
@XmlEnumValue("2303")
ObjectDoesNotExist("Object does not exist"),
@XmlEnumValue("2304")
StatusProhibitsOperation("Object status prohibits operation"),
@XmlEnumValue("2305")
AssociationProhibitsOperation("Object association prohibits operation"),
@XmlEnumValue("2306")
ParameterValuePolicyError("Parameter value policy error"),
@XmlEnumValue("2307")
UnimplementedObjectService("Unimplemented object service"),
@XmlEnumValue("2400")
CommandFailed("Command failed"),
@XmlEnumValue("2501")
AuthenticationErrorClosingConnection("Authentication error; server closing connection");
/** A four-digit (positive) number that describes the success or failure of the command. */
public final int code;
/** A human-readable description of the response code. */
public final String msg;
/**
* An RFC 4646 language code.
*
* @see "http://tools.ietf.org/html/rfc4646"
*/
public final String msgLang;
/** @param msg a human-readable description of the response code; required. */
Code(String msg) {
this.code = Integer.parseInt(enumToXml(this));
Preconditions.checkArgument(
(int) Math.log10(code) == 3,
"Response code must be a four-digit (positive) number.");
this.msg = Preconditions.checkNotNull(msg, "A message must be specified.");
this.msgLang = "en"; // All of our messages are English.
}
/** @return true iff the response code is in the 1xxx category, representing success. */
public boolean isSuccess() {
return code < 2000;
}
@Override
public String toString() {
return String.format("{code:'%s', msg:'%s', msgLang:'%s'}", code, msg, msgLang);
}
}
/** The result code for this result. This is always present. */
@XmlAttribute
Code code;
/** An explanation of the result code. */
String msg;
public Code getCode() {
return code;
}
public String getMsg() {
return msg;
}
public static Result create(Code code, String msg) {
Result instance = new Result();
instance.code = code;
// If no message was set, pick up a default message from the Code enum.
Preconditions.checkState(
!code.isSuccess() || msg == null,
"Only error result codes may have a message");
instance.msg = MoreObjects.firstNonNull(msg, code.msg);
return instance;
}
public static Result create(Code code) {
return create(code, null);
}
}

View file

@ -0,0 +1,31 @@
// 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.
@XmlSchema(
namespace = "urn:ietf:params:xml:ns:epp-1.0",
xmlns = @XmlNs(prefix = "", namespaceURI = "urn:ietf:params:xml:ns:epp-1.0"),
elementFormDefault = XmlNsForm.QUALIFIED)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlJavaTypeAdapter(UtcDateTimeAdapter.class)
package com.google.domain.registry.model.eppoutput;
import com.google.domain.registry.xml.UtcDateTimeAdapter;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;