Skip to content

Commit

Permalink
Merged DSC-1238 into dspace-cris-7
Browse files Browse the repository at this point in the history
  • Loading branch information
corrad82-4s committed Sep 11, 2023
2 parents 7c18ce8 + 191ac97 commit 8071287
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,23 @@ public void setup() throws ParseException {
public void internalRun() throws Exception {
assignCurrentUserInContext();
assignSpecialGroupsInContext();
String typeOption = commandLine.getOptionValue("t");
String frequencyOption = commandLine.getOptionValue("f");
if (StringUtils.isBlank(frequencyOption)) {
throw new IllegalArgumentException("Option --frequency (-f) must be set");
if (StringUtils.isBlank(frequencyOption) || StringUtils.isBlank(typeOption)) {
throw new IllegalArgumentException("Options --frequency (-f) and --type (-t) must be set");
}

if (!FrequencyType.isSupportedFrequencyType(frequencyOption)) {
throw new IllegalArgumentException(
"Option f must be one of following values D(Day), W(Week) or M(Month)");
}
subscriptionEmailNotificationService.perform(getContext(), handler, "content", frequencyOption);

if (!StringUtils.equalsAny(typeOption, "content", "statistics")) {
throw new IllegalArgumentException(
"Option t (type) must be one of \"content\" or \"statistics\"");
}

subscriptionEmailNotificationService.perform(getContext(), handler, typeOption, frequencyOption);
}

private void assignCurrentUserInContext() throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public boolean isAllowedToExecute(Context context) {
public Options getOptions() {
if (Objects.isNull(options)) {
Options options = new Options();
options.addOption("t", "type", true,
"Subscription type, Valid values are \"content\" or \"statistics\"");
options.getOption("t").setRequired(true);
options.addOption("f", "frequency", true,
"Subscription frequency. Valid values include: D (Day), W (Week) and M (Month)");
options.getOption("f").setRequired(true);
Expand Down

0 comments on commit 8071287

Please sign in to comment.