Skip to content

Commit

Permalink
Merge pull request #9835 from mcalmer/sonarcloud-fixes
Browse files Browse the repository at this point in the history
Sonarcloud fixes
  • Loading branch information
mcalmer authored Feb 24, 2025
2 parents 3dbe085 + 3646168 commit e869d3a
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions java/code/src/com/redhat/rhn/taskomatic/TaskomaticApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public class TaskomaticApi {
MINION_ACTION_JOB_PREFIX + "download-";
public static final String MINION_ACTIONCHAIN_BUNCH_LABEL = "minion-action-chain-executor-bunch";
public static final String MINION_ACTIONCHAIN_JOB_PREFIX = "minion-action-chain-executor-";

private static final String SCHEDULE_SINGLE_SAT_BUNCH_RUN = "tasko.scheduleSingleSatBunchRun";
private static final Logger LOG = LogManager.getLogger(TaskomaticApi.class);


Expand Down Expand Up @@ -135,7 +137,7 @@ public void scheduleSSHActionExecution(Action actionIn, MinionServer sshMinion,
scheduleParams.put("action_id", Long.toString(actionIn.getId()));
scheduleParams.put("force_pkg_list_refresh", Boolean.toString(forcePackageListRefresh));
scheduleParams.put("ssh_minion_id", sshMinion.getMinionId());
invoke("tasko.scheduleSingleSatBunchRun",
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN,
"ssh-minion-action-executor-bunch",
StringUtils.substring(
"ssh-minion-action-executor-" + actionIn.getId() + "-" + sshMinion.getId(), 0, 50),
Expand Down Expand Up @@ -263,7 +265,7 @@ public Date scheduleRepoSync(Channel chan, User user, String cron,
public Date scheduleSingleSatBunch(User user, String bunchName,
Map<String, String> params) throws TaskomaticApiException {
ensureSatAdminRole(user);
return (Date) invoke("tasko.scheduleSingleSatBunchRun", bunchName, params);
return (Date) invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, bunchName, params);
}

/**
Expand All @@ -276,7 +278,7 @@ public Date scheduleSingleSatBunch(User user, String bunchName,
*/
public Date scheduleGathererRefresh(User user, Map<String, String> params) throws TaskomaticApiException {
ensureOrgAdminRole(user);
return (Date) invoke("tasko.scheduleSingleSatBunchRun", "gatherer-matcher-bunch", params);
return (Date) invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, "gatherer-matcher-bunch", params);
}

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

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

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

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

invoke("tasko.scheduleSingleSatBunchRun", MINION_ACTIONCHAIN_BUNCH_LABEL,
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, MINION_ACTIONCHAIN_BUNCH_LABEL,
MINION_ACTIONCHAIN_JOB_PREFIX + actionchain.getId(), params,
earliestAction);
}
Expand All @@ -689,7 +690,7 @@ public void scheduleStagingJob(Long actionId, Long minionId, Date stagingDateTim
params.put("staging_job", "true");
params.put("staging_job_minion_server_id", Long.toString(minionId));

invoke("tasko.scheduleSingleSatBunchRun", MINION_ACTION_BUNCH_LABEL,
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, MINION_ACTION_BUNCH_LABEL,
MINION_ACTION_JOB_DOWNLOAD_PREFIX + actionId + "-" + minionId, params,
stagingDateTime);
}
Expand Down Expand Up @@ -751,7 +752,7 @@ public void scheduleSubscribeChannels(User user, SubscribeChannelsAction action)
Map<String, String> params = new HashMap<>();
params.put("action_id", Long.toString(action.getId()));
params.put("user_id", Long.toString(user.getId()));
invoke("tasko.scheduleSingleSatBunchRun", MINION_ACTION_BUNCH_LABEL,
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, MINION_ACTION_BUNCH_LABEL,
MINION_ACTION_JOB_PREFIX + action.getId(), params,
action.getEarliestAction());
}
Expand Down Expand Up @@ -809,7 +810,7 @@ public void scheduleSinglePaygUpdate(PaygSshData sshdata)
throws TaskomaticApiException {
Map<String, String> scheduleParams = new HashMap<>();
scheduleParams.put("sshData_id", sshdata.getId().toString());
invoke("tasko.scheduleSingleSatBunchRun", "update-payg-data-bunch", scheduleParams);
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, "update-payg-data-bunch", scheduleParams);
}

/**
Expand Down Expand Up @@ -856,7 +857,7 @@ public void scheduleSingleRootCaCertUpdate(Map<String, String> filenameToRootCaC

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

/**
Expand All @@ -868,7 +869,7 @@ public void scheduleSingleGpgKeyImport(String gpgKey) throws TaskomaticApiExcept
if (StringUtils.isBlank(gpgKey)) {
return;
}
invoke("tasko.scheduleSingleSatBunchRun", "custom-gpg-key-import-bunch", Map.of("gpg-key", gpgKey));
invoke(SCHEDULE_SINGLE_SAT_BUNCH_RUN, "custom-gpg-key-import-bunch", Map.of("gpg-key", gpgKey));
}

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

0 comments on commit e869d3a

Please sign in to comment.