/** * Method will pull the services-repo to the published-repo and then execute the script to sync with all CAS nodes. * * @param response - HttpServletResponse. * @param request - HttpServletRequest. * @throws PublishFailureException - failed * @throws SyncScriptFailureException - failed */ @GetMapping(value = "/publish") @ResponseStatus(HttpStatus.OK) public void publish(final HttpServletResponse response, final HttpServletRequest request) throws PublishFailureException, SyncScriptFailureException { isAdministrator(request, response); try (GitUtil git = repositoryFactory.masterRepository()) { git.getUnpublishedCommits().forEach(commit -> { val diffs = publishDiffs(git, commit); // Run through deletes first in case of name change diffs.stream().filter(d -> d.getChangeType() == DiffEntry.ChangeType.DELETE) .forEach(c -> this.servicesManager.delete(CasManagementUtils.fromJson(getService(git, c.getOldId())).getId())); diffs.stream().filter(d -> d.getChangeType() != DiffEntry.ChangeType.DELETE) .forEach(c -> this.servicesManager.save(CasManagementUtils.fromJson(getService(git, c.getNewId())))); }); git.setPublished(); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); throw new PublishFailureException(); } runSyncScript(); }