Add --reason flag to UpdateSmdCommand

Just an old patch that I had lying around and never mailed out.  Seemed like it could be worth having checked in.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=124853504
This commit is contained in:
Nick Felt 2016-06-14 10:27:09 -07:00 committed by Justine Tunney
parent cc01035fe8
commit 9a2b88ee28
2 changed files with 13 additions and 4 deletions

View file

@ -57,6 +57,11 @@ final class UpdateSmdCommand implements RemoteApiCommand {
required = true)
private Path smdFile;
@Parameter(
names = "--reason",
description = "Special reason for the SMD update to record in the history entry.")
private String reason;
@Override
public void run() throws Exception {
final EncodedSignedMark encodedSignedMark =
@ -66,14 +71,15 @@ final class UpdateSmdCommand implements RemoteApiCommand {
@Override
public void vrun() {
try {
updateSmd(id, encodedSignedMark);
updateSmd(id, encodedSignedMark, reason);
} catch (EppException e) {
throw new RuntimeException(e);
}
}});
}
private void updateSmd(String applicationId, EncodedSignedMark encodedSignedMark)
private static void updateSmd(
String applicationId, EncodedSignedMark encodedSignedMark, String reason)
throws EppException {
ofy().assertInTransaction();
DateTime now = ofy().getTransactionTime();
@ -105,6 +111,7 @@ final class UpdateSmdCommand implements RemoteApiCommand {
.setModificationTime(now)
.setClientId(domainApplication.getCurrentSponsorClientId())
.setBySuperuser(true)
.setReason("UpdateSmdCommand" + (reason != null ? ": " + reason : ""))
.build();
// Save entities to datastore.