Merge branch 'Extend_end-2-end_tests_for_full_DDI_roundtrip_with_Java_client' of https://github.com/bsinno/hawkbit.git into Extend_end-2-end_tests_for_full_DDI_roundtrip_with_Java_client
Conflicts: hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiArtifactStoreController.java Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
@@ -9,7 +9,9 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the Rootcontroller resource of the DDI API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/{tenant}/controller/v1")
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + RootControllerResourceClient.PATH)
|
||||
public interface RootControllerResourceClient extends DdiRootControllerRestApi {
|
||||
|
||||
static String PATH = "{tenant}/controller/v1";
|
||||
|
||||
}
|
||||
|
||||
@@ -66,6 +66,11 @@
|
||||
<!-- need to overwrite for the interface inheritance feature of feign-core -->
|
||||
<version>8.14.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-jackson</artifactId>
|
||||
<version>8.14.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<groupId>org.hibernate</groupId>
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDistributionSetClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDistributionSetTagClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDistributionSetTypeClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDownloadArtifactClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDownloadClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtRolloutClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtSoftwareModuleClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtSoftwareModuleTypeClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtTargetClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtTargetTagClientResource;
|
||||
import org.springframework.cloud.netflix.feign.support.ResponseEntityDecoder;
|
||||
|
||||
import feign.Feign;
|
||||
import feign.Feign.Builder;
|
||||
import feign.Logger;
|
||||
import feign.Logger.Level;
|
||||
import feign.jackson.JacksonDecoder;
|
||||
import feign.jackson.JacksonEncoder;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class MgmtDefaultFeignClient {
|
||||
|
||||
private MgmtDistributionSetClientResource mgmtDistributionSetClientResource;
|
||||
private MgmtDistributionSetTagClientResource mgmtDistributionSetTagClientResource;
|
||||
private MgmtDistributionSetTypeClientResource mgmtDistributionSetTypeClientResource;
|
||||
private MgmtRolloutClientResource mgmtRolloutClientResource;
|
||||
private MgmtSoftwareModuleClientResource mgmtSoftwareModuleClientResource;
|
||||
private MgmtSoftwareModuleTypeClientResource mgmtSoftwareModuleTypeClientResource;
|
||||
private MgmtTargetClientResource mgmtTargetClientResource;
|
||||
private MgmtTargetTagClientResource mgmtTargetTagClientResource;
|
||||
private MgmtDownloadClientResource mgmtDownloadClientResource;
|
||||
private MgmtDownloadArtifactClientResource mgmtDownloadArtifactClientResource;
|
||||
|
||||
private final Builder feignBuilder;
|
||||
private final String baseUrl;
|
||||
|
||||
public MgmtDefaultFeignClient(final String baseUrl) {
|
||||
feignBuilder = Feign.builder().contract(new IgnoreMultipleConsumersProducersSpringMvcContract())
|
||||
.requestInterceptor(new ApplicationJsonRequestHeaderInterceptor()).logLevel(Level.FULL)
|
||||
.logger(new Logger.ErrorLogger()).encoder(new JacksonEncoder())
|
||||
.decoder(new ResponseEntityDecoder(new JacksonDecoder()));
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public Builder getFeignBuilder() {
|
||||
return feignBuilder;
|
||||
}
|
||||
|
||||
public MgmtDistributionSetClientResource getMgmtDistributionSetClientResource() {
|
||||
if (mgmtDistributionSetClientResource == null) {
|
||||
mgmtDistributionSetClientResource = feignBuilder.target(MgmtDistributionSetClientResource.class,
|
||||
this.baseUrl + MgmtDistributionSetClientResource.PATH);
|
||||
}
|
||||
return mgmtDistributionSetClientResource;
|
||||
}
|
||||
|
||||
public MgmtDistributionSetTagClientResource getMgmtDistributionSetTagClientResource() {
|
||||
if (mgmtDistributionSetTagClientResource == null) {
|
||||
mgmtDistributionSetTagClientResource = feignBuilder.target(MgmtDistributionSetTagClientResource.class,
|
||||
this.baseUrl + MgmtDistributionSetTagClientResource.PATH);
|
||||
}
|
||||
return mgmtDistributionSetTagClientResource;
|
||||
}
|
||||
|
||||
public MgmtDistributionSetTypeClientResource getMgmtDistributionSetTypeClientResource() {
|
||||
if (mgmtDistributionSetTypeClientResource == null) {
|
||||
mgmtDistributionSetTypeClientResource = feignBuilder.target(MgmtDistributionSetTypeClientResource.class,
|
||||
this.baseUrl + MgmtDistributionSetTypeClientResource.PATH);
|
||||
}
|
||||
return mgmtDistributionSetTypeClientResource;
|
||||
}
|
||||
|
||||
public MgmtRolloutClientResource getMgmtRolloutClientResource() {
|
||||
if (mgmtRolloutClientResource == null) {
|
||||
mgmtRolloutClientResource = feignBuilder.target(MgmtRolloutClientResource.class,
|
||||
this.baseUrl + MgmtRolloutClientResource.PATH);
|
||||
}
|
||||
return mgmtRolloutClientResource;
|
||||
}
|
||||
|
||||
public MgmtSoftwareModuleClientResource getMgmtSoftwareModuleClientResource() {
|
||||
if (mgmtSoftwareModuleClientResource == null) {
|
||||
mgmtSoftwareModuleClientResource = feignBuilder.target(MgmtSoftwareModuleClientResource.class,
|
||||
MgmtSoftwareModuleClientResource.PATH);
|
||||
}
|
||||
return mgmtSoftwareModuleClientResource;
|
||||
}
|
||||
|
||||
public MgmtSoftwareModuleTypeClientResource getMgmtSoftwareModuleTypeClientResource() {
|
||||
if (mgmtSoftwareModuleTypeClientResource == null) {
|
||||
mgmtSoftwareModuleTypeClientResource = feignBuilder.target(MgmtSoftwareModuleTypeClientResource.class,
|
||||
this.baseUrl + MgmtSoftwareModuleTypeClientResource.PATH);
|
||||
}
|
||||
return mgmtSoftwareModuleTypeClientResource;
|
||||
}
|
||||
|
||||
public MgmtTargetClientResource getMgmtTargetClientResource() {
|
||||
if (mgmtTargetClientResource == null) {
|
||||
mgmtTargetClientResource = feignBuilder.target(MgmtTargetClientResource.class,
|
||||
this.baseUrl + MgmtTargetClientResource.PATH);
|
||||
}
|
||||
return mgmtTargetClientResource;
|
||||
}
|
||||
|
||||
public MgmtTargetTagClientResource getMgmtTargetTagClientResource() {
|
||||
if (mgmtTargetTagClientResource == null) {
|
||||
mgmtTargetTagClientResource = feignBuilder.target(MgmtTargetTagClientResource.class,
|
||||
this.baseUrl + MgmtTargetTagClientResource.PATH);
|
||||
}
|
||||
return mgmtTargetTagClientResource;
|
||||
}
|
||||
|
||||
public MgmtDownloadClientResource getMgmtDownloadClientResource() {
|
||||
if (mgmtDownloadClientResource == null) {
|
||||
mgmtDownloadClientResource = feignBuilder.target(MgmtDownloadClientResource.class,
|
||||
this.baseUrl + MgmtDownloadClientResource.PATH);
|
||||
}
|
||||
return mgmtDownloadClientResource;
|
||||
}
|
||||
|
||||
public MgmtDownloadArtifactClientResource getMgmtDownloadArtifactClientResource() {
|
||||
if (mgmtDownloadArtifactClientResource == null) {
|
||||
mgmtDownloadArtifactClientResource = feignBuilder.target(MgmtDownloadArtifactClientResource.class,
|
||||
this.baseUrl + MgmtDownloadArtifactClientResource.PATH);
|
||||
}
|
||||
return mgmtDownloadArtifactClientResource;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,8 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the DistributionSet resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/distributionsets")
|
||||
public interface DistributionSetResourceClient extends MgmtDistributionSetRestApi {
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtDistributionSetClientResource.PATH)
|
||||
public interface MgmtDistributionSetClientResource extends MgmtDistributionSetRestApi {
|
||||
|
||||
static String PATH = "rest/v1/distributionsets";
|
||||
}
|
||||
@@ -14,7 +14,8 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the DistributionSetTag resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/distributionsettags")
|
||||
public interface DistributionSetTagResourceClient extends MgmtDistributionSetTagRestApi {
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtDistributionSetTagClientResource.PATH)
|
||||
public interface MgmtDistributionSetTagClientResource extends MgmtDistributionSetTagRestApi {
|
||||
|
||||
static String PATH = "rest/v1/distributionsettags";
|
||||
}
|
||||
@@ -15,7 +15,8 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
* Client binding for the DistributionSetType resource of the management API.
|
||||
*
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/distributionsettypes")
|
||||
public interface DistributionSetTypeResourceClient extends MgmtDistributionSetTypeRestApi {
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtDistributionSetTypeClientResource.PATH)
|
||||
public interface MgmtDistributionSetTypeClientResource extends MgmtDistributionSetTypeRestApi {
|
||||
|
||||
static String PATH = "rest/v1/distributionsettypes";
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDownloadArtifactRestApi;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtDownloadArtifactClientResource.PATH)
|
||||
public interface MgmtDownloadArtifactClientResource extends MgmtDownloadArtifactRestApi {
|
||||
|
||||
static String PATH = "rest/v1/softwaremodules";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.resource;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDownloadRestApi;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtDownloadClientResource.PATH)
|
||||
public interface MgmtDownloadClientResource extends MgmtDownloadRestApi {
|
||||
|
||||
static String PATH = "api/v1/downloadserver/";
|
||||
|
||||
}
|
||||
@@ -14,7 +14,8 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the Rollout resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/rollouts")
|
||||
public interface RolloutResourceClient extends MgmtRolloutRestApi {
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRolloutClientResource.PATH)
|
||||
public interface MgmtRolloutClientResource extends MgmtRolloutRestApi {
|
||||
|
||||
static String PATH = "rest/v1/rollouts";
|
||||
}
|
||||
@@ -14,7 +14,8 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the SoftwareModule resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/softwaremodules")
|
||||
public interface SoftwareModuleResourceClient extends MgmtSoftwareModuleRestApi {
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtSoftwareModuleClientResource.PATH)
|
||||
public interface MgmtSoftwareModuleClientResource extends MgmtSoftwareModuleRestApi {
|
||||
|
||||
static String PATH = "rest/v1/softwaremodules";
|
||||
}
|
||||
@@ -14,7 +14,8 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the oftwareModuleType resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/softwaremoduletypes")
|
||||
public interface SoftwareModuleTypeResourceClient extends MgmtSoftwareModuleTypeRestApi {
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtSoftwareModuleTypeClientResource.PATH)
|
||||
public interface MgmtSoftwareModuleTypeClientResource extends MgmtSoftwareModuleTypeRestApi {
|
||||
|
||||
static String PATH = "rest/v1/softwaremoduletypes";
|
||||
}
|
||||
@@ -14,7 +14,8 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the Target resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/targets")
|
||||
public interface TargetResourceClient extends MgmtTargetRestApi {
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtTargetClientResource.PATH)
|
||||
public interface MgmtTargetClientResource extends MgmtTargetRestApi {
|
||||
|
||||
static String PATH = "/rest/v1/targets";
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
/**
|
||||
* Client binding for the TargetTag resource of the management API.
|
||||
*/
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/rest/v1/targettags")
|
||||
public interface TargetTagResourceClient extends MgmtTargetTagRestApi {
|
||||
|
||||
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtTargetTagClientResource.PATH)
|
||||
public interface MgmtTargetTagClientResource extends MgmtTargetTagRestApi {
|
||||
static String PATH = "rest/v1/targettags";
|
||||
}
|
||||
@@ -10,12 +10,12 @@ package org.eclipse.hawkbit.mgmt.client.scenarios;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.DistributionSetResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.DistributionSetTypeResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.RolloutResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.SoftwareModuleResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.SoftwareModuleTypeResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.TargetResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDistributionSetClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDistributionSetTypeClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtRolloutClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtSoftwareModuleClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtSoftwareModuleTypeClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtTargetClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.DistributionSetBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.DistributionSetTypeBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.RolloutBuilder;
|
||||
@@ -44,22 +44,22 @@ public class CreateStartedRolloutExample {
|
||||
private static final String DS_MODULE_TYPE = SM_MODULE_TYPE;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetResourceClient distributionSetResource;
|
||||
private MgmtDistributionSetClientResource distributionSetResource;
|
||||
|
||||
@Autowired
|
||||
private SoftwareModuleResourceClient softwareModuleResource;
|
||||
private MgmtSoftwareModuleClientResource softwareModuleResource;
|
||||
|
||||
@Autowired
|
||||
private TargetResourceClient targetResource;
|
||||
private MgmtTargetClientResource targetResource;
|
||||
|
||||
@Autowired
|
||||
private RolloutResourceClient rolloutResource;
|
||||
private MgmtRolloutClientResource rolloutResource;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetTypeResourceClient distributionSetTypeResource;
|
||||
private MgmtDistributionSetTypeClientResource distributionSetTypeResource;
|
||||
|
||||
@Autowired
|
||||
private SoftwareModuleTypeResourceClient softwareModuleTypeResource;
|
||||
private MgmtSoftwareModuleTypeClientResource softwareModuleTypeResource;
|
||||
|
||||
/**
|
||||
* Run the Rollout scenario.
|
||||
|
||||
@@ -10,10 +10,10 @@ package org.eclipse.hawkbit.mgmt.client.scenarios;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.DistributionSetResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.DistributionSetTypeResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.SoftwareModuleResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.SoftwareModuleTypeResourceClient;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDistributionSetClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtDistributionSetTypeClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtSoftwareModuleClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.MgmtSoftwareModuleTypeClientResource;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.DistributionSetBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.DistributionSetTypeBuilder;
|
||||
import org.eclipse.hawkbit.mgmt.client.resource.builder.SoftwareModuleAssigmentBuilder;
|
||||
@@ -50,16 +50,16 @@ public class GettingStartedDefaultScenario {
|
||||
private static final String DS_EXAMPLE_NAME = SM_EXAMPLE_NAME;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetResourceClient distributionSetResource;
|
||||
private MgmtDistributionSetClientResource distributionSetResource;
|
||||
|
||||
@Autowired
|
||||
private DistributionSetTypeResourceClient distributionSetTypeResource;
|
||||
private MgmtDistributionSetTypeClientResource distributionSetTypeResource;
|
||||
|
||||
@Autowired
|
||||
private SoftwareModuleResourceClient softwareModuleResource;
|
||||
private MgmtSoftwareModuleClientResource softwareModuleResource;
|
||||
|
||||
@Autowired
|
||||
private SoftwareModuleTypeResourceClient softwareModuleTypeResource;
|
||||
private MgmtSoftwareModuleTypeClientResource softwareModuleTypeResource;
|
||||
|
||||
/**
|
||||
* Run the default getting started scenario.
|
||||
|
||||
@@ -17,7 +17,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@ConfigurationProperties("hawkbit.artifact.url")
|
||||
public class ArtifactUrlHandlerProperties {
|
||||
private static final String DEFAULT_IP_LOCALHOST = "127.0.0.1";
|
||||
private static final String LOCALHOST = "localhost:8080";
|
||||
private static final String DEFAULT_PORT = "8080";
|
||||
private static final String LOCALHOST = "localhost";
|
||||
|
||||
private final Http http = new Http();
|
||||
private final Https https = new Https();
|
||||
@@ -86,7 +87,7 @@ public class ArtifactUrlHandlerProperties {
|
||||
public static class Http implements ProtocolProperties {
|
||||
private String hostname = LOCALHOST;
|
||||
private String ip = DEFAULT_IP_LOCALHOST;
|
||||
private String port = "";
|
||||
private String port = DEFAULT_PORT;
|
||||
/**
|
||||
* An ant-URL pattern with placeholder to build the URL on. The URL can
|
||||
* have specific artifact placeholder.
|
||||
@@ -136,7 +137,7 @@ public class ArtifactUrlHandlerProperties {
|
||||
public static class Https implements ProtocolProperties {
|
||||
private String hostname = LOCALHOST;
|
||||
private String ip = DEFAULT_IP_LOCALHOST;
|
||||
private String port = "";
|
||||
private String port = DEFAULT_PORT;
|
||||
/**
|
||||
* An ant-URL pattern with placeholder to build the URL on. The URL can
|
||||
* have specific artifact placeholder.
|
||||
|
||||
@@ -36,10 +36,9 @@
|
||||
<artifactId>hawkbit-repository</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-core</artifactId>
|
||||
<version>2.0.3</version>
|
||||
<dependency>
|
||||
<groupId>org.springframework.plugin</groupId>
|
||||
<artifactId>spring-plugin-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
@@ -74,39 +74,35 @@ public class DdiArtifactStoreController implements DdiArtifactStoreControllerRes
|
||||
@Override
|
||||
public ResponseEntity<Void> downloadArtifactByFilename(@PathVariable("fileName") final String fileName,
|
||||
@AuthenticationPrincipal final String targetid) {
|
||||
|
||||
ResponseEntity<Void> result;
|
||||
|
||||
final List<LocalArtifact> foundArtifacts = artifactManagement.findLocalArtifactByFilename(fileName);
|
||||
|
||||
if (foundArtifacts.isEmpty()) {
|
||||
LOG.warn("Software artifact with name {} could not be found.", fileName);
|
||||
result = new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
if (foundArtifacts.size() > 1) {
|
||||
LOG.warn("Software artifact name {} is not unique. We will use the first entry.", fileName);
|
||||
}
|
||||
ResponseEntity<Void> result;
|
||||
final LocalArtifact artifact = foundArtifacts.get(0);
|
||||
|
||||
final String ifMatch = getRequest().getHeader("If-Match");
|
||||
if (ifMatch != null && !RestResourceConversionHelper.matchesHttpHeader(ifMatch, artifact.getSha1Hash())) {
|
||||
result = new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED);
|
||||
} else {
|
||||
if (foundArtifacts.size() > 1) {
|
||||
LOG.warn("Software artifact name {} is not unique. We will use the first entry.", fileName);
|
||||
}
|
||||
final DbArtifact file = artifactManagement.loadLocalArtifactBinary(artifact);
|
||||
|
||||
final LocalArtifact artifact = foundArtifacts.get(0);
|
||||
|
||||
final String ifMatch = getRequest().getHeader("If-Match");
|
||||
if (ifMatch != null && !RestResourceConversionHelper.matchesHttpHeader(ifMatch, artifact.getSha1Hash())) {
|
||||
result = new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED);
|
||||
// we set a download status only if we are aware of the
|
||||
// targetid, i.e. authenticated and not anonymous
|
||||
if (targetid != null && !"anonymous".equals(targetid)) {
|
||||
final Action action = checkAndReportDownloadByTarget(getRequest(), targetid, artifact);
|
||||
result = RestResourceConversionHelper.writeFileResponse(artifact, getResponse(), getRequest(), file,
|
||||
cacheWriteNotify, action.getId());
|
||||
} else {
|
||||
final DbArtifact file = artifactManagement.loadLocalArtifactBinary(artifact);
|
||||
|
||||
// we set a download status only if we are aware of the
|
||||
// targetid, i.e. authenticated and not anonymous
|
||||
if (targetid != null && !"anonymous".equals(targetid)) {
|
||||
final Action action = checkAndReportDownloadByTarget(getRequest(), targetid, artifact);
|
||||
result = RestResourceConversionHelper.writeFileResponse(artifact, getResponse(), getRequest(), file,
|
||||
cacheWriteNotify, action.getId());
|
||||
} else {
|
||||
result = RestResourceConversionHelper.writeFileResponse(artifact, getResponse(), getRequest(),
|
||||
file);
|
||||
}
|
||||
|
||||
result = RestResourceConversionHelper.writeFileResponse(artifact, getResponse(), getRequest(), file);
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class PropertyBasedArtifactUrlHandlerTest extends AbstractIntegrationTest
|
||||
final String url = urlHandlerProperties.getUrl(controllerId, softwareModuleId, fileName, sha1Hash,
|
||||
UrlProtocol.HTTP);
|
||||
assertEquals("http is build incorrect",
|
||||
"http://localhost/" + tenantAware.getCurrentTenant() + "/controller/v1/" + controllerId
|
||||
"http://localhost:8080/" + tenantAware.getCurrentTenant() + "/controller/v1/" + controllerId
|
||||
+ "/softwaremodules/" + localArtifact.getSoftwareModule().getId() + "/artifacts/"
|
||||
+ localArtifact.getFilename(),
|
||||
url);
|
||||
@@ -81,7 +81,7 @@ public class PropertyBasedArtifactUrlHandlerTest extends AbstractIntegrationTest
|
||||
final String url = urlHandlerProperties.getUrl(controllerId, softwareModuleId, fileName, sha1Hash,
|
||||
UrlProtocol.HTTPS);
|
||||
assertEquals("https is build incorrect",
|
||||
"https://localhost/" + tenantAware.getCurrentTenant() + "/controller/v1/" + controllerId
|
||||
"https://localhost:8080/" + tenantAware.getCurrentTenant() + "/controller/v1/" + controllerId
|
||||
+ "/softwaremodules/" + localArtifact.getSoftwareModule().getId() + "/artifacts/"
|
||||
+ localArtifact.getFilename(),
|
||||
url);
|
||||
|
||||
@@ -34,10 +34,9 @@
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-core</artifactId>
|
||||
<version>2.0.3</version>
|
||||
<dependency>
|
||||
<groupId>org.springframework.plugin</groupId>
|
||||
<artifactId>spring-plugin-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Test -->
|
||||
|
||||
@@ -29,10 +29,9 @@
|
||||
<artifactId>hawkbit-rest-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-core</artifactId>
|
||||
<version>2.0.3</version>
|
||||
<dependency>
|
||||
<groupId>org.springframework.plugin</groupId>
|
||||
<artifactId>spring-plugin-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Test -->
|
||||
|
||||
Reference in New Issue
Block a user