mirror of
https://github.com/google/nomulus.git
synced 2025-05-07 23:38:21 +02:00
* Remove LINKED when loading an EppResource * Enforce that you can't add it to a resource * Ignore LINKED on xjc import of contacts and hosts After running ResaveAllEppResourcesAction we will no longer have persisted LINKED statuses in datastore. In the process of writing this I discovered that RDAP treats LINKED like any other status value and returns the persisted value rather than the derived one. Since this is an existing bug and is orthogonal to the changes in this CL, I am addressing it in a separate CL. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=145585227
87 lines
3 KiB
Java
87 lines
3 KiB
Java
// Copyright 2016 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.model.eppcommon;
|
|
|
|
import static com.google.common.base.CaseFormat.LOWER_CAMEL;
|
|
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
|
import static com.google.common.base.Strings.nullToEmpty;
|
|
|
|
import google.registry.model.translators.EnumToAttributeAdapter.EppEnum;
|
|
import google.registry.model.translators.StatusValueAdapter;
|
|
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
|
|
|
/**
|
|
* Represents an EPP status value for hosts, contacts, and domains, as defined in RFC 5731, 5732,
|
|
* and 5733. The values here are the union of all 3 sets of status values.
|
|
*
|
|
* <p>The RFCs define extra optional metadata (language and message) that we don't use and therefore
|
|
* don't model.
|
|
*
|
|
* <p>Note that {@code StatusValue.LINKED} should never be stored. Rather, it should be calculated
|
|
* on the fly whenever needed using an eventually consistent query (i.e. in info flows).
|
|
*
|
|
* @see <a href="https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en">EPP Status
|
|
* Codes</a>
|
|
*/
|
|
@XmlJavaTypeAdapter(StatusValueAdapter.class)
|
|
public enum StatusValue implements EppEnum {
|
|
|
|
CLIENT_DELETE_PROHIBITED,
|
|
CLIENT_HOLD,
|
|
CLIENT_RENEW_PROHIBITED,
|
|
CLIENT_TRANSFER_PROHIBITED,
|
|
CLIENT_UPDATE_PROHIBITED,
|
|
INACTIVE,
|
|
|
|
/**
|
|
* A status that means a resource has an incoming reference from an active domain.
|
|
*
|
|
* <p>LINKED is a "virtual" status value that should never be persisted to Datastore on any
|
|
* resource. It must be computed on the fly when we need it, as the set of domains using a
|
|
* resource can change at any time.
|
|
*/
|
|
LINKED,
|
|
|
|
OK,
|
|
PENDING_CREATE,
|
|
PENDING_DELETE,
|
|
PENDING_TRANSFER,
|
|
PENDING_UPDATE,
|
|
SERVER_DELETE_PROHIBITED,
|
|
SERVER_HOLD,
|
|
SERVER_RENEW_PROHIBITED,
|
|
SERVER_TRANSFER_PROHIBITED,
|
|
SERVER_UPDATE_PROHIBITED;
|
|
|
|
private final String xmlName = UPPER_UNDERSCORE.to(LOWER_CAMEL, name());
|
|
|
|
@Override
|
|
public String getXmlName() {
|
|
return xmlName;
|
|
}
|
|
|
|
public boolean isClientSettable() {
|
|
// This is the actual definition of client-settable statuses; see RFC5730 section 2.3.
|
|
return xmlName.startsWith("client");
|
|
}
|
|
|
|
public boolean isChargedStatus() {
|
|
return xmlName.startsWith("server") && xmlName.endsWith("Prohibited");
|
|
}
|
|
|
|
public static StatusValue fromXmlName(String xmlName) {
|
|
return StatusValue.valueOf(LOWER_CAMEL.to(UPPER_UNDERSCORE, nullToEmpty(xmlName)));
|
|
}
|
|
}
|