mirror of
https://github.com/google/nomulus.git
synced 2025-05-29 17:00:11 +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
38
java/google/registry/model/rde/RdeMode.java
Normal file
38
java/google/registry/model/rde/RdeMode.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
// 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.rde;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
|
||||
/** Mode of operation for RDE and BRDA. */
|
||||
public enum RdeMode {
|
||||
|
||||
/** Include all information is in the escrow deposit. */
|
||||
FULL,
|
||||
|
||||
/**
|
||||
* BRDA Periodic Access to Thin Registration Data.
|
||||
*
|
||||
* <p>This mode of operation provides ICANN with minimal information about registered domains
|
||||
* and their associated registrars, per gTLD Registry Agreement, Specification 4 § 3.1.
|
||||
*
|
||||
* @see "http://newgtlds.icann.org/en/applicants/agb/agreement-approved-09jan14-en.htm"
|
||||
*/
|
||||
THIN;
|
||||
|
||||
public String getFilenameComponent() {
|
||||
return Ascii.toLowerCase(name());
|
||||
}
|
||||
}
|
54
java/google/registry/model/rde/RdeNamingUtils.java
Normal file
54
java/google/registry/model/rde/RdeNamingUtils.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
// 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.rde;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
import org.joda.time.format.ISODateTimeFormat;
|
||||
|
||||
/** Utility class for generating RDE filenames and string IDs. */
|
||||
public final class RdeNamingUtils {
|
||||
|
||||
private static final DateTimeFormatter DATE_FORMATTER = ISODateTimeFormat.date();
|
||||
|
||||
/**
|
||||
* Returns extensionless RDE filename in format {@code <gTLD>_<YYYY-MM-DD>_<type>_S<#>_R<rev>}.
|
||||
*
|
||||
* <p>This naming scheme is defined in the {@code gTLD_Applicant_Guidebook_full.pdf}.
|
||||
*/
|
||||
public static
|
||||
String makeRydeFilename(String tld, DateTime date, RdeMode mode, int series, int revision) {
|
||||
checkArgument(series >= 1, "series >= 1");
|
||||
checkArgument(revision >= 0, "revision >= 0");
|
||||
return String.format("%s_S%d_R%d", makePartialName(tld, date, mode), series, revision);
|
||||
}
|
||||
|
||||
/** Returns same thing as {@link #makeRydeFilename} except without the series and revision. */
|
||||
static String makePartialName(String tld, DateTime date, RdeMode mode) {
|
||||
return String.format("%s_%s_%s",
|
||||
checkNotNull(tld), formatDate(date), mode.getFilenameComponent());
|
||||
}
|
||||
|
||||
/** Returns date as a hyphened string with ISO-8601 ordering, e.g. {@code 1984-12-18}. */
|
||||
private static String formatDate(DateTime date) {
|
||||
checkArgument(date.withTimeAtStartOfDay().equals(date), "Not midnight: %s", date);
|
||||
return DATE_FORMATTER.print(date);
|
||||
}
|
||||
|
||||
private RdeNamingUtils() {}
|
||||
}
|
89
java/google/registry/model/rde/RdeRevision.java
Normal file
89
java/google/registry/model/rde/RdeRevision.java
Normal file
|
@ -0,0 +1,89 @@
|
|||
// 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.rde;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Verify.verify;
|
||||
import static com.google.common.base.Verify.verifyNotNull;
|
||||
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static com.google.domain.registry.model.rde.RdeNamingUtils.makePartialName;
|
||||
|
||||
import com.google.common.base.VerifyException;
|
||||
import com.google.domain.registry.model.ImmutableObject;
|
||||
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* Datastore entity for tracking RDE revisions.
|
||||
*
|
||||
* <p>This class is used by the RDE staging, upload, and reporting systems to determine the revision
|
||||
* that should be used in the generated filename. It also determines whether or not a {@code resend}
|
||||
* flag is included in the generated XML.
|
||||
*/
|
||||
@Entity
|
||||
public final class RdeRevision extends ImmutableObject {
|
||||
|
||||
/** String triplet of tld, date, and mode, e.g. {@code soy_2015-09-01_full}. */
|
||||
@Id
|
||||
String id;
|
||||
|
||||
/**
|
||||
* Number of last revision successfully staged to GCS.
|
||||
*
|
||||
* <p>This values begins at zero upon object creation and thenceforth incremented transactionally.
|
||||
*/
|
||||
int revision;
|
||||
|
||||
/**
|
||||
* Returns next revision ID to use when staging a new deposit file for the given triplet.
|
||||
*
|
||||
* @return {@code 0} for first deposit generation and {@code >0} for resends
|
||||
*/
|
||||
public static int getNextRevision(String tld, DateTime date, RdeMode mode) {
|
||||
RdeRevision object =
|
||||
ofy().load().type(RdeRevision.class).id(makePartialName(tld, date, mode)).now();
|
||||
return object == null ? 0 : object.revision + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the revision ID for a given triplet.
|
||||
*
|
||||
* <p>This method verifies that the current revision is {@code revision - 1}, or that the object
|
||||
* does not exist in datastore if {@code revision == 0}.
|
||||
*
|
||||
* @throws IllegalStateException if not in a transaction
|
||||
* @throws VerifyException if datastore state doesn't meet the above criteria
|
||||
*/
|
||||
public static void saveRevision(String tld, DateTime date, RdeMode mode, int revision) {
|
||||
checkArgument(revision >= 0, "Negative revision: %s", revision);
|
||||
String triplet = makePartialName(tld, date, mode);
|
||||
ofy().assertInTransaction();
|
||||
RdeRevision object = ofy().load().type(RdeRevision.class).id(triplet).now();
|
||||
if (revision == 0) {
|
||||
verify(object == null, "RdeRevision object already created: %s", object);
|
||||
} else {
|
||||
verifyNotNull(object, "RDE revision object missing for %s?! revision=%s", triplet, revision);
|
||||
verify(object.revision == revision - 1,
|
||||
"RDE revision object should be at %s but was: %s", revision - 1, object);
|
||||
}
|
||||
object = new RdeRevision();
|
||||
object.id = triplet;
|
||||
object.revision = revision;
|
||||
ofy().save().entity(object);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue