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); }
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; }
private void styleDistributionTableOnPinning() { if (!managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()) { return; } final Target targetObj = targetService.findTargetByControllerIDWithDetails( managementUIState.getDistributionTableFilters().getPinnedTargetId().get()); if (targetObj != null) { final DistributionSet assignedDistribution = targetObj.getAssignedDistributionSet(); final DistributionSet installedDistribution = targetObj.getTargetInfo().getInstalledDistributionSet(); Long installedDistId = null; Long assignedDistId = null; if (null != installedDistribution) { installedDistId = installedDistribution.getId(); } if (null != assignedDistribution) { assignedDistId = assignedDistribution.getId(); } styleDistributionSetTable(installedDistId, assignedDistId); } }