Spring Boot 2.0 (#721)

* Migration to Boot 2.0.

Signed-off-by: Kai Zimmermann <kai.zimmermann@microsoft.com>
This commit is contained in:
Kai Zimmermann
2019-01-31 07:29:27 +01:00
committed by GitHub
parent b42b009f9e
commit d52a720480
263 changed files with 2874 additions and 2692 deletions

View File

@@ -12,6 +12,7 @@ import org.eclipse.hawkbit.rest.RestConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Controller;
/**
@@ -22,6 +23,7 @@ import org.springframework.stereotype.Controller;
@Configuration
@ComponentScan
@Import(RestConfiguration.class)
@PropertySource("classpath:/hawkbit-mgmt-api-defaults.properties")
public class MgmtApiConfiguration {
}

View File

@@ -47,7 +47,6 @@ import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
@@ -66,29 +65,36 @@ import org.springframework.web.bind.annotation.RestController;
public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
private static final Logger LOG = LoggerFactory.getLogger(MgmtDistributionSetResource.class);
@Autowired
private SoftwareModuleManagement softwareModuleManagement;
private final SoftwareModuleManagement softwareModuleManagement;
@Autowired
private TargetManagement targetManagement;
private final TargetManagement targetManagement;
@Autowired
private TargetFilterQueryManagement targetFilterQueryManagement;
private final TargetFilterQueryManagement targetFilterQueryManagement;
@Autowired
private DeploymentManagement deployManagament;
private final DeploymentManagement deployManagament;
@Autowired
private SystemManagement systemManagement;
private final SystemManagement systemManagement;
@Autowired
private EntityFactory entityFactory;
private final EntityFactory entityFactory;
@Autowired
private DistributionSetManagement distributionSetManagement;
private final DistributionSetManagement distributionSetManagement;
@Autowired
private SystemSecurityContext systemSecurityContext;
private final SystemSecurityContext systemSecurityContext;
MgmtDistributionSetResource(final SoftwareModuleManagement softwareModuleManagement,
final TargetManagement targetManagement, final TargetFilterQueryManagement targetFilterQueryManagement,
final DeploymentManagement deployManagament, final SystemManagement systemManagement,
final EntityFactory entityFactory, final DistributionSetManagement distributionSetManagement,
final SystemSecurityContext systemSecurityContext) {
this.softwareModuleManagement = softwareModuleManagement;
this.targetManagement = targetManagement;
this.targetFilterQueryManagement = targetFilterQueryManagement;
this.deployManagament = deployManagament;
this.systemManagement = systemManagement;
this.entityFactory = entityFactory;
this.distributionSetManagement = distributionSetManagement;
this.systemSecurityContext = systemSecurityContext;
}
@Override
public ResponseEntity<PagedList<MgmtDistributionSet>> getDistributionSets(

View File

@@ -29,7 +29,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
@@ -50,14 +49,18 @@ import org.springframework.web.bind.annotation.RestController;
public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRestApi {
private static final Logger LOG = LoggerFactory.getLogger(MgmtDistributionSetTagResource.class);
@Autowired
private DistributionSetTagManagement distributionSetTagManagement;
private final DistributionSetTagManagement distributionSetTagManagement;
@Autowired
private DistributionSetManagement distributionSetManagement;
private final DistributionSetManagement distributionSetManagement;
@Autowired
private EntityFactory entityFactory;
private final EntityFactory entityFactory;
MgmtDistributionSetTagResource(final DistributionSetTagManagement distributionSetTagManagement,
final DistributionSetManagement distributionSetManagement, final EntityFactory entityFactory) {
this.distributionSetTagManagement = distributionSetTagManagement;
this.distributionSetManagement = distributionSetManagement;
this.entityFactory = entityFactory;
}
@Override
public ResponseEntity<PagedList<MgmtTag>> getDistributionSetTags(
@@ -140,7 +143,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
public ResponseEntity<List<MgmtDistributionSet>> getAssignedDistributionSets(
@PathVariable("distributionsetTagId") final Long distributionsetTagId) {
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDistributionSets(distributionSetManagement
.findByTag(new PageRequest(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT),
.findByTag(PageRequest.of(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT),
distributionsetTagId)
.getContent()));
}

View File

@@ -25,6 +25,7 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.rest.data.ResponseList;
/**
* A mapper which maps repository model to RESTful model representation and
@@ -66,20 +67,13 @@ final class MgmtDistributionSetTypeMapper {
.orElse(Collections.emptyList());
}
static List<MgmtDistributionSetType> toTypesResponse(final List<DistributionSetType> types) {
if (types == null) {
return Collections.emptyList();
}
return types.stream().map(MgmtDistributionSetTypeMapper::toResponse).collect(Collectors.toList());
}
static List<MgmtDistributionSetType> toListResponse(final List<DistributionSetType> types) {
if (types == null) {
return Collections.emptyList();
}
return types.stream().map(MgmtDistributionSetTypeMapper::toResponse).collect(Collectors.toList());
return new ResponseList<>(
types.stream().map(MgmtDistributionSetTypeMapper::toResponse).collect(Collectors.toList()));
}
static MgmtDistributionSetType toResponse(final DistributionSetType type) {

View File

@@ -29,7 +29,6 @@ import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
@@ -48,14 +47,18 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeRestApi {
@Autowired
private SoftwareModuleTypeManagement softwareModuleTypeManagement;
private final SoftwareModuleTypeManagement softwareModuleTypeManagement;
@Autowired
private DistributionSetTypeManagement distributionSetTypeManagement;
private final DistributionSetTypeManagement distributionSetTypeManagement;
@Autowired
private EntityFactory entityFactory;
private final EntityFactory entityFactory;
MgmtDistributionSetTypeResource(final SoftwareModuleTypeManagement softwareModuleTypeManagement,
final DistributionSetTypeManagement distributionSetTypeManagement, final EntityFactory entityFactory) {
this.softwareModuleTypeManagement = softwareModuleTypeManagement;
this.distributionSetTypeManagement = distributionSetTypeManagement;
this.entityFactory = entityFactory;
}
@Override
public ResponseEntity<PagedList<MgmtDistributionSetType>> getDistributionSetTypes(
@@ -127,7 +130,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
.create(MgmtDistributionSetTypeMapper.smFromRequest(entityFactory, distributionSetTypes));
return ResponseEntity.status(HttpStatus.CREATED)
.body(MgmtDistributionSetTypeMapper.toTypesResponse(createdSoftwareModules));
.body(MgmtDistributionSetTypeMapper.toListResponse(createdSoftwareModules));
}
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final Long distributionSetTypeId) {

View File

@@ -20,7 +20,6 @@ import org.eclipse.hawkbit.rest.util.FileStreamingUtil;
import org.eclipse.hawkbit.rest.util.RequestResponseContextHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
@@ -37,14 +36,18 @@ public class MgmtDownloadResource implements MgmtDownloadRestApi {
private static final Logger LOGGER = LoggerFactory.getLogger(MgmtDownloadResource.class);
@Autowired
private ArtifactRepository artifactRepository;
private final ArtifactRepository artifactRepository;
@Autowired
private DownloadIdCache downloadIdCache;
private final DownloadIdCache downloadIdCache;
@Autowired
private RequestResponseContextHolder requestResponseContextHolder;
private final RequestResponseContextHolder requestResponseContextHolder;
MgmtDownloadResource(final ArtifactRepository artifactRepository, final DownloadIdCache downloadIdCache,
final RequestResponseContextHolder requestResponseContextHolder) {
this.artifactRepository = artifactRepository;
this.downloadIdCache = downloadIdCache;
this.requestResponseContextHolder = requestResponseContextHolder;
}
@Override
@ResponseBody

View File

@@ -34,7 +34,6 @@ import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
import org.eclipse.hawkbit.repository.model.Target;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
@@ -51,20 +50,25 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
public class MgmtRolloutResource implements MgmtRolloutRestApi {
@Autowired
private RolloutManagement rolloutManagement;
private final RolloutManagement rolloutManagement;
@Autowired
private RolloutGroupManagement rolloutGroupManagement;
private final RolloutGroupManagement rolloutGroupManagement;
@Autowired
private DistributionSetManagement distributionSetManagement;
private final DistributionSetManagement distributionSetManagement;
@Autowired
private TargetFilterQueryManagement targetFilterQueryManagement;
private final TargetFilterQueryManagement targetFilterQueryManagement;
@Autowired
private EntityFactory entityFactory;
private final EntityFactory entityFactory;
MgmtRolloutResource(final RolloutManagement rolloutManagement, final RolloutGroupManagement rolloutGroupManagement,
final DistributionSetManagement distributionSetManagement,
final TargetFilterQueryManagement targetFilterQueryManagement, final EntityFactory entityFactory) {
this.rolloutManagement = rolloutManagement;
this.rolloutGroupManagement = rolloutGroupManagement;
this.distributionSetManagement = distributionSetManagement;
this.targetFilterQueryManagement = targetFilterQueryManagement;
this.entityFactory = entityFactory;
}
@Override
public ResponseEntity<PagedList<MgmtRolloutResponseBody>> getRollouts(
@@ -119,8 +123,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
rollout = rolloutManagement.create(create, rolloutGroups, rolloutGroupConditions);
} else if (rolloutRequestBody.getAmountGroups() != null) {
rollout = rolloutManagement.create(create, rolloutRequestBody.getAmountGroups(),
rolloutGroupConditions);
rollout = rolloutManagement.create(create, rolloutRequestBody.getAmountGroups(), rolloutGroupConditions);
} else {
throw new ValidationException("Either 'amountGroups' or 'groups' must be defined in the request");
@@ -222,7 +225,8 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
final Page<Target> rolloutGroupTargets;
if (rsqlParam != null) {
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(pageable, groupId, rsqlParam);
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(pageable, groupId,
rsqlParam);
} else {
final Page<Target> pageTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroup(pageable, groupId);
rolloutGroupTargets = pageTargets;
@@ -232,9 +236,8 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
}
private DistributionSet findDistributionSetOrThrowException(final MgmtRolloutRestRequestBody rolloutRequestBody) {
return this.distributionSetManagement.get(rolloutRequestBody.getDistributionSetId())
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class,
rolloutRequestBody.getDistributionSetId()));
return this.distributionSetManagement.get(rolloutRequestBody.getDistributionSetId()).orElseThrow(
() -> new EntityNotFoundException(DistributionSet.class, rolloutRequestBody.getDistributionSetId()));
}
}

View File

@@ -33,7 +33,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
@@ -43,6 +42,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@@ -56,18 +56,22 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
private static final Logger LOG = LoggerFactory.getLogger(MgmtSoftwareModuleResource.class);
@Autowired
private ArtifactManagement artifactManagement;
private final ArtifactManagement artifactManagement;
@Autowired
private SoftwareModuleManagement softwareModuleManagement;
private final SoftwareModuleManagement softwareModuleManagement;
@Autowired
private EntityFactory entityFactory;
private final EntityFactory entityFactory;
MgmtSoftwareModuleResource(final ArtifactManagement artifactManagement,
final SoftwareModuleManagement softwareModuleManagement, final EntityFactory entityFactory) {
this.artifactManagement = artifactManagement;
this.softwareModuleManagement = softwareModuleManagement;
this.entityFactory = entityFactory;
}
@Override
public ResponseEntity<MgmtArtifact> uploadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId,
@RequestParam("file") final MultipartFile file,
@RequestPart("file") final MultipartFile file,
@RequestParam(value = "filename", required = false) final String optionalFileName,
@RequestParam(value = "md5sum", required = false) final String md5Sum,
@RequestParam(value = "sha1sum", required = false) final String sha1Sum) {

View File

@@ -23,7 +23,6 @@ import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
@@ -42,11 +41,16 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRestApi {
@Autowired
private SoftwareModuleTypeManagement softwareModuleTypeManagement;
@Autowired
private EntityFactory entityFactory;
private final SoftwareModuleTypeManagement softwareModuleTypeManagement;
private final EntityFactory entityFactory;
MgmtSoftwareModuleTypeResource(final SoftwareModuleTypeManagement softwareModuleTypeManagement,
final EntityFactory entityFactory) {
this.softwareModuleTypeManagement = softwareModuleTypeManagement;
this.entityFactory = entityFactory;
}
@Override
public ResponseEntity<PagedList<MgmtSoftwareModuleType>> getTypes(
@@ -96,10 +100,9 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId,
@RequestBody final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType) {
final SoftwareModuleType updatedSoftwareModuleType = softwareModuleTypeManagement
.update(entityFactory.softwareModuleType().update(softwareModuleTypeId)
.description(restSoftwareModuleType.getDescription())
.colour(restSoftwareModuleType.getColour()));
final SoftwareModuleType updatedSoftwareModuleType = softwareModuleTypeManagement.update(entityFactory
.softwareModuleType().update(softwareModuleTypeId).description(restSoftwareModuleType.getDescription())
.colour(restSoftwareModuleType.getColour()));
return ResponseEntity.ok(MgmtSoftwareModuleTypeMapper.toResponse(updatedSoftwareModuleType));
}
@@ -108,8 +111,8 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
public ResponseEntity<List<MgmtSoftwareModuleType>> createSoftwareModuleTypes(
@RequestBody final List<MgmtSoftwareModuleTypeRequestBodyPost> softwareModuleTypes) {
final List<SoftwareModuleType> createdSoftwareModules = softwareModuleTypeManagement.create(
MgmtSoftwareModuleTypeMapper.smFromRequest(entityFactory, softwareModuleTypes));
final List<SoftwareModuleType> createdSoftwareModules = softwareModuleTypeManagement
.create(MgmtSoftwareModuleTypeMapper.smFromRequest(entityFactory, softwareModuleTypes));
return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules),
HttpStatus.CREATED);

View File

@@ -23,7 +23,6 @@ import org.eclipse.hawkbit.repository.report.model.SystemUsageReportWithTenants;
import org.eclipse.hawkbit.repository.report.model.TenantUsage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.http.ResponseEntity;
@@ -40,11 +39,14 @@ public class MgmtSystemManagementResource implements MgmtSystemManagementRestApi
private static final Logger LOGGER = LoggerFactory.getLogger(MgmtSystemManagementResource.class);
@Autowired
private SystemManagement systemManagement;
private final SystemManagement systemManagement;
@Autowired
private CacheManager cacheManager;
private final CacheManager cacheManager;
MgmtSystemManagementResource(final SystemManagement systemManagement, final CacheManager cacheManager) {
this.systemManagement = systemManagement;
this.cacheManager = cacheManager;
}
/**
* Deletes the tenant data of a given tenant. USE WITH CARE!

View File

@@ -25,7 +25,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
@@ -44,11 +43,15 @@ import org.springframework.web.bind.annotation.RestController;
public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestApi {
private static final Logger LOG = LoggerFactory.getLogger(MgmtTargetFilterQueryResource.class);
@Autowired
private TargetFilterQueryManagement filterManagement;
private final TargetFilterQueryManagement filterManagement;
@Autowired
private EntityFactory entityFactory;
private final EntityFactory entityFactory;
MgmtTargetFilterQueryResource(final TargetFilterQueryManagement filterManagement,
final EntityFactory entityFactory) {
this.filterManagement = filterManagement;
this.entityFactory = entityFactory;
}
@Override
public ResponseEntity<MgmtTargetFilterQuery> getFilter(@PathVariable("filterId") final Long filterId) {

View File

@@ -192,7 +192,7 @@ public final class MgmtTargetMapper {
return actionStatus.stream().map(status -> toResponse(status,
deploymentManagement.findMessagesByActionStatusId(
new PageRequest(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), status.getId())
PageRequest.of(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), status.getId())
.getContent()))
.collect(Collectors.toList());
}

View File

@@ -44,7 +44,6 @@ import org.eclipse.hawkbit.repository.model.TargetMetadata;
import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
@@ -61,16 +60,22 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
public class MgmtTargetResource implements MgmtTargetRestApi {
private static final String ACTION_TARGET_MISSING_ASSIGN_WARN = "given action ({}) is not assigned to given target ({}).";
private static final Logger LOG = LoggerFactory.getLogger(MgmtTargetResource.class);
@Autowired
private TargetManagement targetManagement;
private final TargetManagement targetManagement;
@Autowired
private DeploymentManagement deploymentManagement;
private final DeploymentManagement deploymentManagement;
@Autowired
private EntityFactory entityFactory;
private final EntityFactory entityFactory;
MgmtTargetResource(final TargetManagement targetManagement, final DeploymentManagement deploymentManagement,
final EntityFactory entityFactory) {
this.targetManagement = targetManagement;
this.deploymentManagement = deploymentManagement;
this.entityFactory = entityFactory;
}
@Override
public ResponseEntity<MgmtTarget> getTarget(@PathVariable("targetId") final String targetId) {
@@ -163,8 +168,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
}
@Override
public ResponseEntity<PagedList<MgmtAction>> getActionHistory(
@PathVariable("targetId") final String targetId,
public ResponseEntity<PagedList<MgmtAction>> getActionHistory(@PathVariable("targetId") final String targetId,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
@@ -188,8 +192,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
}
return ResponseEntity.ok(
new PagedList<>(MgmtTargetMapper.toResponse(targetId, activeActions.getContent()),
totalActionCount));
new PagedList<>(MgmtTargetMapper.toResponse(targetId, activeActions.getContent()), totalActionCount));
}
@Override
@@ -199,7 +202,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
final Action action = deploymentManagement.findAction(actionId)
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));
if (!action.getTarget().getControllerId().equals(targetId)) {
LOG.warn("given action ({}) is not assigned to given target ({}).", action.getId(), targetId);
LOG.warn(ACTION_TARGET_MISSING_ASSIGN_WARN, action.getId(), targetId);
return ResponseEntity.notFound().build();
}
@@ -214,7 +217,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));
if (!action.getTarget().getControllerId().equals(targetId)) {
LOG.warn("given action ({}) is not assigned to given target ({}).", actionId, targetId);
LOG.warn(ACTION_TARGET_MISSING_ASSIGN_WARN, actionId, targetId);
return ResponseEntity.notFound().build();
}
@@ -242,7 +245,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));
if (!action.getTarget().getId().equals(target.getId())) {
LOG.warn("given action ({}) is not assigned to given target ({}).", action.getId(), target.getId());
LOG.warn(ACTION_TARGET_MISSING_ASSIGN_WARN, action.getId(), target.getId());
return ResponseEntity.notFound().build();
}
@@ -278,8 +281,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
@Override
public ResponseEntity<MgmtTargetAssignmentResponseBody> postAssignedDistributionSet(
@PathVariable("targetId") final String targetId,
@RequestBody final MgmtDistributionSetAssignment dsId,
@PathVariable("targetId") final String targetId, @RequestBody final MgmtDistributionSetAssignment dsId,
@RequestParam(value = "offline", required = false) final boolean offline) {
if (offline) {
@@ -340,7 +342,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
Action action = deploymentManagement.findAction(actionId)
.orElseThrow(() -> new EntityNotFoundException(Action.class, actionId));
if (!action.getTarget().getControllerId().equals(targetId)) {
LOG.warn("given action ({}) is not assigned to given target ({}).", action.getId(), targetId);
LOG.warn(ACTION_TARGET_MISSING_ASSIGN_WARN, action.getId(), targetId);
return ResponseEntity.notFound().build();
}

View File

@@ -29,7 +29,6 @@ import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
@@ -49,14 +48,18 @@ import org.springframework.web.bind.annotation.RestController;
public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
private static final Logger LOG = LoggerFactory.getLogger(MgmtTargetTagResource.class);
@Autowired
private TargetTagManagement tagManagement;
private final TargetTagManagement tagManagement;
@Autowired
private TargetManagement targetManagement;
private final TargetManagement targetManagement;
@Autowired
private EntityFactory entityFactory;
private final EntityFactory entityFactory;
MgmtTargetTagResource(final TargetTagManagement tagManagement, final TargetManagement targetManagement,
final EntityFactory entityFactory) {
this.tagManagement = tagManagement;
this.targetManagement = targetManagement;
this.entityFactory = entityFactory;
}
@Override
public ResponseEntity<PagedList<MgmtTag>> getTargetTags(
@@ -131,7 +134,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
public ResponseEntity<List<MgmtTarget>> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId) {
return ResponseEntity.ok(MgmtTargetMapper.toResponse(targetManagement
.findByTag(new PageRequest(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), targetTagId)
.findByTag(PageRequest.of(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), targetTagId)
.getContent()));
}

View File

@@ -19,7 +19,6 @@ import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
@@ -37,7 +36,6 @@ public class MgmtTenantManagementResource implements MgmtTenantManagementRestApi
private final TenantConfigurationManagement tenantConfigurationManagement;
private final TenantConfigurationProperties tenantConfigurationProperties;
@Autowired
MgmtTenantManagementResource(final TenantConfigurationManagement tenantConfigurationManagement,
final TenantConfigurationProperties tenantConfigurationProperties) {
this.tenantConfigurationManagement = tenantConfigurationManagement;

View File

@@ -0,0 +1,13 @@
#
# Copyright (c) 2018 Microsoft and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Upload of large files
spring.servlet.multipart.max-file-size=1024MB
spring.servlet.multipart.max-request-size=-1
spring.servlet.multipart.file-size-threshold=1MB