Skip to content

Remote INSPIRE ATOM harvester / fix scheduling #8945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

josegar74
Copy link
Member

The scheduler for the remote INSPIRE ATOM harvester is processed during application start-up,

boolean inspireEnable = settingMan.getValueAsBool(Settings.SYSTEM_INSPIRE_ENABLE, false);
if (inspireEnable) {
String atomType = settingMan.getValue(Settings.SYSTEM_INSPIRE_ATOM);
String atomSchedule = settingMan.getValue(Settings.SYSTEM_INSPIRE_ATOM_SCHEDULE);
if (StringUtils.isNotEmpty(atomType) && StringUtils.isNotEmpty(atomSchedule)
&& atomType.equalsIgnoreCase(InspireAtomType.ATOM_REMOTE)) {
logger.info(" - INSPIRE ATOM feed harvester ...");
InspireAtomHarvesterScheduler.schedule(atomSchedule, context, gnContext);
}
}

but when the related system settings are updated, the scheduler is not updated.

This change request adds a new application event that is triggered when the system settings are updated. This event receives the old and new values of the settings. This event can be used to create listeners to execute for example this code defined currently in SiteApi:

public static void reloadServices(ServiceContext context) throws Exception {
GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
SettingManager settingMan = gc.getBean(SettingManager.class);
LogUtils.refreshLogConfiguration();
try {
// Load proxy information into Jeeves
ProxyInfo pi = JeevesProxyInfo.getInstance();
boolean useProxy = Lib.net.getProxyConfiguration().isEnabled();
if (useProxy) {
String proxyHost = Lib.net.getProxyConfiguration().getHost();
String proxyPort = Lib.net.getProxyConfiguration().getPort();
String username = Lib.net.getProxyConfiguration().getUsername();
String password = Lib.net.getProxyConfiguration().getPassword();
pi.setProxyInfo(proxyHost, Integer.valueOf(proxyPort), username, password);
} else {
pi.setProxyInfo(null, -1, null, null);
}
// Update http.proxyHost, http.proxyPort and http.nonProxyHosts
Lib.net.setupProxy(settingMan);
} catch (Exception e) {
context.error("Reload services. Error: " + e.getMessage());
context.error(e);
throw new OperationAbortedEx("Parameters saved but cannot set proxy information: " + e.getMessage());
}
HarvestManager harvestManager = context.getBean(HarvestManager.class);
harvestManager.rescheduleActiveHarvesters();
}

The inspire-atom module includes a listener for this event, that checks if the related settings for INSPIRE ATOM harvester are updated to update the harvester scheduler.

Checklist

  • I have read the contribution guidelines
  • Pull request provided for main branch, backports managed with label
  • Good housekeeping of code, cleaning up comments, tests, and documentation
  • Clean commit history broken into understandable chucks, avoiding big commits with hundreds of files, cautious of reformatting and whitespace changes
  • Clean commit messages, longer verbose messages are encouraged
  • API Changes are identified in commit messages
  • Testing provided for features or enhancements using automatic tests
  • User documentation provided for new features or enhancements in manual
  • Build documentation provided for development instructions in README.md files
  • Library management using pom.xml dependency management. Update build documentation with intended library use and library tutorials or documentation

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants