Merge remote-tracking branch 'eclipse/master' into MECS-1444-CREATE_UNIT_TEST_FOR_ENUM_FIELDS

This commit is contained in:
Kai Zimmermann
2016-01-27 14:58:30 +01:00
107 changed files with 1225 additions and 1210 deletions

View File

@@ -138,13 +138,11 @@ public class ArtifactStoreController implements EnvironmentAware {
private Action checkAndReportDownloadByTarget(final HttpServletRequest request, final String targetid,
final LocalArtifact artifact) {
final Target target = controllerManagement.updateLastTargetQuery(
targetid,
IpUtil.getClientIpFromRequest(request,
environment.getProperty("security.rp.remote_ip_header", String.class, "X-Forwarded-For")));
final Target target = controllerManagement.updateLastTargetQuery(targetid, IpUtil.getClientIpFromRequest(
request, environment.getProperty("security.rp.remote_ip_header", String.class, "X-Forwarded-For")));
final Action action = controllerManagement.getActionForDownloadByTargetAndSoftwareModule(
target.getControllerId(), artifact.getSoftwareModule());
final Action action = controllerManagement
.getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(), artifact.getSoftwareModule());
final String range = request.getHeader("Range");
final ActionStatus actionStatus = new ActionStatus();

View File

@@ -163,9 +163,10 @@ public class RootController implements EnvironmentAware {
System.currentTimeMillis(), IpUtil.getClientIpFromRequest(request, requestHeader));
}
return new ResponseEntity<>(DataConversionHelper.fromTarget(target,
controllerManagement.findActionByTargetAndActive(target), controllerPollProperties.getPollingTime(),
tenantAware), HttpStatus.OK);
return new ResponseEntity<>(
DataConversionHelper.fromTarget(target, controllerManagement.findActionByTargetAndActive(target),
controllerPollProperties.getPollingTime(), tenantAware),
HttpStatus.OK);
}
/**
@@ -220,8 +221,8 @@ public class RootController implements EnvironmentAware {
private Action checkAndLogDownload(final HttpServletRequest request, final Target target,
final SoftwareModule module) {
final Action action = controllerManagement.getActionForDownloadByTargetAndSoftwareModule(
target.getControllerId(), module);
final Action action = controllerManagement
.getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(), module);
final String range = request.getHeader("Range");
final ActionStatus statusMessage = new ActionStatus();
@@ -274,8 +275,8 @@ public class RootController implements EnvironmentAware {
}
try {
DataConversionHelper.writeMD5FileResponse(fileName, response, module.getLocalArtifactByFilename(fileName)
.get());
DataConversionHelper.writeMD5FileResponse(fileName, response,
module.getLocalArtifactByFilename(fileName).get());
} catch (final IOException e) {
LOG.error("Failed to stream MD5 File", e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
@@ -301,7 +302,8 @@ public class RootController implements EnvironmentAware {
* the HTTP request injected by spring
* @return the response
*/
@RequestMapping(value = "/{targetid}/" + ControllerConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/{targetid}/" + ControllerConstants.DEPLOYMENT_BASE_ACTION
+ "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<DeploymentBase> getControllerBasedeploymentAction(
@PathVariable @NotEmpty final String targetid, @PathVariable @NotEmpty final Long actionId,
@RequestParam(value = "c", required = false, defaultValue = "-1") final int resource,
@@ -323,8 +325,8 @@ public class RootController implements EnvironmentAware {
final HandlingType handlingType = action.isForce() ? HandlingType.FORCED : HandlingType.ATTEMPT;
final DeploymentBase base = new DeploymentBase(Long.toString(action.getId()), new Deployment(handlingType,
handlingType, chunks));
final DeploymentBase base = new DeploymentBase(Long.toString(action.getId()),
new Deployment(handlingType, handlingType, chunks));
LOG.debug("Found an active UpdateAction for target {}. returning deyploment: {}", targetid, base);
@@ -388,8 +390,8 @@ public class RootController implements EnvironmentAware {
}
private ActionStatus generateUpdateStatus(final ActionFeedback feedback, final String targetid,
final Long actionid, final Action action) {
private ActionStatus generateUpdateStatus(final ActionFeedback feedback, final String targetid, final Long actionid,
final Action action) {
final ActionStatus actionStatus = new ActionStatus();
actionStatus.setAction(action);
@@ -430,8 +432,8 @@ public class RootController implements EnvironmentAware {
private static void handleDefaultUpdateStatus(final ActionFeedback feedback, final String targetid,
final Long actionid, final ActionStatus actionStatus) {
LOG.debug("Controller reported intermediate status (actionid: {}, targetid: {}) as we got {} report.",
actionid, targetid, feedback.getStatus().getExecution());
LOG.debug("Controller reported intermediate status (actionid: {}, targetid: {}) as we got {} report.", actionid,
targetid, feedback.getStatus().getExecution());
actionStatus.setStatus(Status.RUNNING);
// MECS-400: we should not use the unstructed message list for
// the server comment on the status.
@@ -463,7 +465,8 @@ public class RootController implements EnvironmentAware {
*
* @return status of the request
*/
@RequestMapping(value = "/{targetid}/" + ControllerConstants.CONFIG_DATA_ACTION, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/{targetid}/"
+ ControllerConstants.CONFIG_DATA_ACTION, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Void> putConfigData(@Valid @RequestBody final ConfigData configData,
@PathVariable final String targetid, final HttpServletRequest request) {
controllerManagement.updateLastTargetQuery(targetid, IpUtil.getClientIpFromRequest(request, requestHeader));
@@ -485,7 +488,8 @@ public class RootController implements EnvironmentAware {
*
* @return the {@link Cancel} response
*/
@RequestMapping(value = "/{targetid}/" + ControllerConstants.CANCEL_ACTION + "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/{targetid}/" + ControllerConstants.CANCEL_ACTION
+ "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Cancel> getControllerCancelAction(@PathVariable @NotEmpty final String targetid,
@PathVariable @NotEmpty final Long actionId, final HttpServletRequest request) {
LOG.debug("getControllerCancelAction({})", targetid);
@@ -500,8 +504,8 @@ public class RootController implements EnvironmentAware {
}
if (action.isCancelingOrCanceled()) {
final Cancel cancel = new Cancel(String.valueOf(action.getId()), new CancelActionToStop(
String.valueOf(action.getId())));
final Cancel cancel = new Cancel(String.valueOf(action.getId()),
new CancelActionToStop(String.valueOf(action.getId())));
LOG.debug("Found an active CancelAction for target {}. returning cancel: {}", targetid, cancel);
@@ -553,8 +557,8 @@ public class RootController implements EnvironmentAware {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
controllerManagement.addCancelActionStatus(
generateActionCancelStatus(feedback, target, feedback.getId(), action), action);
controllerManagement
.addCancelActionStatus(generateActionCancelStatus(feedback, target, feedback.getId(), action), action);
return new ResponseEntity<>(HttpStatus.OK);
}

View File

@@ -57,8 +57,8 @@ public final class DistributionSetMapper {
final DistributionSetType module = distributionSetManagement
.findDistributionSetTypeByKey(distributionSetTypekey);
if (module == null) {
throw new EntityNotFoundException("DistributionSetType with key {" + distributionSetTypekey
+ "} does not exist");
throw new EntityNotFoundException(
"DistributionSetType with key {" + distributionSetTypekey + "} does not exist");
}
return module;
}
@@ -108,18 +108,18 @@ public final class DistributionSetMapper {
}
if (dsRest.getApplication() != null) {
result.addModule(findSoftwareModuleWithExceptionIfNotFound(dsRest.getApplication().getId(),
softwareManagement));
result.addModule(
findSoftwareModuleWithExceptionIfNotFound(dsRest.getApplication().getId(), softwareManagement));
}
if (dsRest.getRuntime() != null) {
result.addModule(findSoftwareModuleWithExceptionIfNotFound(dsRest.getRuntime().getId(), softwareManagement));
result.addModule(
findSoftwareModuleWithExceptionIfNotFound(dsRest.getRuntime().getId(), softwareManagement));
}
if (dsRest.getModules() != null) {
dsRest.getModules().forEach(
module -> result.addModule(findSoftwareModuleWithExceptionIfNotFound(module.getId(),
softwareManagement)));
dsRest.getModules().forEach(module -> result
.addModule(findSoftwareModuleWithExceptionIfNotFound(module.getId(), softwareManagement)));
}
return result;
@@ -163,23 +163,22 @@ public final class DistributionSetMapper {
response.setComplete(distributionSet.isComplete());
response.setType(distributionSet.getType().getKey());
distributionSet.getModules().forEach(
module -> response.getModules().add(SoftwareModuleMapper.toResponse(module)));
distributionSet.getModules()
.forEach(module -> response.getModules().add(SoftwareModuleMapper.toResponse(module)));
response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep());
response.add(linkTo(methodOn(DistributionSetResource.class).getDistributionSet(response.getDsId())).withRel(
"self"));
response.add(
linkTo(methodOn(DistributionSetResource.class).getDistributionSet(response.getDsId())).withRel("self"));
response.add(linkTo(
methodOn(DistributionSetTypeResource.class).getDistributionSetType(distributionSet.getType().getId()))
.withRel("type"));
.withRel("type"));
response.add(linkTo(
methodOn(DistributionSetResource.class).getMetadata(response.getDsId(),
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET),
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)).withRel(
"metadata"));
response.add(linkTo(methodOn(DistributionSetResource.class).getMetadata(response.getDsId(),
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET),
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null))
.withRel("metadata"));
return response;
}

View File

@@ -13,8 +13,6 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.DistributionSetFields;
@@ -92,7 +90,6 @@ public class DistributionSetResource {
@Autowired
private DistributionSetManagement distributionSetManagement;
/**
* Handles the GET request of retrieving all {@link DistributionSet}s within
* SP.

View File

@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.rest.resource;
import java.util.List;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.TagFields;
import org.eclipse.hawkbit.repository.TagManagement;
@@ -60,7 +58,6 @@ public class DistributionSetTagResource {
@Autowired
private DistributionSetManagement distributionSetManagement;
/**
* Handles the GET request of retrieving all DistributionSet tags.
*
@@ -100,8 +97,8 @@ public class DistributionSetTagResource {
countTargetsAll = tagManagement.countTargetTags();
} else {
final Page<DistributionSetTag> findTargetPage = tagManagement.findAllDistributionSetTags(
RSQLUtility.parse(rsqlParam, TagFields.class), pageable);
final Page<DistributionSetTag> findTargetPage = tagManagement
.findAllDistributionSetTags(RSQLUtility.parse(rsqlParam, TagFields.class), pageable);
countTargetsAll = findTargetPage.getTotalElements();
findTargetsAll = findTargetPage;
@@ -139,13 +136,13 @@ public class DistributionSetTagResource {
* with status code 201 - Created. The Response Body are the created
* distribution set tags but without ResponseBody.
*/
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<TagsRest> createDistributionSetTags(@RequestBody final List<TagRequestBodyPut> tags) {
LOG.debug("creating {} ds tags", tags.size());
final List<DistributionSetTag> createdTags = tagManagement.createDistributionSetTags(TagMapper
.mapDistributionSetTagFromRequest(tags));
final List<DistributionSetTag> createdTags = tagManagement
.createDistributionSetTags(TagMapper.mapDistributionSetTagFromRequest(tags));
return new ResponseEntity<>(TagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED);
}
@@ -245,14 +242,14 @@ public class DistributionSetTagResource {
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
final DistributionSetTagAssigmentResult assigmentResult = distributionSetManagement.toggleTagAssignment(
findDistributionSetIds(assignedDSRequestBodies), tag.getName());
final DistributionSetTagAssigmentResult assigmentResult = distributionSetManagement
.toggleTagAssignment(findDistributionSetIds(assignedDSRequestBodies), tag.getName());
final DistributionSetTagAssigmentResultRest tagAssigmentResultRest = new DistributionSetTagAssigmentResultRest();
tagAssigmentResultRest.setAssignedDistributionSets(DistributionSetMapper
.toResponseDistributionSets(assigmentResult.getAssignedDs()));
tagAssigmentResultRest.setUnassignedDistributionSets(DistributionSetMapper
.toResponseDistributionSets(assigmentResult.getUnassignedDs()));
tagAssigmentResultRest.setAssignedDistributionSets(
DistributionSetMapper.toResponseDistributionSets(assigmentResult.getAssignedDs()));
tagAssigmentResultRest.setUnassignedDistributionSets(
DistributionSetMapper.toResponseDistributionSets(assigmentResult.getUnassignedDs()));
LOG.debug("Toggled assignedDS {} and unassignedDS{}", assigmentResult.getAssigned(),
assigmentResult.getUnassigned());
@@ -279,8 +276,8 @@ public class DistributionSetTagResource {
LOG.debug("Assign DistributionSet {} for ds tag {}", assignedDSRequestBodies.size(), distributionsetTagId);
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
final List<DistributionSet> assignedDs = distributionSetManagement.assignTag(
findDistributionSetIds(assignedDSRequestBodies), tag);
final List<DistributionSet> assignedDs = distributionSetManagement
.assignTag(findDistributionSetIds(assignedDSRequestBodies), tag);
LOG.debug("Assignd DistributionSet {}", assignedDs.size());
return new ResponseEntity<>(DistributionSetMapper.toResponseDistributionSets(assignedDs), HttpStatus.OK);
}

View File

@@ -10,8 +10,6 @@ package org.eclipse.hawkbit.rest.resource;
import java.util.List;
import javax.persistence.EntityManager;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.DistributionSetTypeFields;
import org.eclipse.hawkbit.repository.SoftwareManagement;

View File

@@ -60,7 +60,8 @@ public final class SoftwareModuleMapper {
smsRest.getName(), smsRest.getVersion(), smsRest.getDescription(), smsRest.getVendor());
}
static List<SoftwareModuleMetadata> fromRequestSwMetadata(final SoftwareModule sw, final List<MetadataRest> metadata) {
static List<SoftwareModuleMetadata> fromRequestSwMetadata(final SoftwareModule sw,
final List<MetadataRest> metadata) {
final List<SoftwareModuleMetadata> mappedList = new ArrayList<>(metadata.size());
for (final MetadataRest metadataRest : metadata) {
if (metadataRest.getKey() == null) {
@@ -141,20 +142,19 @@ public final class SoftwareModuleMapper {
response.setType(baseSofwareModule.getType().getKey());
response.setVendor(baseSofwareModule.getVendor());
response.add(linkTo(methodOn(SoftwareModuleResource.class).getArtifacts(response.getModuleId())).withRel(
RestConstants.SOFTWAREMODULE_V1_ARTIFACT));
response.add(linkTo(methodOn(SoftwareModuleResource.class).getSoftwareModule(response.getModuleId())).withRel(
"self"));
response.add(linkTo(methodOn(SoftwareModuleResource.class).getArtifacts(response.getModuleId()))
.withRel(RestConstants.SOFTWAREMODULE_V1_ARTIFACT));
response.add(linkTo(methodOn(SoftwareModuleResource.class).getSoftwareModule(response.getModuleId()))
.withRel("self"));
response.add(linkTo(
methodOn(SoftwareModuleTypeResource.class).getSoftwareModuleType(baseSofwareModule.getType().getId()))
.withRel(RestConstants.SOFTWAREMODULE_V1_TYPE));
.withRel(RestConstants.SOFTWAREMODULE_V1_TYPE));
response.add(linkTo(
methodOn(SoftwareModuleResource.class).getMetadata(response.getModuleId(),
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET),
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)).withRel(
"metadata"));
response.add(linkTo(methodOn(SoftwareModuleResource.class).getMetadata(response.getModuleId(),
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET),
Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null))
.withRel("metadata"));
return response;
}
@@ -178,13 +178,12 @@ public final class SoftwareModuleMapper {
RestModelMapper.mapBaseToBase(artifactRest, artifact);
artifactRest.add(linkTo(
methodOn(SoftwareModuleResource.class).getArtifact(artifact.getSoftwareModule().getId(),
artifact.getId())).withRel("self"));
artifactRest.add(linkTo(methodOn(SoftwareModuleResource.class).getArtifact(artifact.getSoftwareModule().getId(),
artifact.getId())).withRel("self"));
if (artifact instanceof LocalArtifact) {
artifactRest.add(linkTo(
methodOn(SoftwareModuleResource.class).downloadArtifact(artifact.getSoftwareModule().getId(),
artifactRest.add(
linkTo(methodOn(SoftwareModuleResource.class).downloadArtifact(artifact.getSoftwareModule().getId(),
artifact.getId(), null, null)).withRel("download"));
}

View File

@@ -261,8 +261,8 @@ public class SoftwareModuleResource {
final Slice<SoftwareModule> findModulesAll;
Long countModulesAll;
if (rsqlParam != null) {
findModulesAll = softwareManagement.findSoftwareModulesByPredicate(
RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class), pageable);
findModulesAll = softwareManagement
.findSoftwareModulesByPredicate(RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class), pageable);
countModulesAll = ((Page<SoftwareModule>) findModulesAll).getTotalElements();
} else {
findModulesAll = softwareManagement.findSoftwareModulesAll(pageable);
@@ -303,8 +303,8 @@ public class SoftwareModuleResource {
* failure the JsonResponseExceptionHandler is handling the
* response.
*/
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<SoftwareModulesRest> createSoftwareModules(
@RequestBody final List<SoftwareModuleRequestBodyPost> softwareModules) {
LOG.debug("creating {} softwareModules", softwareModules.size());
@@ -383,8 +383,7 @@ public class SoftwareModuleResource {
*/
@RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/metadata", produces = {
MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
public ResponseEntity<MetadataRestPageList> getMetadata(
@PathVariable final Long softwareModuleId,
public ResponseEntity<MetadataRestPageList> getMetadata(@PathVariable final Long softwareModuleId,
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@@ -407,8 +406,10 @@ public class SoftwareModuleResource {
metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, pageable);
}
return new ResponseEntity<>(new MetadataRestPageList(SoftwareModuleMapper.toResponseSwMetadata(metaDataPage
.getContent()), metaDataPage.getTotalElements()), HttpStatus.OK);
return new ResponseEntity<>(
new MetadataRestPageList(SoftwareModuleMapper.toResponseSwMetadata(metaDataPage.getContent()),
metaDataPage.getTotalElements()),
HttpStatus.OK);
}
/**
@@ -421,7 +422,8 @@ public class SoftwareModuleResource {
* @return status OK if get request is successful with the value of the meta
* data
*/
@RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/metadata/{metadataKey}", produces = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/metadata/{metadataKey}", produces = {
MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<MetadataRest> getMetadataValue(@PathVariable final Long softwareModuleId,
@PathVariable final String metadataKey) {
// check if distribution set exists otherwise throw exception
@@ -481,8 +483,8 @@ public class SoftwareModuleResource {
* the created meta data
*/
@RequestMapping(method = RequestMethod.POST, value = "/{softwareModuleId}/metadata", consumes = {
MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE,
"application/hal+json" })
MediaType.APPLICATION_JSON_VALUE,
"application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" })
public ResponseEntity<List<MetadataRest>> createMetadata(@PathVariable final Long softwareModuleId,
@RequestBody final List<MetadataRest> metadataRest) {
// check if software module exists otherwise throw exception immediately
@@ -495,7 +497,8 @@ public class SoftwareModuleResource {
}
private SoftwareModule findSoftwareModuleWithExceptionIfNotFound(final Long softwareModuleId, final Long artifactId) {
private SoftwareModule findSoftwareModuleWithExceptionIfNotFound(final Long softwareModuleId,
final Long artifactId) {
final SoftwareModule module = softwareManagement.findSoftwareModuleById(softwareModuleId);
if (module == null) {
throw new EntityNotFoundException("SoftwareModule with Id {" + softwareModuleId + "} does not exist");

View File

@@ -86,8 +86,8 @@ public class SystemManagementResource {
.setOverallArtifactVolumeInBytes(report.getOverallArtifactVolumeInBytes())
.setOverallTargets(report.getOverallTargets()).setOverallTenants(report.getTenants().size());
result.setTenantStats(report.getTenants().stream().map(tenant -> convertTenant(tenant))
.collect(Collectors.toList()));
result.setTenantStats(
report.getTenants().stream().map(tenant -> convertTenant(tenant)).collect(Collectors.toList()));
return ResponseEntity.ok(result);
}

View File

@@ -55,8 +55,8 @@ final class TagMapper {
response.add(linkTo(methodOn(TargetTagResource.class).getTargetTag(targetTag.getId())).withRel("self"));
response.add(linkTo(methodOn(TargetTagResource.class).getAssignedTargets(targetTag.getId())).withRel(
"assignedTargets"));
response.add(linkTo(methodOn(TargetTagResource.class).getAssignedTargets(targetTag.getId()))
.withRel("assignedTargets"));
return response;
}
@@ -83,13 +83,13 @@ final class TagMapper {
mapTag(response, distributionSetTag);
response.add(linkTo(
methodOn(DistributionSetTagResource.class).getDistributionSetTag(distributionSetTag.getId())).withRel(
"self"));
response.add(
linkTo(methodOn(DistributionSetTagResource.class).getDistributionSetTag(distributionSetTag.getId()))
.withRel("self"));
response.add(linkTo(
methodOn(DistributionSetTagResource.class).getAssignedDistributionSets(distributionSetTag.getId()))
.withRel("assignedDistributionSets"));
.withRel("assignedDistributionSets"));
return response;
}
@@ -97,8 +97,8 @@ final class TagMapper {
static List<TargetTag> mapTargeTagFromRequest(final Iterable<TagRequestBodyPut> tags) {
final List<TargetTag> mappedList = new ArrayList<>();
for (final TagRequestBodyPut targetTagRest : tags) {
mappedList.add(new TargetTag(targetTagRest.getName(), targetTagRest.getDescription(), targetTagRest
.getColour()));
mappedList.add(
new TargetTag(targetTagRest.getName(), targetTagRest.getDescription(), targetTagRest.getColour()));
}
return mappedList;
}

View File

@@ -54,13 +54,12 @@ final public class TargetMapper {
.withRel(RestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET));
response.add(linkTo(methodOn(TargetResource.class).getInstalledDistributionSet(response.getControllerId()))
.withRel(RestConstants.TARGET_V1_INSTALLED_DISTRIBUTION_SET));
response.add(linkTo(methodOn(TargetResource.class).getAttributes(response.getControllerId())).withRel(
RestConstants.TARGET_V1_ATTRIBUTES));
response.add(linkTo(
methodOn(TargetResource.class).getActionHistory(response.getControllerId(), 0,
RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE,
ActionFields.ID.getFieldName() + ":" + SortDirection.DESC, null)).withRel(
RestConstants.TARGET_V1_ACTIONS));
response.add(linkTo(methodOn(TargetResource.class).getAttributes(response.getControllerId()))
.withRel(RestConstants.TARGET_V1_ATTRIBUTES));
response.add(linkTo(methodOn(TargetResource.class).getActionHistory(response.getControllerId(), 0,
RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE,
ActionFields.ID.getFieldName() + ":" + SortDirection.DESC, null))
.withRel(RestConstants.TARGET_V1_ACTIONS));
}
/**
@@ -75,10 +74,10 @@ final public class TargetMapper {
final PollStatus pollStatus = target.getTargetInfo().getPollStatus();
if (pollStatus != null) {
final PollStatusRest pollStatusRest = new PollStatusRest();
pollStatusRest.setLastRequestAt(Date.from(
pollStatus.getLastPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime());
pollStatusRest.setNextExpectedRequestAt(Date.from(
pollStatus.getNextPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime());
pollStatusRest.setLastRequestAt(
Date.from(pollStatus.getLastPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime());
pollStatusRest.setNextExpectedRequestAt(
Date.from(pollStatus.getNextPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime());
pollStatusRest.setOverdue(pollStatus.isOverdue());
targetRest.setPollStatus(pollStatusRest);
}

View File

@@ -134,8 +134,8 @@ public class TargetResource {
final Slice<Target> findTargetsAll;
final Long countTargetsAll;
if (rsqlParam != null) {
final Page<Target> findTargetPage = targetManagement.findTargetsAll(
RSQLUtility.parse(rsqlParam, TargetFields.class), pageable);
final Page<Target> findTargetPage = targetManagement
.findTargetsAll(RSQLUtility.parse(rsqlParam, TargetFields.class), pageable);
countTargetsAll = findTargetPage.getTotalElements();
findTargetsAll = findTargetPage;
} else {
@@ -159,8 +159,8 @@ public class TargetResource {
* entities. In any failure the JsonResponseExceptionHandler is
* handling the response.
*/
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<TargetsRest> createTargets(@RequestBody final List<TargetRequestBody> targets) {
LOG.debug("creating {} targets", targets.size());
final Iterable<Target> createdTargets = targetManagement.createTargets(TargetMapper.fromRequest(targets));
@@ -267,8 +267,7 @@ public class TargetResource {
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions", produces = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<ActionPagedList> getActionHistory(
@PathVariable final String targetId,
public ResponseEntity<ActionPagedList> getActionHistory(@PathVariable final String targetId,
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@@ -292,8 +291,9 @@ public class TargetResource {
totalActionCount = deploymentManagement.countActionsByTarget(foundTarget);
}
return new ResponseEntity<>(new ActionPagedList(TargetMapper.toResponse(targetId, activeActions.getContent()),
totalActionCount), HttpStatus.OK);
return new ResponseEntity<>(
new ActionPagedList(TargetMapper.toResponse(targetId, activeActions.getContent()), totalActionCount),
HttpStatus.OK);
}
/**
@@ -308,7 +308,8 @@ public class TargetResource {
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions/{actionId}", produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<ActionRest> getAction(@PathVariable final String targetId, @PathVariable final Long actionId) {
public ResponseEntity<ActionRest> getAction(@PathVariable final String targetId,
@PathVariable final Long actionId) {
final Target target = findTargetWithExceptionIfNotFound(targetId);
final Action action = findActionWithExceptionIfNotFound(actionId);
@@ -322,17 +323,16 @@ public class TargetResource {
if (!action.isCancelingOrCanceled()) {
result.add(linkTo(
methodOn(DistributionSetResource.class).getDistributionSet(action.getDistributionSet().getId()))
.withRel("distributionset"));
.withRel("distributionset"));
} else if (action.isCancelingOrCanceled()) {
result.add(linkTo(methodOn(TargetResource.class).getAction(targetId, action.getId())).withRel(
RestConstants.TARGET_V1_CANCELED_ACTION));
result.add(linkTo(methodOn(TargetResource.class).getAction(targetId, action.getId()))
.withRel(RestConstants.TARGET_V1_CANCELED_ACTION));
}
result.add(linkTo(
methodOn(TargetResource.class).getActionStatusList(targetId, action.getId(), 0,
RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE,
ActionStatusFields.ID.getFieldName() + ":" + SortDirection.DESC)).withRel(
RestConstants.TARGET_V1_ACTION_STATUS));
result.add(linkTo(methodOn(TargetResource.class).getActionStatusList(targetId, action.getId(), 0,
RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE,
ActionStatusFields.ID.getFieldName() + ":" + SortDirection.DESC))
.withRel(RestConstants.TARGET_V1_ACTION_STATUS));
return new ResponseEntity<>(result, HttpStatus.OK);
}
@@ -394,8 +394,7 @@ public class TargetResource {
*/
@RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions/{actionId}/status", produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<ActionStatusPagedList> getActionStatusList(
@PathVariable final String targetId,
public ResponseEntity<ActionStatusPagedList> getActionStatusList(@PathVariable final String targetId,
@PathVariable final Long actionId,
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@@ -416,8 +415,10 @@ public class TargetResource {
final Page<ActionStatus> statusList = deploymentManagement.findActionStatusMessagesByActionInDescOrder(
new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action, true);
return new ResponseEntity<>(new ActionStatusPagedList(TargetMapper.toActionStatusRestResponse(action,
statusList.getContent()), statusList.getTotalElements()), HttpStatus.OK);
return new ResponseEntity<>(
new ActionStatusPagedList(TargetMapper.toActionStatusRestResponse(action, statusList.getContent()),
statusList.getTotalElements()),
HttpStatus.OK);
}
@@ -436,8 +437,8 @@ public class TargetResource {
MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<DistributionSetRest> getAssignedDistributionSet(@PathVariable final String targetId) {
final Target findTarget = findTargetWithExceptionIfNotFound(targetId);
final DistributionSetRest distributionSetRest = DistributionSetMapper.toResponse(findTarget
.getAssignedDistributionSet());
final DistributionSetRest distributionSetRest = DistributionSetMapper
.toResponse(findTarget.getAssignedDistributionSet());
final HttpStatus retStatus;
if (distributionSetRest == null) {
retStatus = HttpStatus.NO_CONTENT;
@@ -466,8 +467,8 @@ public class TargetResource {
@RequestBody final DistributionSetAssigmentRest dsId) {
findTargetWithExceptionIfNotFound(targetId);
final ActionType type = (dsId.getType() != null) ? RestResourceConversionHelper.convertActionType(dsId
.getType()) : ActionType.FORCED;
final ActionType type = (dsId.getType() != null)
? RestResourceConversionHelper.convertActionType(dsId.getType()) : ActionType.FORCED;
final Iterator<Target> changed = deploymentManagement
.assignDistributionSet(dsId.getId(), type, dsId.getForcetime(), targetId).getAssignedTargets()
.iterator();
@@ -496,8 +497,8 @@ public class TargetResource {
MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<DistributionSetRest> getInstalledDistributionSet(@PathVariable final String targetId) {
final Target findTarget = findTargetWithExceptionIfNotFound(targetId);
final DistributionSetRest distributionSetRest = DistributionSetMapper.toResponse(findTarget.getTargetInfo()
.getInstalledDistributionSet());
final DistributionSetRest distributionSetRest = DistributionSetMapper
.toResponse(findTarget.getTargetInfo().getInstalledDistributionSet());
final HttpStatus retStatus;
if (distributionSetRest == null) {
retStatus = HttpStatus.NO_CONTENT;

View File

@@ -102,8 +102,8 @@ public class TargetTagResource {
countTargetsAll = tagManagement.countTargetTags();
} else {
final Page<TargetTag> findTargetPage = tagManagement.findAllTargetTags(
RSQLUtility.parse(rsqlParam, TagFields.class), pageable);
final Page<TargetTag> findTargetPage = tagManagement
.findAllTargetTags(RSQLUtility.parse(rsqlParam, TagFields.class), pageable);
countTargetsAll = findTargetPage.getTotalElements();
findTargetsAll = findTargetPage;
@@ -140,8 +140,8 @@ public class TargetTagResource {
* with status code 201 - Created. The Response Body are the created
* target tags but without ResponseBody.
*/
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = {
"application/hal+json", MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json",
MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
public ResponseEntity<TagsRest> createTargetTags(@RequestBody final List<TagRequestBodyPut> tags) {
LOG.debug("creating {} target tags", tags.size());
final List<TargetTag> createdTargetTags = tagManagement
@@ -233,8 +233,8 @@ public class TargetTagResource {
LOG.debug("Toggle Target assignment {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId);
final TargetTag targetTag = findTargetTagById(targetTagId);
final TargetTagAssigmentResult assigmentResult = targetManagement.toggleTagAssignment(
findTargetControllerIds(assignedTargetRequestBodies), targetTag.getName());
final TargetTagAssigmentResult assigmentResult = targetManagement
.toggleTagAssignment(findTargetControllerIds(assignedTargetRequestBodies), targetTag.getName());
final TargetTagAssigmentResultRest tagAssigmentResultRest = new TargetTagAssigmentResultRest();
tagAssigmentResultRest.setAssignedTargets(TargetMapper.toResponse(assigmentResult.getAssignedTargets()));
@@ -259,8 +259,8 @@ public class TargetTagResource {
@RequestBody final List<AssignedTargetRequestBody> assignedTargetRequestBodies) {
LOG.debug("Assign Targets {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId);
final TargetTag targetTag = findTargetTagById(targetTagId);
final List<Target> assignedTarget = targetManagement.assignTag(
findTargetControllerIds(assignedTargetRequestBodies), targetTag);
final List<Target> assignedTarget = targetManagement
.assignTag(findTargetControllerIds(assignedTargetRequestBodies), targetTag);
return new ResponseEntity<>(TargetMapper.toResponseWithLinksAndPollStatus(assignedTarget), HttpStatus.OK);
}