1
0
mirror of https://github.com/google/nomulus synced 2026-04-13 13:07:16 +00:00

Move premium list static helper methods into their own class

It was kind of messy having all of that logic living alongside the
entities themselves.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=148498024
This commit is contained in:
mcilwain
2017-02-24 13:38:59 -08:00
committed by Ben McIlwain
parent 388dd1055e
commit ea4e471c04
12 changed files with 523 additions and 421 deletions

View File

@@ -16,7 +16,8 @@ package google.registry.tools.server;
import static com.google.common.base.Preconditions.checkArgument;
import static google.registry.model.registry.Registries.assertTldExists;
import static google.registry.model.registry.label.PremiumList.saveWithEntries;
import static google.registry.model.registry.label.PremiumListUtils.doesPremiumListExist;
import static google.registry.model.registry.label.PremiumListUtils.savePremiumListAndEntries;
import static google.registry.request.Action.Method.POST;
import com.google.common.base.Splitter;
@@ -43,8 +44,7 @@ public class CreatePremiumListAction extends CreateOrUpdatePremiumListAction {
@Override
protected void savePremiumList() {
checkArgument(
!PremiumList.exists(name),
"A premium list of this name already exists: %s.", name);
!doesPremiumListExist(name), "A premium list of this name already exists: %s.", name);
if (!override) {
assertTldExists(name);
}
@@ -54,7 +54,7 @@ public class CreatePremiumListAction extends CreateOrUpdatePremiumListAction {
List<String> inputDataPreProcessed =
Splitter.on('\n').omitEmptyStrings().splitToList(inputData);
PremiumList premiumList = new PremiumList.Builder().setName(name).build();
saveWithEntries(premiumList, inputDataPreProcessed);
savePremiumListAndEntries(premiumList, inputDataPreProcessed);
String message =
String.format(

View File

@@ -15,7 +15,7 @@
package google.registry.tools.server;
import static com.google.common.base.Preconditions.checkArgument;
import static google.registry.model.registry.label.PremiumList.saveWithEntries;
import static google.registry.model.registry.label.PremiumListUtils.savePremiumListAndEntries;
import static google.registry.request.Action.Method.POST;
import com.google.common.base.Optional;
@@ -49,7 +49,8 @@ public class UpdatePremiumListAction extends CreateOrUpdatePremiumListAction {
logger.infofmt("Got the following input data: %s", inputData);
List<String> inputDataPreProcessed =
Splitter.on('\n').omitEmptyStrings().splitToList(inputData);
PremiumList newPremiumList = saveWithEntries(existingPremiumList.get(), inputDataPreProcessed);
PremiumList newPremiumList =
savePremiumListAndEntries(existingPremiumList.get(), inputDataPreProcessed);
String message =
String.format(