diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java index 37f65d8a0..0683d0793 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java @@ -169,7 +169,7 @@ public final class MgmtSoftwareModuleMapper { systemManagement.getTenantMetadata().getId(), null, null, new URLPlaceholder.SoftwareData(artifact.getSoftwareModule().getId(), artifact.getFilename(), artifact.getId(), artifact.getSha1Hash())), ApiType.MGMT, null); - response.add(Link.of(urls.get(0).getRef()).withRel("cdn-download").expand()); + response.add(Link.of(urls.get(0).getRef()).withRel("download").expand()); } static List artifactsToResponse(final Collection artifacts) { diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java index 69cb7c34c..fefcdc9b5 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java @@ -616,7 +616,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes .andExpect(jsonPath("$.hashes.sha1", equalTo(artifact.getSha1Hash()))) .andExpect(jsonPath("$.hashes.sha256", equalTo(artifact.getSha256Hash()))) .andExpect(jsonPath("$.providedFilename", equalTo("file1"))) - .andExpect(jsonPath("$._links.cdn-download.href", + .andExpect(jsonPath("$._links.download.href", equalTo("http://localhost:8080/rest/v1/softwaremodules/" + sm.getId() + "/artifacts/" + artifact.getFilename()))) .andExpect(jsonPath("$._links.self.href", equalTo( diff --git a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/softwaremodules-api-guide.adoc b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/softwaremodules-api-guide.adoc index 002d3c1d6..8a8f237e0 100644 --- a/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/softwaremodules-api-guide.adoc +++ b/hawkbit-rest/hawkbit-rest-docs/src/main/asciidoc/softwaremodules-api-guide.adoc @@ -417,6 +417,10 @@ include::{snippets}/softwaremodules/get-artifact/http-request.adoc[] include::{snippets}/softwaremodules/get-artifact/path-parameters.adoc[] +==== Request query parameter + +include::{snippets}/softwaremodules/get-artifact-with-parameters/request-parameters.adoc[] + === Response (Status 200) ==== Response fields diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/MgmtApiModelProperties.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/MgmtApiModelProperties.java index 97d6ed458..a85c2d77b 100644 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/MgmtApiModelProperties.java +++ b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/documentation/MgmtApiModelProperties.java @@ -55,10 +55,9 @@ public final class MgmtApiModelProperties { public static final String ARTIFACT_HASHES_SHA1 = "SHA1 hash of the artifact."; public static final String ARTIFACT_HASHES_MD5 = "MD5 hash of the artifact."; public static final String ARTIFACT_HASHES_SHA256 = "SHA256 hash of the artifact."; - - public static final String ARTIFACT_DOWNLOAD_LINK = "Download link of the artifact."; - + public static final String ARTIFACT_DOWNLOAD_LINK = "Download link of the artifact based on the chosen download url type parameter."; public static final String ARTIFACT_LIST = "List of artifacts of given software module."; + public static final String ARTIFACT_DOWNLOAD_URL_TYPE = "Type of the artifact download url. (can be default or cdn)"; // Distribution Set public static final String DS_OS = "Operating system or firmware software module - DEPRECATED (use modules)."; diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremodulesDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremodulesDocumentationTest.java index 909651e1e..a579cd577 100644 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremodulesDocumentationTest.java +++ b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremodulesDocumentationTest.java @@ -368,7 +368,7 @@ public class SoftwaremodulesDocumentationTest extends AbstractApiRestDocumentati mockMvc.perform( get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}", - sm.getId(), artifact.getId())) + sm.getId(), artifact.getId()).param("downloadurltype", "default")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( @@ -391,6 +391,27 @@ public class SoftwaremodulesDocumentationTest extends AbstractApiRestDocumentati .description(MgmtApiModelProperties.ARTIFACT_DOWNLOAD_LINK)))); } + @Test + @Description("Handles the GET request of retrieving a single Artifact meta data request. Required Permission: " + + SpPermission.READ_REPOSITORY) + public void getArtifactWithParameters() throws Exception { + final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); + + final byte random[] = RandomStringUtils.random(5).getBytes(); + + final Artifact artifact = artifactManagement + .create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, 0)); + + mockMvc.perform( + get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}", + sm.getId(), artifact.getId()).param("downloadurltype", "default")) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) + .andDo(this.document.document( + requestParameters( + parameterWithName("downloadurltype").description(MgmtApiModelProperties.ARTIFACT_DOWNLOAD_URL_TYPE)))); + } + @Test @Description("Handles the GET request for downloading an artifact. Required Permission: " + SpPermission.READ_REPOSITORY)