DDI resource - remove dupplicated annotations (MgmtTargetResource) (#2070)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-11-17 20:10:41 +02:00
committed by GitHub
parent a2172abee6
commit ac0a6d4326
2 changed files with 77 additions and 68 deletions

View File

@@ -177,7 +177,7 @@ public interface MgmtTargetRestApi {
@PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING, @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING,
consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE },
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtTarget>> createTargets(List<MgmtTargetRequestBody> targets); ResponseEntity<List<MgmtTarget>> createTargets(@RequestBody List<MgmtTargetRequestBody> targets);
/** /**
* Handles the PUT request of updating a target. The ID is within the URL path of the request. A given ID in the request body is ignored. * Handles the PUT request of updating a target. The ID is within the URL path of the request. A given ID in the request body is ignored.
@@ -217,7 +217,9 @@ public interface MgmtTargetRestApi {
@PutMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", @PutMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}",
consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE },
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtTarget> updateTarget(@PathVariable("targetId") String targetId, MgmtTargetRequestBody targetRest); ResponseEntity<MgmtTarget> updateTarget(
@PathVariable("targetId") String targetId,
@RequestBody MgmtTargetRequestBody targetRest);
/** /**
* Handles the DELETE request of deleting a target. * Handles the DELETE request of deleting a target.
@@ -302,7 +304,7 @@ public interface MgmtTargetRestApi {
}) })
@PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING, @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING,
consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<Void> assignTargetType(@PathVariable("targetId") String targetId, MgmtId targetTypeId); ResponseEntity<Void> assignTargetType(@PathVariable("targetId") String targetId, @RequestBody MgmtId targetTypeId);
/** /**
* Handles the GET request of retrieving the attributes of a specific target. * Handles the GET request of retrieving the attributes of a specific target.
@@ -422,7 +424,9 @@ public interface MgmtTargetRestApi {
}) })
@GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}",
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtAction> getAction(@PathVariable("targetId") String targetId, @PathVariable("actionId") Long actionId); ResponseEntity<MgmtAction> getAction(
@PathVariable("targetId") String targetId,
@PathVariable("actionId") Long actionId);
/** /**
* Handles the DELETE request of canceling an specific Actions of a specific Target. * Handles the DELETE request of canceling an specific Actions of a specific Target.
@@ -497,7 +501,8 @@ public interface MgmtTargetRestApi {
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtAction> updateAction( ResponseEntity<MgmtAction> updateAction(
@PathVariable("targetId") String targetId, @PathVariable("targetId") String targetId,
@PathVariable("actionId") Long actionId, MgmtActionRequestBodyPut actionUpdate); @PathVariable("actionId") Long actionId,
@RequestBody MgmtActionRequestBodyPut actionUpdate);
/** /**
* Handles the GET request of retrieving the ActionStatus of a specific target and action. * Handles the GET request of retrieving the ActionStatus of a specific target and action.
@@ -610,7 +615,7 @@ public interface MgmtTargetRestApi {
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtTargetAssignmentResponseBody> postAssignedDistributionSet( ResponseEntity<MgmtTargetAssignmentResponseBody> postAssignedDistributionSet(
@PathVariable("targetId") String targetId, @PathVariable("targetId") String targetId,
@Valid MgmtDistributionSetAssignments dsAssignments, @RequestBody @Valid MgmtDistributionSetAssignments dsAssignments,
@RequestParam(value = "offline", required = false) @RequestParam(value = "offline", required = false)
@Schema(description = """ @Schema(description = """
Offline update (set param to true) that is only reported but not managed by the service, e.g. Offline update (set param to true) that is only reported but not managed by the service, e.g.
@@ -709,7 +714,8 @@ public interface MgmtTargetRestApi {
}) })
@GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", produces = { @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", produces = {
MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<PagedList<MgmtMetadata>> getMetadata(@PathVariable("targetId") String targetId, ResponseEntity<PagedList<MgmtMetadata>> getMetadata(
@PathVariable("targetId") String targetId,
@RequestParam( @RequestParam(
value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET,
defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET)
@@ -804,7 +810,8 @@ public interface MgmtTargetRestApi {
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<MgmtMetadata> updateMetadata( ResponseEntity<MgmtMetadata> updateMetadata(
@PathVariable("targetId") String targetId, @PathVariable("targetId") String targetId,
@PathVariable("metadataKey") String metadataKey, MgmtMetadataBodyPut metadata); @PathVariable("metadataKey") String metadataKey,
@RequestBody MgmtMetadataBodyPut metadata);
/** /**
* Deletes a single metadata entry from the target. * Deletes a single metadata entry from the target.
@@ -874,7 +881,9 @@ public interface MgmtTargetRestApi {
@PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata",
consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }, consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE },
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
ResponseEntity<List<MgmtMetadata>> createMetadata(@PathVariable("targetId") String targetId, List<MgmtMetadata> metadataRest); ResponseEntity<List<MgmtMetadata>> createMetadata(
@PathVariable("targetId") String targetId,
@RequestBody List<MgmtMetadata> metadataRest);
/** /**
* Get the current auto-confirm state for a specific target. * Get the current auto-confirm state for a specific target.
@@ -977,5 +986,6 @@ public interface MgmtTargetRestApi {
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) content = @Content(mediaType = "application/json", schema = @Schema(hidden = true)))
}) })
@PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/autoConfirm/deactivate") @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/autoConfirm/deactivate")
ResponseEntity<Void> deactivateAutoConfirm(@PathVariable("targetId") String targetId); ResponseEntity<Void> deactivateAutoConfirm(
@PathVariable("targetId") String targetId);
} }

View File

@@ -64,9 +64,6 @@ import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
@@ -84,7 +81,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
private final EntityFactory entityFactory; private final EntityFactory entityFactory;
private final TenantConfigHelper tenantConfigHelper; private final TenantConfigHelper tenantConfigHelper;
MgmtTargetResource(final TargetManagement targetManagement, final DeploymentManagement deploymentManagement, MgmtTargetResource(
final TargetManagement targetManagement, final DeploymentManagement deploymentManagement,
final ConfirmationManagement confirmationManagement, final EntityFactory entityFactory, final ConfirmationManagement confirmationManagement, final EntityFactory entityFactory,
final SystemSecurityContext systemSecurityContext, final SystemSecurityContext systemSecurityContext,
final TenantConfigurationManagement tenantConfigurationManagement) { final TenantConfigurationManagement tenantConfigurationManagement) {
@@ -96,7 +94,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
} }
@Override @Override
public ResponseEntity<MgmtTarget> getTarget(@PathVariable("targetId") final String targetId) { public ResponseEntity<MgmtTarget> getTarget(final String targetId) {
final Target findTarget = findTargetWithExceptionIfNotFound(targetId); final Target findTarget = findTargetWithExceptionIfNotFound(targetId);
// to single response include poll status // to single response include poll status
final MgmtTarget response = MgmtTargetMapper.toResponse(findTarget, tenantConfigHelper, null); final MgmtTarget response = MgmtTargetMapper.toResponse(findTarget, tenantConfigHelper, null);
@@ -107,10 +105,10 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override @Override
public ResponseEntity<PagedList<MgmtTarget>> getTargets( public ResponseEntity<PagedList<MgmtTarget>> getTargets(
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { final String rsqlParam) {
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
final Sort sorting = PagingUtility.sanitizeTargetSortParam(sortParam); final Sort sorting = PagingUtility.sanitizeTargetSortParam(sortParam);
@@ -131,7 +129,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
} }
@Override @Override
public ResponseEntity<List<MgmtTarget>> createTargets(@RequestBody final List<MgmtTargetRequestBody> targets) { public ResponseEntity<List<MgmtTarget>> createTargets(final List<MgmtTargetRequestBody> targets) {
log.debug("creating {} targets", targets.size()); log.debug("creating {} targets", targets.size());
final Collection<Target> createdTargets = this.targetManagement final Collection<Target> createdTargets = this.targetManagement
.create(MgmtTargetMapper.fromRequest(entityFactory, targets)); .create(MgmtTargetMapper.fromRequest(entityFactory, targets));
@@ -142,8 +140,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override @Override
public ResponseEntity<MgmtTarget> updateTarget( public ResponseEntity<MgmtTarget> updateTarget(
@PathVariable("targetId") final String targetId, final String targetId,
@RequestBody final MgmtTargetRequestBody targetRest) { final MgmtTargetRequestBody targetRest) {
if (targetRest.getRequestAttributes() != null) { if (targetRest.getRequestAttributes() != null) {
if (targetRest.getRequestAttributes()) { if (targetRest.getRequestAttributes()) {
targetManagement.requestControllerAttributes(targetId); targetManagement.requestControllerAttributes(targetId);
@@ -177,27 +175,27 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
} }
@Override @Override
public ResponseEntity<Void> deleteTarget(@PathVariable("targetId") final String targetId) { public ResponseEntity<Void> deleteTarget(final String targetId) {
this.targetManagement.deleteByControllerID(targetId); this.targetManagement.deleteByControllerID(targetId);
log.debug("{} target deleted, return status {}", targetId, HttpStatus.OK); log.debug("{} target deleted, return status {}", targetId, HttpStatus.OK);
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
@Override @Override
public ResponseEntity<Void> unassignTargetType(@PathVariable("targetId") final String targetId) { public ResponseEntity<Void> unassignTargetType(final String targetId) {
this.targetManagement.unassignType(targetId); this.targetManagement.unassignType(targetId);
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
@Override @Override
public ResponseEntity<Void> assignTargetType(@PathVariable("targetId") final String targetId, public ResponseEntity<Void> assignTargetType(final String targetId,
@RequestBody final MgmtId targetTypeId) { final MgmtId targetTypeId) {
this.targetManagement.assignType(targetId, targetTypeId.getId()); this.targetManagement.assignType(targetId, targetTypeId.getId());
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
@Override @Override
public ResponseEntity<MgmtTargetAttributes> getAttributes(@PathVariable("targetId") final String targetId) { public ResponseEntity<MgmtTargetAttributes> getAttributes(final String targetId) {
final Map<String, String> controllerAttributes = targetManagement.getControllerAttributes(targetId); final Map<String, String> controllerAttributes = targetManagement.getControllerAttributes(targetId);
if (controllerAttributes.isEmpty()) { if (controllerAttributes.isEmpty()) {
return ResponseEntity.noContent().build(); return ResponseEntity.noContent().build();
@@ -211,12 +209,11 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override @Override
public ResponseEntity<PagedList<MgmtAction>> getActionHistory( public ResponseEntity<PagedList<MgmtAction>> getActionHistory(
@PathVariable("targetId") final String targetId, final String targetId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { final String rsqlParam) {
findTargetWithExceptionIfNotFound(targetId); findTargetWithExceptionIfNotFound(targetId);
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
@@ -239,8 +236,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override @Override
public ResponseEntity<MgmtAction> getAction( public ResponseEntity<MgmtAction> getAction(
@PathVariable("targetId") final String targetId, final String targetId,
@PathVariable("actionId") final Long actionId) { final Long actionId) {
final Action action = deploymentManagement.findAction(actionId) final Action action = deploymentManagement.findAction(actionId)
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId)); .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));
if (!action.getTarget().getControllerId().equals(targetId)) { if (!action.getTarget().getControllerId().equals(targetId)) {
@@ -253,9 +250,9 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override @Override
public ResponseEntity<Void> cancelAction( public ResponseEntity<Void> cancelAction(
@PathVariable("targetId") final String targetId, final String targetId,
@PathVariable("actionId") final Long actionId, final Long actionId,
@RequestParam(value = "force", required = false, defaultValue = "false") final boolean force) { final boolean force) {
final Action action = deploymentManagement.findAction(actionId) final Action action = deploymentManagement.findAction(actionId)
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId)); .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));
@@ -277,8 +274,9 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override @Override
public ResponseEntity<MgmtAction> updateAction( public ResponseEntity<MgmtAction> updateAction(
@PathVariable("targetId") final String targetId, final String targetId,
@PathVariable("actionId") final Long actionId, @RequestBody final MgmtActionRequestBodyPut actionUpdate) { final Long actionId,
final MgmtActionRequestBodyPut actionUpdate) {
Action action = deploymentManagement.findAction(actionId) Action action = deploymentManagement.findAction(actionId)
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId)); .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));
@@ -298,11 +296,11 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override @Override
public ResponseEntity<PagedList<MgmtActionStatus>> getActionStatusList( public ResponseEntity<PagedList<MgmtActionStatus>> getActionStatusList(
@PathVariable("targetId") final String targetId, @PathVariable("actionId") final Long actionId, final String targetId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, final Long actionId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam) { final int pagingLimitParam,
final String sortParam) {
final Target target = findTargetWithExceptionIfNotFound(targetId); final Target target = findTargetWithExceptionIfNotFound(targetId);
final Action action = deploymentManagement.findAction(actionId) final Action action = deploymentManagement.findAction(actionId)
@@ -326,7 +324,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
} }
@Override @Override
public ResponseEntity<MgmtDistributionSet> getAssignedDistributionSet(@PathVariable("targetId") final String targetId) { public ResponseEntity<MgmtDistributionSet> getAssignedDistributionSet(final String targetId) {
final MgmtDistributionSet distributionSetRest = deploymentManagement.getAssignedDistributionSet(targetId) final MgmtDistributionSet distributionSetRest = deploymentManagement.getAssignedDistributionSet(targetId)
.map(ds -> { .map(ds -> {
final MgmtDistributionSet response = MgmtDistributionSetMapper.toResponse(ds); final MgmtDistributionSet response = MgmtDistributionSetMapper.toResponse(ds);
@@ -343,9 +341,9 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override @Override
public ResponseEntity<MgmtTargetAssignmentResponseBody> postAssignedDistributionSet( public ResponseEntity<MgmtTargetAssignmentResponseBody> postAssignedDistributionSet(
@PathVariable("targetId") final String targetId, final String targetId,
@RequestBody final MgmtDistributionSetAssignments dsAssignments, final MgmtDistributionSetAssignments dsAssignments,
@RequestParam(value = "offline", required = false) final Boolean offline) { final Boolean offline) {
if (offline != null && offline) { if (offline != null && offline) {
final List<Entry<String, Long>> offlineAssignments = dsAssignments.stream() final List<Entry<String, Long>> offlineAssignments = dsAssignments.stream()
.map(dsAssignment -> new SimpleEntry<String, Long>(targetId, dsAssignment.getId())) .map(dsAssignment -> new SimpleEntry<String, Long>(targetId, dsAssignment.getId()))
@@ -369,7 +367,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
} }
@Override @Override
public ResponseEntity<MgmtDistributionSet> getInstalledDistributionSet(@PathVariable("targetId") final String targetId) { public ResponseEntity<MgmtDistributionSet> getInstalledDistributionSet(final String targetId) {
final MgmtDistributionSet distributionSetRest = deploymentManagement.getInstalledDistributionSet(targetId) final MgmtDistributionSet distributionSetRest = deploymentManagement.getInstalledDistributionSet(targetId)
.map(set -> { .map(set -> {
final MgmtDistributionSet response = MgmtDistributionSetMapper.toResponse(set); final MgmtDistributionSet response = MgmtDistributionSetMapper.toResponse(set);
@@ -386,18 +384,18 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
} }
@Override @Override
public ResponseEntity<List<MgmtTag>> getTags(@PathVariable("targetId") String targetId) { public ResponseEntity<List<MgmtTag>> getTags(final String targetId) {
final Set<TargetTag> tags = targetManagement.getTagsByControllerId(targetId); final Set<TargetTag> tags = targetManagement.getTagsByControllerId(targetId);
return ResponseEntity.ok(MgmtTagMapper.toResponse(tags == null ? Collections.emptyList() : tags.stream().toList())); return ResponseEntity.ok(MgmtTagMapper.toResponse(tags == null ? Collections.emptyList() : tags.stream().toList()));
} }
@Override @Override
public ResponseEntity<PagedList<MgmtMetadata>> getMetadata( public ResponseEntity<PagedList<MgmtMetadata>> getMetadata(
@PathVariable("targetId") final String targetId, final String targetId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, final String sortParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { final String rsqlParam) {
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
final Sort sorting = PagingUtility.sanitizeDistributionSetMetadataSortParam(sortParam); final Sort sorting = PagingUtility.sanitizeDistributionSetMetadataSortParam(sortParam);
@@ -417,8 +415,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override @Override
public ResponseEntity<MgmtMetadata> getMetadataValue( public ResponseEntity<MgmtMetadata> getMetadataValue(
@PathVariable("targetId") final String targetId, final String targetId,
@PathVariable("metadataKey") final String metadataKey) { final String metadataKey) {
final TargetMetadata findOne = targetManagement.getMetaDataByControllerId(targetId, metadataKey) final TargetMetadata findOne = targetManagement.getMetaDataByControllerId(targetId, metadataKey)
.orElseThrow(() -> new EntityNotFoundException(TargetMetadata.class, targetId, metadataKey)); .orElseThrow(() -> new EntityNotFoundException(TargetMetadata.class, targetId, metadataKey));
return ResponseEntity.ok(MgmtTargetMapper.toResponseTargetMetadata(findOne)); return ResponseEntity.ok(MgmtTargetMapper.toResponseTargetMetadata(findOne));
@@ -426,8 +424,9 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override @Override
public ResponseEntity<MgmtMetadata> updateMetadata( public ResponseEntity<MgmtMetadata> updateMetadata(
@PathVariable("targetId") final String targetId, final String targetId,
@PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadataBodyPut metadata) { final String metadataKey,
final MgmtMetadataBodyPut metadata) {
final TargetMetadata updated = targetManagement.updateMetadata(targetId, final TargetMetadata updated = targetManagement.updateMetadata(targetId,
entityFactory.generateTargetMetadata(metadataKey, metadata.getValue())); entityFactory.generateTargetMetadata(metadataKey, metadata.getValue()));
return ResponseEntity.ok(MgmtTargetMapper.toResponseTargetMetadata(updated)); return ResponseEntity.ok(MgmtTargetMapper.toResponseTargetMetadata(updated));
@@ -435,23 +434,23 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override @Override
public ResponseEntity<Void> deleteMetadata( public ResponseEntity<Void> deleteMetadata(
@PathVariable("targetId") final String targetId, final String targetId,
@PathVariable("metadataKey") final String metadataKey) { final String metadataKey) {
targetManagement.deleteMetaData(targetId, metadataKey); targetManagement.deleteMetaData(targetId, metadataKey);
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
@Override @Override
public ResponseEntity<List<MgmtMetadata>> createMetadata( public ResponseEntity<List<MgmtMetadata>> createMetadata(
@PathVariable("targetId") final String targetId, final String targetId,
@RequestBody final List<MgmtMetadata> metadataRest) { final List<MgmtMetadata> metadataRest) {
final List<TargetMetadata> created = targetManagement.createMetaData(targetId, final List<TargetMetadata> created = targetManagement.createMetaData(targetId,
MgmtTargetMapper.fromRequestTargetMetadata(metadataRest, entityFactory)); MgmtTargetMapper.fromRequestTargetMetadata(metadataRest, entityFactory));
return new ResponseEntity<>(MgmtTargetMapper.toResponseTargetMetadata(created), HttpStatus.CREATED); return new ResponseEntity<>(MgmtTargetMapper.toResponseTargetMetadata(created), HttpStatus.CREATED);
} }
@Override @Override
public ResponseEntity<MgmtTargetAutoConfirm> getAutoConfirmStatus(@PathVariable("targetId") final String targetId) { public ResponseEntity<MgmtTargetAutoConfirm> getAutoConfirmStatus(final String targetId) {
final Target findTarget = findTargetWithExceptionIfNotFound(targetId); final Target findTarget = findTargetWithExceptionIfNotFound(targetId);
final MgmtTargetAutoConfirm state = MgmtTargetMapper.getTargetAutoConfirmResponse(findTarget); final MgmtTargetAutoConfirm state = MgmtTargetMapper.getTargetAutoConfirmResponse(findTarget);
return ResponseEntity.ok(state); return ResponseEntity.ok(state);
@@ -459,8 +458,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override @Override
public ResponseEntity<Void> activateAutoConfirm( public ResponseEntity<Void> activateAutoConfirm(
@PathVariable("targetId") final String targetId, final String targetId,
@RequestBody(required = false) final MgmtTargetAutoConfirmUpdate update) { final MgmtTargetAutoConfirmUpdate update) {
final String initiator = getNullIfEmpty(update, MgmtTargetAutoConfirmUpdate::getInitiator); final String initiator = getNullIfEmpty(update, MgmtTargetAutoConfirmUpdate::getInitiator);
final String remark = getNullIfEmpty(update, MgmtTargetAutoConfirmUpdate::getRemark); final String remark = getNullIfEmpty(update, MgmtTargetAutoConfirmUpdate::getRemark);
confirmationManagement.activateAutoConfirmation(targetId, initiator, remark); confirmationManagement.activateAutoConfirmation(targetId, initiator, remark);
@@ -468,7 +467,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
} }
@Override @Override
public ResponseEntity<Void> deactivateAutoConfirm(@PathVariable("targetId") final String targetId) { public ResponseEntity<Void> deactivateAutoConfirm(final String targetId) {
confirmationManagement.deactivateAutoConfirmation(targetId); confirmationManagement.deactivateAutoConfirmation(targetId);
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }