Skip to content

Commit

Permalink
Do not update repositories when no ssh data is present
Browse files Browse the repository at this point in the history
  • Loading branch information
mackdk committed Oct 2, 2023
1 parent b6d73fc commit b10214d
Showing 1 changed file with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@

import com.jcraft.jsch.JSchException;

import org.apache.commons.collections.CollectionUtils;
import org.quartz.JobExecutionContext;

import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

public class PaygUpdateAuthTask extends RhnJavaJob {

Expand Down Expand Up @@ -88,25 +91,28 @@ public void execute(JobExecutionContext jobExecutionContext) {

manageLocalHostPayg();

sccRefreshLock.withFileLock(() -> {
if (jobExecutionContext != null && jobExecutionContext.getJobDetail().getJobDataMap().containsKey(KEY_ID)) {
Optional<PaygSshData> paygData = PaygSshDataFactory.lookupById(
Integer.parseInt((String) jobExecutionContext.getJobDetail().getJobDataMap().get(KEY_ID)));
paygData.ifPresent(this::updateInstanceData);
}
else {
PaygSshDataFactory.lookupPaygSshData()
.forEach(this::updateInstanceData);
}
List<PaygSshData> paygSshData;
if (jobExecutionContext != null && jobExecutionContext.getJobDetail().getJobDataMap().containsKey(KEY_ID)) {
int sshId = Integer.parseInt((String) jobExecutionContext.getJobDetail().getJobDataMap().get(KEY_ID));
paygSshData = PaygSshDataFactory.lookupById(sshId).stream().collect(Collectors.toList());
}
else {
paygSshData = PaygSshDataFactory.lookupPaygSshData();
}

// Call the content sync manager to refresh all repositories content sources and the authorizations
try {
contentSyncManager.updateRepositoriesPayg();
}
catch (ContentSyncException ex) {
log.error("Unable to refresh repositories", ex);
}
});
if (CollectionUtils.isNotEmpty(paygSshData)) {
sccRefreshLock.withFileLock(() -> {
paygSshData.forEach(this::updateInstanceData);

// Call the content sync manager to refresh all repositories content sources and the authorizations
try {
contentSyncManager.updateRepositoriesPayg();
}
catch (ContentSyncException ex) {
log.error("Unable to refresh repositories", ex);
}
});
}
}

/**
Expand Down

0 comments on commit b10214d

Please sign in to comment.