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 {
|
||||
return readAndCheckDownloadUrl(url, targetToken, sha1Hash, size);
|
||||
} 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());
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public final class MgmtDistributionSetMapper {
|
||||
response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep());
|
||||
|
||||
response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(response.getDsId()))
|
||||
.withRel("self"));
|
||||
.withSelfRel());
|
||||
|
||||
response.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class)
|
||||
.getDistributionSetType(distributionSet.getType().getId())).withRel("type"));
|
||||
|
||||
@@ -90,7 +90,7 @@ final class MgmtDistributionSetTypeMapper {
|
||||
result.setModuleId(type.getId());
|
||||
|
||||
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(result.getModuleId()))
|
||||
.withRel("self"));
|
||||
.withSelfRel());
|
||||
|
||||
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getMandatoryModules(result.getModuleId()))
|
||||
.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).pause(rollout.getId())).withRel("pause"));
|
||||
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(),
|
||||
rolloutGroup.getId())).withRel("self"));
|
||||
rolloutGroup.getId())).withSelfRel());
|
||||
return body;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public final class MgmtSoftwareModuleMapper {
|
||||
response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getArtifacts(response.getModuleId()))
|
||||
.withRel(MgmtRestConstants.SOFTWAREMODULE_V1_ARTIFACT));
|
||||
response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getSoftwareModule(response.getModuleId()))
|
||||
.withRel("self"));
|
||||
.withSelfRel());
|
||||
|
||||
response.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class)
|
||||
.getSoftwareModuleType(baseSofwareModule.getType().getId()))
|
||||
@@ -135,7 +135,7 @@ public final class MgmtSoftwareModuleMapper {
|
||||
MgmtRestModelMapper.mapBaseToBase(artifactRest, artifact);
|
||||
|
||||
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)
|
||||
.downloadArtifact(artifact.getSoftwareModule().getId(), artifact.getId())).withRel("download"));
|
||||
|
||||
@@ -70,7 +70,7 @@ final class MgmtSoftwareModuleTypeMapper {
|
||||
result.setModuleId(type.getId());
|
||||
|
||||
result.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getModuleId()))
|
||||
.withRel("self"));
|
||||
.withSelfRel());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public final class MgmtSystemMapper {
|
||||
restConfValue.setLastModifiedAt(repoConfValue.getLastModifiedAt());
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ final class MgmtTagMapper {
|
||||
|
||||
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()))
|
||||
.withRel("assignedTargets"));
|
||||
@@ -91,7 +91,7 @@ final class MgmtTagMapper {
|
||||
|
||||
response.add(
|
||||
linkTo(methodOn(MgmtDistributionSetTagRestApi.class).getDistributionSetTag(distributionSetTag.getId()))
|
||||
.withRel("self"));
|
||||
.withSelfRel());
|
||||
|
||||
response.add(linkTo(
|
||||
methodOn(MgmtDistributionSetTagRestApi.class).getAssignedDistributionSets(distributionSetTag.getId()))
|
||||
|
||||
@@ -59,7 +59,7 @@ public final class MgmtTargetFilterQueryMapper {
|
||||
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(
|
||||
linkTo(methodOn(MgmtTargetFilterQueryRestApi.class).postAssignedDistributionSet(filter.getId(), null))
|
||||
.withRel("autoAssignDS"));
|
||||
|
||||
@@ -81,20 +81,14 @@ public final class MgmtTargetMapper {
|
||||
}
|
||||
}
|
||||
|
||||
static List<MgmtTarget> toResponseWithLinksAndPollStatus(final Collection<Target> targets) {
|
||||
if (targets == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return new ResponseList<>(targets.stream().map(target -> {
|
||||
final MgmtTarget response = toResponse(target);
|
||||
addPollStatus(target, response);
|
||||
addTargetLinks(response);
|
||||
return response;
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
static List<MgmtTarget> toResponse(final Collection<Target> targets) {
|
||||
/**
|
||||
* Create a response for targets.
|
||||
*
|
||||
* @param targets
|
||||
* list of targets
|
||||
* @return the response
|
||||
*/
|
||||
public static List<MgmtTarget> toResponse(final Collection<Target> targets) {
|
||||
if (targets == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -146,7 +140,7 @@ public final class MgmtTargetMapper {
|
||||
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;
|
||||
}
|
||||
@@ -189,7 +183,7 @@ public final class MgmtTargetMapper {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -128,8 +128,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
||||
@Override
|
||||
public ResponseEntity<List<MgmtTarget>> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId) {
|
||||
final TargetTag targetTag = findTargetTagById(targetTagId);
|
||||
return new ResponseEntity<>(MgmtTargetMapper.toResponseWithLinksAndPollStatus(targetTag.getAssignedToTargets()),
|
||||
HttpStatus.OK);
|
||||
return new ResponseEntity<>(MgmtTargetMapper.toResponse(targetTag.getAssignedToTargets()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,7 +153,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
||||
LOG.debug("Assign Targets {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId);
|
||||
final List<Target> assignedTarget = this.targetManagement
|
||||
.assignTag(findTargetControllerIds(assignedTargetRequestBodies), targetTagId);
|
||||
return new ResponseEntity<>(MgmtTargetMapper.toResponseWithLinksAndPollStatus(assignedTarget), HttpStatus.OK);
|
||||
return new ResponseEntity<>(MgmtTargetMapper.toResponse(assignedTarget), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user