@Override public ResponseEntity<MgmtAction> getAction(@PathVariable("targetId") final String targetId, @PathVariable("actionId") final Long actionId) { final Action action = deploymentManagement.findAction(actionId) .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId)); if (!action.getTarget().getControllerId().equals(targetId)) { LOG.warn(ACTION_TARGET_MISSING_ASSIGN_WARN, action.getId(), targetId); return ResponseEntity.notFound().build(); } return ResponseEntity.ok(MgmtTargetMapper.toResponseWithLinks(targetId, action)); }
@Override public ResponseEntity<PagedList<MgmtActionStatus>> getActionStatusList( @PathVariable("targetId") final String targetId, @PathVariable("actionId") final Long actionId, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam) { final Target target = findTargetWithExceptionIfNotFound(targetId); final Action action = deploymentManagement.findAction(actionId) .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId)); if (!action.getTarget().getId().equals(target.getId())) { LOG.warn(ACTION_TARGET_MISSING_ASSIGN_WARN, action.getId(), target.getId()); return ResponseEntity.notFound().build(); } final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final Sort sorting = PagingUtility.sanitizeActionStatusSortParam(sortParam); final Page<ActionStatus> statusList = this.deploymentManagement.findActionStatusByAction( new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action.getId()); return ResponseEntity.ok(new PagedList<>( MgmtTargetMapper.toActionStatusRestResponse(statusList.getContent(), deploymentManagement), statusList.getTotalElements())); }
@Override public ResponseEntity<MgmtAction> updateAction(@PathVariable("targetId") final String targetId, @PathVariable("actionId") final Long actionId, @RequestBody final MgmtActionRequestBodyPut actionUpdate) { Action action = deploymentManagement.findAction(actionId) .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId)); if (!action.getTarget().getControllerId().equals(targetId)) { LOG.warn(ACTION_TARGET_MISSING_ASSIGN_WARN, action.getId(), targetId); return ResponseEntity.notFound().build(); } if (!MgmtActionType.FORCED.equals(actionUpdate.getForceType())) { throw new ValidationException("Resource supports only switch to FORCED."); } action = deploymentManagement.forceTargetAction(actionId); return ResponseEntity.ok(MgmtTargetMapper.toResponseWithLinks(targetId, action)); }
@Override public ResponseEntity<Void> cancelAction(@PathVariable("targetId") final String targetId, @PathVariable("actionId") final Long actionId, @RequestParam(value = "force", required = false, defaultValue = "false") final boolean force) { final Action action = deploymentManagement.findAction(actionId) .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId)); if (!action.getTarget().getControllerId().equals(targetId)) { LOG.warn(ACTION_TARGET_MISSING_ASSIGN_WARN, actionId, targetId); return ResponseEntity.notFound().build(); } if (force) { this.deploymentManagement.forceQuitAction(actionId); } else { this.deploymentManagement.cancelAction(actionId); } // both functions will throw an exception, when action is in wrong // state, which is mapped by MgmtResponseExceptionHandler. return ResponseEntity.noContent().build(); }
.assignDistributionSet(set.getId(), ActionType.SOFT, 0, Arrays.asList(target.getControllerId())) .getActions().get(0); assertThat(deploymentManagement.findAction(actionId).get().getActionType()).isEqualTo(ActionType.SOFT);
public void getActionFromTarget() throws Exception { final Action action = generateActionForTarget(targetId, true, true); assertThat(deploymentManagement.findAction(action.getId()).get().getActionType()) .isEqualTo(ActionType.TIMEFORCED);