private Artifact convertArtifact( final Target target, final org.eclipse.hawkbit.repository.model.Artifact localArtifact) { final Artifact artifact = new Artifact(); artifact.setUrls( artifactUrlHandler .getUrls( new URLPlaceholder( systemManagement.getTenantMetadata().getTenant(), systemManagement.getTenantMetadata().getId(), target.getControllerId(), target.getId(), new SoftwareData( localArtifact.getSoftwareModule().getId(), localArtifact.getFilename(), localArtifact.getId(), localArtifact.getSha1Hash())), ApiType.DMF) .stream() .collect(Collectors.toMap(e -> e.getProtocol(), e -> e.getRef()))); artifact.setFilename(localArtifact.getFilename()); artifact.setHashes(new ArtifactHash(localArtifact.getSha1Hash(), localArtifact.getMd5Hash())); artifact.setSize(localArtifact.getSize()); return artifact; }
void sendUpdateMessageToTarget( final String tenant, final Target target, final Long actionId, final Collection<org.eclipse.hawkbit.repository.model.SoftwareModule> modules) { if (target == null) { return; } final URI targetAdress = target.getTargetInfo().getAddress(); if (!IpUtil.isAmqpUri(targetAdress)) { return; } final DownloadAndUpdateRequest downloadAndUpdateRequest = new DownloadAndUpdateRequest(); downloadAndUpdateRequest.setActionId(actionId); final String targetSecurityToken = systemSecurityContext.runAsSystem(target::getSecurityToken); downloadAndUpdateRequest.setTargetSecurityToken(targetSecurityToken); for (final org.eclipse.hawkbit.repository.model.SoftwareModule softwareModule : modules) { final SoftwareModule amqpSoftwareModule = convertToAmqpSoftwareModule(target, softwareModule); downloadAndUpdateRequest.addSoftwareModule(amqpSoftwareModule); } final Message message = getMessageConverter() .toMessage( downloadAndUpdateRequest, createConnectorMessageProperties( tenant, target.getControllerId(), EventTopic.DOWNLOAD_AND_INSTALL)); amqpSenderService.sendMessage(message, targetAdress); }