private static String getType(final Action action) { if (!action.isCancelingOrCanceled()) { return MgmtAction.ACTION_UPDATE; } else if (action.isCancelingOrCanceled()) { return MgmtAction.ACTION_CANCEL; } return null; }
@Override public Optional<Action> getActionForDownloadByTargetAndSoftwareModule(final String controllerId, final long moduleId) { throwExceptionIfTargetDoesNotExist(controllerId); throwExceptionIfSoftwareModuleDoesNotExist(moduleId); final List<Action> action = actionRepository.findActionByTargetAndSoftwareModule(controllerId, moduleId); if (action.isEmpty() || action.get(0).isCancelingOrCanceled()) { return Optional.empty(); } return Optional.ofNullable(action.get(0)); }
@Override public Optional<Action> getActionForDownloadByTargetAndSoftwareModule(final String controllerId, final long moduleId) { throwExceptionIfTargetDoesNotExist(controllerId); throwExceptionIfSoftwareModuleDoesNotExist(moduleId); final List<Action> action = actionRepository.findActionByTargetAndSoftwareModule(controllerId, moduleId); if (action.isEmpty() || action.get(0).isCancelingOrCanceled()) { return Optional.empty(); } return Optional.ofNullable(action.get(0)); }
private Status handleCancelRejectedState(final Message message, final Action action) { if (action.isCancelingOrCanceled()) { return Status.CANCEL_REJECTED; } logAndThrowMessageError(message, "Cancel rejected message is not allowed, if action is on state: " + action.getStatus()); return null; }
private StatusFontIcon createCancelButtonMetadata(final Action action) { final boolean isDisabled = !action.isActive() || action.isCancelingOrCanceled(); return new StatusFontIcon(FontAwesome.TIMES, STATUS_ICON_NEUTRAL, i18n.getMessage("message.cancel.action"), UIComponentIdProvider.ACTION_HISTORY_TABLE_CANCEL_ID, isDisabled); }
private StatusFontIcon createForceQuitButtonMetadata(final Action action) { final boolean isDisabled = !action.isActive() || !action.isCancelingOrCanceled(); return new StatusFontIcon(FontAwesome.TIMES, STATUS_ICON_RED, i18n.getMessage("message.forcequit.action"), UIComponentIdProvider.ACTION_HISTORY_TABLE_FORCE_QUIT_ID, isDisabled); }
private StatusFontIcon createForceButtonMetadata(final Action action) { final boolean isDisabled = !action.isActive() || action.isForce() || action.isCancelingOrCanceled(); return new StatusFontIcon(FontAwesome.BOLT, STATUS_ICON_NEUTRAL, i18n.getMessage("message.force.action"), UIComponentIdProvider.ACTION_HISTORY_TABLE_FORCE_ID, isDisabled); }
private StatusFontIcon createCancelButtonMetadata(final Action action) { final boolean isDisabled = !action.isActive() || action.isCancelingOrCanceled() || !permissionChecker.hasUpdateTargetPermission(); return new StatusFontIcon(FontAwesome.TIMES, STATUS_ICON_NEUTRAL, i18n.getMessage("message.cancel.action"), UIComponentIdProvider.ACTION_HISTORY_TABLE_CANCEL_ID, isDisabled); }
private StatusFontIcon createForceQuitButtonMetadata(final Action action) { final boolean isDisabled = !action.isActive() || !action.isCancelingOrCanceled() || !permissionChecker.hasUpdateTargetPermission(); return new StatusFontIcon(FontAwesome.TIMES, STATUS_ICON_RED, i18n.getMessage("message.forcequit.action"), UIComponentIdProvider.ACTION_HISTORY_TABLE_FORCE_QUIT_ID, isDisabled); }
private StatusFontIcon createForceButtonMetadata(final Action action) { final boolean isDisabled = !action.isActive() || action.isForce() || action.isCancelingOrCanceled() || !permissionChecker.hasUpdateTargetPermission(); return new StatusFontIcon(FontAwesome.BOLT, STATUS_ICON_NEUTRAL, i18n.getMessage("message.force.action"), UIComponentIdProvider.ACTION_HISTORY_TABLE_FORCE_ID, isDisabled); }
@Override public ResponseEntity<DdiCancel> getControllerCancelAction(@PathVariable("tenant") final String tenant, @PathVariable("controllerId") @NotEmpty final String controllerId, @PathVariable("actionId") @NotEmpty final Long actionId) { LOG.debug("getControllerCancelAction({})", controllerId); final Target target = controllerManagement.getByControllerId(controllerId) .orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId)); final Action action = findActionWithExceptionIfNotFound(actionId); if (!action.getTarget().getId().equals(target.getId())) { LOG.warn(GIVEN_ACTION_IS_NOT_ASSIGNED_TO_GIVEN_TARGET, action.getId(), target.getId()); return ResponseEntity.notFound().build(); } if (action.isCancelingOrCanceled()) { final DdiCancel cancel = new DdiCancel(String.valueOf(action.getId()), new DdiCancelActionToStop(String.valueOf(action.getId()))); LOG.debug("Found an active CancelAction for target {}. returning cancel: {}", controllerId, cancel); controllerManagement.registerRetrieved(action.getId(), RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target retrieved cancel action and should start now the cancelation."); return new ResponseEntity<>(cancel, HttpStatus.OK); } return ResponseEntity.notFound().build(); }
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()); }
@Override public ResponseEntity<DdiCancel> getControllerCancelAction(@PathVariable("tenant") final String tenant, @PathVariable("controllerId") @NotEmpty final String controllerId, @PathVariable("actionId") @NotEmpty final Long actionId) { LOG.debug("getControllerCancelAction({})", controllerId); final Target target = controllerManagement.getByControllerId(controllerId) .orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId)); final Action action = findActionWithExceptionIfNotFound(actionId); if (!action.getTarget().getId().equals(target.getId())) { LOG.warn(GIVEN_ACTION_IS_NOT_ASSIGNED_TO_GIVEN_TARGET, action.getId(), target.getId()); return ResponseEntity.notFound().build(); } if (action.isCancelingOrCanceled()) { final DdiCancel cancel = new DdiCancel(String.valueOf(action.getId()), new DdiCancelActionToStop(String.valueOf(action.getId()))); LOG.debug("Found an active CancelAction for target {}. returning cancel: {}", controllerId, cancel); controllerManagement.registerRetrieved(action.getId(), RepositoryConstants.SERVER_MESSAGE_PREFIX + "Target retrieved cancel action and should start now the cancelation."); return new ResponseEntity<>(cancel, HttpStatus.OK); } return ResponseEntity.notFound().build(); }
if (!action.isCancelingOrCanceled()) {
static MgmtAction toResponseWithLinks(final String controllerId, final Action action) { final MgmtAction result = toResponse(controllerId, action); if (action.isCancelingOrCanceled()) { result.add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(controllerId, action.getId())) .withRel(MgmtRestConstants.TARGET_V1_CANCELED_ACTION)); } result.add(linkTo( methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(action.getDistributionSet().getId())) .withRel("distributionset")); result.add(linkTo(methodOn(MgmtTargetRestApi.class).getActionStatusList(controllerId, action.getId(), 0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, ActionStatusFields.ID.getFieldName() + ":" + SortDirection.DESC)) .withRel(MgmtRestConstants.TARGET_V1_ACTION_STATUS)); return result; }
if (action.isCancelingOrCanceled()) { result.add(ControllerLinkBuilder .linkTo(ControllerLinkBuilder.methodOn(DdiRootController.class, tenantAware.getCurrentTenant())
if (action.isCancelingOrCanceled()) { result.add(ControllerLinkBuilder .linkTo(ControllerLinkBuilder.methodOn(DdiRootController.class, tenantAware.getCurrentTenant())