Fix tag resource for assigned targets. (#425)
* Fix tag resource for assigned targets. Shoudl behave as targets resource. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix class Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -222,7 +222,7 @@ public class DeviceSimulatorUpdater {
|
|||||||
try {
|
try {
|
||||||
return readAndCheckDownloadUrl(url, targetToken, sha1Hash, size);
|
return readAndCheckDownloadUrl(url, targetToken, sha1Hash, size);
|
||||||
} catch (IOException | KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
|
} catch (IOException | KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
|
||||||
LOGGER.error("Failed to download" + url, e);
|
LOGGER.error("Failed to download " + url, e);
|
||||||
return new UpdateStatus(ResponseStatus.ERROR, "Failed to download " + url + ": " + e.getMessage());
|
return new UpdateStatus(ResponseStatus.ERROR, "Failed to download " + url + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public final class MgmtDistributionSetMapper {
|
|||||||
response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep());
|
response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep());
|
||||||
|
|
||||||
response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(response.getDsId()))
|
response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(response.getDsId()))
|
||||||
.withRel("self"));
|
.withSelfRel());
|
||||||
|
|
||||||
response.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class)
|
response.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class)
|
||||||
.getDistributionSetType(distributionSet.getType().getId())).withRel("type"));
|
.getDistributionSetType(distributionSet.getType().getId())).withRel("type"));
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ final class MgmtDistributionSetTypeMapper {
|
|||||||
result.setModuleId(type.getId());
|
result.setModuleId(type.getId());
|
||||||
|
|
||||||
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(result.getModuleId()))
|
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(result.getModuleId()))
|
||||||
.withRel("self"));
|
.withSelfRel());
|
||||||
|
|
||||||
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getMandatoryModules(result.getModuleId()))
|
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getMandatoryModules(result.getModuleId()))
|
||||||
.withRel(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULES));
|
.withRel(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULES));
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ final class MgmtRolloutMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).getRollout(rollout.getId())).withRel("self"));
|
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).getRollout(rollout.getId())).withSelfRel());
|
||||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).start(rollout.getId())).withRel("start"));
|
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).start(rollout.getId())).withRel("start"));
|
||||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).pause(rollout.getId())).withRel("pause"));
|
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).pause(rollout.getId())).withRel("pause"));
|
||||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).resume(rollout.getId())).withRel("resume"));
|
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).resume(rollout.getId())).withRel("resume"));
|
||||||
@@ -182,7 +182,7 @@ final class MgmtRolloutMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).getRolloutGroup(rolloutGroup.getRollout().getId(),
|
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).getRolloutGroup(rolloutGroup.getRollout().getId(),
|
||||||
rolloutGroup.getId())).withRel("self"));
|
rolloutGroup.getId())).withSelfRel());
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public final class MgmtSoftwareModuleMapper {
|
|||||||
response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getArtifacts(response.getModuleId()))
|
response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getArtifacts(response.getModuleId()))
|
||||||
.withRel(MgmtRestConstants.SOFTWAREMODULE_V1_ARTIFACT));
|
.withRel(MgmtRestConstants.SOFTWAREMODULE_V1_ARTIFACT));
|
||||||
response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getSoftwareModule(response.getModuleId()))
|
response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getSoftwareModule(response.getModuleId()))
|
||||||
.withRel("self"));
|
.withSelfRel());
|
||||||
|
|
||||||
response.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class)
|
response.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class)
|
||||||
.getSoftwareModuleType(baseSofwareModule.getType().getId()))
|
.getSoftwareModuleType(baseSofwareModule.getType().getId()))
|
||||||
@@ -135,7 +135,7 @@ public final class MgmtSoftwareModuleMapper {
|
|||||||
MgmtRestModelMapper.mapBaseToBase(artifactRest, artifact);
|
MgmtRestModelMapper.mapBaseToBase(artifactRest, artifact);
|
||||||
|
|
||||||
artifactRest.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class)
|
artifactRest.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class)
|
||||||
.getArtifact(artifact.getSoftwareModule().getId(), artifact.getId())).withRel("self"));
|
.getArtifact(artifact.getSoftwareModule().getId(), artifact.getId())).withSelfRel());
|
||||||
|
|
||||||
artifactRest.add(linkTo(methodOn(MgmtDownloadArtifactResource.class)
|
artifactRest.add(linkTo(methodOn(MgmtDownloadArtifactResource.class)
|
||||||
.downloadArtifact(artifact.getSoftwareModule().getId(), artifact.getId())).withRel("download"));
|
.downloadArtifact(artifact.getSoftwareModule().getId(), artifact.getId())).withRel("download"));
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ final class MgmtSoftwareModuleTypeMapper {
|
|||||||
result.setModuleId(type.getId());
|
result.setModuleId(type.getId());
|
||||||
|
|
||||||
result.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getModuleId()))
|
result.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getModuleId()))
|
||||||
.withRel("self"));
|
.withSelfRel());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public final class MgmtSystemMapper {
|
|||||||
restConfValue.setLastModifiedAt(repoConfValue.getLastModifiedAt());
|
restConfValue.setLastModifiedAt(repoConfValue.getLastModifiedAt());
|
||||||
restConfValue.setLastModifiedBy(repoConfValue.getLastModifiedBy());
|
restConfValue.setLastModifiedBy(repoConfValue.getLastModifiedBy());
|
||||||
|
|
||||||
restConfValue.add(linkTo(methodOn(MgmtSystemResource.class).getConfigurationValue(key)).withRel("self"));
|
restConfValue.add(linkTo(methodOn(MgmtSystemResource.class).getConfigurationValue(key)).withSelfRel());
|
||||||
|
|
||||||
return restConfValue;
|
return restConfValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ final class MgmtTagMapper {
|
|||||||
|
|
||||||
mapTag(response, targetTag);
|
mapTag(response, targetTag);
|
||||||
|
|
||||||
response.add(linkTo(methodOn(MgmtTargetTagRestApi.class).getTargetTag(targetTag.getId())).withRel("self"));
|
response.add(linkTo(methodOn(MgmtTargetTagRestApi.class).getTargetTag(targetTag.getId())).withSelfRel());
|
||||||
|
|
||||||
response.add(linkTo(methodOn(MgmtTargetTagRestApi.class).getAssignedTargets(targetTag.getId()))
|
response.add(linkTo(methodOn(MgmtTargetTagRestApi.class).getAssignedTargets(targetTag.getId()))
|
||||||
.withRel("assignedTargets"));
|
.withRel("assignedTargets"));
|
||||||
@@ -91,7 +91,7 @@ final class MgmtTagMapper {
|
|||||||
|
|
||||||
response.add(
|
response.add(
|
||||||
linkTo(methodOn(MgmtDistributionSetTagRestApi.class).getDistributionSetTag(distributionSetTag.getId()))
|
linkTo(methodOn(MgmtDistributionSetTagRestApi.class).getDistributionSetTag(distributionSetTag.getId()))
|
||||||
.withRel("self"));
|
.withSelfRel());
|
||||||
|
|
||||||
response.add(linkTo(
|
response.add(linkTo(
|
||||||
methodOn(MgmtDistributionSetTagRestApi.class).getAssignedDistributionSets(distributionSetTag.getId()))
|
methodOn(MgmtDistributionSetTagRestApi.class).getAssignedDistributionSets(distributionSetTag.getId()))
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public final class MgmtTargetFilterQueryMapper {
|
|||||||
targetRest.setAutoAssignDistributionSet(distributionSet.getId());
|
targetRest.setAutoAssignDistributionSet(distributionSet.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
targetRest.add(linkTo(methodOn(MgmtTargetFilterQueryRestApi.class).getFilter(filter.getId())).withRel("self"));
|
targetRest.add(linkTo(methodOn(MgmtTargetFilterQueryRestApi.class).getFilter(filter.getId())).withSelfRel());
|
||||||
targetRest.add(
|
targetRest.add(
|
||||||
linkTo(methodOn(MgmtTargetFilterQueryRestApi.class).postAssignedDistributionSet(filter.getId(), null))
|
linkTo(methodOn(MgmtTargetFilterQueryRestApi.class).postAssignedDistributionSet(filter.getId(), null))
|
||||||
.withRel("autoAssignDS"));
|
.withRel("autoAssignDS"));
|
||||||
|
|||||||
@@ -81,20 +81,14 @@ public final class MgmtTargetMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<MgmtTarget> toResponseWithLinksAndPollStatus(final Collection<Target> targets) {
|
/**
|
||||||
if (targets == null) {
|
* Create a response for targets.
|
||||||
return Collections.emptyList();
|
*
|
||||||
}
|
* @param targets
|
||||||
|
* list of targets
|
||||||
return new ResponseList<>(targets.stream().map(target -> {
|
* @return the response
|
||||||
final MgmtTarget response = toResponse(target);
|
*/
|
||||||
addPollStatus(target, response);
|
public static List<MgmtTarget> toResponse(final Collection<Target> targets) {
|
||||||
addTargetLinks(response);
|
|
||||||
return response;
|
|
||||||
}).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
static List<MgmtTarget> toResponse(final Collection<Target> targets) {
|
|
||||||
if (targets == null) {
|
if (targets == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@@ -146,7 +140,7 @@ public final class MgmtTargetMapper {
|
|||||||
targetRest.setInstalledAt(installationDate);
|
targetRest.setInstalledAt(installationDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
targetRest.add(linkTo(methodOn(MgmtTargetRestApi.class).getTarget(target.getControllerId())).withRel("self"));
|
targetRest.add(linkTo(methodOn(MgmtTargetRestApi.class).getTarget(target.getControllerId())).withSelfRel());
|
||||||
|
|
||||||
return targetRest;
|
return targetRest;
|
||||||
}
|
}
|
||||||
@@ -189,7 +183,7 @@ public final class MgmtTargetMapper {
|
|||||||
|
|
||||||
MgmtRestModelMapper.mapBaseToBase(result, action);
|
MgmtRestModelMapper.mapBaseToBase(result, action);
|
||||||
|
|
||||||
result.add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(targetId, action.getId())).withRel("self"));
|
result.add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(targetId, action.getId())).withSelfRel());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,8 +128,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
|||||||
@Override
|
@Override
|
||||||
public ResponseEntity<List<MgmtTarget>> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId) {
|
public ResponseEntity<List<MgmtTarget>> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId) {
|
||||||
final TargetTag targetTag = findTargetTagById(targetTagId);
|
final TargetTag targetTag = findTargetTagById(targetTagId);
|
||||||
return new ResponseEntity<>(MgmtTargetMapper.toResponseWithLinksAndPollStatus(targetTag.getAssignedToTargets()),
|
return new ResponseEntity<>(MgmtTargetMapper.toResponse(targetTag.getAssignedToTargets()), HttpStatus.OK);
|
||||||
HttpStatus.OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -154,7 +153,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
|||||||
LOG.debug("Assign Targets {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId);
|
LOG.debug("Assign Targets {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId);
|
||||||
final List<Target> assignedTarget = this.targetManagement
|
final List<Target> assignedTarget = this.targetManagement
|
||||||
.assignTag(findTargetControllerIds(assignedTargetRequestBodies), targetTagId);
|
.assignTag(findTargetControllerIds(assignedTargetRequestBodies), targetTagId);
|
||||||
return new ResponseEntity<>(MgmtTargetMapper.toResponseWithLinksAndPollStatus(assignedTarget), HttpStatus.OK);
|
return new ResponseEntity<>(MgmtTargetMapper.toResponse(assignedTarget), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user