@Override public ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId) { LOG.debug("getControllerBase({})", controllerId); final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(controllerId, IpUtil .getClientIpFromRequest(requestResponseContextHolder.getHttpServletRequest(), securityProperties)); final Action action = controllerManagement.findOldestActiveActionByTarget(controllerId).orElse(null); checkAndCancelExpiredAction(action); return new ResponseEntity<>( DataConversionHelper.fromTarget(target, action, action == null ? controllerManagement.getPollingTime() : controllerManagement.getPollingTimeForAction(action.getId()), tenantAware), HttpStatus.OK); }
@Override public ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId) { LOG.debug("getControllerBase({})", controllerId); final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(controllerId, IpUtil .getClientIpFromRequest(requestResponseContextHolder.getHttpServletRequest(), securityProperties)); final Action action = controllerManagement.findOldestActiveActionByTarget(controllerId).orElse(null); checkAndCancelExpiredAction(action); return new ResponseEntity<>( DataConversionHelper.fromTarget(target, action, action == null ? controllerManagement.getPollingTime() : controllerManagement.getPollingTimeForAction(action.getId()), tenantAware), HttpStatus.OK); }
private void lookIfUpdateAvailable(final Target target) { final Optional<Action> actionOptional = controllerManagement .findOldestActiveActionByTarget(target.getControllerId()); if (!actionOptional.isPresent()) { return; } final Action action = actionOptional.get(); if (action.isCancelingOrCanceled()) { amqpMessageDispatcherService.sendCancelMessageToTarget(target.getTenant(), target.getControllerId(), action.getId(), target.getAddress()); return; } final Map<SoftwareModule, List<SoftwareModuleMetadata>> modules = Maps .newHashMapWithExpectedSize(action.getDistributionSet().getModules().size()); final Map<Long, List<SoftwareModuleMetadata>> metadata = controllerManagement .findTargetVisibleMetaDataBySoftwareModuleId(action.getDistributionSet().getModules().stream() .map(SoftwareModule::getId).collect(Collectors.toList())); action.getDistributionSet().getModules().forEach(module -> modules.put(module, metadata.get(module.getId()))); amqpMessageDispatcherService.sendUpdateMessageToTarget(action.getTenant(), action.getTarget(), action.getId(), modules, action.isMaintenanceWindowAvailable()); }