/** * Generates a virtual IsActiveDecoration for the presentation layer that is * calculated from {@link Action#isActive()} and * {@link Action#getActionStatus()}. * * @param action * the action combined IsActiveDecoration is calculated from * @return IsActiveDecoration combined decoration for the presentation * layer. */ private static IsActiveDecoration buildIsActiveDecoration(final Action action) { final Action.Status status = action.getStatus(); if (status == Action.Status.SCHEDULED) { return IsActiveDecoration.SCHEDULED; } else if (status == Action.Status.ERROR) { return IsActiveDecoration.IN_ACTIVE_ERROR; } return action.isActive() ? IsActiveDecoration.ACTIVE : IsActiveDecoration.IN_ACTIVE; }
/** * Generates a virtual IsActiveDecoration for the presentation layer that is * calculated from {@link Action#isActive()} and * {@link Action#getActionStatus()}. * * @param action * the action combined IsActiveDecoration is calculated from * @return IsActiveDecoration combined decoration for the presentation * layer. */ private static IsActiveDecoration buildIsActiveDecoration(final Action action) { final Action.Status status = action.getStatus(); if (status == Action.Status.SCHEDULED) { return IsActiveDecoration.SCHEDULED; } else if (status == Action.Status.ERROR) { return IsActiveDecoration.IN_ACTIVE_ERROR; } return action.isActive() ? IsActiveDecoration.ACTIVE : IsActiveDecoration.IN_ACTIVE; }
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<Void> postBasedeploymentActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback, @PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId, @PathVariable("actionId") @NotEmpty final Long actionId) { LOG.debug("provideBasedeploymentActionFeedback for target [{},{}]: {}", controllerId, actionId, feedback); final Target target = controllerManagement.getByControllerId(controllerId) .orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId)); if (!actionId.equals(feedback.getId())) { LOG.warn( "provideBasedeploymentActionFeedback: action in payload ({}) was not identical to action in path ({}).", feedback.getId(), actionId); return ResponseEntity.notFound().build(); } 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.isActive()) { LOG.warn("Updating action {} with feedback {} not possible since action not active anymore.", action.getId(), feedback.getId()); return new ResponseEntity<>(HttpStatus.GONE); } controllerManagement.addUpdateActionStatus(generateUpdateStatus(feedback, controllerId, feedback.getId())); return ResponseEntity.ok().build(); }
@Override public ResponseEntity<Void> postBasedeploymentActionFeedback(@Valid @RequestBody final DdiActionFeedback feedback, @PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId, @PathVariable("actionId") @NotEmpty final Long actionId) { LOG.debug("provideBasedeploymentActionFeedback for target [{},{}]: {}", controllerId, actionId, feedback); final Target target = controllerManagement.getByControllerId(controllerId) .orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId)); if (!actionId.equals(feedback.getId())) { LOG.warn( "provideBasedeploymentActionFeedback: action in payload ({}) was not identical to action in path ({}).", feedback.getId(), actionId); return ResponseEntity.notFound().build(); } 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.isActive()) { LOG.warn("Updating action {} with feedback {} not possible since action not active anymore.", action.getId(), feedback.getId()); return new ResponseEntity<>(HttpStatus.GONE); } controllerManagement.addUpdateActionStatus(generateUpdateStatus(feedback, controllerId, feedback.getId())); return ResponseEntity.ok().build(); }
/** * Method to update the action status of an action through the event. * * @param actionUpdateStatus * the object form the ampq message */ private void updateActionStatus(final Message message) { final DmfActionUpdateStatus actionUpdateStatus = convertMessage(message, DmfActionUpdateStatus.class); final Action action = checkActionExist(message, actionUpdateStatus); final List<String> messages = actionUpdateStatus.getMessage(); if (isCorrelationIdNotEmpty(message)) { messages.add(RepositoryConstants.SERVER_MESSAGE_PREFIX + "DMF message correlation-id " + message.getMessageProperties().getCorrelationId()); } final Status status = mapStatus(message, actionUpdateStatus, action); final ActionStatusCreate actionStatus = entityFactory.actionStatus().create(action.getId()).status(status) .messages(messages); final Action addUpdateActionStatus = getUpdateActionStatus(status, actionStatus); if (!addUpdateActionStatus.isActive() || (addUpdateActionStatus.hasMaintenanceSchedule() && addUpdateActionStatus.isMaintenanceWindowAvailable())) { lookIfUpdateAvailable(action.getTarget()); } }
/** * Creates a list of {@link ProxyAction}s for presentation layer from slice * of {@link Action}s. * * @param actionBeans * slice of {@link Action}s * @return list of {@link ProxyAction}s */ private static List<ProxyAction> createProxyActions(final Slice<Action> actionBeans) { final List<ProxyAction> proxyActions = new ArrayList<>(); for (final Action action : actionBeans) { final ProxyAction proxyAction = new ProxyAction(); final String dsNameVersion = action.getDistributionSet().getName() + ":" + action.getDistributionSet().getVersion(); proxyAction.setActive(action.isActive()); proxyAction.setIsActiveDecoration(buildIsActiveDecoration(action)); proxyAction.setDsNameVersion(dsNameVersion); proxyAction.setAction(action); proxyAction.setId(action.getId()); proxyAction.setLastModifiedAt(action.getLastModifiedAt()); proxyAction.setRolloutName(action.getRollout() != null ? action.getRollout().getName() : ""); proxyAction.setStatus(action.getStatus()); proxyAction.setMaintenanceWindow( action.hasMaintenanceSchedule() ? buildMaintenanceWindowDisplayText(action) : ""); proxyActions.add(proxyAction); } return proxyActions; }
/** * Creates a list of {@link ProxyAction}s for presentation layer from slice * of {@link Action}s. * * @param actionBeans * slice of {@link Action}s * @return list of {@link ProxyAction}s */ private static List<ProxyAction> createProxyActions(final Slice<Action> actionBeans) { final List<ProxyAction> proxyActions = new ArrayList<>(); for (final Action action : actionBeans) { final ProxyAction proxyAction = new ProxyAction(); final String dsNameVersion = action.getDistributionSet().getName() + ":" + action.getDistributionSet().getVersion(); proxyAction.setActive(action.isActive()); proxyAction.setIsActiveDecoration(buildIsActiveDecoration(action)); proxyAction.setDsNameVersion(dsNameVersion); proxyAction.setAction(action); proxyAction.setId(action.getId()); proxyAction.setLastModifiedAt(action.getLastModifiedAt()); proxyAction.setRolloutName(action.getRollout() != null ? action.getRollout().getName() : ""); proxyAction.setStatus(action.getStatus()); proxyAction.setMaintenanceWindow( action.hasMaintenanceSchedule() ? buildMaintenanceWindowDisplayText(action) : ""); proxyActions.add(proxyAction); } return proxyActions; }
static MgmtAction toResponse(final String targetId, final Action action) { final MgmtAction result = new MgmtAction(); result.setActionId(action.getId()); result.setType(getType(action)); if (ActionType.TIMEFORCED.equals(action.getActionType())) { result.setForceTime(action.getForcedTime()); } result.setForceType(MgmtRestModelMapper.convertActionType(action.getActionType())); if (action.isActive()) { result.setStatus(MgmtAction.ACTION_PENDING); } else { result.setStatus(MgmtAction.ACTION_FINISHED); } if (action.hasMaintenanceSchedule()) { final MgmtMaintenanceWindow maintenanceWindow = new MgmtMaintenanceWindow(); maintenanceWindow.setSchedule(action.getMaintenanceWindowSchedule()); maintenanceWindow.setDuration(action.getMaintenanceWindowDuration()); maintenanceWindow.setTimezone(action.getMaintenanceWindowTimeZone()); action.getMaintenanceWindowStartTime() .ifPresent(nextStart -> maintenanceWindow.setNextStartAt(nextStart.toInstant().toEpochMilli())); result.setMaintenanceWindow(maintenanceWindow); } MgmtRestModelMapper.mapBaseToBase(result, action); result.add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(targetId, action.getId())).withSelfRel()); return result; }