Merge branch 'Download_server_supports_download_through_HTTP_and_HTTPs' of https://github.com/bsinno/hawkbit.git into Download_server_supports_download_through_HTTP_and_HTTPs

This commit is contained in:
Jonathan Philip Knoblauch
2016-04-04 10:48:33 +02:00
2 changed files with 9 additions and 13 deletions

View File

@@ -49,11 +49,11 @@ public final class DataConversionHelper {
} }
static List<Chunk> createChunks(final String targetid, final Action uAction, final TenantAware tenantAware, static List<Chunk> createChunks(final String targetid, final Action uAction,
final ArtifactUrlHandler artifactUrlHandler) { final ArtifactUrlHandler artifactUrlHandler) {
return uAction.getDistributionSet().getModules().stream() return uAction.getDistributionSet().getModules().stream()
.map(module -> new Chunk(mapChunkLegacyKeys(module.getType().getKey()), module.getVersion(), .map(module -> new Chunk(mapChunkLegacyKeys(module.getType().getKey()), module.getVersion(),
module.getName(), createArtifacts(targetid, module, tenantAware, artifactUrlHandler))) module.getName(), createArtifacts(targetid, module, artifactUrlHandler)))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@@ -76,12 +76,10 @@ public final class DataConversionHelper {
* of the target * of the target
* @param module * @param module
* the software module * the software module
* @param tenantAware
* of the tenant
* @return a list of artifacts or a empty list. Cannot be <null>. * @return a list of artifacts or a empty list. Cannot be <null>.
*/ */
public static List<Artifact> createArtifacts(final String targetid, public static List<Artifact> createArtifacts(final String targetid,
final org.eclipse.hawkbit.repository.model.SoftwareModule module, final TenantAware tenantAware, final org.eclipse.hawkbit.repository.model.SoftwareModule module,
final ArtifactUrlHandler artifactUrlHandler) { final ArtifactUrlHandler artifactUrlHandler) {
final List<Artifact> files = new ArrayList<>(); final List<Artifact> files = new ArrayList<>();
module.getLocalArtifacts().forEach(artifact -> { module.getLocalArtifacts().forEach(artifact -> {
@@ -94,9 +92,9 @@ public final class DataConversionHelper {
final String linkHttps = artifactUrlHandler.getUrl(targetid, artifact.getSoftwareModule().getId(), final String linkHttps = artifactUrlHandler.getUrl(targetid, artifact.getSoftwareModule().getId(),
artifact.getFilename(), artifact.getSha1Hash(), UrlProtocol.HTTPS); artifact.getFilename(), artifact.getSha1Hash(), UrlProtocol.HTTPS);
file.add(new Link(linkHttps).withRel("download")); file.add(new Link(linkHttps).withRel("download"));
file.add(new Link(linkHttps + ".MD5SUM").withRel("md5sum")); file.add(new Link(linkHttps + ControllerConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum"));
file.add(new Link(linkHttp).withRel("download-http")); file.add(new Link(linkHttp).withRel("download-http"));
file.add(new Link(linkHttp + ".MD5SUM").withRel("md5sum-http")); file.add(new Link(linkHttp + ControllerConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum-http"));
files.add(file); files.add(file);
}); });

View File

@@ -90,10 +90,10 @@ public class RootController {
private CacheWriteNotify cacheWriteNotify; private CacheWriteNotify cacheWriteNotify;
@Autowired @Autowired
private TenantAware tenantAware; private HawkbitSecurityProperties securityProperties;
@Autowired @Autowired
private HawkbitSecurityProperties securityProperties; private TenantAware tenantAware;
@Autowired @Autowired
private ArtifactUrlHandler artifactUrlHandler; private ArtifactUrlHandler artifactUrlHandler;
@@ -122,8 +122,7 @@ public class RootController {
} }
return new ResponseEntity<>( return new ResponseEntity<>(DataConversionHelper.createArtifacts(targetid, softwareModule, artifactUrlHandler),
DataConversionHelper.createArtifacts(targetid, softwareModule, tenantAware, artifactUrlHandler),
HttpStatus.OK); HttpStatus.OK);
} }
@@ -312,8 +311,7 @@ public class RootController {
if (!action.isCancelingOrCanceled()) { if (!action.isCancelingOrCanceled()) {
final List<Chunk> chunks = DataConversionHelper.createChunks(targetid, action, tenantAware, final List<Chunk> chunks = DataConversionHelper.createChunks(targetid, action, artifactUrlHandler);
artifactUrlHandler);
final HandlingType handlingType = action.isForce() ? HandlingType.FORCED : HandlingType.ATTEMPT; final HandlingType handlingType = action.isForce() ? HandlingType.FORCED : HandlingType.ATTEMPT;