Skip to content

Commit e869d3a

Browse files
authored
Merge pull request #9835 from mcalmer/sonarcloud-fixes
Sonarcloud fixes
2 parents 3dbe085 + 3646168 commit e869d3a

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

java/code/src/com/redhat/rhn/taskomatic/TaskomaticApi.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public class TaskomaticApi {
7272
MINION_ACTION_JOB_PREFIX + "download-";
7373
public static final String MINION_ACTIONCHAIN_BUNCH_LABEL = "minion-action-chain-executor-bunch";
7474
public static final String MINION_ACTIONCHAIN_JOB_PREFIX = "minion-action-chain-executor-";
75+
76+
private static final String SCHEDULE_SINGLE_SAT_BUNCH_RUN = "tasko.scheduleSingleSatBunchRun";
7577
private static final Logger LOG = LogManager.getLogger(TaskomaticApi.class);
7678

7779

@@ -135,7 +137,7 @@ public void scheduleSSHActionExecution(Action actionIn, MinionServer sshMinion,
135137
scheduleParams.put("action_id", Long.toString(actionIn.getId()));
136138
scheduleParams.put("force_pkg_list_refresh", Boolean.toString(forcePackageListRefresh));
137139
scheduleParams.put("ssh_minion_id", sshMinion.getMinionId());
138-
invoke("tasko.scheduleSingleSatBunchRun",
140+
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN,
139141
"ssh-minion-action-executor-bunch",
140142
StringUtils.substring(
141143
"ssh-minion-action-executor-" + actionIn.getId() + "-" + sshMinion.getId(), 0, 50),
@@ -263,7 +265,7 @@ public Date scheduleRepoSync(Channel chan, User user, String cron,
263265
public Date scheduleSingleSatBunch(User user, String bunchName,
264266
Map<String, String> params) throws TaskomaticApiException {
265267
ensureSatAdminRole(user);
266-
return (Date) invoke("tasko.scheduleSingleSatBunchRun", bunchName, params);
268+
return (Date) invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, bunchName, params);
267269
}
268270

269271
/**
@@ -276,7 +278,7 @@ public Date scheduleSingleSatBunch(User user, String bunchName,
276278
*/
277279
public Date scheduleGathererRefresh(User user, Map<String, String> params) throws TaskomaticApiException {
278280
ensureOrgAdminRole(user);
279-
return (Date) invoke("tasko.scheduleSingleSatBunchRun", "gatherer-matcher-bunch", params);
281+
return (Date) invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, "gatherer-matcher-bunch", params);
280282
}
281283

282284
/**
@@ -342,7 +344,7 @@ public Date scheduleSatBunch(User user, String jobLabel, String bunchName, Strin
342344
*/
343345
public void scheduleRecurringAction(RecurringAction action, User user) throws TaskomaticApiException {
344346
if (!action.canAccess(user)) {
345-
throw new PermissionException(String.format("User '%s' can't schedule action '$s'", user, action));
347+
throw new PermissionException(String.format("User '%s' can't schedule action '%s'", user, action));
346348
}
347349

348350
doScheduleSatBunch(user, action.computeTaskoScheduleName(), "recurring-action-executor-bunch",
@@ -369,7 +371,7 @@ private Date doScheduleSatBunch(User user, String jobLabel, String bunchName, St
369371
*/
370372
public void unscheduleRecurringAction(RecurringAction action, User user) throws TaskomaticApiException {
371373
if (!action.canAccess(user)) {
372-
throw new PermissionException(String.format("User '%s' can't unschedule action '$s'", user, action));
374+
throw new PermissionException(String.format("User '%s' can't unschedule action '%s'", user, action));
373375
}
374376

375377
doUnscheduleSatBunch(user, action.computeTaskoScheduleName(), "recurring-action-executor-bunch");
@@ -517,8 +519,7 @@ public String getRepoSyncSchedule(Channel chan, User user)
517519
* @throws TaskomaticApiException if there was an error
518520
*/
519521
public List<Map<String, Object>> listSatBunchSchedules(User user) throws TaskomaticApiException {
520-
List<Map<String, Object>> bunches = (List<Map<String, Object>>) invoke("tasko.listSatBunches");
521-
return bunches;
522+
return (List<Map<String, Object>>) invoke("tasko.listSatBunches");
522523
}
523524

524525
/**
@@ -669,7 +670,7 @@ public void scheduleActionChainExecution(ActionChain actionchain)
669670
Map<String, String> params = new HashMap<>();
670671
params.put("actionchain_id", Long.toString(actionchain.getId()));
671672

672-
invoke("tasko.scheduleSingleSatBunchRun", MINION_ACTIONCHAIN_BUNCH_LABEL,
673+
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, MINION_ACTIONCHAIN_BUNCH_LABEL,
673674
MINION_ACTIONCHAIN_JOB_PREFIX + actionchain.getId(), params,
674675
earliestAction);
675676
}
@@ -689,7 +690,7 @@ public void scheduleStagingJob(Long actionId, Long minionId, Date stagingDateTim
689690
params.put("staging_job", "true");
690691
params.put("staging_job_minion_server_id", Long.toString(minionId));
691692

692-
invoke("tasko.scheduleSingleSatBunchRun", MINION_ACTION_BUNCH_LABEL,
693+
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, MINION_ACTION_BUNCH_LABEL,
693694
MINION_ACTION_JOB_DOWNLOAD_PREFIX + actionId + "-" + minionId, params,
694695
stagingDateTime);
695696
}
@@ -751,7 +752,7 @@ public void scheduleSubscribeChannels(User user, SubscribeChannelsAction action)
751752
Map<String, String> params = new HashMap<>();
752753
params.put("action_id", Long.toString(action.getId()));
753754
params.put("user_id", Long.toString(user.getId()));
754-
invoke("tasko.scheduleSingleSatBunchRun", MINION_ACTION_BUNCH_LABEL,
755+
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, MINION_ACTION_BUNCH_LABEL,
755756
MINION_ACTION_JOB_PREFIX + action.getId(), params,
756757
action.getEarliestAction());
757758
}
@@ -809,7 +810,7 @@ public void scheduleSinglePaygUpdate(PaygSshData sshdata)
809810
throws TaskomaticApiException {
810811
Map<String, String> scheduleParams = new HashMap<>();
811812
scheduleParams.put("sshData_id", sshdata.getId().toString());
812-
invoke("tasko.scheduleSingleSatBunchRun", "update-payg-data-bunch", scheduleParams);
813+
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, "update-payg-data-bunch", scheduleParams);
813814
}
814815

815816
/**
@@ -856,7 +857,7 @@ public void scheduleSingleRootCaCertUpdate(Map<String, String> filenameToRootCaC
856857

857858
Map<String, Object> paramList = new HashMap<>();
858859
paramList.put("filename_to_root_ca_cert_map", sanitisedFilenameToRootCaCertMap);
859-
invoke("tasko.scheduleSingleSatBunchRun", "root-ca-cert-update-bunch", paramList);
860+
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, "root-ca-cert-update-bunch", paramList);
860861
}
861862

862863
/**
@@ -868,7 +869,7 @@ public void scheduleSingleGpgKeyImport(String gpgKey) throws TaskomaticApiExcept
868869
if (StringUtils.isBlank(gpgKey)) {
869870
return;
870871
}
871-
invoke("tasko.scheduleSingleSatBunchRun", "custom-gpg-key-import-bunch", Map.of("gpg-key", gpgKey));
872+
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, "custom-gpg-key-import-bunch", Map.of("gpg-key", gpgKey));
872873
}
873874

874875
/**
@@ -878,7 +879,7 @@ public void scheduleSingleGpgKeyImport(String gpgKey) throws TaskomaticApiExcept
878879
* @throws TaskomaticApiException if there is an error
879880
*/
880881
public void scheduleProductRefresh(Date earliest, boolean withReposync) throws TaskomaticApiException {
881-
invoke("tasko.scheduleSingleSatBunchRun", "mgr-sync-refresh-bunch",
882+
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, "mgr-sync-refresh-bunch",
882883
Map.of("noRepoSync", !withReposync), earliest);
883884
}
884885
}

0 commit comments

Comments
 (0)