DDI resource - remove dupplicated annotations (MgmtSoftwareModuleRestResource) (#2063)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
@@ -84,12 +85,12 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
@PostMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts",
|
@PostMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts",
|
||||||
consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||||
ResponseEntity<MgmtArtifact> uploadArtifact(
|
ResponseEntity<MgmtArtifact> uploadArtifact(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
@PathVariable("softwareModuleId") Long softwareModuleId,
|
||||||
@RequestPart("file") final MultipartFile file,
|
@RequestPart("file") MultipartFile file,
|
||||||
@RequestParam(value = "filename", required = false) final String optionalFileName,
|
@RequestParam(value = "filename", required = false) String optionalFileName,
|
||||||
@RequestParam(value = "md5sum", required = false) final String md5Sum,
|
@RequestParam(value = "md5sum", required = false) String md5Sum,
|
||||||
@RequestParam(value = "sha1sum", required = false) final String sha1Sum,
|
@RequestParam(value = "sha1sum", required = false) String sha1Sum,
|
||||||
@RequestParam(value = "sha256sum", required = false) final String sha256sum);
|
@RequestParam(value = "sha256sum", required = false) String sha256Sum);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the GET request of retrieving all metadata of artifacts assigned to a software module.
|
* Handles the GET request of retrieving all metadata of artifacts assigned to a software module.
|
||||||
@@ -124,9 +125,9 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
@GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts",
|
@GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts",
|
||||||
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||||
ResponseEntity<List<MgmtArtifact>> getArtifacts(
|
ResponseEntity<List<MgmtArtifact>> getArtifacts(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
@PathVariable("softwareModuleId") Long softwareModuleId,
|
||||||
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) String representationModeParam,
|
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) String representationModeParam,
|
||||||
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER, required = false) final Boolean useArtifactUrlHandler);
|
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER, required = false) Boolean useArtifactUrlHandler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the GET request of retrieving a single Artifact metadata request.
|
* Handles the GET request of retrieving a single Artifact metadata request.
|
||||||
@@ -159,9 +160,9 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
ResponseEntity<MgmtArtifact> getArtifact(
|
ResponseEntity<MgmtArtifact> getArtifact(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
@PathVariable("softwareModuleId") Long softwareModuleId,
|
||||||
@PathVariable("artifactId") final Long artifactId,
|
@PathVariable("artifactId") Long artifactId,
|
||||||
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER, required = false) final Boolean useArtifactUrlHandler);
|
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER, required = false) Boolean useArtifactUrlHandler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the DELETE request for a single SoftwareModule.
|
* Handles the DELETE request for a single SoftwareModule.
|
||||||
@@ -193,8 +194,8 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
@DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}")
|
@DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
ResponseEntity<Void> deleteArtifact(
|
ResponseEntity<Void> deleteArtifact(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
@PathVariable("softwareModuleId") Long softwareModuleId,
|
||||||
@PathVariable("artifactId") final Long artifactId);
|
@PathVariable("artifactId") Long artifactId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the GET request of retrieving all software modules.
|
* Handles the GET request of retrieving all software modules.
|
||||||
@@ -281,7 +282,7 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
})
|
})
|
||||||
@GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}",
|
@GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}",
|
||||||
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||||
ResponseEntity<MgmtSoftwareModule> getSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId);
|
ResponseEntity<MgmtSoftwareModule> getSoftwareModule(@PathVariable("softwareModuleId") Long softwareModuleId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the POST request of creating new software modules. The request body must always be a list of modules.
|
* Handles the POST request of creating new software modules. The request body must always be a list of modules.
|
||||||
@@ -315,7 +316,7 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
@PostMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING,
|
@PostMapping(value = MgmtRestConstants.SOFTWAREMODULE_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<MgmtSoftwareModule>> createSoftwareModules(final List<MgmtSoftwareModuleRequestBodyPost> softwareModules);
|
ResponseEntity<List<MgmtSoftwareModule>> createSoftwareModules(@RequestBody List<MgmtSoftwareModuleRequestBodyPost> softwareModules);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the PUT request of updating a software module.
|
* Handles the PUT request of updating a software module.
|
||||||
@@ -354,8 +355,8 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
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<MgmtSoftwareModule> updateSoftwareModule(
|
ResponseEntity<MgmtSoftwareModule> updateSoftwareModule(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
@PathVariable("softwareModuleId") Long softwareModuleId,
|
||||||
final MgmtSoftwareModuleRequestBodyPut restSoftwareModule);
|
@RequestBody MgmtSoftwareModuleRequestBodyPut restSoftwareModule);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the DELETE request for a single software module.
|
* Handles the DELETE request for a single software module.
|
||||||
@@ -384,7 +385,7 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true)))
|
content = @Content(mediaType = "application/json", schema = @Schema(hidden = true)))
|
||||||
})
|
})
|
||||||
@DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}")
|
@DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}")
|
||||||
ResponseEntity<Void> deleteSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId);
|
ResponseEntity<Void> deleteSoftwareModule(@PathVariable("softwareModuleId") Long softwareModuleId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a paged list of metadata for a software module.
|
* Gets a paged list of metadata for a software module.
|
||||||
@@ -421,7 +422,7 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
@GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata",
|
@GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata",
|
||||||
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||||
ResponseEntity<PagedList<MgmtSoftwareModuleMetadata>> getMetadata(
|
ResponseEntity<PagedList<MgmtSoftwareModuleMetadata>> getMetadata(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
@PathVariable("softwareModuleId") Long softwareModuleId,
|
||||||
@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)
|
||||||
@@ -476,8 +477,8 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
@GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}",
|
@GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}",
|
||||||
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||||
ResponseEntity<MgmtSoftwareModuleMetadata> getMetadataValue(
|
ResponseEntity<MgmtSoftwareModuleMetadata> getMetadataValue(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
@PathVariable("softwareModuleId") Long softwareModuleId,
|
||||||
@PathVariable("metadataKey") final String metadataKey);
|
@PathVariable("metadataKey") String metadataKey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a single metadata value of a software module.
|
* Updates a single metadata value of a software module.
|
||||||
@@ -510,8 +511,9 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
@PutMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}",
|
@PutMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}",
|
||||||
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE })
|
||||||
ResponseEntity<MgmtSoftwareModuleMetadata> updateMetadata(
|
ResponseEntity<MgmtSoftwareModuleMetadata> updateMetadata(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
@PathVariable("softwareModuleId") Long softwareModuleId,
|
||||||
@PathVariable("metadataKey") final String metadataKey, final MgmtSoftwareModuleMetadataBodyPut metadata);
|
@PathVariable("metadataKey") String metadataKey,
|
||||||
|
@RequestBody MgmtSoftwareModuleMetadataBodyPut metadata);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a single metadata entry from the software module.
|
* Deletes a single metadata entry from the software module.
|
||||||
@@ -542,8 +544,8 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
})
|
})
|
||||||
@DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}")
|
@DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}")
|
||||||
ResponseEntity<Void> deleteMetadata(
|
ResponseEntity<Void> deleteMetadata(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
@PathVariable("softwareModuleId") Long softwareModuleId,
|
||||||
@PathVariable("metadataKey") final String metadataKey);
|
@PathVariable("metadataKey") String metadataKey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a list of metadata for a specific software module.
|
* Creates a list of metadata for a specific software module.
|
||||||
@@ -582,6 +584,6 @@ public interface MgmtSoftwareModuleRestApi {
|
|||||||
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<MgmtSoftwareModuleMetadata>> createMetadata(
|
ResponseEntity<List<MgmtSoftwareModuleMetadata>> createMetadata(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
@PathVariable("softwareModuleId") Long softwareModuleId,
|
||||||
final List<MgmtSoftwareModuleMetadata> metadataRest);
|
@RequestBody List<MgmtSoftwareModuleMetadata> metadataRest);
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,6 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleMeta
|
|||||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost;
|
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPost;
|
||||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPut;
|
import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleRequestBodyPut;
|
||||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode;
|
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode;
|
||||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
|
||||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi;
|
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi;
|
||||||
import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility;
|
import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility;
|
||||||
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||||
@@ -50,17 +49,11 @@ 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.RequestPart;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* REST Resource handling for {@link SoftwareModule} and related
|
* REST Resource handling for {@link SoftwareModule} and related {@link Artifact} CRUD operations.
|
||||||
* {@link Artifact} CRUD operations.
|
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@@ -88,12 +81,12 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<MgmtArtifact> uploadArtifact(
|
public ResponseEntity<MgmtArtifact> uploadArtifact(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
final Long softwareModuleId,
|
||||||
@RequestPart("file") final MultipartFile file,
|
final MultipartFile file,
|
||||||
@RequestParam(value = "filename", required = false) final String optionalFileName,
|
final String optionalFileName,
|
||||||
@RequestParam(value = "md5sum", required = false) final String md5Sum,
|
final String md5Sum,
|
||||||
@RequestParam(value = "sha1sum", required = false) final String sha1Sum,
|
final String sha1Sum,
|
||||||
@RequestParam(value = "sha256sum", required = false) final String sha256Sum) {
|
final String sha256Sum) {
|
||||||
|
|
||||||
if (file.isEmpty()) {
|
if (file.isEmpty()) {
|
||||||
return ResponseEntity.badRequest().build();
|
return ResponseEntity.badRequest().build();
|
||||||
@@ -121,7 +114,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<List<MgmtArtifact>> getArtifacts(
|
public ResponseEntity<List<MgmtArtifact>> getArtifacts(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId, final String representationModeParam,
|
final Long softwareModuleId,
|
||||||
|
final String representationModeParam,
|
||||||
final Boolean useArtifactUrlHandler) {
|
final Boolean useArtifactUrlHandler) {
|
||||||
final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
||||||
|
|
||||||
@@ -139,16 +133,13 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
return ResponseEntity.ok(new ResponseList<>(response));
|
return ResponseEntity.ok(new ResponseList<>(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exception squid:S3655 - Optional access is checked in
|
// Exception squid:S3655 - Optional access is checked in findSoftwareModuleWithExceptionIfNotFound subroutine
|
||||||
// findSoftwareModuleWithExceptionIfNotFound
|
|
||||||
// subroutine
|
|
||||||
@SuppressWarnings("squid:S3655")
|
@SuppressWarnings("squid:S3655")
|
||||||
@Override
|
@Override
|
||||||
@ResponseBody
|
|
||||||
public ResponseEntity<MgmtArtifact> getArtifact(
|
public ResponseEntity<MgmtArtifact> getArtifact(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
final Long softwareModuleId,
|
||||||
@PathVariable("artifactId") final Long artifactId,
|
final Long artifactId,
|
||||||
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER, required = false) final Boolean useArtifactUrlHandler) {
|
final Boolean useArtifactUrlHandler) {
|
||||||
final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId);
|
final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId);
|
||||||
|
|
||||||
final MgmtArtifact response = MgmtSoftwareModuleMapper.toResponse(module.getArtifact(artifactId).get());
|
final MgmtArtifact response = MgmtSoftwareModuleMapper.toResponse(module.getArtifact(artifactId).get());
|
||||||
@@ -165,10 +156,9 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ResponseBody
|
|
||||||
public ResponseEntity<Void> deleteArtifact(
|
public ResponseEntity<Void> deleteArtifact(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
final Long softwareModuleId,
|
||||||
@PathVariable("artifactId") final Long artifactId) {
|
final Long artifactId) {
|
||||||
findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId);
|
findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId);
|
||||||
artifactManagement.delete(artifactId);
|
artifactManagement.delete(artifactId);
|
||||||
|
|
||||||
@@ -177,10 +167,10 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<PagedList<MgmtSoftwareModule>> getSoftwareModules(
|
public ResponseEntity<PagedList<MgmtSoftwareModule>> getSoftwareModules(
|
||||||
@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.sanitizeSoftwareModuleSortParam(sortParam);
|
final Sort sorting = PagingUtility.sanitizeSoftwareModuleSortParam(sortParam);
|
||||||
@@ -202,7 +192,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<MgmtSoftwareModule> getSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId) {
|
public ResponseEntity<MgmtSoftwareModule> getSoftwareModule(final Long softwareModuleId) {
|
||||||
final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
||||||
|
|
||||||
final MgmtSoftwareModule response = MgmtSoftwareModuleMapper.toResponse(module);
|
final MgmtSoftwareModule response = MgmtSoftwareModuleMapper.toResponse(module);
|
||||||
@@ -212,8 +202,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<List<MgmtSoftwareModule>> createSoftwareModules(
|
public ResponseEntity<List<MgmtSoftwareModule>> createSoftwareModules(final List<MgmtSoftwareModuleRequestBodyPost> softwareModules) {
|
||||||
@RequestBody final List<MgmtSoftwareModuleRequestBodyPost> softwareModules) {
|
|
||||||
log.debug("creating {} softwareModules", softwareModules.size());
|
log.debug("creating {} softwareModules", softwareModules.size());
|
||||||
|
|
||||||
for (final MgmtSoftwareModuleRequestBodyPost sm : softwareModules) {
|
for (final MgmtSoftwareModuleRequestBodyPost sm : softwareModules) {
|
||||||
@@ -236,8 +225,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<MgmtSoftwareModule> updateSoftwareModule(
|
public ResponseEntity<MgmtSoftwareModule> updateSoftwareModule(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
final Long softwareModuleId,
|
||||||
@RequestBody final MgmtSoftwareModuleRequestBodyPut restSoftwareModule) {
|
final MgmtSoftwareModuleRequestBodyPut restSoftwareModule) {
|
||||||
final SoftwareModule module = softwareModuleManagement
|
final SoftwareModule module = softwareModuleManagement
|
||||||
.update(entityFactory.softwareModule().update(softwareModuleId)
|
.update(entityFactory.softwareModule().update(softwareModuleId)
|
||||||
.description(restSoftwareModule.getDescription())
|
.description(restSoftwareModule.getDescription())
|
||||||
@@ -251,8 +240,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Void> deleteSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId) {
|
public ResponseEntity<Void> deleteSoftwareModule(final Long softwareModuleId) {
|
||||||
|
|
||||||
final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
||||||
softwareModuleManagement.delete(module.getId());
|
softwareModuleManagement.delete(module.getId());
|
||||||
|
|
||||||
@@ -261,12 +249,11 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<PagedList<MgmtSoftwareModuleMetadata>> getMetadata(
|
public ResponseEntity<PagedList<MgmtSoftwareModuleMetadata>> getMetadata(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
final Long softwareModuleId,
|
||||||
@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) {
|
||||||
|
|
||||||
// check if software module exists otherwise throw exception immediately
|
// check if software module exists otherwise throw exception immediately
|
||||||
findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
||||||
|
|
||||||
@@ -289,9 +276,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<MgmtSoftwareModuleMetadata> getMetadataValue(
|
public ResponseEntity<MgmtSoftwareModuleMetadata> getMetadataValue(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
final Long softwareModuleId,
|
||||||
@PathVariable("metadataKey") final String metadataKey) {
|
final String metadataKey) {
|
||||||
|
|
||||||
final SoftwareModuleMetadata findOne = softwareModuleManagement
|
final SoftwareModuleMetadata findOne = softwareModuleManagement
|
||||||
.getMetaDataBySoftwareModuleId(softwareModuleId, metadataKey).orElseThrow(
|
.getMetaDataBySoftwareModuleId(softwareModuleId, metadataKey).orElseThrow(
|
||||||
() -> new EntityNotFoundException(SoftwareModuleMetadata.class, softwareModuleId, metadataKey));
|
() -> new EntityNotFoundException(SoftwareModuleMetadata.class, softwareModuleId, metadataKey));
|
||||||
@@ -301,9 +287,9 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<MgmtSoftwareModuleMetadata> updateMetadata(
|
public ResponseEntity<MgmtSoftwareModuleMetadata> updateMetadata(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
final Long softwareModuleId,
|
||||||
@PathVariable("metadataKey") final String metadataKey,
|
final String metadataKey,
|
||||||
@RequestBody final MgmtSoftwareModuleMetadataBodyPut metadata) {
|
final MgmtSoftwareModuleMetadataBodyPut metadata) {
|
||||||
final SoftwareModuleMetadata updated = softwareModuleManagement
|
final SoftwareModuleMetadata updated = softwareModuleManagement
|
||||||
.updateMetaData(entityFactory.softwareModuleMetadata().update(softwareModuleId, metadataKey)
|
.updateMetaData(entityFactory.softwareModuleMetadata().update(softwareModuleId, metadataKey)
|
||||||
.value(metadata.getValue()).targetVisible(metadata.getTargetVisible()));
|
.value(metadata.getValue()).targetVisible(metadata.getTargetVisible()));
|
||||||
@@ -312,8 +298,9 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Void> deleteMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
|
public ResponseEntity<Void> deleteMetadata(
|
||||||
@PathVariable("metadataKey") final String metadataKey) {
|
final Long softwareModuleId,
|
||||||
|
final String metadataKey) {
|
||||||
softwareModuleManagement.deleteMetaData(softwareModuleId, metadataKey);
|
softwareModuleManagement.deleteMetaData(softwareModuleId, metadataKey);
|
||||||
|
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
@@ -321,9 +308,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<List<MgmtSoftwareModuleMetadata>> createMetadata(
|
public ResponseEntity<List<MgmtSoftwareModuleMetadata>> createMetadata(
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
final Long softwareModuleId,
|
||||||
@RequestBody final List<MgmtSoftwareModuleMetadata> metadataRest) {
|
final List<MgmtSoftwareModuleMetadata> metadataRest) {
|
||||||
|
|
||||||
final List<SoftwareModuleMetadata> created = softwareModuleManagement.createMetaData(
|
final List<SoftwareModuleMetadata> created = softwareModuleManagement.createMetaData(
|
||||||
MgmtSoftwareModuleMapper.fromRequestSwMetadata(entityFactory, softwareModuleId, metadataRest));
|
MgmtSoftwareModuleMapper.fromRequestSwMetadata(entityFactory, softwareModuleId, metadataRest));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user