Merged changes from master into ddi-resources
Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
@@ -33,7 +33,6 @@ import org.eclipse.hawkbit.repository.model.Action.Status;
|
|||||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.hateoas.Link;
|
import org.springframework.hateoas.Link;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
@@ -42,10 +41,6 @@ import com.google.common.base.Charsets;
|
|||||||
* Utility class for the DDI API.
|
* Utility class for the DDI API.
|
||||||
*/
|
*/
|
||||||
public final class DataConversionHelper {
|
public final class DataConversionHelper {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
ArtifactUrlHandler artifactUrlHandler;
|
|
||||||
|
|
||||||
// utility class, private constructor.
|
// utility class, private constructor.
|
||||||
private DataConversionHelper() {
|
private DataConversionHelper() {
|
||||||
|
|
||||||
@@ -84,23 +79,33 @@ public final class DataConversionHelper {
|
|||||||
final org.eclipse.hawkbit.repository.model.SoftwareModule module,
|
final org.eclipse.hawkbit.repository.model.SoftwareModule module,
|
||||||
final ArtifactUrlHandler artifactUrlHandler) {
|
final ArtifactUrlHandler artifactUrlHandler) {
|
||||||
final List<DdiArtifact> files = new ArrayList<>();
|
final List<DdiArtifact> files = new ArrayList<>();
|
||||||
module.getLocalArtifacts().forEach(artifact -> {
|
|
||||||
final DdiArtifact file = new DdiArtifact();
|
module.getLocalArtifacts()
|
||||||
file.setHashes(new DdiArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash()));
|
.forEach(artifact -> files.add(createArtifact(targetid, artifactUrlHandler, artifact)));
|
||||||
file.setFilename(artifact.getFilename());
|
return files;
|
||||||
file.setSize(artifact.getSize());
|
}
|
||||||
|
|
||||||
|
private static DdiArtifact createArtifact(final String targetid, final ArtifactUrlHandler artifactUrlHandler,
|
||||||
|
final LocalArtifact artifact) {
|
||||||
|
final DdiArtifact file = new DdiArtifact();
|
||||||
|
file.setHashes(new DdiArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash()));
|
||||||
|
file.setFilename(artifact.getFilename());
|
||||||
|
file.setSize(artifact.getSize());
|
||||||
|
|
||||||
|
if (artifactUrlHandler.protocolSupported(UrlProtocol.HTTP)) {
|
||||||
final String linkHttp = artifactUrlHandler.getUrl(targetid, artifact.getSoftwareModule().getId(),
|
final String linkHttp = artifactUrlHandler.getUrl(targetid, artifact.getSoftwareModule().getId(),
|
||||||
artifact.getFilename(), artifact.getSha1Hash(), UrlProtocol.HTTP);
|
artifact.getFilename(), artifact.getSha1Hash(), UrlProtocol.HTTP);
|
||||||
|
file.add(new Link(linkHttp).withRel("download-http"));
|
||||||
|
file.add(new Link(linkHttp + DdiDlRestConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum-http"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (artifactUrlHandler.protocolSupported(UrlProtocol.HTTPS)) {
|
||||||
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 + DdiDlRestConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum"));
|
file.add(new Link(linkHttps + DdiDlRestConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum"));
|
||||||
file.add(new Link(linkHttp).withRel("download-http"));
|
}
|
||||||
file.add(new Link(linkHttp + DdiDlRestConstants.ARTIFACT_MD5_DWNL_SUFFIX).withRel("md5sum-http"));
|
return file;
|
||||||
|
|
||||||
files.add(file);
|
|
||||||
});
|
|
||||||
return files;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DdiControllerBase fromTarget(final Target target, final List<Action> actions,
|
static DdiControllerBase fromTarget(final Target target, final List<Action> actions,
|
||||||
|
|||||||
@@ -102,8 +102,6 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
@PathVariable("softwareModuleId") final Long softwareModuleId) {
|
@PathVariable("softwareModuleId") final Long softwareModuleId) {
|
||||||
LOG.debug("getSoftwareModulesArtifacts({})", targetid);
|
LOG.debug("getSoftwareModulesArtifacts({})", targetid);
|
||||||
|
|
||||||
// SecurityContextHolder.getContext().getAuthentication().
|
|
||||||
|
|
||||||
final SoftwareModule softwareModule = softwareManagement.findSoftwareModuleById(softwareModuleId);
|
final SoftwareModule softwareModule = softwareManagement.findSoftwareModuleById(softwareModuleId);
|
||||||
|
|
||||||
if (softwareModule == null) {
|
if (softwareModule == null) {
|
||||||
@@ -250,7 +248,8 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
LOG.debug("Found an active UpdateAction for target {}. returning deyploment: {}", targetid, base);
|
LOG.debug("Found an active UpdateAction for target {}. returning deyploment: {}", targetid, base);
|
||||||
|
|
||||||
controllerManagement.registerRetrieved(action,
|
controllerManagement.registerRetrieved(action,
|
||||||
"Controller retrieved update action and should start now the download.");
|
ControllerManagement.SERVER_MESSAGE_PREFIX
|
||||||
|
+ "Target retrieved update action and should start now the download.");
|
||||||
|
|
||||||
return new ResponseEntity<>(base, HttpStatus.OK);
|
return new ResponseEntity<>(base, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
@@ -287,7 +286,6 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
controllerManagement.addUpdateActionStatus(
|
controllerManagement.addUpdateActionStatus(
|
||||||
|
|
||||||
generateUpdateStatus(feedback, targetid, feedback.getId(), action), action);
|
generateUpdateStatus(feedback, targetid, feedback.getId(), action), action);
|
||||||
|
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
|||||||
Reference in New Issue
Block a user