Refactoring of RepostioryManagement and extending classes (#2174)
* createMetaData renamed to putMetaData * getXXX methods returing Optional are renamed to findXXX * unified method order (code cosmetics) Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -122,7 +122,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
assertThat(actionStatusRepository.count()).isEqualTo(2);
|
assertThat(actionStatusRepository.count()).isEqualTo(2);
|
||||||
|
|
||||||
final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId()).get();
|
final DistributionSet findDistributionSetByAction = distributionSetManagement.findByAction(action.getId()).get();
|
||||||
|
|
||||||
getAndVerifyConfirmationBasePayload(
|
getAndVerifyConfirmationBasePayload(
|
||||||
DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, artifact,
|
DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, artifact,
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
assertThat(countActionStatusAll()).isEqualTo(2);
|
assertThat(countActionStatusAll()).isEqualTo(2);
|
||||||
|
|
||||||
final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId()).get();
|
final DistributionSet findDistributionSetByAction = distributionSetManagement.findByAction(action.getId()).get();
|
||||||
getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, artifact,
|
getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, artifact,
|
||||||
artifactSignature, action.getId(),
|
artifactSignature, action.getId(),
|
||||||
findDistributionSetByAction.findFirstModuleByType(osType).get().getId(), "forced", "forced");
|
findDistributionSetByAction.findFirstModuleByType(osType).get().getId(), "forced", "forced");
|
||||||
@@ -244,9 +244,9 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
final Artifact artifactSignature = testdataFactory.createArtifact(nextBytes(ARTIFACT_SIZE),
|
final Artifact artifactSignature = testdataFactory.createArtifact(nextBytes(ARTIFACT_SIZE),
|
||||||
getOsModule(ds), "test1.signature", ARTIFACT_SIZE);
|
getOsModule(ds), "test1.signature", ARTIFACT_SIZE);
|
||||||
|
|
||||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(getOsModule(ds))
|
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(getOsModule(ds))
|
||||||
.key(visibleMetadataOsKey).value(visibleMetadataOsValue).targetVisible(true));
|
.key(visibleMetadataOsKey).value(visibleMetadataOsValue).targetVisible(true));
|
||||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(getOsModule(ds))
|
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(getOsModule(ds))
|
||||||
.key("metaDataNotVisible").value("withValue").targetVisible(false));
|
.key("metaDataNotVisible").value("withValue").targetVisible(false));
|
||||||
|
|
||||||
final Target savedTarget = createTargetAndAssertNoActiveActions();
|
final Target savedTarget = createTargetAndAssertNoActiveActions();
|
||||||
@@ -279,7 +279,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
assertThat(countActionStatusAll()).isEqualTo(2);
|
assertThat(countActionStatusAll()).isEqualTo(2);
|
||||||
|
|
||||||
final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId()).get();
|
final DistributionSet findDistributionSetByAction = distributionSetManagement.findByAction(action.getId()).get();
|
||||||
|
|
||||||
getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, visibleMetadataOsKey,
|
getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, visibleMetadataOsKey,
|
||||||
visibleMetadataOsValue, artifact, artifactSignature, action.getId(), "attempt", "attempt",
|
visibleMetadataOsValue, artifact, artifactSignature, action.getId(), "attempt", "attempt",
|
||||||
@@ -334,7 +334,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
assertThat(countActionStatusAll()).isEqualTo(2);
|
assertThat(countActionStatusAll()).isEqualTo(2);
|
||||||
|
|
||||||
final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId()).get();
|
final DistributionSet findDistributionSetByAction = distributionSetManagement.findByAction(action.getId()).get();
|
||||||
getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, artifact,
|
getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, artifact,
|
||||||
artifactSignature, action.getId(),
|
artifactSignature, action.getId(),
|
||||||
findDistributionSetByAction.findFirstModuleByType(osType).get().getId(), "forced", "forced");
|
findDistributionSetByAction.findFirstModuleByType(osType).get().getId(), "forced", "forced");
|
||||||
@@ -361,9 +361,9 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
final Artifact artifactSignature = testdataFactory.createArtifact(
|
final Artifact artifactSignature = testdataFactory.createArtifact(
|
||||||
nextBytes(ARTIFACT_SIZE), getOsModule(ds), "test1.signature", ARTIFACT_SIZE);
|
nextBytes(ARTIFACT_SIZE), getOsModule(ds), "test1.signature", ARTIFACT_SIZE);
|
||||||
|
|
||||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(getOsModule(ds))
|
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(getOsModule(ds))
|
||||||
.key("metaDataVisible").value("withValue").targetVisible(true));
|
.key("metaDataVisible").value("withValue").targetVisible(true));
|
||||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(getOsModule(ds))
|
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(getOsModule(ds))
|
||||||
.key("metaDataNotVisible").value("withValue").targetVisible(false));
|
.key("metaDataNotVisible").value("withValue").targetVisible(false));
|
||||||
|
|
||||||
final Target savedTarget = createTargetAndAssertNoActiveActions();
|
final Target savedTarget = createTargetAndAssertNoActiveActions();
|
||||||
@@ -399,7 +399,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
assertThat(countActionStatusAll()).isEqualTo(2);
|
assertThat(countActionStatusAll()).isEqualTo(2);
|
||||||
|
|
||||||
final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId()).get();
|
final DistributionSet findDistributionSetByAction = distributionSetManagement.findByAction(action.getId()).get();
|
||||||
getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, "metaDataVisible",
|
getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, "metaDataVisible",
|
||||||
"withValue", artifact, artifactSignature, action.getId(), "forced", "skip",
|
"withValue", artifact, artifactSignature, action.getId(), "forced", "skip",
|
||||||
getOsModule(findDistributionSetByAction));
|
getOsModule(findDistributionSetByAction));
|
||||||
@@ -794,7 +794,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Page<ActionStatus> findActionStatusAll(final Pageable pageable) {
|
private Page<ActionStatus> findActionStatusAll(final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(actionStatusRepository, pageable, null);
|
return JpaManagementHelper.findAllWithCountBySpec(actionStatusRepository, null, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ActionStatusCondition extends Condition<ActionStatus> {
|
private static class ActionStatusCondition extends Condition<ActionStatus> {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
final Slice<DistributionSet> findDsPage;
|
final Slice<DistributionSet> findDsPage;
|
||||||
final long countModulesAll;
|
final long countModulesAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findDsPage = distributionSetManagement.findByRsql(pageable, rsqlParam);
|
findDsPage = distributionSetManagement.findByRsql(rsqlParam, pageable);
|
||||||
countModulesAll = ((Page<DistributionSet>) findDsPage).getTotalElements();
|
countModulesAll = ((Page<DistributionSet>) findDsPage).getTotalElements();
|
||||||
} else {
|
} else {
|
||||||
findDsPage = distributionSetManagement.findAll(pageable);
|
findDsPage = distributionSetManagement.findAll(pageable);
|
||||||
@@ -150,7 +150,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
|
|
||||||
//check if there is already deleted DS Type
|
//check if there is already deleted DS Type
|
||||||
for (MgmtDistributionSetRequestBodyPost ds : sets) {
|
for (MgmtDistributionSetRequestBodyPost ds : sets) {
|
||||||
final Optional<DistributionSetType> opt = distributionSetTypeManagement.getByKey(ds.getType());
|
final Optional<DistributionSetType> opt = distributionSetTypeManagement.findByKey(ds.getType());
|
||||||
opt.ifPresent(dsType -> {
|
opt.ifPresent(dsType -> {
|
||||||
if (dsType.isDeleted()) {
|
if (dsType.isDeleted()) {
|
||||||
final String text = "Cannot create Distribution Set from type with key {0}. Distribution Set Type already deleted!";
|
final String text = "Cannot create Distribution Set from type with key {0}. Distribution Set Type already deleted!";
|
||||||
@@ -288,10 +288,10 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
final Page<DistributionSetMetadata> metaDataPage;
|
final Page<DistributionSetMetadata> metaDataPage;
|
||||||
|
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
metaDataPage = distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(pageable, distributionSetId,
|
metaDataPage = distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(distributionSetId, rsqlParam, pageable
|
||||||
rsqlParam);
|
);
|
||||||
} else {
|
} else {
|
||||||
metaDataPage = distributionSetManagement.findMetaDataByDistributionSetId(pageable, distributionSetId);
|
metaDataPage = distributionSetManagement.findMetaDataByDistributionSetId(distributionSetId, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
@@ -302,7 +302,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
public ResponseEntity<MgmtMetadata> getMetadataValue(final Long distributionSetId, final String metadataKey) {
|
public ResponseEntity<MgmtMetadata> getMetadataValue(final Long distributionSetId, final String metadataKey) {
|
||||||
// check if distribution set exists otherwise throw exception immediately
|
// check if distribution set exists otherwise throw exception immediately
|
||||||
final DistributionSetMetadata findOne = distributionSetManagement
|
final DistributionSetMetadata findOne = distributionSetManagement
|
||||||
.getMetaDataByDistributionSetId(distributionSetId, metadataKey)
|
.findMetaDataByDistributionSetId(distributionSetId, metadataKey)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId, metadataKey));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId, metadataKey));
|
||||||
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(findOne));
|
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(findOne));
|
||||||
}
|
}
|
||||||
@@ -326,7 +326,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
@Override
|
@Override
|
||||||
public ResponseEntity<List<MgmtMetadata>> createMetadata(final Long distributionSetId, final List<MgmtMetadata> metadataRest) {
|
public ResponseEntity<List<MgmtMetadata>> createMetadata(final Long distributionSetId, final List<MgmtMetadata> metadataRest) {
|
||||||
// check if distribution set exists otherwise throw exception immediately
|
// check if distribution set exists otherwise throw exception immediately
|
||||||
final List<DistributionSetMetadata> created = distributionSetManagement.createMetaData(distributionSetId,
|
final List<DistributionSetMetadata> created = distributionSetManagement.putMetaData(distributionSetId,
|
||||||
MgmtDistributionSetMapper.fromRequestDsMetadata(metadataRest, entityFactory));
|
MgmtDistributionSetMapper.fromRequestDsMetadata(metadataRest, entityFactory));
|
||||||
return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDsMetadata(created), HttpStatus.CREATED);
|
return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDsMetadata(created), HttpStatus.CREATED);
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
|
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
|
||||||
final Sort sorting = PagingUtility.sanitizeSoftwareModuleSortParam(sortParam);
|
final Sort sorting = PagingUtility.sanitizeSoftwareModuleSortParam(sortParam);
|
||||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||||
final Page<SoftwareModule> softwaremodules = softwareModuleManagement.findByAssignedTo(pageable, distributionSetId);
|
final Page<SoftwareModule> softwaremodules = softwareModuleManagement.findByAssignedTo(distributionSetId, pageable);
|
||||||
return ResponseEntity.ok(new PagedList<>(MgmtSoftwareModuleMapper.toResponse(
|
return ResponseEntity.ok(new PagedList<>(MgmtSoftwareModuleMapper.toResponse(
|
||||||
softwaremodules.getContent()), softwaremodules.getTotalElements()));
|
softwaremodules.getContent()), softwaremodules.getTotalElements()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
|||||||
distributionSetTags = distributionSetTagManagement.findAll(pageable);
|
distributionSetTags = distributionSetTagManagement.findAll(pageable);
|
||||||
count = distributionSetTagManagement.count();
|
count = distributionSetTagManagement.count();
|
||||||
} else {
|
} else {
|
||||||
final Page<DistributionSetTag> page = distributionSetTagManagement.findByRsql(pageable, rsqlParam);
|
final Page<DistributionSetTag> page = distributionSetTagManagement.findByRsql(rsqlParam, pageable);
|
||||||
distributionSetTags = page;
|
distributionSetTags = page;
|
||||||
count = page.getTotalElements();
|
count = page.getTotalElements();
|
||||||
}
|
}
|
||||||
@@ -137,9 +137,9 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
|||||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||||
Page<DistributionSet> findDistrAll;
|
Page<DistributionSet> findDistrAll;
|
||||||
if (rsqlParam == null) {
|
if (rsqlParam == null) {
|
||||||
findDistrAll = distributionSetManagement.findByTag(pageable, distributionsetTagId);
|
findDistrAll = distributionSetManagement.findByTag(distributionsetTagId, pageable);
|
||||||
} else {
|
} else {
|
||||||
findDistrAll = distributionSetManagement.findByRsqlAndTag(pageable, rsqlParam, distributionsetTagId);
|
findDistrAll = distributionSetManagement.findByRsqlAndTag(rsqlParam, distributionsetTagId, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<MgmtDistributionSet> rest = MgmtDistributionSetMapper.toResponseFromDsList(findDistrAll.getContent());
|
final List<MgmtDistributionSet> rest = MgmtDistributionSetMapper.toResponseFromDsList(findDistrAll.getContent());
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
|
|||||||
final Slice<DistributionSetType> findModuleTypessAll;
|
final Slice<DistributionSetType> findModuleTypessAll;
|
||||||
long countModulesAll;
|
long countModulesAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findModuleTypessAll = distributionSetTypeManagement.findByRsql(pageable, rsqlParam);
|
findModuleTypessAll = distributionSetTypeManagement.findByRsql(rsqlParam, pageable);
|
||||||
countModulesAll = ((Page<DistributionSetType>) findModuleTypessAll).getTotalElements();
|
countModulesAll = ((Page<DistributionSetType>) findModuleTypessAll).getTotalElements();
|
||||||
} else {
|
} else {
|
||||||
findModuleTypessAll = distributionSetTypeManagement.findAll(pageable);
|
findModuleTypessAll = distributionSetTypeManagement.findAll(pageable);
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
final Slice<SoftwareModule> findModulesAll;
|
final Slice<SoftwareModule> findModulesAll;
|
||||||
final long countModulesAll;
|
final long countModulesAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findModulesAll = softwareModuleManagement.findByRsql(pageable, rsqlParam);
|
findModulesAll = softwareModuleManagement.findByRsql(rsqlParam, pageable);
|
||||||
countModulesAll = ((Page<SoftwareModule>) findModulesAll).getTotalElements();
|
countModulesAll = ((Page<SoftwareModule>) findModulesAll).getTotalElements();
|
||||||
} else {
|
} else {
|
||||||
findModulesAll = softwareModuleManagement.findAll(pageable);
|
findModulesAll = softwareModuleManagement.findAll(pageable);
|
||||||
@@ -191,7 +191,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
log.debug("creating {} softwareModules", softwareModules.size());
|
log.debug("creating {} softwareModules", softwareModules.size());
|
||||||
|
|
||||||
for (final MgmtSoftwareModuleRequestBodyPost sm : softwareModules) {
|
for (final MgmtSoftwareModuleRequestBodyPost sm : softwareModules) {
|
||||||
final Optional<SoftwareModuleType> opt = softwareModuleTypeManagement.getByKey(sm.getType());
|
final Optional<SoftwareModuleType> opt = softwareModuleTypeManagement.findByKey(sm.getType());
|
||||||
opt.ifPresent(smType -> {
|
opt.ifPresent(smType -> {
|
||||||
if (smType.isDeleted()) {
|
if (smType.isDeleted()) {
|
||||||
final String text = "Cannot create Software Module from type with key {0}. Software Module Type already deleted!";
|
final String text = "Cannot create Software Module from type with key {0}. Software Module Type already deleted!";
|
||||||
@@ -245,7 +245,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
final Page<SoftwareModuleMetadata> metaDataPage;
|
final Page<SoftwareModuleMetadata> metaDataPage;
|
||||||
|
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
metaDataPage = softwareModuleManagement.findMetaDataByRsql(pageable, softwareModuleId, rsqlParam);
|
metaDataPage = softwareModuleManagement.findMetaDataByRsql(softwareModuleId, rsqlParam, pageable);
|
||||||
} else {
|
} else {
|
||||||
metaDataPage = softwareModuleManagement.findMetaDataBySoftwareModuleId(pageable, softwareModuleId);
|
metaDataPage = softwareModuleManagement.findMetaDataBySoftwareModuleId(pageable, softwareModuleId);
|
||||||
}
|
}
|
||||||
@@ -257,7 +257,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
@Override
|
@Override
|
||||||
public ResponseEntity<MgmtSoftwareModuleMetadata> getMetadataValue(final Long softwareModuleId, final String metadataKey) {
|
public ResponseEntity<MgmtSoftwareModuleMetadata> getMetadataValue(final Long softwareModuleId, final String metadataKey) {
|
||||||
final SoftwareModuleMetadata findOne = softwareModuleManagement
|
final SoftwareModuleMetadata findOne = softwareModuleManagement
|
||||||
.getMetaDataBySoftwareModuleId(softwareModuleId, metadataKey).orElseThrow(
|
.findMetaDataBySoftwareModuleId(softwareModuleId, metadataKey).orElseThrow(
|
||||||
() -> new EntityNotFoundException(SoftwareModuleMetadata.class, softwareModuleId, metadataKey));
|
() -> new EntityNotFoundException(SoftwareModuleMetadata.class, softwareModuleId, metadataKey));
|
||||||
|
|
||||||
return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(findOne));
|
return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(findOne));
|
||||||
@@ -282,7 +282,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
@Override
|
@Override
|
||||||
public ResponseEntity<List<MgmtSoftwareModuleMetadata>> createMetadata(
|
public ResponseEntity<List<MgmtSoftwareModuleMetadata>> createMetadata(
|
||||||
final Long softwareModuleId, final List<MgmtSoftwareModuleMetadata> metadataRest) {
|
final Long softwareModuleId, final List<MgmtSoftwareModuleMetadata> metadataRest) {
|
||||||
final List<SoftwareModuleMetadata> created = softwareModuleManagement.createMetaData(
|
final List<SoftwareModuleMetadata> created = softwareModuleManagement.putMetaData(
|
||||||
MgmtSoftwareModuleMapper.fromRequestSwMetadata(entityFactory, softwareModuleId, metadataRest));
|
MgmtSoftwareModuleMapper.fromRequestSwMetadata(entityFactory, softwareModuleId, metadataRest));
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(MgmtSoftwareModuleMapper.toResponseSwMetadata(created));
|
return ResponseEntity.status(HttpStatus.CREATED).body(MgmtSoftwareModuleMapper.toResponseSwMetadata(created));
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
|
|||||||
final Slice<SoftwareModuleType> findModuleTypessAll;
|
final Slice<SoftwareModuleType> findModuleTypessAll;
|
||||||
final long countModulesAll;
|
final long countModulesAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findModuleTypessAll = softwareModuleTypeManagement.findByRsql(pageable, rsqlParam);
|
findModuleTypessAll = softwareModuleTypeManagement.findByRsql(rsqlParam, pageable);
|
||||||
countModulesAll = ((Page<SoftwareModuleType>) findModuleTypessAll).getTotalElements();
|
countModulesAll = ((Page<SoftwareModuleType>) findModuleTypessAll).getTotalElements();
|
||||||
} else {
|
} else {
|
||||||
findModuleTypessAll = softwareModuleTypeManagement.findAll(pageable);
|
findModuleTypessAll = softwareModuleTypeManagement.findAll(pageable);
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
distributionSetTypeManagement.delete(type.getId());
|
distributionSetTypeManagement.delete(type.getId());
|
||||||
|
|
||||||
// check if the ds type is marked as deleted
|
// check if the ds type is marked as deleted
|
||||||
final Optional<DistributionSetType> opt = distributionSetTypeManagement.getByKey(type.getKey());
|
final Optional<DistributionSetType> opt = distributionSetTypeManagement.findByKey(type.getKey());
|
||||||
if (opt.isEmpty()) {
|
if (opt.isEmpty()) {
|
||||||
throw new AssertionError("The Optional object of distribution set type should not be empty!");
|
throw new AssertionError("The Optional object of distribution set type should not be empty!");
|
||||||
}
|
}
|
||||||
@@ -883,13 +883,13 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
final MvcResult mvcResult = executeMgmtTargetPost(one, two, three);
|
final MvcResult mvcResult = executeMgmtTargetPost(one, two, three);
|
||||||
|
|
||||||
one = distributionSetManagement
|
one = distributionSetManagement
|
||||||
.getWithDetails(distributionSetManagement.findByRsql(PAGE, "name==one").getContent().get(0).getId())
|
.getWithDetails(distributionSetManagement.findByRsql("name==one", PAGE).getContent().get(0).getId())
|
||||||
.get();
|
.get();
|
||||||
two = distributionSetManagement
|
two = distributionSetManagement
|
||||||
.getWithDetails(distributionSetManagement.findByRsql(PAGE, "name==two").getContent().get(0).getId())
|
.getWithDetails(distributionSetManagement.findByRsql("name==two", PAGE).getContent().get(0).getId())
|
||||||
.get();
|
.get();
|
||||||
three = distributionSetManagement
|
three = distributionSetManagement
|
||||||
.getWithDetails(distributionSetManagement.findByRsql(PAGE, "name==three").getContent().get(0).getId())
|
.getWithDetails(distributionSetManagement.findByRsql("name==three", PAGE).getContent().get(0).getId())
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
@@ -1122,9 +1122,9 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
|
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
|
||||||
|
|
||||||
final DistributionSetMetadata metaKey1 = distributionSetManagement
|
final DistributionSetMetadata metaKey1 = distributionSetManagement
|
||||||
.getMetaDataByDistributionSetId(testDS.getId(), knownKey1).get();
|
.findMetaDataByDistributionSetId(testDS.getId(), knownKey1).get();
|
||||||
final DistributionSetMetadata metaKey2 = distributionSetManagement
|
final DistributionSetMetadata metaKey2 = distributionSetManagement
|
||||||
.getMetaDataByDistributionSetId(testDS.getId(), knownKey2).get();
|
.findMetaDataByDistributionSetId(testDS.getId(), knownKey2).get();
|
||||||
|
|
||||||
assertThat(metaKey1.getValue()).isEqualTo(knownValue1);
|
assertThat(metaKey1.getValue()).isEqualTo(knownValue1);
|
||||||
assertThat(metaKey2.getValue()).isEqualTo(knownValue2);
|
assertThat(metaKey2.getValue()).isEqualTo(knownValue2);
|
||||||
@@ -1145,7 +1145,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
// verify that the number of meta data entries has not changed
|
// verify that the number of meta data entries has not changed
|
||||||
// (we cannot use the PAGE constant here as it tries to sort by ID)
|
// (we cannot use the PAGE constant here as it tries to sort by ID)
|
||||||
assertThat(distributionSetManagement
|
assertThat(distributionSetManagement
|
||||||
.findMetaDataByDistributionSetId(PageRequest.of(0, Integer.MAX_VALUE), testDS.getId())
|
.findMetaDataByDistributionSetId(testDS.getId(), PageRequest.of(0, Integer.MAX_VALUE))
|
||||||
.getTotalElements()).isEqualTo(metaData1.length());
|
.getTotalElements()).isEqualTo(metaData1.length());
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1173,7 +1173,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
.andExpect(jsonPath("value", equalTo(updateValue)));
|
.andExpect(jsonPath("value", equalTo(updateValue)));
|
||||||
|
|
||||||
final DistributionSetMetadata assertDS = distributionSetManagement
|
final DistributionSetMetadata assertDS = distributionSetManagement
|
||||||
.getMetaDataByDistributionSetId(testDS.getId(), knownKey).get();
|
.findMetaDataByDistributionSetId(testDS.getId(), knownKey).get();
|
||||||
assertThat(assertDS.getValue()).isEqualTo(updateValue);
|
assertThat(assertDS.getValue()).isEqualTo(updateValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1192,7 +1192,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
.andDo(MockMvcResultPrinter.print())
|
.andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(distributionSetManagement.getMetaDataByDistributionSetId(testDS.getId(), knownKey)).isNotPresent();
|
assertThat(distributionSetManagement.findMetaDataByDistributionSetId(testDS.getId(), knownKey)).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1213,7 +1213,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
.andDo(MockMvcResultPrinter.print())
|
.andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isNotFound());
|
.andExpect(status().isNotFound());
|
||||||
|
|
||||||
assertThat(distributionSetManagement.getMetaDataByDistributionSetId(testDS.getId(), knownKey)).isPresent();
|
assertThat(distributionSetManagement.findMetaDataByDistributionSetId(testDS.getId(), knownKey)).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1240,7 +1240,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
final String knownValuePrefix = "knownValue";
|
final String knownValuePrefix = "knownValue";
|
||||||
final DistributionSet testDS = testdataFactory.createDistributionSet("one");
|
final DistributionSet testDS = testdataFactory.createDistributionSet("one");
|
||||||
for (int index = 0; index < totalMetadata; index++) {
|
for (int index = 0; index < totalMetadata; index++) {
|
||||||
distributionSetManagement.createMetaData(testDS.getId(),
|
distributionSetManagement.putMetaData(testDS.getId(),
|
||||||
List.of(entityFactory.generateDsMetadata(knownKeyPrefix + index, knownValuePrefix + index)));
|
List.of(entityFactory.generateDsMetadata(knownKeyPrefix + index, knownValuePrefix + index)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -194,11 +194,11 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
.andExpect(status().isCreated())
|
.andExpect(status().isCreated())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE));
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE));
|
||||||
|
|
||||||
final Tag createdOne = distributionSetTagManagement.findByRsql(PAGE, "name==thetest1").getContent().get(0);
|
final Tag createdOne = distributionSetTagManagement.findByRsql("name==thetest1", PAGE).getContent().get(0);
|
||||||
assertThat(createdOne.getName()).isEqualTo(tagOne.getName());
|
assertThat(createdOne.getName()).isEqualTo(tagOne.getName());
|
||||||
assertThat(createdOne.getDescription()).isEqualTo(tagOne.getDescription());
|
assertThat(createdOne.getDescription()).isEqualTo(tagOne.getDescription());
|
||||||
assertThat(createdOne.getColour()).isEqualTo(tagOne.getColour());
|
assertThat(createdOne.getColour()).isEqualTo(tagOne.getColour());
|
||||||
final Tag createdTwo = distributionSetTagManagement.findByRsql(PAGE, "name==thetest2").getContent().get(0);
|
final Tag createdTwo = distributionSetTagManagement.findByRsql("name==thetest2", PAGE).getContent().get(0);
|
||||||
assertThat(createdTwo.getName()).isEqualTo(tagTwo.getName());
|
assertThat(createdTwo.getName()).isEqualTo(tagTwo.getName());
|
||||||
assertThat(createdTwo.getDescription()).isEqualTo(tagTwo.getDescription());
|
assertThat(createdTwo.getDescription()).isEqualTo(tagTwo.getDescription());
|
||||||
assertThat(createdTwo.getColour()).isEqualTo(tagTwo.getColour());
|
assertThat(createdTwo.getColour()).isEqualTo(tagTwo.getColour());
|
||||||
@@ -227,7 +227,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE));
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE));
|
||||||
|
|
||||||
final Tag updated = distributionSetTagManagement.findByRsql(PAGE, "name==updatedName").getContent().get(0);
|
final Tag updated = distributionSetTagManagement.findByRsql("name==updatedName", PAGE).getContent().get(0);
|
||||||
assertThat(updated.getName()).isEqualTo(update.getName());
|
assertThat(updated.getName()).isEqualTo(update.getName());
|
||||||
assertThat(updated.getDescription()).isEqualTo(update.getDescription());
|
assertThat(updated.getDescription()).isEqualTo(update.getDescription());
|
||||||
assertThat(updated.getColour()).isEqualTo(update.getColour());
|
assertThat(updated.getColour()).isEqualTo(update.getColour());
|
||||||
@@ -333,7 +333,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
// 2 DistributionSetUpdateEvent
|
// 2 DistributionSetUpdateEvent
|
||||||
ResultActions result = toggle(tag, sets);
|
ResultActions result = toggle(tag, sets);
|
||||||
|
|
||||||
List<DistributionSet> updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent();
|
List<DistributionSet> updated = distributionSetManagement.findByTag(tag.getId(), PAGE).getContent();
|
||||||
|
|
||||||
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
|
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
|
||||||
.containsAll(sets.stream().map(DistributionSet::getId).collect(Collectors.toList()));
|
.containsAll(sets.stream().map(DistributionSet::getId).collect(Collectors.toList()));
|
||||||
@@ -349,7 +349,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
result.andExpect(applyBaseEntityMatcherOnArrayResult(updated.get(0), "unassignedDistributionSets"))
|
result.andExpect(applyBaseEntityMatcherOnArrayResult(updated.get(0), "unassignedDistributionSets"))
|
||||||
.andExpect(applyBaseEntityMatcherOnArrayResult(updated.get(1), "unassignedDistributionSets"));
|
.andExpect(applyBaseEntityMatcherOnArrayResult(updated.get(1), "unassignedDistributionSets"));
|
||||||
|
|
||||||
assertThat(distributionSetManagement.findByTag(PAGE, tag.getId())).isEmpty();
|
assertThat(distributionSetManagement.findByTag(tag.getId(), PAGE)).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -367,7 +367,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
.andDo(MockMvcResultPrinter.print())
|
.andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
final List<DistributionSet> updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent();
|
final List<DistributionSet> updated = distributionSetManagement.findByTag(tag.getId(), PAGE).getContent();
|
||||||
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
|
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
|
||||||
.containsOnly(set.getId());
|
.containsOnly(set.getId());
|
||||||
}
|
}
|
||||||
@@ -389,7 +389,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
.andDo(MockMvcResultPrinter.print())
|
.andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
final List<DistributionSet> updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent();
|
final List<DistributionSet> updated = distributionSetManagement.findByTag(tag.getId(), PAGE).getContent();
|
||||||
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
|
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
|
||||||
.containsAll(sets.stream().map(DistributionSet::getId).collect(Collectors.toList()));
|
.containsAll(sets.stream().map(DistributionSet::getId).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
@@ -414,7 +414,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
.andDo(MockMvcResultPrinter.print())
|
.andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
final List<DistributionSet> updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent();
|
final List<DistributionSet> updated = distributionSetManagement.findByTag(tag.getId(), PAGE).getContent();
|
||||||
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
|
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
|
||||||
.containsOnly(assigned.getId());
|
.containsOnly(assigned.getId());
|
||||||
}
|
}
|
||||||
@@ -440,7 +440,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
.andDo(MockMvcResultPrinter.print())
|
.andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
final List<DistributionSet> updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent();
|
final List<DistributionSet> updated = distributionSetManagement.findByTag(tag.getId(), PAGE).getContent();
|
||||||
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
|
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
|
||||||
.containsOnly(assigned.getId());
|
.containsOnly(assigned.getId());
|
||||||
}
|
}
|
||||||
@@ -505,7 +505,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE));
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE));
|
||||||
|
|
||||||
final List<DistributionSet> updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent();
|
final List<DistributionSet> updated = distributionSetManagement.findByTag(tag.getId(), PAGE).getContent();
|
||||||
|
|
||||||
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
|
assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList()))
|
||||||
.containsAll(sets.stream().map(DistributionSet::getId).collect(Collectors.toList()));
|
.containsAll(sets.stream().map(DistributionSet::getId).collect(Collectors.toList()));
|
||||||
|
|||||||
@@ -675,9 +675,9 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
|
|||||||
|
|
||||||
@Step
|
@Step
|
||||||
private void verifyCreatedDistributionSetTypes(final MvcResult mvcResult) throws UnsupportedEncodingException {
|
private void verifyCreatedDistributionSetTypes(final MvcResult mvcResult) throws UnsupportedEncodingException {
|
||||||
final DistributionSetType created1 = distributionSetTypeManagement.getByKey("testKey1").get();
|
final DistributionSetType created1 = distributionSetTypeManagement.findByKey("testKey1").get();
|
||||||
final DistributionSetType created2 = distributionSetTypeManagement.getByKey("testKey2").get();
|
final DistributionSetType created2 = distributionSetTypeManagement.findByKey("testKey2").get();
|
||||||
final DistributionSetType created3 = distributionSetTypeManagement.getByKey("testKey3").get();
|
final DistributionSetType created3 = distributionSetTypeManagement.findByKey("testKey3").get();
|
||||||
|
|
||||||
assertThat(created1.getMandatoryModuleTypes()).containsOnly(osType);
|
assertThat(created1.getMandatoryModuleTypes()).containsOnly(osType);
|
||||||
assertThat(created1.getOptionalModuleTypes()).containsOnly(runtimeType);
|
assertThat(created1.getOptionalModuleTypes()).containsOnly(runtimeType);
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
softwareModuleTypeManagement.delete(sm.getType().getId());
|
softwareModuleTypeManagement.delete(sm.getType().getId());
|
||||||
|
|
||||||
//check if it is marked as deleted
|
//check if it is marked as deleted
|
||||||
final Optional<SoftwareModuleType> opt = softwareModuleTypeManagement.getByKey(SM_TYPE);
|
final Optional<SoftwareModuleType> opt = softwareModuleTypeManagement.findByKey(SM_TYPE);
|
||||||
if (opt.isEmpty()) {
|
if (opt.isEmpty()) {
|
||||||
throw new AssertionError("The Optional object of software module type should not be empty!");
|
throw new AssertionError("The Optional object of software module type should not be empty!");
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get();
|
final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get();
|
||||||
|
|
||||||
for (int index = 0; index < totalMetadata; index++) {
|
for (int index = 0; index < totalMetadata; index++) {
|
||||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(module.getId())
|
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(module.getId())
|
||||||
.key(knownKeyPrefix + index).value(knownValuePrefix + index));
|
.key(knownKeyPrefix + index).value(knownValuePrefix + index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get();
|
final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get();
|
||||||
|
|
||||||
for (int index = 0; index < totalMetadata; index++) {
|
for (int index = 0; index < totalMetadata; index++) {
|
||||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(module.getId())
|
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(module.getId())
|
||||||
.key(knownKeyPrefix + index).value(knownValuePrefix + index));
|
.key(knownKeyPrefix + index).value(knownValuePrefix + index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
final String knownKey = "knownKey";
|
final String knownKey = "knownKey";
|
||||||
final String knownValue = "knownValue";
|
final String knownValue = "knownValue";
|
||||||
final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get();
|
final SoftwareModule module = testdataFactory.createDistributionSet("one").findFirstModuleByType(osType).get();
|
||||||
softwareModuleManagement.createMetaData(
|
softwareModuleManagement.updateMetaData(
|
||||||
entityFactory.softwareModuleMetadata().create(module.getId()).key(knownKey).value(knownValue));
|
entityFactory.softwareModuleMetadata().create(module.getId()).key(knownKey).value(knownValue));
|
||||||
|
|
||||||
mvc.perform(
|
mvc.perform(
|
||||||
@@ -1265,9 +1265,9 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
.andExpect(jsonPath("[1].createdAt", not(equalTo(0))))
|
.andExpect(jsonPath("[1].createdAt", not(equalTo(0))))
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
final SoftwareModule osCreated = softwareModuleManagement.getByNameAndVersionAndType("name1", "version1",
|
final SoftwareModule osCreated = softwareModuleManagement.findByNameAndVersionAndType("name1", "version1",
|
||||||
osType.getId()).get();
|
osType.getId()).get();
|
||||||
final SoftwareModule appCreated = softwareModuleManagement.getByNameAndVersionAndType("name3", "version3",
|
final SoftwareModule appCreated = softwareModuleManagement.findByNameAndVersionAndType("name3", "version3",
|
||||||
appType.getId()).get();
|
appType.getId()).get();
|
||||||
|
|
||||||
assertThat(JsonPath.compile("[0]._links.self.href")
|
assertThat(JsonPath.compile("[0]._links.self.href")
|
||||||
@@ -1281,13 +1281,13 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
.isEqualTo("http://localhost/rest/v1/softwaremodules/" + appCreated.getId());
|
.isEqualTo("http://localhost/rest/v1/softwaremodules/" + appCreated.getId());
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findAll(PAGE)).as("Wrong softwaremodule size").hasSize(2);
|
assertThat(softwareModuleManagement.findAll(PAGE)).as("Wrong softwaremodule size").hasSize(2);
|
||||||
assertThat(softwareModuleManagement.findByType(PAGE, osType.getId()).getContent().get(0).getName()).as(
|
assertThat(softwareModuleManagement.findByType(osType.getId(), PAGE).getContent().get(0).getName()).as(
|
||||||
"Softwaremoudle name is wrong").isEqualTo(os.getName());
|
"Softwaremoudle name is wrong").isEqualTo(os.getName());
|
||||||
assertThat(softwareModuleManagement.findByType(PAGE, osType.getId()).getContent().get(0).getCreatedBy()).as(
|
assertThat(softwareModuleManagement.findByType(osType.getId(), PAGE).getContent().get(0).getCreatedBy()).as(
|
||||||
"Softwaremoudle created by is wrong").isEqualTo("uploadTester");
|
"Softwaremoudle created by is wrong").isEqualTo("uploadTester");
|
||||||
assertThat(softwareModuleManagement.findByType(PAGE, osType.getId()).getContent().get(0).getCreatedAt()).as(
|
assertThat(softwareModuleManagement.findByType(osType.getId(), PAGE).getContent().get(0).getCreatedAt()).as(
|
||||||
"Softwaremoudle created at is wrong").isGreaterThanOrEqualTo(current);
|
"Softwaremoudle created at is wrong").isGreaterThanOrEqualTo(current);
|
||||||
assertThat(softwareModuleManagement.findByType(PAGE, appType.getId()).getContent().get(0).getName()).as(
|
assertThat(softwareModuleManagement.findByType(appType.getId(), PAGE).getContent().get(0).getName()).as(
|
||||||
"Softwaremoudle name is wrong").isEqualTo(ah.getName());
|
"Softwaremoudle name is wrong").isEqualTo(ah.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1376,9 +1376,9 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
.andExpect(jsonPath("[1].value", equalTo(knownValue2)))
|
.andExpect(jsonPath("[1].value", equalTo(knownValue2)))
|
||||||
.andExpect(jsonPath("[1].targetVisible", equalTo(true)));
|
.andExpect(jsonPath("[1].targetVisible", equalTo(true)));
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(sm.getId(), knownKey1))
|
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(sm.getId(), knownKey1))
|
||||||
.as("Metadata key is wrong").get().extracting(SoftwareModuleMetadata::getValue).isEqualTo(knownValue1);
|
.as("Metadata key is wrong").get().extracting(SoftwareModuleMetadata::getValue).isEqualTo(knownValue1);
|
||||||
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(sm.getId(), knownKey2))
|
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(sm.getId(), knownKey2))
|
||||||
.as("Metadata key is wrong").get().extracting(SoftwareModuleMetadata::getValue).isEqualTo(knownValue2);
|
.as("Metadata key is wrong").get().extracting(SoftwareModuleMetadata::getValue).isEqualTo(knownValue2);
|
||||||
|
|
||||||
// verify quota enforcement
|
// verify quota enforcement
|
||||||
@@ -1411,7 +1411,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
final String updateValue = "valueForUpdate";
|
final String updateValue = "valueForUpdate";
|
||||||
|
|
||||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||||
softwareModuleManagement.createMetaData(
|
softwareModuleManagement.updateMetaData(
|
||||||
entityFactory.softwareModuleMetadata().create(sm.getId()).key(knownKey).value(knownValue));
|
entityFactory.softwareModuleMetadata().create(sm.getId()).key(knownKey).value(knownValue));
|
||||||
|
|
||||||
final JSONObject jsonObject = new JSONObject().put("key", knownKey)
|
final JSONObject jsonObject = new JSONObject().put("key", knownKey)
|
||||||
@@ -1426,7 +1426,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
.andExpect(jsonPath("key", equalTo(knownKey)))
|
.andExpect(jsonPath("key", equalTo(knownKey)))
|
||||||
.andExpect(jsonPath("value", equalTo(updateValue)));
|
.andExpect(jsonPath("value", equalTo(updateValue)));
|
||||||
|
|
||||||
final SoftwareModuleMetadata assertDS = softwareModuleManagement.getMetaDataBySoftwareModuleId(sm.getId(),
|
final SoftwareModuleMetadata assertDS = softwareModuleManagement.findMetaDataBySoftwareModuleId(sm.getId(),
|
||||||
knownKey).get();
|
knownKey).get();
|
||||||
assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue);
|
assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue);
|
||||||
assertThat(assertDS.isTargetVisible()).as("target visible is wrong").isTrue();
|
assertThat(assertDS.isTargetVisible()).as("target visible is wrong").isTrue();
|
||||||
@@ -1440,14 +1440,14 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
final String knownValue = "knownValue";
|
final String knownValue = "knownValue";
|
||||||
|
|
||||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||||
softwareModuleManagement.createMetaData(
|
softwareModuleManagement.updateMetaData(
|
||||||
entityFactory.softwareModuleMetadata().create(sm.getId()).key(knownKey).value(knownValue));
|
entityFactory.softwareModuleMetadata().create(sm.getId()).key(knownKey).value(knownValue));
|
||||||
|
|
||||||
mvc.perform(delete("/rest/v1/softwaremodules/{swId}/metadata/{key}", sm.getId(), knownKey))
|
mvc.perform(delete("/rest/v1/softwaremodules/{swId}/metadata/{key}", sm.getId(), knownKey))
|
||||||
.andDo(MockMvcResultPrinter.print())
|
.andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(sm.getId(), knownKey)).isNotPresent();
|
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(sm.getId(), knownKey)).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1458,7 +1458,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
final String knownValue = "knownValue";
|
final String knownValue = "knownValue";
|
||||||
|
|
||||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||||
softwareModuleManagement.createMetaData(
|
softwareModuleManagement.updateMetaData(
|
||||||
entityFactory.softwareModuleMetadata().create(sm.getId()).key(knownKey).value(knownValue));
|
entityFactory.softwareModuleMetadata().create(sm.getId()).key(knownKey).value(knownValue));
|
||||||
|
|
||||||
mvc.perform(delete("/rest/v1/softwaremodules/{swId}/metadata/XXX", sm.getId(), knownKey))
|
mvc.perform(delete("/rest/v1/softwaremodules/{swId}/metadata/XXX", sm.getId(), knownKey))
|
||||||
@@ -1469,7 +1469,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
.andDo(MockMvcResultPrinter.print())
|
.andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isNotFound());
|
.andExpect(status().isNotFound());
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(sm.getId(), knownKey)).isPresent();
|
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(sm.getId(), knownKey)).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1489,7 +1489,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||||
|
|
||||||
for (int index = 0; index < totalMetadata; index++) {
|
for (int index = 0; index < totalMetadata; index++) {
|
||||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata()
|
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata()
|
||||||
.create(sm.getId())
|
.create(sm.getId())
|
||||||
.key(knownKeyPrefix + index)
|
.key(knownKeyPrefix + index)
|
||||||
.value(knownValuePrefix + index));
|
.value(knownValuePrefix + index));
|
||||||
|
|||||||
@@ -210,9 +210,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
|||||||
.andExpect(jsonPath("[2].maxAssignments", equalTo(3)))
|
.andExpect(jsonPath("[2].maxAssignments", equalTo(3)))
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
|
||||||
final SoftwareModuleType created1 = softwareModuleTypeManagement.getByKey("test1").get();
|
final SoftwareModuleType created1 = softwareModuleTypeManagement.findByKey("test1").get();
|
||||||
final SoftwareModuleType created2 = softwareModuleTypeManagement.getByKey("test2").get();
|
final SoftwareModuleType created2 = softwareModuleTypeManagement.findByKey("test2").get();
|
||||||
final SoftwareModuleType created3 = softwareModuleTypeManagement.getByKey("test3").get();
|
final SoftwareModuleType created3 = softwareModuleTypeManagement.findByKey("test3").get();
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
|
|||||||
void deletingDsTypeRemovesAssignmentFromTargetType() throws Exception {
|
void deletingDsTypeRemovesAssignmentFromTargetType() throws Exception {
|
||||||
TargetType testType = createTestTargetTypeInDB("TestTypeRemoveDs", Collections.singletonList(standardDsType));
|
TargetType testType = createTestTargetTypeInDB("TestTypeRemoveDs", Collections.singletonList(standardDsType));
|
||||||
assertThat(testType.getCompatibleDistributionSetTypes()).hasSize(1);
|
assertThat(testType.getCompatibleDistributionSetTypes()).hasSize(1);
|
||||||
assertThat(distributionSetTypeManagement.getByKey(standardDsType.getKey())).isNotEmpty();
|
assertThat(distributionSetTypeManagement.findByKey(standardDsType.getKey())).isNotEmpty();
|
||||||
|
|
||||||
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/" + standardDsType.getId()))
|
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/" + standardDsType.getId()))
|
||||||
.andDo(MockMvcResultPrinter.print())
|
.andDo(MockMvcResultPrinter.print())
|
||||||
@@ -400,7 +400,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
|
|||||||
assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER);
|
assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER);
|
||||||
assertThat(testType.getOptLockRevision()).isEqualTo(2);
|
assertThat(testType.getOptLockRevision()).isEqualTo(2);
|
||||||
assertThat(testType.getCompatibleDistributionSetTypes()).isEmpty();
|
assertThat(testType.getCompatibleDistributionSetTypes()).isEmpty();
|
||||||
assertThat(distributionSetTypeManagement.getByKey(standardDsType.getKey())).isEmpty();
|
assertThat(distributionSetTypeManagement.findByKey(standardDsType.getKey())).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -80,8 +80,7 @@ public class MgmtSecurityConfiguration {
|
|||||||
@Qualifier("hawkbitOAuth2ResourceServerCustomizer") final Customizer<OAuth2ResourceServerConfigurer<HttpSecurity>> oauth2ResourceServerCustomizer,
|
@Qualifier("hawkbitOAuth2ResourceServerCustomizer") final Customizer<OAuth2ResourceServerConfigurer<HttpSecurity>> oauth2ResourceServerCustomizer,
|
||||||
// called just before build of the SecurityFilterChain.
|
// called just before build of the SecurityFilterChain.
|
||||||
// could be used for instance to set authentication provider
|
// could be used for instance to set authentication provider
|
||||||
// Note: implementation of the customizer shall always take in account what is the already set by the
|
// Note: implementation of the customizer shall always take in account what is the already set by the hawkBit
|
||||||
// hawkBit
|
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
@Qualifier("hawkbitHttpSecurityCustomizer") final Customizer<HttpSecurity> httpSecurityCustomizer,
|
@Qualifier("hawkbitHttpSecurityCustomizer") final Customizer<HttpSecurity> httpSecurityCustomizer,
|
||||||
final SystemManagement systemManagement,
|
final SystemManagement systemManagement,
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
|||||||
import org.eclipse.hawkbit.repository.model.MetaData;
|
import org.eclipse.hawkbit.repository.model.MetaData;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.repository.model.Statistic;
|
import org.eclipse.hawkbit.repository.model.Statistic;
|
||||||
import org.eclipse.hawkbit.repository.model.Tag;
|
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Slice;
|
import org.springframework.data.domain.Slice;
|
||||||
@@ -46,8 +44,35 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
/**
|
/**
|
||||||
* Management service for {@link DistributionSet}s.
|
* Management service for {@link DistributionSet}s.
|
||||||
*/
|
*/
|
||||||
public interface DistributionSetManagement
|
public interface DistributionSetManagement extends RepositoryManagement<DistributionSet, DistributionSetCreate, DistributionSetUpdate> {
|
||||||
extends RepositoryManagement<DistributionSet, DistributionSetCreate, DistributionSetUpdate> {
|
|
||||||
|
/**
|
||||||
|
* Find {@link DistributionSet} based on given ID including (lazy loaded) details, e.g. {@link DistributionSet#getModules()}. <br/>
|
||||||
|
* For performance reasons it is recommended to use {@link #get(long)} if the details are not required.
|
||||||
|
*
|
||||||
|
* @param id to look for.
|
||||||
|
* @return {@link DistributionSet}
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Optional<DistributionSet> getWithDetails(long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find distribution set by id and throw an exception if it is (soft) deleted.
|
||||||
|
*
|
||||||
|
* @param id id of {@link DistributionSet}
|
||||||
|
* @return the found valid {@link DistributionSet}
|
||||||
|
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
DistributionSet getOrElseThrowException(long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the specified {@link DistributionSet} as invalidated.
|
||||||
|
*
|
||||||
|
* @param distributionSet the ID of the {@link DistributionSet} to be set to invalid
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
|
void invalidate(DistributionSet distributionSet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigns {@link SoftwareModule} to existing {@link DistributionSet}.
|
* Assigns {@link SoftwareModule} to existing {@link DistributionSet}.
|
||||||
@@ -56,25 +81,34 @@ public interface DistributionSetManagement
|
|||||||
* @param moduleIds to get assigned
|
* @param moduleIds to get assigned
|
||||||
* @return the updated {@link DistributionSet}.
|
* @return the updated {@link DistributionSet}.
|
||||||
* @throws EntityNotFoundException if (at least one) given module does not exist
|
* @throws EntityNotFoundException if (at least one) given module does not exist
|
||||||
* @throws EntityReadOnlyException if use tries to change the {@link DistributionSet} s while
|
* @throws EntityReadOnlyException if tries to change the {@link DistributionSet} s while the DS is already in use.
|
||||||
* the DS is already in use.
|
|
||||||
* @throws UnsupportedSoftwareModuleForThisDistributionSetException if {@link SoftwareModule#getType()} is not supported by this
|
* @throws UnsupportedSoftwareModuleForThisDistributionSetException if {@link SoftwareModule#getType()} is not supported by this
|
||||||
* {@link DistributionSet#getType()}.
|
* {@link DistributionSet#getType()}.
|
||||||
* @throws AssignmentQuotaExceededException if the maximum number of {@link SoftwareModule}s is exceeded
|
* @throws AssignmentQuotaExceededException if the maximum number of {@link SoftwareModule}s is exceeded for the addressed
|
||||||
* for the addressed {@link DistributionSet}.
|
* {@link DistributionSet}.
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
DistributionSet assignSoftwareModules(long id, @NotEmpty Collection<Long> moduleIds);
|
DistributionSet assignSoftwareModules(long id, @NotEmpty Collection<Long> moduleIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign a {@link DistributionSetTag} assignment to given
|
* Unassigns a {@link SoftwareModule} form an existing {@link DistributionSet}.
|
||||||
* {@link DistributionSet}s.
|
*
|
||||||
|
* @param id to get unassigned form
|
||||||
|
* @param moduleId to be unassigned
|
||||||
|
* @return the updated {@link DistributionSet}.
|
||||||
|
* @throws EntityNotFoundException if given module or DS does not exist
|
||||||
|
* @throws EntityReadOnlyException if use tries to change the {@link DistributionSet} s while the DS is already in use.
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
|
DistributionSet unassignSoftwareModule(long id, long moduleId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign a {@link DistributionSetTag} assignment to given {@link DistributionSet}s.
|
||||||
*
|
*
|
||||||
* @param ids to assign for
|
* @param ids to assign for
|
||||||
* @param tagId to assign
|
* @param tagId to assign
|
||||||
* @return list of assigned ds
|
* @return list of assigned ds
|
||||||
* @throws EntityNotFoundException if tag with given ID does not exist or (at least one) of the
|
* @throws EntityNotFoundException if tag with given ID does not exist or (at least one) of the distribution sets.
|
||||||
* distribution sets.
|
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
List<DistributionSet> assignTag(@NotEmpty Collection<Long> ids, long tagId);
|
List<DistributionSet> assignTag(@NotEmpty Collection<Long> ids, long tagId);
|
||||||
@@ -91,34 +125,42 @@ public interface DistributionSetManagement
|
|||||||
List<DistributionSet> unassignTag(@NotEmpty Collection<Long> ids, long tagId);
|
List<DistributionSet> unassignTag(@NotEmpty Collection<Long> ids, long tagId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a list of distribution set meta data entries.
|
* Creates a list of distribution set meta-data entries.
|
||||||
*
|
*
|
||||||
* @param id if the {@link DistributionSet} the metadata has to be created
|
* @param id if the {@link DistributionSet} the metadata has to be created for
|
||||||
* for
|
* @param metadata the meta-data entries to create or update
|
||||||
* @param metadata the meta data entries to create or update
|
* @return the updated or created distribution set meta-data entries
|
||||||
* @return the updated or created distribution set meta data entries
|
|
||||||
* @throws EntityNotFoundException if given set does not exist
|
* @throws EntityNotFoundException if given set does not exist
|
||||||
* @throws EntityAlreadyExistsException in case one of the meta data entry already exists for the
|
* @throws EntityAlreadyExistsException in case one of the meta-data entry already exists for the specific key
|
||||||
* specific key
|
* @throws AssignmentQuotaExceededException if the maximum number of {@link MetaData} entries is exceeded for the addressed
|
||||||
* @throws AssignmentQuotaExceededException if the maximum number of {@link MetaData} entries is exceeded
|
* {@link DistributionSet}
|
||||||
* for the addressed {@link DistributionSet}
|
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
List<DistributionSetMetadata> createMetaData(long id, @NotEmpty Collection<MetaData> metadata);
|
List<DistributionSetMetadata> putMetaData(long id, @NotEmpty Collection<MetaData> metadata);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a distribution set meta data entry.
|
* Updates a distribution set meta-data value if corresponding entry exists.
|
||||||
*
|
*
|
||||||
* @param id where meta data has to be deleted
|
* @param id {@link DistributionSet} of the meta-data entry to be updated
|
||||||
* @param key of the meta data element
|
* @param metadata meta-data entry to be updated
|
||||||
|
* @return the updated meta-data entry
|
||||||
|
* @throws EntityNotFoundException in case the meta-data entry does not exist and cannot be updated
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
|
DistributionSetMetadata updateMetaData(long id, @NotNull MetaData metadata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a distribution set meta-data entry.
|
||||||
|
*
|
||||||
|
* @param id where meta-data has to be deleted
|
||||||
|
* @param key of the meta-data element
|
||||||
* @throws EntityNotFoundException if given set does not exist
|
* @throws EntityNotFoundException if given set does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
void deleteMetaData(long id, @NotEmpty String key);
|
void deleteMetaData(long id, @NotEmpty String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locks a distribution set. From then on its functional properties could not be changed and
|
* Locks a distribution set. From then on its functional properties could not be changed, and it could be assigned to targets
|
||||||
* it could be assigned to targets
|
|
||||||
*
|
*
|
||||||
* @param id the distribution set id
|
* @param id the distribution set id
|
||||||
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
||||||
@@ -128,8 +170,8 @@ public interface DistributionSetManagement
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlocks a distribution set.<br/>
|
* Unlocks a distribution set.<br/>
|
||||||
* Use it with extreme care! In general once distribution set is locked
|
* Use it with extreme care! In general once distribution set is locked it shall not be unlocked. Note that it could have been assigned /
|
||||||
* it shall not be unlocked. Note that it could have been assigned / deployed to targets.
|
* deployed to targets.
|
||||||
*
|
*
|
||||||
* @param id the distribution set id
|
* @param id the distribution set id
|
||||||
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
||||||
@@ -138,41 +180,18 @@ public interface DistributionSetManagement
|
|||||||
void unlock(final long id);
|
void unlock(final long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the distribution set for a given action.
|
* Find distribution set by id and throw an exception if it is deleted or invalidated.
|
||||||
*
|
*
|
||||||
* @param actionId the action associated with the distribution set
|
* @param id id of {@link DistributionSet}
|
||||||
* @return the distribution set which is associated with the action
|
* @return the found valid {@link DistributionSet}
|
||||||
* @throws EntityNotFoundException if action with given ID does not exist
|
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
||||||
|
* @throws InvalidDistributionSetException if distribution set with given ID is invalidated
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<DistributionSet> getByAction(long actionId);
|
DistributionSet getValid(long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find {@link DistributionSet} based on given ID including (lazy loaded)
|
* Find distribution set by id and throw an exception if it is deleted, incomplete or invalidated.
|
||||||
* details, e.g. {@link DistributionSet#getModules()}.
|
|
||||||
*
|
|
||||||
* Note: for performance reasons it is recommended to use {@link #get(Long)}
|
|
||||||
* if details are not necessary.
|
|
||||||
*
|
|
||||||
* @param id to look for.
|
|
||||||
* @return {@link DistributionSet}
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Optional<DistributionSet> getWithDetails(long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find distribution set by name and version.
|
|
||||||
*
|
|
||||||
* @param distributionName name of {@link DistributionSet}; case insensitive
|
|
||||||
* @param version version of {@link DistributionSet}
|
|
||||||
* @return the page with the found {@link DistributionSet}
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Optional<DistributionSet> getByNameAndVersion(@NotEmpty String distributionName, @NotEmpty String version);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find distribution set by id and throw an exception if it is deleted,
|
|
||||||
* incomplete or invalidated.
|
|
||||||
*
|
*
|
||||||
* @param id id of {@link DistributionSet}
|
* @param id id of {@link DistributionSet}
|
||||||
* @return the found valid {@link DistributionSet}
|
* @return the found valid {@link DistributionSet}
|
||||||
@@ -184,73 +203,57 @@ public interface DistributionSetManagement
|
|||||||
DistributionSet getValidAndComplete(long id);
|
DistributionSet getValidAndComplete(long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find distribution set by id and throw an exception if it is deleted or
|
* Retrieves the distribution set for a given action.
|
||||||
* invalidated.
|
|
||||||
*
|
*
|
||||||
* @param id id of {@link DistributionSet}
|
* @param actionId the action associated with the distribution set
|
||||||
* @return the found valid {@link DistributionSet}
|
* @return the distribution set which is associated with the action
|
||||||
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
* @throws EntityNotFoundException if action with given ID does not exist
|
||||||
* @throws InvalidDistributionSetException if distribution set with given ID is invalidated
|
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
DistributionSet getValid(long id);
|
Optional<DistributionSet> findByAction(long actionId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find distribution set by id and throw an exception if it is (soft)
|
* Find distribution set by name and version.
|
||||||
* deleted.
|
|
||||||
*
|
*
|
||||||
* @param id id of {@link DistributionSet}
|
* @param distributionName name of {@link DistributionSet}; case insensitive
|
||||||
* @return the found valid {@link DistributionSet}
|
* @param version version of {@link DistributionSet}
|
||||||
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
* @return the page with the found {@link DistributionSet}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
DistributionSet getOrElseThrowException(long id);
|
Optional<DistributionSet> findByNameAndVersion(@NotEmpty String distributionName, @NotEmpty String version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all meta data by the given distribution set id.
|
* Finds all meta-data by the given distribution set id.
|
||||||
*
|
*
|
||||||
|
* @param id the distribution set id to retrieve the meta-data from
|
||||||
* @param pageable the page request to page the result
|
* @param pageable the page request to page the result
|
||||||
* @param id the distribution set id to retrieve the meta data from
|
* @return a paged result of all meta-data entries for a given distribution
|
||||||
* @return a paged result of all meta data entries for a given distribution
|
|
||||||
* set id
|
* set id
|
||||||
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<DistributionSetMetadata> findMetaDataByDistributionSetId(@NotNull Pageable pageable, long id);
|
Page<DistributionSetMetadata> findMetaDataByDistributionSetId(long id, @NotNull Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts all meta data by the given distribution set id.
|
* Finds all meta-data by the given distribution set id.
|
||||||
*
|
*
|
||||||
* @param id the distribution set id to retrieve the meta data count from
|
* @param id the distribution set id to retrieve the meta-data from
|
||||||
* @return count of ds metadata
|
|
||||||
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
long countMetaDataByDistributionSetId(long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds all meta data by the given distribution set id.
|
|
||||||
*
|
|
||||||
* @param pageable the page request to page the result
|
|
||||||
* @param id the distribution set id to retrieve the meta data from
|
|
||||||
* @param rsqlParam rsql query string
|
* @param rsqlParam rsql query string
|
||||||
* @return a paged result of all meta data entries for a given distribution
|
* @param pageable the page request to page the result
|
||||||
* set id
|
* @return a paged result of all meta-data entries for a given distribution set id
|
||||||
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
|
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the given
|
||||||
* given {@code fieldNameProvider}
|
* {@code fieldNameProvider}
|
||||||
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
|
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
|
||||||
* @throws EntityNotFoundException of distribution set with given ID does not exist
|
* @throws EntityNotFoundException of distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<DistributionSetMetadata> findMetaDataByDistributionSetIdAndRsql(@NotNull Pageable pageable,
|
Page<DistributionSetMetadata> findMetaDataByDistributionSetIdAndRsql(long id, @NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||||
long id, @NotNull String rsqlParam);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all {@link DistributionSet}s based on completeness.
|
* Finds all {@link DistributionSet}s based on completeness.
|
||||||
*
|
*
|
||||||
* @param pageable the pagination parameter
|
* @param pageable the pagination parameter
|
||||||
* @param complete to <code>true</code> for returning only completed distribution
|
* @param complete to <code>true</code> for returning only completed distribution sets or <code>false</code> for only incomplete ones nor
|
||||||
* sets or <code>false</code> for only incomplete ones nor
|
|
||||||
* <code>null</code> to return both.
|
* <code>null</code> to return both.
|
||||||
* @return all found {@link DistributionSet}s
|
* @return all found {@link DistributionSet}s
|
||||||
*/
|
*/
|
||||||
@@ -258,26 +261,69 @@ public interface DistributionSetManagement
|
|||||||
Slice<DistributionSet> findByCompleted(@NotNull Pageable pageable, Boolean complete);
|
Slice<DistributionSet> findByCompleted(@NotNull Pageable pageable, Boolean complete);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts all {@link DistributionSet}s based on completeness.
|
* Retrieves {@link DistributionSet}s by filtering on the given parameters.
|
||||||
*
|
*
|
||||||
* @param complete to <code>true</code> for counting only completed distribution
|
* @param distributionSetFilter has details of filters to be applied.
|
||||||
* sets or <code>false</code> for only incomplete ones nor
|
* @param pageable page parameter
|
||||||
* <code>null</code> to count both.
|
* @return the page of found {@link DistributionSet}
|
||||||
* @return count of all found {@link DistributionSet}s
|
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
long countByCompleted(Boolean complete);
|
Slice<DistributionSet> findByDistributionSetFilter(@NotNull DistributionSetFilter distributionSetFilter, @NotNull Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves {@link DistributionSet}s by filtering on the given parameters.
|
* Retrieves {@link DistributionSet}s by filtering on the given parameters.
|
||||||
*
|
*
|
||||||
|
* @param tagId of the tag the DS are assigned to
|
||||||
* @param pageable page parameter
|
* @param pageable page parameter
|
||||||
* @param distributionSetFilter has details of filters to be applied.
|
|
||||||
* @return the page of found {@link DistributionSet}
|
* @return the page of found {@link DistributionSet}
|
||||||
|
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
|
||||||
|
* given {@code fieldNameProvider}
|
||||||
|
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
|
||||||
|
* @throws EntityNotFoundException of distribution set tag with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Slice<DistributionSet> findByDistributionSetFilter(@NotNull Pageable pageable,
|
Page<DistributionSet> findByTag(long tagId, @NotNull Pageable pageable);
|
||||||
@NotNull DistributionSetFilter distributionSetFilter);
|
|
||||||
|
/**
|
||||||
|
* Retrieves {@link DistributionSet}s by filtering on the given parameters.
|
||||||
|
*
|
||||||
|
* @param rsqlParam rsql query string
|
||||||
|
* @param tagId of the tag the DS are assigned to
|
||||||
|
* @param pageable page parameter
|
||||||
|
* @return the page of found {@link DistributionSet}
|
||||||
|
* @throws EntityNotFoundException of distribution set tag with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Page<DistributionSet> findByRsqlAndTag(@NotNull String rsqlParam, long tagId, @NotNull Pageable pageable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a single distribution set meta-data by its id.
|
||||||
|
*
|
||||||
|
* @param id of the {@link DistributionSet}
|
||||||
|
* @param key of the meta-data element
|
||||||
|
* @return the found DistributionSetMetadata
|
||||||
|
* @throws EntityNotFoundException is set with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Optional<DistributionSetMetadata> findMetaDataByDistributionSetId(long id, @NotEmpty String key);/**
|
||||||
|
* Counts all meta-data by the given distribution set id.
|
||||||
|
*
|
||||||
|
* @param id the distribution set id to retrieve the meta-data count from
|
||||||
|
* @return count of ds metadata
|
||||||
|
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
long countMetaDataByDistributionSetId(long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts all {@link DistributionSet}s based on completeness.
|
||||||
|
*
|
||||||
|
* @param complete to <code>true</code> for counting only completed distribution sets or <code>false</code> for only incomplete ones
|
||||||
|
* nor <code>null</code> to count both.
|
||||||
|
* @return count of all found {@link DistributionSet}s
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
long countByCompleted(Boolean complete);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts all {@link DistributionSet}s in repository based on given filter.
|
* Counts all {@link DistributionSet}s in repository based on given filter.
|
||||||
@@ -289,41 +335,15 @@ public interface DistributionSetManagement
|
|||||||
long countByDistributionSetFilter(@NotNull DistributionSetFilter distributionSetFilter);
|
long countByDistributionSetFilter(@NotNull DistributionSetFilter distributionSetFilter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves {@link DistributionSet}s by filtering on the given parameters.
|
* Count all {@link DistributionSet}s in the repository that are not marked
|
||||||
|
* as deleted.
|
||||||
*
|
*
|
||||||
* @param pageable page parameter
|
* @param typeId to look for
|
||||||
* @param tagId of the tag the DS are assigned to
|
* @return number of {@link DistributionSet}s
|
||||||
* @return the page of found {@link DistributionSet}
|
* @throws EntityNotFoundException if type with given ID does not exist
|
||||||
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
|
|
||||||
* given {@code fieldNameProvider}
|
|
||||||
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
|
|
||||||
* @throws EntityNotFoundException of distribution set tag with given ID does not exist
|
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<DistributionSet> findByTag(@NotNull Pageable pageable, long tagId);
|
long countByTypeId(long typeId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves {@link DistributionSet}s by filtering on the given parameters.
|
|
||||||
*
|
|
||||||
* @param pageable page parameter
|
|
||||||
* @param rsqlParam rsql query string
|
|
||||||
* @param tagId of the tag the DS are assigned to
|
|
||||||
* @return the page of found {@link DistributionSet}
|
|
||||||
* @throws EntityNotFoundException of distribution set tag with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<DistributionSet> findByRsqlAndTag(@NotNull Pageable pageable, @NotNull String rsqlParam, long tagId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds a single distribution set meta data by its id.
|
|
||||||
*
|
|
||||||
* @param id of the {@link DistributionSet}
|
|
||||||
* @param key of the meta data element
|
|
||||||
* @return the found DistributionSetMetadata
|
|
||||||
* @throws EntityNotFoundException is set with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Optional<DistributionSetMetadata> getMetaDataByDistributionSetId(long id, @NotEmpty String key);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a {@link DistributionSet} is currently in use by a target in
|
* Checks if a {@link DistributionSet} is currently in use by a target in
|
||||||
@@ -335,43 +355,6 @@ public interface DistributionSetManagement
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
boolean isInUse(long id);
|
boolean isInUse(long id);
|
||||||
|
|
||||||
/**
|
|
||||||
* Unassigns a {@link SoftwareModule} form an existing
|
|
||||||
* {@link DistributionSet}.
|
|
||||||
*
|
|
||||||
* @param id to get unassigned form
|
|
||||||
* @param moduleId to be unassigned
|
|
||||||
* @return the updated {@link DistributionSet}.
|
|
||||||
* @throws EntityNotFoundException if given module or DS does not exist
|
|
||||||
* @throws EntityReadOnlyException if use tries to change the {@link DistributionSet} s while
|
|
||||||
* the DS is already in use.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
|
||||||
DistributionSet unassignSoftwareModule(long id, long moduleId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates a distribution set meta data value if corresponding entry exists.
|
|
||||||
*
|
|
||||||
* @param id {@link DistributionSet} of the meta data entry to be updated
|
|
||||||
* @param metadata meta data entry to be updated
|
|
||||||
* @return the updated meta data entry
|
|
||||||
* @throws EntityNotFoundException in case the meta data entry does not exists and cannot be
|
|
||||||
* updated
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
|
||||||
DistributionSetMetadata updateMetaData(long id, @NotNull MetaData metadata);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Count all {@link DistributionSet}s in the repository that are not marked
|
|
||||||
* as deleted.
|
|
||||||
*
|
|
||||||
* @param typeId to look for
|
|
||||||
* @return number of {@link DistributionSet}s
|
|
||||||
* @throws EntityNotFoundException if type with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
long countByTypeId(long typeId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count all {@link org.eclipse.hawkbit.repository.model.Rollout}s by status for
|
* Count all {@link org.eclipse.hawkbit.repository.model.Rollout}s by status for
|
||||||
* Distribution Set.
|
* Distribution Set.
|
||||||
@@ -402,18 +385,10 @@ public interface DistributionSetManagement
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Long countAutoAssignmentsForDistributionSet(@NotNull Long id);
|
Long countAutoAssignmentsForDistributionSet(@NotNull Long id);
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the specified {@link DistributionSet} as invalidated.
|
|
||||||
*
|
|
||||||
* @param distributionSet the ID of the {@link DistributionSet} to be set to invalid
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
|
||||||
void invalidate(DistributionSet distributionSet);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles {@link DistributionSetTag} assignment to given
|
* Toggles {@link DistributionSetTag} assignment to given
|
||||||
* {@link DistributionSet}s by means that if some (or all) of the targets in
|
* {@link DistributionSet}s by means that if some (or all) of the targets in
|
||||||
* the list have the {@link Tag} not yet assigned, they will be. Only if all
|
* the list have the {@link org.eclipse.hawkbit.repository.model.Tag} not yet assigned, they will be. Only if all
|
||||||
* of theme have the tag already assigned they will be removed instead.
|
* of theme have the tag already assigned they will be removed instead.
|
||||||
*
|
*
|
||||||
* @param ids to toggle for
|
* @param ids to toggle for
|
||||||
|
|||||||
@@ -31,16 +31,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
*/
|
*/
|
||||||
public interface DistributionSetTagManagement extends RepositoryManagement<DistributionSetTag, TagCreate, TagUpdate> {
|
public interface DistributionSetTagManagement extends RepositoryManagement<DistributionSetTag, TagCreate, TagUpdate> {
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes {@link DistributionSetTag} by given
|
|
||||||
* {@link DistributionSetTag#getName()}.
|
|
||||||
*
|
|
||||||
* @param tagName to be deleted
|
|
||||||
* @throws EntityNotFoundException if tag with given name does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
|
||||||
void delete(@NotEmpty String tagName);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find {@link DistributionSet} based on given name.
|
* Find {@link DistributionSet} based on given name.
|
||||||
*
|
*
|
||||||
@@ -48,7 +38,7 @@ public interface DistributionSetTagManagement extends RepositoryManagement<Distr
|
|||||||
* @return {@link DistributionSet}
|
* @return {@link DistributionSet}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<DistributionSetTag> getByName(@NotEmpty String name);
|
Optional<DistributionSetTag> findByName(@NotEmpty String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all {@link TargetTag} assigned to given {@link Target}.
|
* Finds all {@link TargetTag} assigned to given {@link Target}.
|
||||||
@@ -60,4 +50,14 @@ public interface DistributionSetTagManagement extends RepositoryManagement<Distr
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<DistributionSetTag> findByDistributionSet(@NotNull Pageable pageable, long distributionSetId);
|
Page<DistributionSetTag> findByDistributionSet(@NotNull Pageable pageable, long distributionSetId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes {@link DistributionSetTag} by given
|
||||||
|
* {@link DistributionSetTag#getName()}.
|
||||||
|
*
|
||||||
|
* @param tagName to be deleted
|
||||||
|
* @throws EntityNotFoundException if tag with given name does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
|
void delete(@NotEmpty String tagName);
|
||||||
}
|
}
|
||||||
@@ -32,10 +32,10 @@ public interface DistributionSetTypeManagement
|
|||||||
extends RepositoryManagement<DistributionSetType, DistributionSetTypeCreate, DistributionSetTypeUpdate> {
|
extends RepositoryManagement<DistributionSetType, DistributionSetTypeCreate, DistributionSetTypeUpdate> {
|
||||||
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<DistributionSetType> getByKey(@NotEmpty String key);
|
Optional<DistributionSetType> findByKey(@NotEmpty String key);
|
||||||
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<DistributionSetType> getByName(@NotEmpty String name);
|
Optional<DistributionSetType> findByName(@NotEmpty String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigns {@link DistributionSetType#getMandatoryModuleTypes()}.
|
* Assigns {@link DistributionSetType#getMandatoryModuleTypes()}.
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ public interface RepositoryManagement<T, C, U> {
|
|||||||
*
|
*
|
||||||
* @param creates to create
|
* @param creates to create
|
||||||
* @return created Entity
|
* @return created Entity
|
||||||
* @throws ConstraintViolationException if fields are not filled as specified. Check
|
* @throws ConstraintViolationException if fields are not filled as specified. Check {@link BaseEntity} for field constraints.
|
||||||
* {@link BaseEntity} for field constraints.
|
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
List<T> create(@NotNull @Valid Collection<C> creates);
|
List<T> create(@NotNull @Valid Collection<C> creates);
|
||||||
@@ -54,8 +53,7 @@ public interface RepositoryManagement<T, C, U> {
|
|||||||
*
|
*
|
||||||
* @param create to create
|
* @param create to create
|
||||||
* @return created Entity
|
* @return created Entity
|
||||||
* @throws ConstraintViolationException if fields are not filled as specified. Check
|
* @throws ConstraintViolationException if fields are not filled as specified. Check {@link BaseEntity} for field constraints.
|
||||||
* {@link BaseEntity} for field constraints.
|
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
T create(@NotNull @Valid C create);
|
T create(@NotNull @Valid C create);
|
||||||
@@ -65,22 +63,13 @@ public interface RepositoryManagement<T, C, U> {
|
|||||||
*
|
*
|
||||||
* @param update to update
|
* @param update to update
|
||||||
* @return updated Entity
|
* @return updated Entity
|
||||||
* @throws EntityReadOnlyException if the {@link BaseEntity} cannot be updated (e.g. is already
|
* @throws EntityReadOnlyException if the {@link BaseEntity} cannot be updated (e.g. is already in use)
|
||||||
* in use)
|
* @throws EntityNotFoundException in case the {@link BaseEntity} does not exist and cannot be updated
|
||||||
* @throws EntityNotFoundException in case the {@link BaseEntity} does not exists and cannot be
|
* @throws ConstraintViolationException if fields are not filled as specified. Check {@link BaseEntity} for field constraints.
|
||||||
* updated
|
|
||||||
* @throws ConstraintViolationException if fields are not filled as specified. Check
|
|
||||||
* {@link BaseEntity} for field constraints.
|
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
T update(@NotNull @Valid U update);
|
T update(@NotNull @Valid U update);
|
||||||
|
|
||||||
/**
|
|
||||||
* @return number of {@link BaseEntity}s in the repository.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
long count();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes or marks as delete in case the {@link BaseEntity} is in use.
|
* Deletes or marks as delete in case the {@link BaseEntity} is in use.
|
||||||
*
|
*
|
||||||
@@ -91,9 +80,8 @@ public interface RepositoryManagement<T, C, U> {
|
|||||||
void delete(long id);
|
void delete(long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete {@link BaseEntity}s by their IDs. That is either a soft delete of
|
* Delete {@link BaseEntity}s by their IDs. That is either a soft delete of the entities have been linked to another entity before or a hard
|
||||||
* the entities have been linked to another entity before or a hard delete
|
* delete if not.
|
||||||
* if not.
|
|
||||||
*
|
*
|
||||||
* @param ids to be deleted
|
* @param ids to be deleted
|
||||||
* @throws EntityNotFoundException if (at least one) given distribution set does not exist
|
* @throws EntityNotFoundException if (at least one) given distribution set does not exist
|
||||||
@@ -110,21 +98,11 @@ public interface RepositoryManagement<T, C, U> {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
List<T> get(@NotEmpty Collection<Long> ids);
|
List<T> get(@NotEmpty Collection<Long> ids);
|
||||||
|
|
||||||
/**
|
|
||||||
* Verifies that {@link BaseEntity} with given ID exists in the repository.
|
|
||||||
*
|
|
||||||
* @param id of entity to check existence
|
|
||||||
* @return <code>true</code> if entity with given ID exists
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
boolean exists(long id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve {@link BaseEntity}
|
* Retrieve {@link BaseEntity}
|
||||||
*
|
*
|
||||||
* @param id to search for
|
* @param id to search for
|
||||||
* @return {@link BaseEntity} in the repository with given
|
* @return {@link BaseEntity} in the repository with given {@link BaseEntity#getId()}
|
||||||
* {@link BaseEntity#getId()}
|
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<T> get(long id);
|
Optional<T> get(long id);
|
||||||
@@ -141,13 +119,28 @@ public interface RepositoryManagement<T, C, U> {
|
|||||||
/**
|
/**
|
||||||
* Retrieves all {@link BaseEntity}s with a given specification.
|
* Retrieves all {@link BaseEntity}s with a given specification.
|
||||||
*
|
*
|
||||||
* @param pageable pagination parameter
|
|
||||||
* @param rsqlParam filter definition in RSQL syntax
|
* @param rsqlParam filter definition in RSQL syntax
|
||||||
|
* @param pageable pagination parameter
|
||||||
* @return the found {@link BaseEntity}s
|
* @return the found {@link BaseEntity}s
|
||||||
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
|
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the given
|
||||||
* given {@code fieldNameProvider}
|
* {@code fieldNameProvider}
|
||||||
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
|
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<T> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam);
|
Page<T> findByRsql(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies that {@link BaseEntity} with given ID exists in the repository.
|
||||||
|
*
|
||||||
|
* @param id of entity to check existence
|
||||||
|
* @return <code>true</code> if entity with given ID exists
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
boolean exists(long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return number of {@link BaseEntity}s in the repository.
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
long count();
|
||||||
}
|
}
|
||||||
@@ -40,170 +40,54 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||||||
/**
|
/**
|
||||||
* Service for managing {@link SoftwareModule}s.
|
* Service for managing {@link SoftwareModule}s.
|
||||||
*/
|
*/
|
||||||
public interface SoftwareModuleManagement
|
public interface SoftwareModuleManagement extends RepositoryManagement<SoftwareModule, SoftwareModuleCreate, SoftwareModuleUpdate> {
|
||||||
extends RepositoryManagement<SoftwareModule, SoftwareModuleCreate, SoftwareModuleUpdate> {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a list of software module meta data entries.
|
* Creates a list of software module meta-data entries.
|
||||||
*
|
*
|
||||||
* @param metadata the meta data entries to create
|
* @param metadata the meta-data entries to create
|
||||||
* @return the updated or created software module meta data entries
|
* @return the updated or created software module meta-data entries
|
||||||
* @throws EntityAlreadyExistsException in case one of the meta data entry already exists for the
|
* @throws EntityAlreadyExistsException in case one of the meta-data entry already exists for the specific key
|
||||||
* specific key
|
* @throws EntityNotFoundException if software module with given ID does not exist
|
||||||
|
* @throws AssignmentQuotaExceededException if the maximum number of {@link SoftwareModuleMetadata} entries is exceeded for the addressed
|
||||||
|
* {@link SoftwareModule}
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
|
List<SoftwareModuleMetadata> putMetaData(@NotNull @Valid Collection<SoftwareModuleMetadataCreate> metadata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates or updates a single software module meta-data entry.
|
||||||
|
*
|
||||||
|
* @param metadata the meta-data entry to create
|
||||||
|
* @return the updated or created software module meta-data entry
|
||||||
|
* @throws EntityAlreadyExistsException in case the meta-data entry already exists for the specific key
|
||||||
* @throws EntityNotFoundException if software module with given ID does not exist
|
* @throws EntityNotFoundException if software module with given ID does not exist
|
||||||
* @throws AssignmentQuotaExceededException if the maximum number of {@link SoftwareModuleMetadata}
|
* @throws AssignmentQuotaExceededException if the maximum number of {@link SoftwareModuleMetadata}
|
||||||
* entries is exceeded for the addressed {@link SoftwareModule}
|
* entries is exceeded for the addressed {@link SoftwareModule}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
List<SoftwareModuleMetadata> createMetaData(@NotNull @Valid Collection<SoftwareModuleMetadataCreate> metadata);
|
SoftwareModuleMetadata updateMetaData(@NotNull @Valid SoftwareModuleMetadataCreate metadata);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates or updates a single software module meta data entry.
|
* Updates a distribution set meta-data value if corresponding entry exists.
|
||||||
*
|
*
|
||||||
* @param metadata the meta data entry to create
|
* @param update the meta-data entry to be updated
|
||||||
* @return the updated or created software module meta data entry
|
* @return the updated meta-data entry
|
||||||
* @throws EntityAlreadyExistsException in case the meta data entry already exists for the specific
|
* @throws EntityNotFoundException in case the meta-data entry does not exist and cannot be updated
|
||||||
* key
|
|
||||||
* @throws EntityNotFoundException if software module with given ID does not exist
|
|
||||||
* @throws AssignmentQuotaExceededException if the maximum number of {@link SoftwareModuleMetadata}
|
|
||||||
* entries is exceeded for the addressed {@link SoftwareModule}
|
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
SoftwareModuleMetadata createMetaData(@NotNull @Valid SoftwareModuleMetadataCreate metadata);
|
SoftwareModuleMetadata updateMetaData(@NotNull @Valid SoftwareModuleMetadataUpdate update);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a software module meta data entry.
|
* Deletes a software module meta-data entry.
|
||||||
*
|
*
|
||||||
* @param id where meta data has to be deleted
|
* @param id where meta-data has to be deleted
|
||||||
* @param key of the metda data element
|
* @param key of the meta-data element
|
||||||
* @throws EntityNotFoundException of module or metadata entry does not exist
|
* @throws EntityNotFoundException of module or metadata entry does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
void deleteMetaData(long id, @NotEmpty String key);
|
void deleteMetaData(long id, @NotEmpty String key);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all modules assigned to given {@link DistributionSet}.
|
|
||||||
*
|
|
||||||
* @param pageable the page request to page the result set
|
|
||||||
* @param distributionSetId to search for
|
|
||||||
* @return all {@link SoftwareModule}s that are assigned to given
|
|
||||||
* {@link DistributionSet}.
|
|
||||||
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<SoftwareModule> findByAssignedTo(@NotNull Pageable pageable, long distributionSetId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns count of all modules assigned to given {@link DistributionSet}.
|
|
||||||
*
|
|
||||||
* @param distributionSetId to search for
|
|
||||||
* @return count of {@link SoftwareModule}s that are assigned to given
|
|
||||||
* {@link DistributionSet}.
|
|
||||||
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
long countByAssignedTo(long distributionSetId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter {@link SoftwareModule}s with given
|
|
||||||
* {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()}
|
|
||||||
* and {@link SoftwareModule#getType()} that are not marked as deleted.
|
|
||||||
*
|
|
||||||
* @param pageable page parameter
|
|
||||||
* @param searchText to be filtered as "like" on {@link SoftwareModule#getName()}
|
|
||||||
* @param typeId to be filtered as "like" on {@link SoftwareModule#getType()}
|
|
||||||
* @return the page of found {@link SoftwareModule}
|
|
||||||
* @throws EntityNotFoundException if given software module type does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Slice<SoftwareModule> findByTextAndType(@NotNull Pageable pageable, String searchText, Long typeId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves {@link SoftwareModule} by their name AND version AND type..
|
|
||||||
*
|
|
||||||
* @param name of the {@link SoftwareModule}
|
|
||||||
* @param version of the {@link SoftwareModule}
|
|
||||||
* @param typeId of the {@link SoftwareModule}
|
|
||||||
* @return the found {@link SoftwareModule}
|
|
||||||
* @throws EntityNotFoundException if software module type with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Optional<SoftwareModule> getByNameAndVersionAndType(@NotEmpty String name, @NotEmpty String version, long typeId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds a single software module meta data by its id.
|
|
||||||
*
|
|
||||||
* @param id where meta data has to be found
|
|
||||||
* @param key of the meta data element
|
|
||||||
* @return the found SoftwareModuleMetadata or {@code null} if not exits
|
|
||||||
* @throws EntityNotFoundException is module with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Optional<SoftwareModuleMetadata> getMetaDataBySoftwareModuleId(long id, @NotEmpty String key);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds all meta data by the given software module id.
|
|
||||||
*
|
|
||||||
* @param pageable the page request to page the result
|
|
||||||
* @param id the software module id to retrieve the meta data from
|
|
||||||
* @return a paged result of all meta data entries for a given software
|
|
||||||
* module id
|
|
||||||
* @throws EntityNotFoundException if software module with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleId(@NotNull Pageable pageable, long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Counts all meta data by the given software module id.
|
|
||||||
*
|
|
||||||
* @param id the software module id to retrieve the meta data count from
|
|
||||||
* @return count of all meta data entries for a given software module id
|
|
||||||
* @throws EntityNotFoundException if software module with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
long countMetaDataBySoftwareModuleId(long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds all meta data by the given software module id where
|
|
||||||
* {@link SoftwareModuleMetadata#isTargetVisible()}.
|
|
||||||
*
|
|
||||||
* @param pageable the page request to page the result
|
|
||||||
* @param id the software module id to retrieve the meta data from
|
|
||||||
* @return a paged result of all meta data entries for a given software
|
|
||||||
* module id
|
|
||||||
* @throws EntityNotFoundException if software module with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleIdAndTargetVisible(@NotNull Pageable pageable, long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds all meta data by the given software module id.
|
|
||||||
*
|
|
||||||
* @param pageable the page request to page the result
|
|
||||||
* @param id the software module id to retrieve the meta data from
|
|
||||||
* @param rsqlParam filter definition in RSQL syntax
|
|
||||||
* @return a paged result of all meta data entries for a given software
|
|
||||||
* module id
|
|
||||||
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
|
|
||||||
* given {@code fieldNameProvider}
|
|
||||||
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
|
|
||||||
* @throws EntityNotFoundException if software module with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<SoftwareModuleMetadata> findMetaDataByRsql(@NotNull Pageable pageable, long id, @NotNull String rsqlParam);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the {@link SoftwareModule}s by their {@link SoftwareModuleType}
|
|
||||||
* .
|
|
||||||
*
|
|
||||||
* @param pageable page parameters
|
|
||||||
* @param typeId to be filtered on
|
|
||||||
* @return the found {@link SoftwareModule}s
|
|
||||||
* @throws EntityNotFoundException if software module type with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Slice<SoftwareModule> findByType(@NotNull Pageable pageable, long typeId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locks a software module.
|
* Locks a software module.
|
||||||
*
|
*
|
||||||
@@ -225,16 +109,120 @@ public interface SoftwareModuleManagement
|
|||||||
void unlock(long id);
|
void unlock(long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a distribution set meta data value if corresponding entry exists.
|
* Returns all modules assigned to given {@link DistributionSet}.
|
||||||
*
|
*
|
||||||
* @param update the meta data entry to be updated
|
* @param distributionSetId to search for
|
||||||
* @return the updated meta data entry
|
* @param pageable the page request to page the result set
|
||||||
* @throws EntityNotFoundException in case the meta data entry does not exists and cannot be
|
* @return all {@link SoftwareModule}s that are assigned to given {@link DistributionSet}.
|
||||||
* updated
|
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
SoftwareModuleMetadata updateMetaData(@NotNull @Valid SoftwareModuleMetadataUpdate update);
|
Page<SoftwareModule> findByAssignedTo(long distributionSetId, @NotNull Pageable pageable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter {@link SoftwareModule}s with given {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()}
|
||||||
|
* and {@link SoftwareModule#getType()} that are not marked as deleted.
|
||||||
|
*
|
||||||
|
* @param searchText to be filtered as "like" on {@link SoftwareModule#getName()}
|
||||||
|
* @param typeId to be filtered as "like" on {@link SoftwareModule#getType()}
|
||||||
|
* @param pageable page parameter
|
||||||
|
* @return the page of found {@link SoftwareModule}
|
||||||
|
* @throws EntityNotFoundException if given software module type does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Slice<SoftwareModule> findByTextAndType(String searchText, Long typeId, @NotNull Pageable pageable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves {@link SoftwareModule} by their name AND version AND type.
|
||||||
|
*
|
||||||
|
* @param name of the {@link SoftwareModule}
|
||||||
|
* @param version of the {@link SoftwareModule}
|
||||||
|
* @param typeId of the {@link SoftwareModule}
|
||||||
|
* @return the found {@link SoftwareModule}
|
||||||
|
* @throws EntityNotFoundException if software module type with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Optional<SoftwareModule> findByNameAndVersionAndType(@NotEmpty String name, @NotEmpty String version, long typeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a single software module meta-data by its id.
|
||||||
|
*
|
||||||
|
* @param id where meta-data has to be found
|
||||||
|
* @param key of the meta-data element
|
||||||
|
* @return the found SoftwareModuleMetadata or {@code null} if not exits
|
||||||
|
* @throws EntityNotFoundException is module with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Optional<SoftwareModuleMetadata> findMetaDataBySoftwareModuleId(long id, @NotEmpty String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds all meta-data by the given software module id.
|
||||||
|
*
|
||||||
|
* @param pageable the page request to page the result
|
||||||
|
* @param id the software module id to retrieve the meta-data from
|
||||||
|
* @return a paged result of all meta-data entries for a given software module id
|
||||||
|
* @throws EntityNotFoundException if software module with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleId(@NotNull Pageable pageable, long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds all meta-data by the given software module id where {@link SoftwareModuleMetadata#isTargetVisible()}.
|
||||||
|
*
|
||||||
|
* @param pageable the page request to page the result
|
||||||
|
* @param id the software module id to retrieve the meta-data from
|
||||||
|
* @return a paged result of all meta-data entries for a given software module id
|
||||||
|
* @throws EntityNotFoundException if software module with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleIdAndTargetVisible(@NotNull Pageable pageable, long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds all meta-data by the given software module id.
|
||||||
|
*
|
||||||
|
* @param id the software module id to retrieve the meta-data from
|
||||||
|
* @param rsqlParam filter definition in RSQL syntax
|
||||||
|
* @param pageable the page request to page the result
|
||||||
|
* @return a paged result of all meta-data entries for a given software module id
|
||||||
|
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the given
|
||||||
|
* {@code fieldNameProvider}
|
||||||
|
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
|
||||||
|
* @throws EntityNotFoundException if software module with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Page<SoftwareModuleMetadata> findMetaDataByRsql(long id, @NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the {@link SoftwareModule}s by their {@link SoftwareModuleType}
|
||||||
|
*
|
||||||
|
* @param typeId to be filtered on
|
||||||
|
* @param pageable page parameters
|
||||||
|
* @return the found {@link SoftwareModule}s
|
||||||
|
* @throws EntityNotFoundException if software module type with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Slice<SoftwareModule> findByType(long typeId, @NotNull Pageable pageable);
|
||||||
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Map<Long, List<SoftwareModuleMetadata>> findMetaDataBySoftwareModuleIdsAndTargetVisible(Collection<Long> moduleIds);
|
Map<Long, List<SoftwareModuleMetadata>> findMetaDataBySoftwareModuleIdsAndTargetVisible(Collection<Long> moduleIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns count of all modules assigned to given {@link DistributionSet}.
|
||||||
|
*
|
||||||
|
* @param distributionSetId to search for
|
||||||
|
* @return count of {@link SoftwareModule}s that are assigned to given {@link DistributionSet}.
|
||||||
|
* @throws EntityNotFoundException if distribution set with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
long countByAssignedTo(long distributionSetId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Counts all meta-data by the given software module id.
|
||||||
|
*
|
||||||
|
* @param id the software module id to retrieve the meta-data count from
|
||||||
|
* @return count of all meta-data entries for a given software module id
|
||||||
|
* @throws EntityNotFoundException if software module with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
long countMetaDataBySoftwareModuleId(long id);
|
||||||
}
|
}
|
||||||
@@ -30,12 +30,12 @@ public interface SoftwareModuleTypeManagement
|
|||||||
* @return {@link SoftwareModuleType} in the repository with given {@link SoftwareModuleType#getKey()}
|
* @return {@link SoftwareModuleType} in the repository with given {@link SoftwareModuleType#getKey()}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<SoftwareModuleType> getByKey(@NotEmpty String key);
|
Optional<SoftwareModuleType> findByKey(@NotEmpty String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name to search for
|
* @param name to search for
|
||||||
* @return all {@link SoftwareModuleType}s in the repository with given {@link SoftwareModuleType#getName()}
|
* @return all {@link SoftwareModuleType}s in the repository with given {@link SoftwareModuleType#getName()}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<SoftwareModuleType> getByName(@NotEmpty String name);
|
Optional<SoftwareModuleType> findByName(@NotEmpty String name);
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ public final class JpaManagementHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T, J extends T> Page<T> findAllWithCountBySpec(final JpaSpecificationExecutor<J> repository,
|
public static <T, J extends T> Page<T> findAllWithCountBySpec(final JpaSpecificationExecutor<J> repository,
|
||||||
final Pageable pageable, final List<Specification<J>> specList) {
|
final List<Specification<J>> specList, final Pageable pageable) {
|
||||||
if (CollectionUtils.isEmpty(specList)) {
|
if (CollectionUtils.isEmpty(specList)) {
|
||||||
return convertPage(repository.findAll(Specification.where(null), pageable), pageable);
|
return convertPage(repository.findAll(Specification.where(null), pageable), pageable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreat
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final String distributionSetTypekey) {
|
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final String distributionSetTypekey) {
|
||||||
return distributionSetTypeManagement.getByKey(distributionSetTypekey)
|
return distributionSetTypeManagement.findByKey(distributionSetTypekey)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypekey));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypekey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class JpaSoftwareModuleCreate extends AbstractSoftwareModuleUpdateCreate<
|
|||||||
throw new ValidationException("type cannot be null");
|
throw new ValidationException("type cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
return softwareModuleTypeManagement.getByKey(type.trim())
|
return softwareModuleTypeManagement.findByKey(type.trim())
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, type.trim()));
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, type.trim()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -582,7 +582,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
|||||||
public boolean updateOfflineAssignedVersion(@NotEmpty final String controllerId, final String distributionName, final String version) {
|
public boolean updateOfflineAssignedVersion(@NotEmpty final String controllerId, final String distributionName, final String version) {
|
||||||
List<DistributionSetAssignmentResult> distributionSetAssignmentResults =
|
List<DistributionSetAssignmentResult> distributionSetAssignmentResults =
|
||||||
systemSecurityContext.runAsSystem(() ->
|
systemSecurityContext.runAsSystem(() ->
|
||||||
distributionSetManagement.getByNameAndVersion(distributionName, version).map(
|
distributionSetManagement.findByNameAndVersion(distributionName, version).map(
|
||||||
distributionSet -> deploymentManagement.offlineAssignedDistributionSets(
|
distributionSet -> deploymentManagement.offlineAssignedDistributionSets(
|
||||||
List.of(Map.entry(controllerId, distributionSet.getId())), controllerId))
|
List.of(Map.entry(controllerId, distributionSet.getId())), controllerId))
|
||||||
.orElseThrow(() ->
|
.orElseThrow(() ->
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database),
|
RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database),
|
||||||
ActionSpecifications.byTargetControllerId(controllerId));
|
ActionSpecifications.byTargetControllerId(controllerId));
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(actionRepository, pageable, specList);
|
return JpaManagementHelper.findAllWithCountBySpec(actionRepository, specList, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -155,8 +155,9 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<DistributionSet> create(final Collection<DistributionSetCreate> creates) {
|
public List<DistributionSet> create(final Collection<DistributionSetCreate> creates) {
|
||||||
final List<JpaDistributionSet> toCreate = creates.stream().map(JpaDistributionSetCreate.class::cast)
|
final List<JpaDistributionSet> toCreate = creates.stream().map(JpaDistributionSetCreate.class::cast)
|
||||||
.map(this::setDefaultTypeIfMissing).map(JpaDistributionSetCreate::build).toList();
|
.map(this::setDefaultTypeIfMissing)
|
||||||
|
.map(JpaDistributionSetCreate::build)
|
||||||
|
.toList();
|
||||||
return Collections.unmodifiableList(distributionSetRepository.saveAll(AccessController.Operation.CREATE, toCreate));
|
return Collections.unmodifiableList(distributionSetRepository.saveAll(AccessController.Operation.CREATE, toCreate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +169,6 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
public DistributionSet create(final DistributionSetCreate c) {
|
public DistributionSet create(final DistributionSetCreate c) {
|
||||||
final JpaDistributionSetCreate create = (JpaDistributionSetCreate) c;
|
final JpaDistributionSetCreate create = (JpaDistributionSetCreate) c;
|
||||||
setDefaultTypeIfMissing(create);
|
setDefaultTypeIfMissing(create);
|
||||||
|
|
||||||
return distributionSetRepository.save(AccessController.Operation.CREATE, create.build());
|
return distributionSetRepository.save(AccessController.Operation.CREATE, create.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,11 +207,6 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
return distributionSetRepository.save(set);
|
return distributionSetRepository.save(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long count() {
|
|
||||||
return distributionSetRepository.count(DistributionSetSpecification.isNotDeleted());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
@@ -263,6 +258,11 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<DistributionSet> get(final long id) {
|
||||||
|
return distributionSetRepository.findById(id).map(DistributionSet.class::cast);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DistributionSet> get(final Collection<Long> ids) {
|
public List<DistributionSet> get(final Collection<Long> ids) {
|
||||||
return Collections.unmodifiableList(getDistributionSets(ids));
|
return Collections.unmodifiableList(getDistributionSets(ids));
|
||||||
@@ -274,8 +274,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSet> get(final long id) {
|
public long count() {
|
||||||
return distributionSetRepository.findById(id).map(DistributionSet.class::cast);
|
return distributionSetRepository.count(DistributionSetSpecification.isNotDeleted());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -285,11 +285,30 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSet> findByRsql(final Pageable pageable, final String rsqlParam) {
|
public Page<DistributionSet> findByRsql(final String rsqlParam, final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, pageable, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetFields.class, virtualPropertyReplacer,
|
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetFields.class, virtualPropertyReplacer, database),
|
||||||
database),
|
DistributionSetSpecification.isNotDeleted()), pageable);
|
||||||
DistributionSetSpecification.isNotDeleted()));
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<DistributionSet> getWithDetails(final long id) {
|
||||||
|
return distributionSetRepository
|
||||||
|
.findOne(distributionSetRepository.byIdSpec(id), JpaDistributionSet_.GRAPH_DISTRIBUTION_SET_DETAIL)
|
||||||
|
.map(DistributionSet.class::cast);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void invalidate(final DistributionSet distributionSet) {
|
||||||
|
final JpaDistributionSet jpaSet = (JpaDistributionSet) distributionSet;
|
||||||
|
jpaSet.invalidate();
|
||||||
|
distributionSetRepository.save(jpaSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DistributionSet getOrElseThrowException(final long id) {
|
||||||
|
return getById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -312,6 +331,20 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
return distributionSetRepository.save(set);
|
return distributionSetRepository.save(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public DistributionSet unassignSoftwareModule(final long id, final long moduleId) {
|
||||||
|
final JpaDistributionSet set = (JpaDistributionSet) getValid(id);
|
||||||
|
assertDistributionSetIsNotAssignedToTargets(id);
|
||||||
|
|
||||||
|
final JpaSoftwareModule module = findSoftwareModuleAndThrowExceptionIfNotFound(moduleId);
|
||||||
|
set.removeModule(module);
|
||||||
|
|
||||||
|
return distributionSetRepository.save(set);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
@@ -327,6 +360,21 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public DistributionSetMetadata updateMetaData(final long id, final MetaData md) {
|
||||||
|
// check if exists otherwise throw entity not found exception
|
||||||
|
final JpaDistributionSetMetadata toUpdate = (JpaDistributionSetMetadata) findMetaDataByDistributionSetId(id, md.getKey())
|
||||||
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetMetadata.class, id, md.getKey()));
|
||||||
|
toUpdate.setValue(md.getValue());
|
||||||
|
|
||||||
|
// touch it to update the lock revision because we are modifying the DS indirectly, it will, also check UPDATE access
|
||||||
|
JpaManagementHelper.touch(entityManager, distributionSetRepository, (JpaDistributionSet) getValid(id));
|
||||||
|
return distributionSetMetadataRepository.save(toUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
@@ -346,7 +394,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<DistributionSetMetadata> createMetaData(final long id, final Collection<MetaData> md) {
|
public List<DistributionSetMetadata> putMetaData(final long id, final Collection<MetaData> md) {
|
||||||
final JpaDistributionSet distributionSet = (JpaDistributionSet) getValid(id);
|
final JpaDistributionSet distributionSet = (JpaDistributionSet) getValid(id);
|
||||||
assertMetaDataQuota(id, md.size());
|
assertMetaDataQuota(id, md.size());
|
||||||
|
|
||||||
@@ -366,7 +414,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteMetaData(final long id, final String key) {
|
public void deleteMetaData(final long id, final String key) {
|
||||||
final JpaDistributionSetMetadata metadata = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId(
|
final JpaDistributionSetMetadata metadata = (JpaDistributionSetMetadata) findMetaDataByDistributionSetId(
|
||||||
id, key)
|
id, key)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetMetadata.class, id, key));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetMetadata.class, id, key));
|
||||||
|
|
||||||
@@ -403,7 +451,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSet> getByAction(final long actionId) {
|
public Optional<DistributionSet> findByAction(final long actionId) {
|
||||||
return actionRepository
|
return actionRepository
|
||||||
.findById(actionId)
|
.findById(actionId)
|
||||||
.map(action -> {
|
.map(action -> {
|
||||||
@@ -422,14 +470,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSet> getWithDetails(final long id) {
|
public Optional<DistributionSet> findByNameAndVersion(final String distributionName, final String version) {
|
||||||
return distributionSetRepository
|
|
||||||
.findOne(distributionSetRepository.byIdSpec(id), JpaDistributionSet_.GRAPH_DISTRIBUTION_SET_DETAIL)
|
|
||||||
.map(DistributionSet.class::cast);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<DistributionSet> getByNameAndVersion(final String distributionName, final String version) {
|
|
||||||
return distributionSetRepository
|
return distributionSetRepository
|
||||||
.findOne(DistributionSetSpecification.equalsNameAndVersionIgnoreCase(distributionName, version))
|
.findOne(DistributionSetSpecification.equalsNameAndVersionIgnoreCase(distributionName, version))
|
||||||
.map(DistributionSet.class::cast);
|
.map(DistributionSet.class::cast);
|
||||||
@@ -465,17 +506,11 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DistributionSet getOrElseThrowException(final long id) {
|
public Page<DistributionSetMetadata> findMetaDataByDistributionSetId(final long id, final Pageable pageable) {
|
||||||
return getById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<DistributionSetMetadata> findMetaDataByDistributionSetId(final Pageable pageable,
|
|
||||||
final long id) {
|
|
||||||
assertDistributionSetExists(id);
|
assertDistributionSetExists(id);
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetMetadataRepository, pageable,
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetMetadataRepository, Collections.singletonList(byDsIdSpec(id)), pageable
|
||||||
Collections.singletonList(byDsIdSpec(id)));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -486,15 +521,15 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSetMetadata> findMetaDataByDistributionSetIdAndRsql(final Pageable pageable,
|
public Page<DistributionSetMetadata> findMetaDataByDistributionSetIdAndRsql(final long id, final String rsqlParam,
|
||||||
final long id, final String rsqlParam) {
|
final Pageable pageable) {
|
||||||
assertDistributionSetExists(id);
|
assertDistributionSetExists(id);
|
||||||
|
|
||||||
final List<Specification<JpaDistributionSetMetadata>> specList = Arrays
|
final List<Specification<JpaDistributionSetMetadata>> specList = Arrays
|
||||||
.asList(RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetMetadataFields.class,
|
.asList(RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetMetadataFields.class,
|
||||||
virtualPropertyReplacer, database), byDsIdSpec(id));
|
virtualPropertyReplacer, database), byDsIdSpec(id));
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetMetadataRepository, pageable, specList);
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetMetadataRepository, specList, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -512,8 +547,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Slice<DistributionSet> findByDistributionSetFilter(final Pageable pageable,
|
public Slice<DistributionSet> findByDistributionSetFilter(final DistributionSetFilter distributionSetFilter, final Pageable pageable) {
|
||||||
final DistributionSetFilter distributionSetFilter) {
|
|
||||||
final List<Specification<JpaDistributionSet>> specList = buildDistributionSetSpecifications(
|
final List<Specification<JpaDistributionSet>> specList = buildDistributionSetSpecifications(
|
||||||
distributionSetFilter);
|
distributionSetFilter);
|
||||||
|
|
||||||
@@ -527,25 +561,25 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSet> findByTag(final Pageable pageable, final long tagId) {
|
public Page<DistributionSet> findByTag(final long tagId, final Pageable pageable) {
|
||||||
assertDsTagExists(tagId);
|
assertDsTagExists(tagId);
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, pageable, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of(
|
||||||
DistributionSetSpecification.hasTag(tagId)));
|
DistributionSetSpecification.hasTag(tagId)), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSet> findByRsqlAndTag(final Pageable pageable, final String rsqlParam, final long tagId) {
|
public Page<DistributionSet> findByRsqlAndTag(final String rsqlParam, final long tagId, final Pageable pageable) {
|
||||||
assertDsTagExists(tagId);
|
assertDsTagExists(tagId);
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, pageable, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetFields.class, virtualPropertyReplacer,
|
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetFields.class, virtualPropertyReplacer,
|
||||||
database),
|
database),
|
||||||
DistributionSetSpecification.hasTag(tagId), DistributionSetSpecification.isNotDeleted()));
|
DistributionSetSpecification.hasTag(tagId), DistributionSetSpecification.isNotDeleted()), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSetMetadata> getMetaDataByDistributionSetId(final long id, final String key) {
|
public Optional<DistributionSetMetadata> findMetaDataByDistributionSetId(final long id, final String key) {
|
||||||
assertDistributionSetExists(id);
|
assertDistributionSetExists(id);
|
||||||
|
|
||||||
return distributionSetMetadataRepository
|
return distributionSetMetadataRepository
|
||||||
@@ -553,42 +587,6 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
.map(DistributionSetMetadata.class::cast);
|
.map(DistributionSetMetadata.class::cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInUse(final long id) {
|
|
||||||
assertDistributionSetExists(id);
|
|
||||||
|
|
||||||
return actionRepository.countByDistributionSetId(id) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
|
||||||
public DistributionSet unassignSoftwareModule(final long id, final long moduleId) {
|
|
||||||
final JpaDistributionSet set = (JpaDistributionSet) getValid(id);
|
|
||||||
assertDistributionSetIsNotAssignedToTargets(id);
|
|
||||||
|
|
||||||
final JpaSoftwareModule module = findSoftwareModuleAndThrowExceptionIfNotFound(moduleId);
|
|
||||||
set.removeModule(module);
|
|
||||||
|
|
||||||
return distributionSetRepository.save(set);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
|
||||||
public DistributionSetMetadata updateMetaData(final long id, final MetaData md) {
|
|
||||||
// check if exists otherwise throw entity not found exception
|
|
||||||
final JpaDistributionSetMetadata toUpdate = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId(id, md.getKey())
|
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetMetadata.class, id, md.getKey()));
|
|
||||||
toUpdate.setValue(md.getValue());
|
|
||||||
|
|
||||||
// touch it to update the lock revision because we are modifying the DS indirectly, it will, also check UPDATE access
|
|
||||||
JpaManagementHelper.touch(entityManager, distributionSetRepository, (JpaDistributionSet) getValid(id));
|
|
||||||
return distributionSetMetadataRepository.save(toUpdate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long countByTypeId(final long typeId) {
|
public long countByTypeId(final long typeId) {
|
||||||
if (!distributionSetTypeManagement.exists(typeId)) {
|
if (!distributionSetTypeManagement.exists(typeId)) {
|
||||||
@@ -598,9 +596,17 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
return distributionSetRepository.count(DistributionSetSpecification.byType(typeId));
|
return distributionSetRepository.count(DistributionSetSpecification.byType(typeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInUse(final long id) {
|
||||||
|
assertDistributionSetExists(id);
|
||||||
|
|
||||||
|
return actionRepository.countByDistributionSetId(id) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Statistic> countRolloutsByStatusForDistributionSet(final Long id) {
|
public List<Statistic> countRolloutsByStatusForDistributionSet(final Long id) {
|
||||||
assertDistributionSetExists(id);
|
assertDistributionSetExists(id);
|
||||||
|
|
||||||
return distributionSetRepository.countRolloutsByStatusForDistributionSet(id).stream().map(Statistic.class::cast).toList();
|
return distributionSetRepository.countRolloutsByStatusForDistributionSet(id).stream().map(Statistic.class::cast).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -619,14 +625,6 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
return distributionSetRepository.countAutoAssignmentsForDistributionSet(id);
|
return distributionSetRepository.countAutoAssignmentsForDistributionSet(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void invalidate(final DistributionSet distributionSet) {
|
|
||||||
final JpaDistributionSet jpaSet = (JpaDistributionSet) distributionSet;
|
|
||||||
jpaSet.invalidate();
|
|
||||||
distributionSetRepository.save(jpaSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
@@ -635,7 +633,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
return updateTag(
|
return updateTag(
|
||||||
ids,
|
ids,
|
||||||
() -> distributionSetTagManagement
|
() -> distributionSetTagManagement
|
||||||
.getByName(tagName)
|
.findByName(tagName)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, tagName)),
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, tagName)),
|
||||||
(allDs, distributionSetTag) -> {
|
(allDs, distributionSetTag) -> {
|
||||||
final List<JpaDistributionSet> toBeChangedDSs = allDs.stream().filter(set -> set.addTag(distributionSetTag))
|
final List<JpaDistributionSet> toBeChangedDSs = allDs.stream().filter(set -> set.addTag(distributionSetTag))
|
||||||
|
|||||||
@@ -75,10 +75,11 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<DistributionSetTag> create(final Collection<TagCreate> dst) {
|
public List<DistributionSetTag> create(final Collection<TagCreate> dst) {
|
||||||
final List<JpaDistributionSetTag> toCreate = dst.stream().map(JpaTagCreate.class::cast)
|
final List<JpaDistributionSetTag> toCreate = dst.stream()
|
||||||
.map(JpaTagCreate::buildDistributionSetTag).toList();
|
.map(JpaTagCreate.class::cast)
|
||||||
return Collections
|
.map(JpaTagCreate::buildDistributionSetTag)
|
||||||
.unmodifiableList(distributionSetTagRepository.saveAll(AccessController.Operation.CREATE, toCreate));
|
.toList();
|
||||||
|
return Collections.unmodifiableList(distributionSetTagRepository.saveAll(AccessController.Operation.CREATE, toCreate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -87,8 +88,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
public DistributionSetTag create(final TagCreate c) {
|
public DistributionSetTag create(final TagCreate c) {
|
||||||
final JpaTagCreate create = (JpaTagCreate) c;
|
return distributionSetTagRepository.save(AccessController.Operation.CREATE, ((JpaTagCreate) c).buildDistributionSetTag());
|
||||||
return distributionSetTagRepository.save(AccessController.Operation.CREATE, create.buildDistributionSetTag());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -98,7 +98,6 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
public DistributionSetTag update(final TagUpdate u) {
|
public DistributionSetTag update(final TagUpdate u) {
|
||||||
final GenericTagUpdate update = (GenericTagUpdate) u;
|
final GenericTagUpdate update = (GenericTagUpdate) u;
|
||||||
|
|
||||||
final JpaDistributionSetTag tag = distributionSetTagRepository.findById(update.getId())
|
final JpaDistributionSetTag tag = distributionSetTagRepository.findById(update.getId())
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, update.getId()));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, update.getId()));
|
||||||
|
|
||||||
@@ -109,11 +108,6 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
return distributionSetTagRepository.save(tag);
|
return distributionSetTagRepository.save(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long count() {
|
|
||||||
return distributionSetTagRepository.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
@@ -137,6 +131,11 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
distributionSetTagRepository.deleteAll(setsFound);
|
distributionSetTagRepository.deleteAll(setsFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<DistributionSetTag> get(final long id) {
|
||||||
|
return distributionSetTagRepository.findById(id).map(DistributionSetTag.class::cast);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DistributionSetTag> get(final Collection<Long> ids) {
|
public List<DistributionSetTag> get(final Collection<Long> ids) {
|
||||||
return Collections.unmodifiableList(distributionSetTagRepository.findAllById(ids));
|
return Collections.unmodifiableList(distributionSetTagRepository.findAllById(ids));
|
||||||
@@ -148,22 +147,37 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSetTag> get(final long id) {
|
public long count() {
|
||||||
return distributionSetTagRepository.findById(id).map(DistributionSetTag.class::cast);
|
return distributionSetTagRepository.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Slice<DistributionSetTag> findAll(final Pageable pageable) {
|
public Slice<DistributionSetTag> findAll(final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetTagRepository, pageable, null);
|
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetTagRepository, pageable, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSetTag> findByRsql(final Pageable pageable, final String rsqlParam) {
|
public Page<DistributionSetTag> findByRsql(final String rsqlParam, final Pageable pageable) {
|
||||||
final Specification<JpaDistributionSetTag> spec = RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetTagFields.class,
|
final Specification<JpaDistributionSetTag> spec = RSQLUtility.buildRsqlSpecification(
|
||||||
virtualPropertyReplacer, database);
|
rsqlParam, DistributionSetTagFields.class, virtualPropertyReplacer, database);
|
||||||
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTagRepository, Collections.singletonList(spec), pageable);
|
||||||
|
}
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTagRepository, pageable,
|
@Override
|
||||||
Collections.singletonList(spec));
|
public Optional<DistributionSetTag> findByName(final String name) {
|
||||||
|
return distributionSetTagRepository.findByNameEquals(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<DistributionSetTag> findByDistributionSet(final Pageable pageable, final long distributionSetId) {
|
||||||
|
if (!distributionSetRepository.existsById(distributionSetId)) {
|
||||||
|
throw new EntityNotFoundException(DistributionSet.class, distributionSetId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTagRepository,
|
||||||
|
Collections.singletonList(TagSpecification.ofDistributionSet(distributionSetId)), pageable
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -174,22 +188,6 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
|||||||
final JpaDistributionSetTag dsTag = distributionSetTagRepository
|
final JpaDistributionSetTag dsTag = distributionSetTagRepository
|
||||||
.findOne(DistributionSetTagSpecifications.byName(tagName))
|
.findOne(DistributionSetTagSpecifications.byName(tagName))
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, tagName));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, tagName));
|
||||||
|
|
||||||
distributionSetTagRepository.delete(dsTag);
|
distributionSetTagRepository.delete(dsTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<DistributionSetTag> getByName(final String name) {
|
|
||||||
return distributionSetTagRepository.findByNameEquals(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<DistributionSetTag> findByDistributionSet(final Pageable pageable, final long distributionSetId) {
|
|
||||||
if (!distributionSetRepository.existsById(distributionSetId)) {
|
|
||||||
throw new EntityNotFoundException(DistributionSet.class, distributionSetId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTagRepository, pageable,
|
|
||||||
Collections.singletonList(TagSpecification.ofDistributionSet(distributionSetId)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,43 +88,6 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
this.quotaManagement = quotaManagement;
|
this.quotaManagement = quotaManagement;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<DistributionSetType> getByKey(final String key) {
|
|
||||||
return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byKey(key)).map(DistributionSetType.class::cast);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<DistributionSetType> getByName(final String name) {
|
|
||||||
return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byName(name)).map(DistributionSetType.class::cast);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
|
||||||
public DistributionSetType assignOptionalSoftwareModuleTypes(final long id, final Collection<Long> softwareModulesTypeIds) {
|
|
||||||
return assignSoftwareModuleTypes(id, softwareModulesTypeIds, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
|
||||||
public DistributionSetType assignMandatorySoftwareModuleTypes(final long id, final Collection<Long> softwareModuleTypeIds) {
|
|
||||||
return assignSoftwareModuleTypes(id, softwareModuleTypeIds, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
|
||||||
public DistributionSetType unassignSoftwareModuleType(final long id, final long softwareModuleTypeId) {
|
|
||||||
final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(id);
|
|
||||||
checkDistributionSetTypeNotAssigned(id);
|
|
||||||
type.removeModuleType(softwareModuleTypeId);
|
|
||||||
return distributionSetTypeRepository.save(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
@@ -184,11 +147,6 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
return distributionSetTypeRepository.save(type);
|
return distributionSetTypeRepository.save(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long count() {
|
|
||||||
return distributionSetTypeRepository.count(DistributionSetTypeSpecification.isNotDeleted());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
@@ -215,6 +173,11 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
distributionSetTypeRepository.deleteAllById(ids);
|
distributionSetTypeRepository.deleteAllById(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<DistributionSetType> get(final long id) {
|
||||||
|
return distributionSetTypeRepository.findById(id).map(DistributionSetType.class::cast);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DistributionSetType> get(final Collection<Long> ids) {
|
public List<DistributionSetType> get(final Collection<Long> ids) {
|
||||||
return Collections.unmodifiableList(distributionSetTypeRepository.findAllById(ids));
|
return Collections.unmodifiableList(distributionSetTypeRepository.findAllById(ids));
|
||||||
@@ -226,8 +189,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSetType> get(final long id) {
|
public long count() {
|
||||||
return distributionSetTypeRepository.findById(id).map(DistributionSetType.class::cast);
|
return distributionSetTypeRepository.count(DistributionSetTypeSpecification.isNotDeleted());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -237,10 +200,47 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSetType> findByRsql(final Pageable pageable, final String rsqlParam) {
|
public Page<DistributionSetType> findByRsql(final String rsqlParam, final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTypeRepository, pageable, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTypeRepository, List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetTypeFields.class, virtualPropertyReplacer, database),
|
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetTypeFields.class, virtualPropertyReplacer, database),
|
||||||
DistributionSetTypeSpecification.isNotDeleted()));
|
DistributionSetTypeSpecification.isNotDeleted()), pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<DistributionSetType> findByKey(final String key) {
|
||||||
|
return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byKey(key)).map(DistributionSetType.class::cast);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<DistributionSetType> findByName(final String name) {
|
||||||
|
return distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byName(name)).map(DistributionSetType.class::cast);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public DistributionSetType assignOptionalSoftwareModuleTypes(final long id, final Collection<Long> softwareModulesTypeIds) {
|
||||||
|
return assignSoftwareModuleTypes(id, softwareModulesTypeIds, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public DistributionSetType assignMandatorySoftwareModuleTypes(final long id, final Collection<Long> softwareModuleTypeIds) {
|
||||||
|
return assignSoftwareModuleTypes(id, softwareModuleTypeIds, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public DistributionSetType unassignSoftwareModuleType(final long id, final long softwareModuleTypeId) {
|
||||||
|
final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(id);
|
||||||
|
checkDistributionSetTypeNotAssigned(id);
|
||||||
|
type.removeModuleType(softwareModuleTypeId);
|
||||||
|
return distributionSetTypeRepository.save(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void removeModuleTypes(
|
private static void removeModuleTypes(
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
database),
|
database),
|
||||||
(root, query, cb) -> cb.equal(root.get(JpaRolloutGroup_.rollout).get(JpaRollout_.id), rolloutId));
|
(root, query, cb) -> cb.equal(root.get(JpaRolloutGroup_.rollout).get(JpaRollout_.id), rolloutId));
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(rolloutGroupRepository, pageable, specList);
|
return JpaManagementHelper.findAllWithCountBySpec(rolloutGroupRepository, specList, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -180,11 +180,13 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
// in case of status ready the action has not been created yet and
|
// in case of status ready the action has not been created yet and
|
||||||
// the relation information between target and rollout-group is
|
// the relation information between target and rollout-group is
|
||||||
// stored in the #TargetRolloutGroup.
|
// stored in the #TargetRolloutGroup.
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, page,
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository,
|
||||||
Collections.singletonList(TargetSpecifications.isInRolloutGroup(rolloutGroupId)));
|
Collections.singletonList(TargetSpecifications.isInRolloutGroup(rolloutGroupId)), page
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, page,
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository,
|
||||||
Collections.singletonList(TargetSpecifications.isInActionRolloutGroup(rolloutGroupId)));
|
Collections.singletonList(TargetSpecifications.isInActionRolloutGroup(rolloutGroupId)), page
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -201,7 +203,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
rolloutGroupId);
|
rolloutGroupId);
|
||||||
});
|
});
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, pageable, specList);
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -178,11 +178,6 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
return softwareModuleRepository.save(module);
|
return softwareModuleRepository.save(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long count() {
|
|
||||||
return softwareModuleRepository.count(SoftwareModuleSpecification.isNotDeleted());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
@@ -238,6 +233,11 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<SoftwareModule> get(final long id) {
|
||||||
|
return softwareModuleRepository.findById(id).map(SoftwareModule.class::cast);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SoftwareModule> get(final Collection<Long> ids) {
|
public List<SoftwareModule> get(final Collection<Long> ids) {
|
||||||
return Collections.unmodifiableList(softwareModuleRepository.findAllById(ids));
|
return Collections.unmodifiableList(softwareModuleRepository.findAllById(ids));
|
||||||
@@ -249,8 +249,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SoftwareModule> get(final long id) {
|
public long count() {
|
||||||
return softwareModuleRepository.findById(id).map(SoftwareModule.class::cast);
|
return softwareModuleRepository.count(SoftwareModuleSpecification.isNotDeleted());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -261,18 +261,18 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<SoftwareModule> findByRsql(final Pageable pageable, final String rsqlParam) {
|
public Page<SoftwareModule> findByRsql(final String rsqlParam, final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleRepository, pageable, List.of(
|
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleRepository, List.of(
|
||||||
RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleFields.class, virtualPropertyReplacer,
|
RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleFields.class, virtualPropertyReplacer,
|
||||||
database),
|
database),
|
||||||
SoftwareModuleSpecification.isNotDeleted()));
|
SoftwareModuleSpecification.isNotDeleted()), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<SoftwareModuleMetadata> createMetaData(final Collection<SoftwareModuleMetadataCreate> create) {
|
public List<SoftwareModuleMetadata> putMetaData(final Collection<SoftwareModuleMetadataCreate> create) {
|
||||||
if (!create.isEmpty()) {
|
if (!create.isEmpty()) {
|
||||||
// check if all metadata entries refer to the same software module
|
// check if all metadata entries refer to the same software module
|
||||||
final Long id = ((JpaSoftwareModuleMetadataCreate) create.iterator().next()).getSoftwareModuleId();
|
final Long id = ((JpaSoftwareModuleMetadataCreate) create.iterator().next()).getSoftwareModuleId();
|
||||||
@@ -309,7 +309,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public SoftwareModuleMetadata createMetaData(final SoftwareModuleMetadataCreate c) {
|
public SoftwareModuleMetadata updateMetaData(final SoftwareModuleMetadataCreate c) {
|
||||||
final JpaSoftwareModuleMetadataCreate create = (JpaSoftwareModuleMetadataCreate) c;
|
final JpaSoftwareModuleMetadataCreate create = (JpaSoftwareModuleMetadataCreate) c;
|
||||||
final Long id = create.getSoftwareModuleId();
|
final Long id = create.getSoftwareModuleId();
|
||||||
|
|
||||||
@@ -322,12 +322,31 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
return saveMetadata(create);
|
return saveMetadata(create);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public SoftwareModuleMetadata updateMetaData(final SoftwareModuleMetadataUpdate u) {
|
||||||
|
final GenericSoftwareModuleMetadataUpdate update = (GenericSoftwareModuleMetadataUpdate) u;
|
||||||
|
|
||||||
|
// check if exists otherwise throw entity not found exception
|
||||||
|
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) findMetaDataBySoftwareModuleId(
|
||||||
|
update.getSoftwareModuleId(), update.getKey())
|
||||||
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, update.getSoftwareModuleId(), update.getKey()));
|
||||||
|
|
||||||
|
update.getValue().ifPresent(metadata::setValue);
|
||||||
|
update.isTargetVisible().ifPresent(metadata::setTargetVisible);
|
||||||
|
|
||||||
|
JpaManagementHelper.touch(entityManager, softwareModuleRepository, metadata.getSoftwareModule());
|
||||||
|
return softwareModuleMetadataRepository.save(metadata);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteMetaData(final long id, final String key) {
|
public void deleteMetaData(final long id, final String key) {
|
||||||
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) getMetaDataBySoftwareModuleId(id,
|
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) findMetaDataBySoftwareModuleId(id,
|
||||||
key).orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, id, key));
|
key).orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, id, key));
|
||||||
|
|
||||||
JpaManagementHelper.touch(entityManager, softwareModuleRepository,
|
JpaManagementHelper.touch(entityManager, softwareModuleRepository,
|
||||||
@@ -335,111 +354,6 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
softwareModuleMetadataRepository.deleteById(metadata.getId());
|
softwareModuleMetadataRepository.deleteById(metadata.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<SoftwareModule> findByAssignedTo(final Pageable pageable, final long distributionSetId) {
|
|
||||||
assertDistributionSetExists(distributionSetId);
|
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleRepository, pageable,
|
|
||||||
Collections.singletonList(SoftwareModuleSpecification.byAssignedToDs(distributionSetId)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long countByAssignedTo(final long distributionSetId) {
|
|
||||||
assertDistributionSetExists(distributionSetId);
|
|
||||||
|
|
||||||
return softwareModuleRepository.count(SoftwareModuleSpecification.byAssignedToDs(distributionSetId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Slice<SoftwareModule> findByTextAndType(final Pageable pageable, final String searchText,
|
|
||||||
final Long typeId) {
|
|
||||||
final List<Specification<JpaSoftwareModule>> specList = new ArrayList<>(3);
|
|
||||||
specList.add(SoftwareModuleSpecification.isNotDeleted());
|
|
||||||
|
|
||||||
if (!ObjectUtils.isEmpty(searchText)) {
|
|
||||||
specList.add(buildSmSearchQuerySpec(searchText));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null != typeId) {
|
|
||||||
assertSoftwareModuleTypeExists(typeId);
|
|
||||||
specList.add(SoftwareModuleSpecification.equalType(typeId));
|
|
||||||
}
|
|
||||||
|
|
||||||
specList.add(SoftwareModuleSpecification.fetchType());
|
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithoutCountBySpec(softwareModuleRepository, pageable, specList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<SoftwareModule> getByNameAndVersionAndType(final String name, final String version,
|
|
||||||
final long typeId) {
|
|
||||||
assertSoftwareModuleTypeExists(typeId);
|
|
||||||
|
|
||||||
// TODO AC - Access is restricted. This could have problem with UI when access control is enabled.
|
|
||||||
// Vaadin UI use this for validation. May need to be called via elevated access
|
|
||||||
return JpaManagementHelper
|
|
||||||
.findOneBySpec(softwareModuleRepository, List.of(
|
|
||||||
SoftwareModuleSpecification.likeNameAndVersion(name, version),
|
|
||||||
SoftwareModuleSpecification.equalType(typeId),
|
|
||||||
SoftwareModuleSpecification.fetchType()))
|
|
||||||
.map(SoftwareModule.class::cast);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<SoftwareModuleMetadata> getMetaDataBySoftwareModuleId(final long id, final String key) {
|
|
||||||
assertSoftwareModuleExists(id);
|
|
||||||
|
|
||||||
return softwareModuleMetadataRepository.findById(new SwMetadataCompositeKey(id, key))
|
|
||||||
.map(SoftwareModuleMetadata.class::cast);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleId(final Pageable pageable, final long id) {
|
|
||||||
assertSoftwareModuleExists(id);
|
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleMetadataRepository, pageable,
|
|
||||||
Collections.singletonList(metadataBySoftwareModuleIdSpec(id)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long countMetaDataBySoftwareModuleId(final long id) {
|
|
||||||
assertSoftwareModuleExists(id);
|
|
||||||
|
|
||||||
return softwareModuleMetadataRepository.countBySoftwareModuleId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleIdAndTargetVisible(final Pageable pageable,
|
|
||||||
final long id) {
|
|
||||||
assertSoftwareModuleExists(id);
|
|
||||||
|
|
||||||
return JpaManagementHelper.convertPage(softwareModuleMetadataRepository.findBySoftwareModuleIdAndTargetVisible(
|
|
||||||
id, true, PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT)), pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<SoftwareModuleMetadata> findMetaDataByRsql(final Pageable pageable, final long id,
|
|
||||||
final String rsqlParam) {
|
|
||||||
assertSoftwareModuleExists(id);
|
|
||||||
|
|
||||||
final List<Specification<JpaSoftwareModuleMetadata>> specList = Arrays
|
|
||||||
.asList(RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleMetadataFields.class,
|
|
||||||
virtualPropertyReplacer, database), metadataBySoftwareModuleIdSpec(id));
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleMetadataRepository, pageable, specList);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Slice<SoftwareModule> findByType(final Pageable pageable, final long typeId) {
|
|
||||||
assertSoftwareModuleTypeExists(typeId);
|
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithoutCountBySpec(
|
|
||||||
softwareModuleRepository,
|
|
||||||
pageable,
|
|
||||||
List.of(
|
|
||||||
SoftwareModuleSpecification.equalType(typeId),
|
|
||||||
SoftwareModuleSpecification.isNotDeleted()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
@@ -469,22 +383,94 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
public Page<SoftwareModule> findByAssignedTo(final long distributionSetId, final Pageable pageable) {
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
assertDistributionSetExists(distributionSetId);
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
|
||||||
public SoftwareModuleMetadata updateMetaData(final SoftwareModuleMetadataUpdate u) {
|
|
||||||
final GenericSoftwareModuleMetadataUpdate update = (GenericSoftwareModuleMetadataUpdate) u;
|
|
||||||
|
|
||||||
// check if exists otherwise throw entity not found exception
|
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleRepository,
|
||||||
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) getMetaDataBySoftwareModuleId(
|
Collections.singletonList(SoftwareModuleSpecification.byAssignedToDs(distributionSetId)), pageable
|
||||||
update.getSoftwareModuleId(), update.getKey())
|
);
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, update.getSoftwareModuleId(), update.getKey()));
|
}
|
||||||
|
|
||||||
update.getValue().ifPresent(metadata::setValue);
|
@Override
|
||||||
update.isTargetVisible().ifPresent(metadata::setTargetVisible);
|
public Slice<SoftwareModule> findByTextAndType(final String searchText, final Long typeId, final Pageable pageable) {
|
||||||
|
final List<Specification<JpaSoftwareModule>> specList = new ArrayList<>(3);
|
||||||
|
specList.add(SoftwareModuleSpecification.isNotDeleted());
|
||||||
|
|
||||||
JpaManagementHelper.touch(entityManager, softwareModuleRepository, metadata.getSoftwareModule());
|
if (!ObjectUtils.isEmpty(searchText)) {
|
||||||
return softwareModuleMetadataRepository.save(metadata);
|
specList.add(buildSmSearchQuerySpec(searchText));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null != typeId) {
|
||||||
|
assertSoftwareModuleTypeExists(typeId);
|
||||||
|
specList.add(SoftwareModuleSpecification.equalType(typeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
specList.add(SoftwareModuleSpecification.fetchType());
|
||||||
|
|
||||||
|
return JpaManagementHelper.findAllWithoutCountBySpec(softwareModuleRepository, pageable, specList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<SoftwareModule> findByNameAndVersionAndType(final String name, final String version,
|
||||||
|
final long typeId) {
|
||||||
|
assertSoftwareModuleTypeExists(typeId);
|
||||||
|
|
||||||
|
// TODO AC - Access is restricted. This could have problem with UI when access control is enabled.
|
||||||
|
// Vaadin UI use this for validation. May need to be called via elevated access
|
||||||
|
return JpaManagementHelper
|
||||||
|
.findOneBySpec(softwareModuleRepository, List.of(
|
||||||
|
SoftwareModuleSpecification.likeNameAndVersion(name, version),
|
||||||
|
SoftwareModuleSpecification.equalType(typeId),
|
||||||
|
SoftwareModuleSpecification.fetchType()))
|
||||||
|
.map(SoftwareModule.class::cast);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<SoftwareModuleMetadata> findMetaDataBySoftwareModuleId(final long id, final String key) {
|
||||||
|
assertSoftwareModuleExists(id);
|
||||||
|
|
||||||
|
return softwareModuleMetadataRepository.findById(new SwMetadataCompositeKey(id, key))
|
||||||
|
.map(SoftwareModuleMetadata.class::cast);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleId(final Pageable pageable, final long id) {
|
||||||
|
assertSoftwareModuleExists(id);
|
||||||
|
|
||||||
|
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleMetadataRepository,
|
||||||
|
Collections.singletonList(metadataBySoftwareModuleIdSpec(id)), pageable
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleIdAndTargetVisible(final Pageable pageable,
|
||||||
|
final long id) {
|
||||||
|
assertSoftwareModuleExists(id);
|
||||||
|
|
||||||
|
return JpaManagementHelper.convertPage(softwareModuleMetadataRepository.findBySoftwareModuleIdAndTargetVisible(
|
||||||
|
id, true, PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT)), pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<SoftwareModuleMetadata> findMetaDataByRsql(final long id, final String rsqlParam, final Pageable pageable) {
|
||||||
|
assertSoftwareModuleExists(id);
|
||||||
|
|
||||||
|
final List<Specification<JpaSoftwareModuleMetadata>> specList = Arrays
|
||||||
|
.asList(RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleMetadataFields.class,
|
||||||
|
virtualPropertyReplacer, database), metadataBySoftwareModuleIdSpec(id));
|
||||||
|
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleMetadataRepository, specList, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Slice<SoftwareModule> findByType(final long typeId, final Pageable pageable) {
|
||||||
|
assertSoftwareModuleTypeExists(typeId);
|
||||||
|
|
||||||
|
return JpaManagementHelper.findAllWithoutCountBySpec(
|
||||||
|
softwareModuleRepository,
|
||||||
|
pageable,
|
||||||
|
List.of(
|
||||||
|
SoftwareModuleSpecification.equalType(typeId),
|
||||||
|
SoftwareModuleSpecification.isNotDeleted()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -495,6 +481,20 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
.collect(Collectors.groupingBy(o -> (Long) o[0], Collectors.mapping(o -> (SoftwareModuleMetadata) o[1], Collectors.toList())));
|
.collect(Collectors.groupingBy(o -> (Long) o[0], Collectors.mapping(o -> (SoftwareModuleMetadata) o[1], Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long countByAssignedTo(final long distributionSetId) {
|
||||||
|
assertDistributionSetExists(distributionSetId);
|
||||||
|
|
||||||
|
return softwareModuleRepository.count(SoftwareModuleSpecification.byAssignedToDs(distributionSetId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long countMetaDataBySoftwareModuleId(final long id) {
|
||||||
|
assertSoftwareModuleExists(id);
|
||||||
|
|
||||||
|
return softwareModuleMetadataRepository.countBySoftwareModuleId(id);
|
||||||
|
}
|
||||||
|
|
||||||
private static Stream<JpaSoftwareModuleMetadataCreate> createJpaMetadataCreateStream(
|
private static Stream<JpaSoftwareModuleMetadataCreate> createJpaMetadataCreateStream(
|
||||||
final Collection<SoftwareModuleMetadataCreate> create) {
|
final Collection<SoftwareModuleMetadataCreate> create) {
|
||||||
return create.stream().map(JpaSoftwareModuleMetadataCreate.class::cast);
|
return create.stream().map(JpaSoftwareModuleMetadataCreate.class::cast);
|
||||||
|
|||||||
@@ -69,27 +69,6 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
this.database = database;
|
this.database = database;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<SoftwareModuleType> getByKey(final String key) {
|
|
||||||
return softwareModuleTypeRepository.findByKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<SoftwareModuleType> getByName(final String name) {
|
|
||||||
return softwareModuleTypeRepository.findByName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
|
||||||
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
|
||||||
public List<SoftwareModuleType> create(final Collection<SoftwareModuleTypeCreate> c) {
|
|
||||||
final List<JpaSoftwareModuleType> creates = c.stream().map(JpaSoftwareModuleTypeCreate.class::cast)
|
|
||||||
.map(JpaSoftwareModuleTypeCreate::build).toList();
|
|
||||||
return Collections.unmodifiableList(
|
|
||||||
softwareModuleTypeRepository.saveAll(AccessController.Operation.CREATE, creates));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
@@ -118,11 +97,6 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
return softwareModuleTypeRepository.save(type);
|
return softwareModuleTypeRepository.save(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long count() {
|
|
||||||
return softwareModuleTypeRepository.count(SoftwareModuleTypeSpecification.isNotDeleted());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
@@ -144,6 +118,11 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
.forEach(this::delete);
|
.forEach(this::delete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<SoftwareModuleType> get(final long id) {
|
||||||
|
return softwareModuleTypeRepository.findById(id).map(SoftwareModuleType.class::cast);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SoftwareModuleType> get(final Collection<Long> ids) {
|
public List<SoftwareModuleType> get(final Collection<Long> ids) {
|
||||||
return Collections.unmodifiableList(softwareModuleTypeRepository.findAllById(ids));
|
return Collections.unmodifiableList(softwareModuleTypeRepository.findAllById(ids));
|
||||||
@@ -155,8 +134,8 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SoftwareModuleType> get(final long id) {
|
public long count() {
|
||||||
return softwareModuleTypeRepository.findById(id).map(SoftwareModuleType.class::cast);
|
return softwareModuleTypeRepository.count(SoftwareModuleTypeSpecification.isNotDeleted());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -166,12 +145,33 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<SoftwareModuleType> findByRsql(final Pageable pageable, final String rsqlParam) {
|
public Page<SoftwareModuleType> findByRsql(final String rsqlParam, final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleTypeRepository, pageable,
|
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleTypeRepository, List.of(
|
||||||
List.of(
|
RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleTypeFields.class,
|
||||||
RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleTypeFields.class,
|
virtualPropertyReplacer, database),
|
||||||
virtualPropertyReplacer, database),
|
SoftwareModuleTypeSpecification.isNotDeleted()), pageable
|
||||||
SoftwareModuleTypeSpecification.isNotDeleted()));
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<SoftwareModuleType> findByKey(final String key) {
|
||||||
|
return softwareModuleTypeRepository.findByKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<SoftwareModuleType> findByName(final String name) {
|
||||||
|
return softwareModuleTypeRepository.findByName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(retryFor = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX,
|
||||||
|
backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public List<SoftwareModuleType> create(final Collection<SoftwareModuleTypeCreate> c) {
|
||||||
|
final List<JpaSoftwareModuleType> creates = c.stream().map(JpaSoftwareModuleTypeCreate.class::cast)
|
||||||
|
.map(JpaSoftwareModuleTypeCreate::build).toList();
|
||||||
|
return Collections.unmodifiableList(
|
||||||
|
softwareModuleTypeRepository.saveAll(AccessController.Operation.CREATE, creates));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void delete(JpaSoftwareModuleType toDelete) {
|
private void delete(JpaSoftwareModuleType toDelete) {
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
TargetFilterQueryFields.class, virtualPropertyReplacer, database))
|
TargetFilterQueryFields.class, virtualPropertyReplacer, database))
|
||||||
: Collections.emptyList();
|
: Collections.emptyList();
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetFilterQueryRepository, pageable, specList);
|
return JpaManagementHelper.findAllWithCountBySpec(targetFilterQueryRepository, specList, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -225,7 +225,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
virtualPropertyReplacer, database));
|
virtualPropertyReplacer, database));
|
||||||
}
|
}
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetFilterQueryRepository, pageable, specList);
|
return JpaManagementHelper.findAllWithCountBySpec(targetFilterQueryRepository, specList, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
TargetSpecifications.failedActionsForRollout(rolloutId),
|
TargetSpecifications.failedActionsForRollout(rolloutId),
|
||||||
TargetSpecifications.isNotInRolloutGroups(groups));
|
TargetSpecifications.isNotInRolloutGroups(groups));
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, pageRequest, specList);
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -382,8 +382,9 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
public Page<Target> findByAssignedDistributionSet(final Pageable pageReq, final long distributionSetId) {
|
public Page<Target> findByAssignedDistributionSet(final Pageable pageReq, final long distributionSetId) {
|
||||||
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, pageReq,
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository,
|
||||||
List.of(TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId())));
|
List.of(TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId())), pageReq
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -395,7 +396,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database),
|
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId()));
|
TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId()));
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, pageReq, specList);
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -419,8 +420,9 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
public Page<Target> findByInstalledDistributionSet(final Pageable pageReq, final long distributionSetId) {
|
public Page<Target> findByInstalledDistributionSet(final Pageable pageReq, final long distributionSetId) {
|
||||||
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, pageReq,
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository,
|
||||||
List.of(TargetSpecifications.hasInstalledDistributionSet(validDistSet.getId())));
|
List.of(TargetSpecifications.hasInstalledDistributionSet(validDistSet.getId())), pageReq
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -432,13 +434,14 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database),
|
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.hasInstalledDistributionSet(validDistSet.getId()));
|
TargetSpecifications.hasInstalledDistributionSet(validDistSet.getId()));
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, pageable, specList);
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findByUpdateStatus(final Pageable pageable, final TargetUpdateStatus status) {
|
public Page<Target> findByUpdateStatus(final Pageable pageable, final TargetUpdateStatus status) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, pageable,
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, List.of(TargetSpecifications.hasTargetUpdateStatus(status)),
|
||||||
List.of(TargetSpecifications.hasTargetUpdateStatus(status)));
|
pageable
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -466,8 +469,8 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
public Page<Target> findByTag(final Pageable pageable, final long tagId) {
|
public Page<Target> findByTag(final Pageable pageable, final long tagId) {
|
||||||
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
|
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, pageable,
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, List.of(TargetSpecifications.hasTag(tagId)), pageable
|
||||||
List.of(TargetSpecifications.hasTag(tagId)));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -478,7 +481,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database),
|
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database),
|
||||||
TargetSpecifications.hasTag(tagId));
|
TargetSpecifications.hasTag(tagId));
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, pageable, specList);
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -685,8 +688,9 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findByControllerAttributesRequested(final Pageable pageReq) {
|
public Page<Target> findByControllerAttributesRequested(final Pageable pageReq) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, pageReq,
|
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, List.of(TargetSpecifications.hasRequestControllerAttributesTrue()),
|
||||||
List.of(TargetSpecifications.hasRequestControllerAttributesTrue()));
|
pageReq
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -770,8 +774,9 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
public Page<TargetMetadata> findMetaDataByControllerId(final Pageable pageable, final String controllerId) {
|
public Page<TargetMetadata> findMetaDataByControllerId(final Pageable pageable, final String controllerId) {
|
||||||
final Long id = getByControllerIdAndThrowIfNotFound(controllerId).getId();
|
final Long id = getByControllerIdAndThrowIfNotFound(controllerId).getId();
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetMetadataRepository, pageable,
|
return JpaManagementHelper.findAllWithCountBySpec(targetMetadataRepository, Collections.singletonList(metadataByTargetIdSpec(id)),
|
||||||
Collections.singletonList(metadataByTargetIdSpec(id)));
|
pageable
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -791,7 +796,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
.buildRsqlSpecification(rsqlParam, TargetMetadataFields.class, virtualPropertyReplacer, database),
|
.buildRsqlSpecification(rsqlParam, TargetMetadataFields.class, virtualPropertyReplacer, database),
|
||||||
metadataByTargetIdSpec(targetId));
|
metadataByTargetIdSpec(targetId));
|
||||||
|
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetMetadataRepository, pageable, specList);
|
return JpaManagementHelper.findAllWithCountBySpec(targetMetadataRepository, specList, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -99,13 +99,13 @@ public class JpaTargetTagManagement implements TargetTagManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<TargetTag> findAll(final Pageable pageable) {
|
public Page<TargetTag> findAll(final Pageable pageable) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetTagRepository, pageable, null);
|
return JpaManagementHelper.findAllWithCountBySpec(targetTagRepository, null, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<TargetTag> findByRsql(final Pageable pageable, final String rsqlParam) {
|
public Page<TargetTag> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetTagRepository, pageable, Collections.singletonList(
|
return JpaManagementHelper.findAllWithCountBySpec(targetTagRepository, Collections.singletonList(
|
||||||
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetTagFields.class, virtualPropertyReplacer, database)));
|
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetTagFields.class, virtualPropertyReplacer, database)), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -144,10 +144,10 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<TargetType> findByRsql(final Pageable pageable, final String rsqlParam) {
|
public Page<TargetType> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||||
return JpaManagementHelper.findAllWithCountBySpec(targetTypeRepository, pageable,
|
return JpaManagementHelper.findAllWithCountBySpec(targetTypeRepository, List.of(
|
||||||
List.of(
|
RSQLUtility.buildRsqlSpecification(
|
||||||
RSQLUtility.buildRsqlSpecification(
|
rsqlParam, TargetTypeFields.class, virtualPropertyReplacer, database)), pageable
|
||||||
rsqlParam, TargetTypeFields.class, virtualPropertyReplacer, database)));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import java.util.List;
|
|||||||
import io.qameta.allure.Description;
|
import io.qameta.allure.Description;
|
||||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||||
import org.eclipse.hawkbit.repository.RepositoryManagement;
|
import org.eclipse.hawkbit.repository.RepositoryManagement;
|
||||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
@@ -105,7 +104,7 @@ public abstract class AbstractRepositoryManagementSecurityTest<T, C, U> extends
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions.")
|
||||||
public void findByRsqlPermissionCheck() {
|
public void findByRsqlPermissionCheck() {
|
||||||
assertPermissions(() -> getRepositoryManagement().findByRsql(Pageable.ofSize(1), "(name==*)"), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> getRepositoryManagement().findByRsql("(name==*)", Pageable.ofSize(1)), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
|
|||||||
.containsOnly(permitted.getId());
|
.containsOnly(permitted.getId());
|
||||||
|
|
||||||
// verify distributionSetManagement#findByRsql
|
// verify distributionSetManagement#findByRsql
|
||||||
assertThat(distributionSetManagement.findByRsql(Pageable.unpaged(), "name==*").get().map(Identifiable::getId)
|
assertThat(distributionSetManagement.findByRsql("name==*", Pageable.unpaged()).get().map(Identifiable::getId)
|
||||||
.toList()).containsOnly(permitted.getId());
|
.toList()).containsOnly(permitted.getId());
|
||||||
|
|
||||||
// verify distributionSetManagement#findByCompleted
|
// verify distributionSetManagement#findByCompleted
|
||||||
@@ -82,8 +82,8 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
|
|||||||
|
|
||||||
// verify distributionSetManagement#findByDistributionSetFilter
|
// verify distributionSetManagement#findByDistributionSetFilter
|
||||||
assertThat(distributionSetManagement
|
assertThat(distributionSetManagement
|
||||||
.findByDistributionSetFilter(Pageable.unpaged(),
|
.findByDistributionSetFilter(DistributionSetFilter.builder().isDeleted(false).build(), Pageable.unpaged()
|
||||||
DistributionSetFilter.builder().isDeleted(false).build())
|
)
|
||||||
.get().map(Identifiable::getId).toList()).containsOnly(permitted.getId());
|
.get().map(Identifiable::getId).toList()).containsOnly(permitted.getId());
|
||||||
|
|
||||||
// verify distributionSetManagement#get
|
// verify distributionSetManagement#get
|
||||||
@@ -106,14 +106,14 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
|
|||||||
}).as("Fail if request hidden.").isInstanceOf(EntityNotFoundException.class);
|
}).as("Fail if request hidden.").isInstanceOf(EntityNotFoundException.class);
|
||||||
|
|
||||||
// verify distributionSetManagement#getByNameAndVersion
|
// verify distributionSetManagement#getByNameAndVersion
|
||||||
assertThat(distributionSetManagement.getByNameAndVersion(permitted.getName(), permitted.getVersion()))
|
assertThat(distributionSetManagement.findByNameAndVersion(permitted.getName(), permitted.getVersion()))
|
||||||
.isPresent();
|
.isPresent();
|
||||||
assertThat(distributionSetManagement.getByNameAndVersion(hidden.getName(), hidden.getVersion())).isEmpty();
|
assertThat(distributionSetManagement.findByNameAndVersion(hidden.getName(), hidden.getVersion())).isEmpty();
|
||||||
|
|
||||||
// verify distributionSetManagement#getByAction
|
// verify distributionSetManagement#getByAction
|
||||||
assertThat(distributionSetManagement.getByAction(permittedAction.getId())).isPresent();
|
assertThat(distributionSetManagement.findByAction(permittedAction.getId())).isPresent();
|
||||||
assertThatThrownBy(() -> {
|
assertThatThrownBy(() -> {
|
||||||
distributionSetManagement.getByAction(hiddenAction.getId());
|
distributionSetManagement.findByAction(hiddenAction.getId());
|
||||||
}).as("Action is hidden.").isInstanceOf(InsufficientPermissionException.class);
|
}).as("Action is hidden.").isInstanceOf(InsufficientPermissionException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,11 +152,11 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
|
|||||||
final JpaDistributionSetMetadata metadata = new JpaDistributionSetMetadata("test", "test");
|
final JpaDistributionSetMetadata metadata = new JpaDistributionSetMetadata("test", "test");
|
||||||
|
|
||||||
// verify distributionSetManagement#createMetaData
|
// verify distributionSetManagement#createMetaData
|
||||||
distributionSetManagement.createMetaData(permitted.getId(), Collections.singletonList(metadata));
|
distributionSetManagement.putMetaData(permitted.getId(), Collections.singletonList(metadata));
|
||||||
assertThatThrownBy(() -> distributionSetManagement.createMetaData(readOnly.getId(), Collections.singletonList(metadata)))
|
assertThatThrownBy(() -> distributionSetManagement.putMetaData(readOnly.getId(), Collections.singletonList(metadata)))
|
||||||
.as("Distribution set not allowed to me modified.")
|
.as("Distribution set not allowed to me modified.")
|
||||||
.isInstanceOf(EntityNotFoundException.class);
|
.isInstanceOf(EntityNotFoundException.class);
|
||||||
assertThatThrownBy(() -> distributionSetManagement.createMetaData(hidden.getId(), Collections.singletonList(metadata)))
|
assertThatThrownBy(() -> distributionSetManagement.putMetaData(hidden.getId(), Collections.singletonList(metadata)))
|
||||||
.as("Distribution set should not be visible.")
|
.as("Distribution set should not be visible.")
|
||||||
.isInstanceOf(EntityNotFoundException.class);
|
.isInstanceOf(EntityNotFoundException.class);
|
||||||
|
|
||||||
@@ -204,10 +204,10 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
|
|||||||
// allow updating the permitted distributionSet
|
// allow updating the permitted distributionSet
|
||||||
defineAccess(AccessController.Operation.UPDATE, permitted);
|
defineAccess(AccessController.Operation.UPDATE, permitted);
|
||||||
|
|
||||||
assertThat(distributionSetManagement.findByTag(Pageable.unpaged(), dsTag.getId()).get().map(Identifiable::getId)
|
assertThat(distributionSetManagement.findByTag(dsTag.getId(), Pageable.unpaged()).get().map(Identifiable::getId)
|
||||||
.toList()).containsOnly(permitted.getId(), readOnly.getId());
|
.toList()).containsOnly(permitted.getId(), readOnly.getId());
|
||||||
|
|
||||||
assertThat(distributionSetManagement.findByRsqlAndTag(Pageable.unpaged(), "name==*", dsTag.getId()).get()
|
assertThat(distributionSetManagement.findByRsqlAndTag("name==*", dsTag.getId(), Pageable.unpaged()).get()
|
||||||
.map(Identifiable::getId).toList()).containsOnly(permitted.getId(), readOnly.getId());
|
.map(Identifiable::getId).toList()).containsOnly(permitted.getId(), readOnly.getId());
|
||||||
|
|
||||||
// verify distributionSetManagement#unassignTag on permitted target
|
// verify distributionSetManagement#unassignTag on permitted target
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
package org.eclipse.hawkbit.repository.jpa.management;
|
package org.eclipse.hawkbit.repository.jpa.management;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import io.qameta.allure.Description;
|
import io.qameta.allure.Description;
|
||||||
import io.qameta.allure.Feature;
|
import io.qameta.allure.Feature;
|
||||||
@@ -69,7 +68,7 @@ class DistributionSetManagementSecurityTest
|
|||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void createMetaDataPermissionsCheck() {
|
void createMetaDataPermissionsCheck() {
|
||||||
assertPermissions(
|
assertPermissions(
|
||||||
() -> distributionSetManagement.createMetaData(1L, List.of(entityFactory.generateTargetMetadata("key", "value"))),
|
() -> distributionSetManagement.putMetaData(1L, List.of(entityFactory.generateTargetMetadata("key", "value"))),
|
||||||
List.of(SpPermission.UPDATE_REPOSITORY));
|
List.of(SpPermission.UPDATE_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +102,7 @@ class DistributionSetManagementSecurityTest
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void getByActionPermissionsCheck() {
|
void getByActionPermissionsCheck() {
|
||||||
assertPermissions(() -> distributionSetManagement.getByAction(1L), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> distributionSetManagement.findByAction(1L), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -115,7 +114,7 @@ class DistributionSetManagementSecurityTest
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void getByNameAndVersionPermissionsCheck() {
|
void getByNameAndVersionPermissionsCheck() {
|
||||||
assertPermissions(() -> distributionSetManagement.getByNameAndVersion("name", "version"), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> distributionSetManagement.findByNameAndVersion("name", "version"), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -139,7 +138,7 @@ class DistributionSetManagementSecurityTest
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void findMetaDataByDistributionSetIdPermissionsCheck() {
|
void findMetaDataByDistributionSetIdPermissionsCheck() {
|
||||||
assertPermissions(() -> distributionSetManagement.findMetaDataByDistributionSetId(PAGE, 1L), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> distributionSetManagement.findMetaDataByDistributionSetId(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -151,7 +150,7 @@ class DistributionSetManagementSecurityTest
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void findMetaDataByDistributionSetIdAndRsqlPermissionsCheck() {
|
void findMetaDataByDistributionSetIdAndRsqlPermissionsCheck() {
|
||||||
assertPermissions(() -> distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(PAGE, 1L, "rsql"),
|
assertPermissions(() -> distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(1L, "rsql", PAGE),
|
||||||
List.of(SpPermission.READ_REPOSITORY));
|
List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +169,7 @@ class DistributionSetManagementSecurityTest
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void findByDistributionSetFilterPermissionsCheck() {
|
void findByDistributionSetFilterPermissionsCheck() {
|
||||||
assertPermissions(() -> distributionSetManagement.findByDistributionSetFilter(PAGE, DistributionSetFilter.builder().build()),
|
assertPermissions(() -> distributionSetManagement.findByDistributionSetFilter(DistributionSetFilter.builder().build(), PAGE),
|
||||||
List.of(SpPermission.READ_REPOSITORY));
|
List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,19 +183,19 @@ class DistributionSetManagementSecurityTest
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void findByTagPermissionsCheck() {
|
void findByTagPermissionsCheck() {
|
||||||
assertPermissions(() -> distributionSetManagement.findByTag(PAGE, 1L), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> distributionSetManagement.findByTag(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void findByRsqlAndTagPermissionsCheck() {
|
void findByRsqlAndTagPermissionsCheck() {
|
||||||
assertPermissions(() -> distributionSetManagement.findByRsqlAndTag(PAGE, "rsql", 1L), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> distributionSetManagement.findByRsqlAndTag("rsql", 1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void getMetaDataByDistributionSetIdPermissionsCheck() {
|
void getMetaDataByDistributionSetIdPermissionsCheck() {
|
||||||
assertPermissions(() -> distributionSetManagement.getMetaDataByDistributionSetId(1L, "key"), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> distributionSetManagement.findMetaDataByDistributionSetId(1L, "key"), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final DistributionSet set = testdataFactory.createDistributionSet();
|
final DistributionSet set = testdataFactory.createDistributionSet();
|
||||||
assertThat(distributionSetManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
assertThat(distributionSetManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||||
assertThat(distributionSetManagement.getWithDetails(NOT_EXIST_IDL)).isNotPresent();
|
assertThat(distributionSetManagement.getWithDetails(NOT_EXIST_IDL)).isNotPresent();
|
||||||
assertThat(distributionSetManagement.getByNameAndVersion(NOT_EXIST_ID, NOT_EXIST_ID)).isNotPresent();
|
assertThat(distributionSetManagement.findByNameAndVersion(NOT_EXIST_ID, NOT_EXIST_ID)).isNotPresent();
|
||||||
assertThat(distributionSetManagement.getMetaDataByDistributionSetId(set.getId(), NOT_EXIST_ID)).isNotPresent();
|
assertThat(distributionSetManagement.findMetaDataByDistributionSetId(set.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -125,8 +125,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
verifyThrownExceptionBy(() -> distributionSetManagement.assignTag(singletonList(set.getId()), NOT_EXIST_IDL), "DistributionSetTag");
|
verifyThrownExceptionBy(() -> distributionSetManagement.assignTag(singletonList(set.getId()), NOT_EXIST_IDL), "DistributionSetTag");
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.assignTag(singletonList(NOT_EXIST_IDL), dsTag.getId()), "DistributionSet");
|
verifyThrownExceptionBy(() -> distributionSetManagement.assignTag(singletonList(NOT_EXIST_IDL), dsTag.getId()), "DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.findByTag(PAGE, NOT_EXIST_IDL), "DistributionSetTag");
|
verifyThrownExceptionBy(() -> distributionSetManagement.findByTag(NOT_EXIST_IDL, PAGE), "DistributionSetTag");
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.findByRsqlAndTag(PAGE, "name==*", NOT_EXIST_IDL), "DistributionSetTag");
|
verifyThrownExceptionBy(() -> distributionSetManagement.findByRsqlAndTag("name==*", NOT_EXIST_IDL, PAGE), "DistributionSetTag");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.assignTag(singletonList(NOT_EXIST_IDL), dsTag.getId()), "DistributionSet");
|
verifyThrownExceptionBy(() -> distributionSetManagement.assignTag(singletonList(NOT_EXIST_IDL), dsTag.getId()), "DistributionSet");
|
||||||
verifyThrownExceptionBy(() ->
|
verifyThrownExceptionBy(() ->
|
||||||
@@ -139,7 +139,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
verifyThrownExceptionBy(() -> distributionSetManagement.create(
|
verifyThrownExceptionBy(() -> distributionSetManagement.create(
|
||||||
entityFactory.distributionSet().create().name("xxx").type(NOT_EXIST_ID)), "DistributionSetType");
|
entityFactory.distributionSet().create().name("xxx").type(NOT_EXIST_ID)), "DistributionSetType");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.createMetaData(
|
verifyThrownExceptionBy(() -> distributionSetManagement.putMetaData(
|
||||||
NOT_EXIST_IDL, singletonList(entityFactory.generateDsMetadata("123", "123"))), "DistributionSet");
|
NOT_EXIST_IDL, singletonList(entityFactory.generateDsMetadata("123", "123"))), "DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.delete(singletonList(NOT_EXIST_IDL)), "DistributionSet");
|
verifyThrownExceptionBy(() -> distributionSetManagement.delete(singletonList(NOT_EXIST_IDL)), "DistributionSet");
|
||||||
@@ -149,16 +149,16 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteMetaData(set.getId(), NOT_EXIST_ID),
|
verifyThrownExceptionBy(() -> distributionSetManagement.deleteMetaData(set.getId(), NOT_EXIST_ID),
|
||||||
"DistributionSetMetadata");
|
"DistributionSetMetadata");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.getByAction(NOT_EXIST_IDL), "Action");
|
verifyThrownExceptionBy(() -> distributionSetManagement.findByAction(NOT_EXIST_IDL), "Action");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.getMetaDataByDistributionSetId(NOT_EXIST_IDL, "xxx"),
|
verifyThrownExceptionBy(() -> distributionSetManagement.findMetaDataByDistributionSetId(NOT_EXIST_IDL, "xxx"),
|
||||||
"DistributionSet");
|
"DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.findMetaDataByDistributionSetId(PAGE, NOT_EXIST_IDL),
|
verifyThrownExceptionBy(() -> distributionSetManagement.findMetaDataByDistributionSetId(NOT_EXIST_IDL, PAGE),
|
||||||
"DistributionSet");
|
"DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(
|
verifyThrownExceptionBy(
|
||||||
() -> distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
() -> distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(NOT_EXIST_IDL, "name==*", PAGE),
|
||||||
"DistributionSet");
|
"DistributionSet");
|
||||||
|
|
||||||
assertThatThrownBy(() -> distributionSetManagement.isInUse(NOT_EXIST_IDL))
|
assertThatThrownBy(() -> distributionSetManagement.isInUse(NOT_EXIST_IDL))
|
||||||
@@ -325,22 +325,22 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
.as("ds has wrong tag size")
|
.as("ds has wrong tag size")
|
||||||
.isEqualTo(1));
|
.isEqualTo(1));
|
||||||
|
|
||||||
final DistributionSetTag findDistributionSetTag = getOrThrow(distributionSetTagManagement.getByName(TAG1_NAME));
|
final DistributionSetTag findDistributionSetTag = getOrThrow(distributionSetTagManagement.findByName(TAG1_NAME));
|
||||||
|
|
||||||
assertThat(assignedDS.size()).as("assigned ds has wrong size")
|
assertThat(assignedDS.size()).as("assigned ds has wrong size")
|
||||||
.isEqualTo(distributionSetManagement.findByTag(PAGE, tag.getId()).getNumberOfElements());
|
.isEqualTo(distributionSetManagement.findByTag(tag.getId(), PAGE).getNumberOfElements());
|
||||||
|
|
||||||
final JpaDistributionSet unAssignDS = (JpaDistributionSet) distributionSetManagement
|
final JpaDistributionSet unAssignDS = (JpaDistributionSet) distributionSetManagement
|
||||||
.unassignTag(assignDS.get(0), findDistributionSetTag.getId());
|
.unassignTag(assignDS.get(0), findDistributionSetTag.getId());
|
||||||
assertThat(unAssignDS.getId()).as("unassigned ds is wrong").isEqualTo(assignDS.get(0));
|
assertThat(unAssignDS.getId()).as("unassigned ds is wrong").isEqualTo(assignDS.get(0));
|
||||||
assertThat(unAssignDS.getTags().size()).as("unassigned ds has wrong tag size").isZero();
|
assertThat(unAssignDS.getTags().size()).as("unassigned ds has wrong tag size").isZero();
|
||||||
assertThat(distributionSetTagManagement.getByName(TAG1_NAME)).isPresent();
|
assertThat(distributionSetTagManagement.findByName(TAG1_NAME)).isPresent();
|
||||||
assertThat(distributionSetManagement.findByTag(PAGE, tag.getId()).getNumberOfElements())
|
assertThat(distributionSetManagement.findByTag(tag.getId(), PAGE).getNumberOfElements())
|
||||||
.as("ds tag ds has wrong ds size").isEqualTo(3);
|
.as("ds tag ds has wrong ds size").isEqualTo(3);
|
||||||
|
|
||||||
assertThat(distributionSetManagement.findByRsqlAndTag(PAGE, "name==" + unAssignDS.getName(), tag.getId())
|
assertThat(distributionSetManagement.findByRsqlAndTag("name==" + unAssignDS.getName(), tag.getId(), PAGE)
|
||||||
.getNumberOfElements()).as("ds tag ds has wrong ds size").isZero();
|
.getNumberOfElements()).as("ds tag ds has wrong ds size").isZero();
|
||||||
assertThat(distributionSetManagement.findByRsqlAndTag(PAGE, "name!=" + unAssignDS.getName(), tag.getId())
|
assertThat(distributionSetManagement.findByRsqlAndTag("name!=" + unAssignDS.getName(), tag.getId(), PAGE)
|
||||||
.getNumberOfElements()).as("ds tag ds has wrong ds size").isEqualTo(3);
|
.getNumberOfElements()).as("ds tag ds has wrong ds size").isEqualTo(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -791,10 +791,10 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Page<DistributionSetMetadata> metadataOfDs1 = distributionSetManagement
|
final Page<DistributionSetMetadata> metadataOfDs1 = distributionSetManagement
|
||||||
.findMetaDataByDistributionSetId(PageRequest.of(0, 100), ds1.getId());
|
.findMetaDataByDistributionSetId(ds1.getId(), PageRequest.of(0, 100));
|
||||||
|
|
||||||
final Page<DistributionSetMetadata> metadataOfDs2 = distributionSetManagement
|
final Page<DistributionSetMetadata> metadataOfDs2 = distributionSetManagement
|
||||||
.findMetaDataByDistributionSetId(PageRequest.of(0, 100), ds2.getId());
|
.findMetaDataByDistributionSetId(ds2.getId(), PageRequest.of(0, 100));
|
||||||
|
|
||||||
assertThat(metadataOfDs1.getNumberOfElements())
|
assertThat(metadataOfDs1.getNumberOfElements())
|
||||||
.isEqualTo(quotaManagement.getMaxMetaDataEntriesPerDistributionSet());
|
.isEqualTo(quotaManagement.getMaxMetaDataEntriesPerDistributionSet());
|
||||||
@@ -831,7 +831,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
||||||
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(2);
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(2);
|
||||||
assertThat(distributionSetManagement.findAll(PAGE)).hasSize(2);
|
assertThat(distributionSetManagement.findAll(PAGE)).hasSize(2);
|
||||||
assertThat(distributionSetManagement.findByRsql(PAGE, "name==*")).hasSize(2);
|
assertThat(distributionSetManagement.findByRsql("name==*", PAGE)).hasSize(2);
|
||||||
assertThat(distributionSetManagement.count()).isEqualTo(2);
|
assertThat(distributionSetManagement.count()).isEqualTo(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -889,7 +889,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final String knownUpdateValue = "knownUpdateValue";
|
final String knownUpdateValue = "knownUpdateValue";
|
||||||
|
|
||||||
final DistributionSet ds = testdataFactory.createDistributionSet();
|
final DistributionSet ds = testdataFactory.createDistributionSet();
|
||||||
distributionSetManagement.createMetaData(ds.getId(),
|
distributionSetManagement.putMetaData(ds.getId(),
|
||||||
singletonList(entityFactory.generateDsMetadata(knownKey1, knownValue)));
|
singletonList(entityFactory.generateDsMetadata(knownKey1, knownValue)));
|
||||||
|
|
||||||
distributionSetInvalidationManagement.invalidateDistributionSet(
|
distributionSetInvalidationManagement.invalidateDistributionSet(
|
||||||
@@ -898,7 +898,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
// assert that no new metadata can be created
|
// assert that no new metadata can be created
|
||||||
assertThatExceptionOfType(InvalidDistributionSetException.class)
|
assertThatExceptionOfType(InvalidDistributionSetException.class)
|
||||||
.as("Invalid distributionSet should throw an exception")
|
.as("Invalid distributionSet should throw an exception")
|
||||||
.isThrownBy(() -> distributionSetManagement.createMetaData(ds.getId(),
|
.isThrownBy(() -> distributionSetManagement.putMetaData(ds.getId(),
|
||||||
singletonList(entityFactory.generateDsMetadata(knownKey2, knownValue))));
|
singletonList(entityFactory.generateDsMetadata(knownKey2, knownValue))));
|
||||||
|
|
||||||
// assert that an existing metadata can not be updated
|
// assert that an existing metadata can not be updated
|
||||||
@@ -1251,18 +1251,18 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
private void assertThatFilterContainsOnlyGivenDistributionSets(final DistributionSetFilterBuilder filterBuilder,
|
private void assertThatFilterContainsOnlyGivenDistributionSets(final DistributionSetFilterBuilder filterBuilder,
|
||||||
final List<DistributionSet> distributionSets) {
|
final List<DistributionSet> distributionSets) {
|
||||||
final int expectedDsSize = distributionSets.size();
|
final int expectedDsSize = distributionSets.size();
|
||||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, filterBuilder.build()).getContent())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(filterBuilder.build(), PAGE).getContent())
|
||||||
.hasSize(expectedDsSize).containsOnly(distributionSets.toArray(new DistributionSet[expectedDsSize]));
|
.hasSize(expectedDsSize).containsOnly(distributionSets.toArray(new DistributionSet[expectedDsSize]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertThatFilterDoesNotContainAnyDistributionSet(final DistributionSetFilterBuilder filterBuilder) {
|
private void assertThatFilterDoesNotContainAnyDistributionSet(final DistributionSetFilterBuilder filterBuilder) {
|
||||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, filterBuilder.build()).getContent())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(filterBuilder.build(), PAGE).getContent())
|
||||||
.isEmpty();
|
.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertThatFilterHasSizeAndDoesNotContainDistributionSet(
|
private void assertThatFilterHasSizeAndDoesNotContainDistributionSet(
|
||||||
final DistributionSetFilterBuilder filterBuilder, final int size, final DistributionSet ds) {
|
final DistributionSetFilterBuilder filterBuilder, final int size, final DistributionSet ds) {
|
||||||
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, filterBuilder.build()).getContent())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(filterBuilder.build(), PAGE).getContent())
|
||||||
.hasSize(size).doesNotContain(ds);
|
.hasSize(size).doesNotContain(ds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class DistributionSetTagManagementSecurityTest
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void getByNameWitPermissionWorks() {
|
void getByNameWitPermissionWorks() {
|
||||||
assertPermissions(() -> distributionSetTagManagement.getByName("tagName"), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> distributionSetTagManagement.findByName("tagName"), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@Description("Verifies that management get access reacts as specified on calls for non existing entities by means of Optional not present.")
|
@Description("Verifies that management get access reacts as specified on calls for non existing entities by means of Optional not present.")
|
||||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||||
void nonExistingEntityAccessReturnsNotPresent() {
|
void nonExistingEntityAccessReturnsNotPresent() {
|
||||||
assertThat(distributionSetTagManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
assertThat(distributionSetTagManagement.findByName(NOT_EXIST_ID)).isNotPresent();
|
||||||
assertThat(distributionSetTagManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
assertThat(distributionSetTagManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,18 +95,18 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assignTag(dsBs, tagB);
|
assignTag(dsBs, tagB);
|
||||||
assignTag(dsCs, tagC);
|
assignTag(dsCs, tagC);
|
||||||
|
|
||||||
assignTag(dsABs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
assignTag(dsABs, distributionSetTagManagement.findByName(tagA.getName()).get());
|
||||||
assignTag(dsABs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
assignTag(dsABs, distributionSetTagManagement.findByName(tagB.getName()).get());
|
||||||
|
|
||||||
assignTag(dsACs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
assignTag(dsACs, distributionSetTagManagement.findByName(tagA.getName()).get());
|
||||||
assignTag(dsACs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
assignTag(dsACs, distributionSetTagManagement.findByName(tagC.getName()).get());
|
||||||
|
|
||||||
assignTag(dsBCs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
assignTag(dsBCs, distributionSetTagManagement.findByName(tagB.getName()).get());
|
||||||
assignTag(dsBCs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
assignTag(dsBCs, distributionSetTagManagement.findByName(tagC.getName()).get());
|
||||||
|
|
||||||
assignTag(dsABCs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
assignTag(dsABCs, distributionSetTagManagement.findByName(tagA.getName()).get());
|
||||||
assignTag(dsABCs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
assignTag(dsABCs, distributionSetTagManagement.findByName(tagB.getName()).get());
|
||||||
assignTag(dsABCs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
assignTag(dsABCs, distributionSetTagManagement.findByName(tagC.getName()).get());
|
||||||
|
|
||||||
// search for not deleted
|
// search for not deleted
|
||||||
final DistributionSetFilter.DistributionSetFilterBuilder distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
final DistributionSetFilter.DistributionSetFilterBuilder distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
||||||
@@ -150,7 +150,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertThat(result).size().isEqualTo(20);
|
assertThat(result).size().isEqualTo(20);
|
||||||
assertThat(result).containsAll(distributionSetManagement.get(groupA.stream().map(DistributionSet::getId).toList()));
|
assertThat(result).containsAll(distributionSetManagement.get(groupA.stream().map(DistributionSet::getId).toList()));
|
||||||
assertThat(
|
assertThat(
|
||||||
distributionSetManagement.findByTag(Pageable.unpaged(), tag.getId()).getContent().stream()
|
distributionSetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent().stream()
|
||||||
.map(DistributionSet::getId)
|
.map(DistributionSet::getId)
|
||||||
.sorted()
|
.sorted()
|
||||||
.toList())
|
.toList())
|
||||||
@@ -163,7 +163,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertThat(result).containsAll(distributionSetManagement
|
assertThat(result).containsAll(distributionSetManagement
|
||||||
.get(groupAB.stream().map(DistributionSet::getId).toList()));
|
.get(groupAB.stream().map(DistributionSet::getId).toList()));
|
||||||
assertThat(
|
assertThat(
|
||||||
distributionSetManagement.findByTag(Pageable.unpaged(), tag.getId()).getContent().stream().map(DistributionSet::getId).sorted()
|
distributionSetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent().stream().map(DistributionSet::getId).sorted()
|
||||||
.toList())
|
.toList())
|
||||||
.isEqualTo(groupAB.stream().map(DistributionSet::getId).sorted().toList());
|
.isEqualTo(groupAB.stream().map(DistributionSet::getId).sorted().toList());
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
result = unassignTag(concat(groupA, groupB), tag);
|
result = unassignTag(concat(groupA, groupB), tag);
|
||||||
assertThat(result).size().isEqualTo(40);
|
assertThat(result).size().isEqualTo(40);
|
||||||
assertThat(result).containsAll(distributionSetManagement.get(concat(groupB, groupA).stream().map(DistributionSet::getId).toList()));
|
assertThat(result).containsAll(distributionSetManagement.get(concat(groupB, groupA).stream().map(DistributionSet::getId).toList()));
|
||||||
assertThat(distributionSetManagement.findByTag(Pageable.unpaged(), tag.getId()).getContent()).isEmpty();
|
assertThat(distributionSetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -210,7 +210,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
assertThat(distributionSetTagRepository.findByNameEquals("kai1").get().getDescription()).as("wrong tag found")
|
assertThat(distributionSetTagRepository.findByNameEquals("kai1").get().getDescription()).as("wrong tag found")
|
||||||
.isEqualTo("kai2");
|
.isEqualTo("kai2");
|
||||||
assertThat(distributionSetTagManagement.getByName("kai1").get().getColour()).as("wrong tag found")
|
assertThat(distributionSetTagManagement.findByName("kai1").get().getColour()).as("wrong tag found")
|
||||||
.isEqualTo("colour");
|
.isEqualTo("colour");
|
||||||
assertThat(distributionSetTagManagement.get(tag.getId()).get().getColour()).as("wrong tag found")
|
assertThat(distributionSetTagManagement.get(tag.getId()).get().getColour()).as("wrong tag found")
|
||||||
.isEqualTo("colour");
|
.isEqualTo("colour");
|
||||||
@@ -302,7 +302,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
private void verifyExpectedFilteredDistributionSets(final DistributionSetFilter.DistributionSetFilterBuilder distributionSetFilterBuilder,
|
private void verifyExpectedFilteredDistributionSets(final DistributionSetFilter.DistributionSetFilterBuilder distributionSetFilterBuilder,
|
||||||
final Stream<Collection<DistributionSet>> expectedFilteredDistributionSets) {
|
final Stream<Collection<DistributionSet>> expectedFilteredDistributionSets) {
|
||||||
final Collection<Long> retrievedFilteredDsIds = distributionSetManagement
|
final Collection<Long> retrievedFilteredDsIds = distributionSetManagement
|
||||||
.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build()).stream()
|
.findByDistributionSetFilter(distributionSetFilterBuilder.build(), PAGE).stream()
|
||||||
.map(DistributionSet::getId).toList();
|
.map(DistributionSet::getId).toList();
|
||||||
final Collection<Long> expectedFilteredDsIds = expectedFilteredDistributionSets.flatMap(Collection::stream)
|
final Collection<Long> expectedFilteredDsIds = expectedFilteredDistributionSets.flatMap(Collection::stream)
|
||||||
.map(DistributionSet::getId).toList();
|
.map(DistributionSet::getId).toList();
|
||||||
|
|||||||
@@ -46,13 +46,13 @@ public class DistributionSetTypeManagementSecurityTest
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void getByKeyPermissionsCheck() {
|
void getByKeyPermissionsCheck() {
|
||||||
assertPermissions(() -> distributionSetTypeManagement.getByKey("key"), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> distributionSetTypeManagement.findByKey("key"), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void getByNamePermissionsCheck() {
|
void getByNamePermissionsCheck() {
|
||||||
assertPermissions(() -> distributionSetTypeManagement.getByName("name"), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> distributionSetTypeManagement.findByName("name"), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
|||||||
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 0) })
|
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 0) })
|
||||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||||
assertThat(distributionSetTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
assertThat(distributionSetTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||||
assertThat(distributionSetTypeManagement.getByKey(NOT_EXIST_ID)).isNotPresent();
|
assertThat(distributionSetTypeManagement.findByKey(NOT_EXIST_ID)).isNotPresent();
|
||||||
assertThat(distributionSetTypeManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
assertThat(distributionSetTypeManagement.findByName(NOT_EXIST_ID)).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -111,23 +111,23 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
|||||||
public void updateUnassignedDistributionSetTypeModules() {
|
public void updateUnassignedDistributionSetTypeModules() {
|
||||||
final DistributionSetType updatableType = distributionSetTypeManagement
|
final DistributionSetType updatableType = distributionSetTypeManagement
|
||||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||||
|
|
||||||
// add OS
|
// add OS
|
||||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
|
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
|
||||||
Set.of(osType.getId()));
|
Set.of(osType.getId()));
|
||||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes())
|
||||||
.containsOnly(osType);
|
.containsOnly(osType);
|
||||||
|
|
||||||
// add JVM
|
// add JVM
|
||||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
|
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
|
||||||
Set.of(runtimeType.getId()));
|
Set.of(runtimeType.getId()));
|
||||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes())
|
||||||
.containsOnly(osType, runtimeType);
|
.containsOnly(osType, runtimeType);
|
||||||
|
|
||||||
// remove OS
|
// remove OS
|
||||||
distributionSetTypeManagement.unassignSoftwareModuleType(updatableType.getId(), osType.getId());
|
distributionSetTypeManagement.unassignSoftwareModuleType(updatableType.getId(), osType.getId());
|
||||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes())
|
||||||
.containsOnly(runtimeType);
|
.containsOnly(runtimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,9 +186,9 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
|||||||
distributionSetTypeManagement.update(
|
distributionSetTypeManagement.update(
|
||||||
entityFactory.distributionSetType().update(nonUpdatableType.getId()).description("a new description"));
|
entityFactory.distributionSetType().update(nonUpdatableType.getId()).description("a new description"));
|
||||||
|
|
||||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getDescription())
|
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getDescription())
|
||||||
.isEqualTo("a new description");
|
.isEqualTo("a new description");
|
||||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getColour()).isEqualTo("test123");
|
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getColour()).isEqualTo("test123");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -206,7 +206,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
|||||||
public void removeModuleToAssignedDistributionSetTypeFails() {
|
public void removeModuleToAssignedDistributionSetTypeFails() {
|
||||||
DistributionSetType nonUpdatableType = distributionSetTypeManagement
|
DistributionSetType nonUpdatableType = distributionSetTypeManagement
|
||||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||||
|
|
||||||
nonUpdatableType = distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(nonUpdatableType.getId(),
|
nonUpdatableType = distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(nonUpdatableType.getId(),
|
||||||
Set.of(osType.getId()));
|
Set.of(osType.getId()));
|
||||||
@@ -242,11 +242,11 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
|||||||
entityFactory.distributionSet().create().name("softdeleted").version("1").type(toBeDeleted.getKey()));
|
entityFactory.distributionSet().create().name("softdeleted").version("1").type(toBeDeleted.getKey()));
|
||||||
|
|
||||||
distributionSetTypeManagement.delete(toBeDeleted.getId());
|
distributionSetTypeManagement.delete(toBeDeleted.getId());
|
||||||
final Optional<DistributionSetType> softdeleted = distributionSetTypeManagement.getByKey("softdeleted");
|
final Optional<DistributionSetType> softdeleted = distributionSetTypeManagement.findByKey("softdeleted");
|
||||||
assertThat(softdeleted).isPresent();
|
assertThat(softdeleted).isPresent();
|
||||||
assertThat(softdeleted.get().isDeleted()).isTrue();
|
assertThat(softdeleted.get().isDeleted()).isTrue();
|
||||||
assertThat(distributionSetTypeManagement.findAll(PAGE)).hasSize(existing);
|
assertThat(distributionSetTypeManagement.findAll(PAGE)).hasSize(existing);
|
||||||
assertThat(distributionSetTypeManagement.findByRsql(PAGE, "name==*")).hasSize(existing);
|
assertThat(distributionSetTypeManagement.findByRsql("name==*", PAGE)).hasSize(existing);
|
||||||
assertThat(distributionSetTypeManagement.count()).isEqualTo(existing);
|
assertThat(distributionSetTypeManagement.count()).isEqualTo(existing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,7 +358,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
|||||||
private DistributionSetType createDistributionSetTypeUsedByDs() {
|
private DistributionSetType createDistributionSetTypeUsedByDs() {
|
||||||
final DistributionSetType nonUpdatableType = distributionSetTypeManagement.create(entityFactory
|
final DistributionSetType nonUpdatableType = distributionSetTypeManagement.create(entityFactory
|
||||||
.distributionSetType().create().key("updatableType").name("to be deleted").colour("test123"));
|
.distributionSetType().create().key("updatableType").name("to be deleted").colour("test123"));
|
||||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||||
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft").version("1")
|
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft").version("1")
|
||||||
.type(nonUpdatableType.getKey()));
|
.type(nonUpdatableType.getKey()));
|
||||||
return nonUpdatableType;
|
return nonUpdatableType;
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ public class SoftwareManagementSecurityTest
|
|||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void createMetaDataPermissionsCheck() {
|
void createMetaDataPermissionsCheck() {
|
||||||
assertPermissions(
|
assertPermissions(
|
||||||
() -> softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(1L).key("key").value("value")),
|
() -> softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(1L).key("key").value("value")),
|
||||||
List.of(SpPermission.UPDATE_REPOSITORY));
|
List.of(SpPermission.UPDATE_REPOSITORY));
|
||||||
assertPermissions(() -> softwareModuleManagement.createMetaData(
|
assertPermissions(() -> softwareModuleManagement.putMetaData(
|
||||||
List.of(entityFactory.softwareModuleMetadata().create(1L).key("key").value("value"))), List.of(SpPermission.UPDATE_REPOSITORY));
|
List.of(entityFactory.softwareModuleMetadata().create(1L).key("key").value("value"))), List.of(SpPermission.UPDATE_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ public class SoftwareManagementSecurityTest
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void findByAssignedToPermissionsCheck() {
|
void findByAssignedToPermissionsCheck() {
|
||||||
assertPermissions(() -> softwareModuleManagement.findByAssignedTo(PAGE, 1L), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> softwareModuleManagement.findByAssignedTo(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -76,19 +76,19 @@ public class SoftwareManagementSecurityTest
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void findByTextAndTypePermissionsCheck() {
|
void findByTextAndTypePermissionsCheck() {
|
||||||
assertPermissions(() -> softwareModuleManagement.findByTextAndType(PAGE, "text", 1L), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> softwareModuleManagement.findByTextAndType("text", 1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getByNameAndVersionAndTypePermissionsCheck() {
|
void getByNameAndVersionAndTypePermissionsCheck() {
|
||||||
assertPermissions(() -> softwareModuleManagement.getByNameAndVersionAndType("name", "version", 1L),
|
assertPermissions(() -> softwareModuleManagement.findByNameAndVersionAndType("name", "version", 1L),
|
||||||
List.of(SpPermission.READ_REPOSITORY));
|
List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void getMetaDataBySoftwareModuleIdPermissionsCheck() {
|
void getMetaDataBySoftwareModuleIdPermissionsCheck() {
|
||||||
assertPermissions(() -> softwareModuleManagement.getMetaDataBySoftwareModuleId(1L, "key"), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleId(1L, "key"), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -113,13 +113,13 @@ public class SoftwareManagementSecurityTest
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void findMetaDataByRsqlPermissionsCheck() {
|
void findMetaDataByRsqlPermissionsCheck() {
|
||||||
assertPermissions(() -> softwareModuleManagement.findMetaDataByRsql(PAGE, 1L, "key==value"), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> softwareModuleManagement.findMetaDataByRsql(1L, "key==value", PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void findByTypePermissionsCheck() {
|
void findByTypePermissionsCheck() {
|
||||||
assertPermissions(() -> softwareModuleManagement.findByType(PAGE, 1L), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> softwareModuleManagement.findByType(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -68,10 +68,10 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
assertThat(softwareModuleManagement.get(1234L)).isNotPresent();
|
assertThat(softwareModuleManagement.get(1234L)).isNotPresent();
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.getByNameAndVersionAndType(NOT_EXIST_ID, NOT_EXIST_ID, osType.getId()))
|
assertThat(softwareModuleManagement.findByNameAndVersionAndType(NOT_EXIST_ID, NOT_EXIST_ID, osType.getId()))
|
||||||
.isNotPresent();
|
.isNotPresent();
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(module.getId(), NOT_EXIST_ID)).isNotPresent();
|
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(module.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -91,11 +91,11 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
"SoftwareModuleType");
|
"SoftwareModuleType");
|
||||||
|
|
||||||
verifyThrownExceptionBy(
|
verifyThrownExceptionBy(
|
||||||
() -> softwareModuleManagement.createMetaData(
|
() -> softwareModuleManagement.updateMetaData(
|
||||||
entityFactory.softwareModuleMetadata().create(NOT_EXIST_IDL).key("xxx").value("xxx")),
|
entityFactory.softwareModuleMetadata().create(NOT_EXIST_IDL).key("xxx").value("xxx")),
|
||||||
"SoftwareModule");
|
"SoftwareModule");
|
||||||
verifyThrownExceptionBy(
|
verifyThrownExceptionBy(
|
||||||
() -> softwareModuleManagement.createMetaData(Collections.singletonList(
|
() -> softwareModuleManagement.putMetaData(Collections.singletonList(
|
||||||
entityFactory.softwareModuleMetadata().create(NOT_EXIST_IDL).key("xxx").value("xxx"))),
|
entityFactory.softwareModuleMetadata().create(NOT_EXIST_IDL).key("xxx").value("xxx"))),
|
||||||
"SoftwareModule");
|
"SoftwareModule");
|
||||||
|
|
||||||
@@ -115,21 +115,21 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
entityFactory.softwareModuleMetadata().update(module.getId(), NOT_EXIST_ID).value("xxx")),
|
entityFactory.softwareModuleMetadata().update(module.getId(), NOT_EXIST_ID).value("xxx")),
|
||||||
"SoftwareModuleMetadata");
|
"SoftwareModuleMetadata");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findByAssignedTo(PAGE, NOT_EXIST_IDL),
|
verifyThrownExceptionBy(() -> softwareModuleManagement.findByAssignedTo(NOT_EXIST_IDL, PAGE),
|
||||||
"DistributionSet");
|
"DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> softwareModuleManagement.getByNameAndVersionAndType("xxx", "xxx", NOT_EXIST_IDL),
|
verifyThrownExceptionBy(() -> softwareModuleManagement.findByNameAndVersionAndType("xxx", "xxx", NOT_EXIST_IDL),
|
||||||
"SoftwareModuleType");
|
"SoftwareModuleType");
|
||||||
|
|
||||||
verifyThrownExceptionBy(
|
verifyThrownExceptionBy(
|
||||||
() -> softwareModuleManagement.getMetaDataBySoftwareModuleId(NOT_EXIST_IDL, NOT_EXIST_ID),
|
() -> softwareModuleManagement.findMetaDataBySoftwareModuleId(NOT_EXIST_IDL, NOT_EXIST_ID),
|
||||||
"SoftwareModule");
|
"SoftwareModule");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findMetaDataBySoftwareModuleId(PAGE, NOT_EXIST_IDL),
|
verifyThrownExceptionBy(() -> softwareModuleManagement.findMetaDataBySoftwareModuleId(PAGE, NOT_EXIST_IDL),
|
||||||
"SoftwareModule");
|
"SoftwareModule");
|
||||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findMetaDataByRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
verifyThrownExceptionBy(() -> softwareModuleManagement.findMetaDataByRsql(NOT_EXIST_IDL, "name==*", PAGE),
|
||||||
"SoftwareModule");
|
"SoftwareModule");
|
||||||
verifyThrownExceptionBy(() -> softwareModuleManagement.findByType(PAGE, NOT_EXIST_IDL), "SoftwareModule");
|
verifyThrownExceptionBy(() -> softwareModuleManagement.findByType(NOT_EXIST_IDL, PAGE), "SoftwareModule");
|
||||||
|
|
||||||
verifyThrownExceptionBy(
|
verifyThrownExceptionBy(
|
||||||
() -> softwareModuleManagement.update(entityFactory.softwareModule().update(NOT_EXIST_IDL)),
|
() -> softwareModuleManagement.update(entityFactory.softwareModule().update(NOT_EXIST_IDL)),
|
||||||
@@ -195,23 +195,23 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
implicitLock(jvm);
|
implicitLock(jvm);
|
||||||
|
|
||||||
// standard searches
|
// standard searches
|
||||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "poky", osType.getId()).getContent()).hasSize(1);
|
assertThat(softwareModuleManagement.findByTextAndType("poky", osType.getId(), PAGE).getContent()).hasSize(1);
|
||||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "poky", osType.getId()).getContent().get(0))
|
assertThat(softwareModuleManagement.findByTextAndType("poky", osType.getId(), PAGE).getContent().get(0))
|
||||||
.isEqualTo(os);
|
.isEqualTo(os);
|
||||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, "oracle", runtimeType.getId()).getContent())
|
assertThat(softwareModuleManagement.findByTextAndType("oracle", runtimeType.getId(), PAGE).getContent())
|
||||||
.hasSize(1);
|
.hasSize(1);
|
||||||
assertThat(
|
assertThat(
|
||||||
softwareModuleManagement.findByTextAndType(PAGE, "oracle", runtimeType.getId()).getContent().get(0))
|
softwareModuleManagement.findByTextAndType("oracle", runtimeType.getId(), PAGE).getContent().get(0))
|
||||||
.isEqualTo(jvm);
|
.isEqualTo(jvm);
|
||||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, ":1.0.1", appType.getId()).getContent()).hasSize(1)
|
assertThat(softwareModuleManagement.findByTextAndType(":1.0.1", appType.getId(), PAGE).getContent()).hasSize(1)
|
||||||
.first().isEqualTo(ah);
|
.first().isEqualTo(ah);
|
||||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, ":1.0", appType.getId()).getContent()).hasSize(2);
|
assertThat(softwareModuleManagement.findByTextAndType(":1.0", appType.getId(), PAGE).getContent()).hasSize(2);
|
||||||
|
|
||||||
distributionSetManagement.unlock(ds.getId()); // otherwise delete will be rejected as a part of a locked DS
|
distributionSetManagement.unlock(ds.getId()); // otherwise delete will be rejected as a part of a locked DS
|
||||||
softwareModuleManagement.delete(ah2.getId());
|
softwareModuleManagement.delete(ah2.getId());
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, ":1.0", appType.getId()).getContent()).hasSize(1);
|
assertThat(softwareModuleManagement.findByTextAndType(":1.0", appType.getId(), PAGE).getContent()).hasSize(1);
|
||||||
assertThat(softwareModuleManagement.findByTextAndType(PAGE, ":1.0", appType.getId()).getContent().get(0))
|
assertThat(softwareModuleManagement.findByTextAndType(":1.0", appType.getId(), PAGE).getContent().get(0))
|
||||||
.isEqualTo(ah);
|
.isEqualTo(ah);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +235,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
softwareModuleManagement.delete(testdataFactory.createSoftwareModuleOs("deleted").getId());
|
softwareModuleManagement.delete(testdataFactory.createSoftwareModuleOs("deleted").getId());
|
||||||
testdataFactory.createSoftwareModuleApp();
|
testdataFactory.createSoftwareModuleApp();
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findByType(PAGE, osType.getId()).getContent())
|
assertThat(softwareModuleManagement.findByType(osType.getId(), PAGE).getContent())
|
||||||
.as("Expected to find the following number of modules:").hasSize(2).as("with the following elements")
|
.as("Expected to find the following number of modules:").hasSize(2).as("with the following elements")
|
||||||
.contains(two, one);
|
.contains(two, one);
|
||||||
}
|
}
|
||||||
@@ -297,7 +297,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assignedModule = softwareModuleManagement.get(assignedModule.getId()).get();
|
assignedModule = softwareModuleManagement.get(assignedModule.getId()).get();
|
||||||
assertTrue(assignedModule.isDeleted(), "The module should be flagged as deleted");
|
assertTrue(assignedModule.isDeleted(), "The module should be flagged as deleted");
|
||||||
assertThat(softwareModuleManagement.findAll(PAGE)).isEmpty();
|
assertThat(softwareModuleManagement.findAll(PAGE)).isEmpty();
|
||||||
assertThat(softwareModuleManagement.findByRsql(PAGE, "name==*")).isEmpty();
|
assertThat(softwareModuleManagement.findByRsql("name==*", PAGE)).isEmpty();
|
||||||
assertThat(softwareModuleManagement.count()).isZero();
|
assertThat(softwareModuleManagement.count()).isZero();
|
||||||
assertThat(softwareModuleRepository.findAll()).hasSize(1);
|
assertThat(softwareModuleRepository.findAll()).hasSize(1);
|
||||||
|
|
||||||
@@ -484,7 +484,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
.name("set").version("1").modules(Arrays.asList(one.getId(), deleted.getId())));
|
.name("set").version("1").modules(Arrays.asList(one.getId(), deleted.getId())));
|
||||||
softwareModuleManagement.delete(deleted.getId());
|
softwareModuleManagement.delete(deleted.getId());
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findByAssignedTo(PAGE, set.getId()).getContent())
|
assertThat(softwareModuleManagement.findByAssignedTo(set.getId(), PAGE).getContent())
|
||||||
.as("Found this number of modules").hasSize(2);
|
.as("Found this number of modules").hasSize(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,7 +508,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
.key(knownKey2).value(knownValue2);
|
.key(knownKey2).value(knownValue2);
|
||||||
|
|
||||||
final List<SoftwareModuleMetadata> softwareModuleMetadata = softwareModuleManagement
|
final List<SoftwareModuleMetadata> softwareModuleMetadata = softwareModuleManagement
|
||||||
.createMetaData(Arrays.asList(swMetadata1, swMetadata2));
|
.putMetaData(Arrays.asList(swMetadata1, swMetadata2));
|
||||||
|
|
||||||
final SoftwareModule changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
|
final SoftwareModule changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
|
||||||
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(2);
|
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(2);
|
||||||
@@ -528,13 +528,13 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final SoftwareModule module = testdataFactory.createSoftwareModuleApp("m1");
|
final SoftwareModule module = testdataFactory.createSoftwareModuleApp("m1");
|
||||||
final int maxMetaData = quotaManagement.getMaxMetaDataEntriesPerSoftwareModule();
|
final int maxMetaData = quotaManagement.getMaxMetaDataEntriesPerSoftwareModule();
|
||||||
for (int i = 0; i < maxMetaData; ++i) {
|
for (int i = 0; i < maxMetaData; ++i) {
|
||||||
softwareModuleManagement.createMetaData(
|
softwareModuleManagement.updateMetaData(
|
||||||
entityFactory.softwareModuleMetadata().create(module.getId()).key("k" + i).value("v" + i));
|
entityFactory.softwareModuleMetadata().create(module.getId()).key("k" + i).value("v" + i));
|
||||||
}
|
}
|
||||||
|
|
||||||
// quota exceeded
|
// quota exceeded
|
||||||
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
|
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
|
||||||
.isThrownBy(() -> softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata()
|
.isThrownBy(() -> softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata()
|
||||||
.create(module.getId()).key("k" + maxMetaData).value("v" + maxMetaData)));
|
.create(module.getId()).key("k" + maxMetaData).value("v" + maxMetaData)));
|
||||||
|
|
||||||
// add multiple meta data entries at once
|
// add multiple meta data entries at once
|
||||||
@@ -545,13 +545,13 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
}
|
}
|
||||||
// quota exceeded
|
// quota exceeded
|
||||||
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
|
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
|
||||||
.isThrownBy(() -> softwareModuleManagement.createMetaData(create));
|
.isThrownBy(() -> softwareModuleManagement.putMetaData(create));
|
||||||
|
|
||||||
// add some meta data entries
|
// add some meta data entries
|
||||||
final SoftwareModule module3 = testdataFactory.createSoftwareModuleApp("m3");
|
final SoftwareModule module3 = testdataFactory.createSoftwareModuleApp("m3");
|
||||||
final int firstHalf = Math.round((maxMetaData) / 2.f);
|
final int firstHalf = Math.round((maxMetaData) / 2.f);
|
||||||
for (int i = 0; i < firstHalf; ++i) {
|
for (int i = 0; i < firstHalf; ++i) {
|
||||||
softwareModuleManagement.createMetaData(
|
softwareModuleManagement.updateMetaData(
|
||||||
entityFactory.softwareModuleMetadata().create(module3.getId()).key("k" + i).value("v" + i));
|
entityFactory.softwareModuleMetadata().create(module3.getId()).key("k" + i).value("v" + i));
|
||||||
}
|
}
|
||||||
// add too many data entries
|
// add too many data entries
|
||||||
@@ -562,7 +562,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
}
|
}
|
||||||
// quota exceeded
|
// quota exceeded
|
||||||
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
|
assertThatExceptionOfType(AssignmentQuotaExceededException.class)
|
||||||
.isThrownBy(() -> softwareModuleManagement.createMetaData(create2));
|
.isThrownBy(() -> softwareModuleManagement.putMetaData(create2));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -574,21 +574,21 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final String knownValue1 = "myKnownValue1";
|
final String knownValue1 = "myKnownValue1";
|
||||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||||
|
|
||||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey1)
|
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey1)
|
||||||
.value(knownValue1).targetVisible(true));
|
.value(knownValue1).targetVisible(true));
|
||||||
|
|
||||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||||
.isThrownBy(() -> softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata()
|
.isThrownBy(() -> softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata()
|
||||||
.create(ah.getId()).key(knownKey1).value(knownValue1).targetVisible(true)))
|
.create(ah.getId()).key(knownKey1).value(knownValue1).targetVisible(true)))
|
||||||
.withMessageContaining("Metadata").withMessageContaining(knownKey1);
|
.withMessageContaining("Metadata").withMessageContaining(knownKey1);
|
||||||
|
|
||||||
final String knownKey2 = "myKnownKey2";
|
final String knownKey2 = "myKnownKey2";
|
||||||
|
|
||||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey2)
|
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey2)
|
||||||
.value(knownValue1).targetVisible(false));
|
.value(knownValue1).targetVisible(false));
|
||||||
|
|
||||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||||
.isThrownBy(() -> softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata()
|
.isThrownBy(() -> softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata()
|
||||||
.create(ah.getId()).key(knownKey2).value(knownValue1).targetVisible(true)))
|
.create(ah.getId()).key(knownKey2).value(knownValue1).targetVisible(true)))
|
||||||
.withMessageContaining("Metadata").withMessageContaining(knownKey2);
|
.withMessageContaining("Metadata").withMessageContaining(knownKey2);
|
||||||
}
|
}
|
||||||
@@ -607,7 +607,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertThat(ah.getOptLockRevision()).isEqualTo(1);
|
assertThat(ah.getOptLockRevision()).isEqualTo(1);
|
||||||
|
|
||||||
// create an software module meta data entry
|
// create an software module meta data entry
|
||||||
final SoftwareModuleMetadata softwareModuleMetadata = softwareModuleManagement.createMetaData(
|
final SoftwareModuleMetadata softwareModuleMetadata = softwareModuleManagement.updateMetaData(
|
||||||
entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey).value(knownValue));
|
entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey).value(knownValue));
|
||||||
assertThat(softwareModuleMetadata.isTargetVisible()).isFalse();
|
assertThat(softwareModuleMetadata.isTargetVisible()).isFalse();
|
||||||
assertThat(softwareModuleMetadata.getValue()).isEqualTo(knownValue);
|
assertThat(softwareModuleMetadata.getValue()).isEqualTo(knownValue);
|
||||||
@@ -642,7 +642,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
final SoftwareModule swModule = testdataFactory.createSoftwareModuleApp();
|
final SoftwareModule swModule = testdataFactory.createSoftwareModuleApp();
|
||||||
|
|
||||||
softwareModuleManagement.createMetaData(
|
softwareModuleManagement.updateMetaData(
|
||||||
entityFactory.softwareModuleMetadata().create(swModule.getId()).key(knownKey1).value(knownValue1));
|
entityFactory.softwareModuleMetadata().create(swModule.getId()).key(knownKey1).value(knownValue1));
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(PageRequest.of(0, 10), swModule.getId())
|
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(PageRequest.of(0, 10), swModule.getId())
|
||||||
@@ -665,10 +665,10 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||||
|
|
||||||
softwareModuleManagement.createMetaData(
|
softwareModuleManagement.updateMetaData(
|
||||||
entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey1).value(knownValue1));
|
entityFactory.softwareModuleMetadata().create(ah.getId()).key(knownKey1).value(knownValue1));
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(ah.getId(), "doesnotexist")).isNotPresent();
|
assertThat(softwareModuleManagement.findMetaDataBySoftwareModuleId(ah.getId(), "doesnotexist")).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -682,12 +682,12 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final int metadataCountSw2 = 10;
|
final int metadataCountSw2 = 10;
|
||||||
|
|
||||||
for (int index = 0; index < metadataCountSw1; index++) {
|
for (int index = 0; index < metadataCountSw1; index++) {
|
||||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(sw1.getId())
|
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(sw1.getId())
|
||||||
.key("key" + index).value("value" + index).targetVisible(true));
|
.key("key" + index).value("value" + index).targetVisible(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int index = 0; index < metadataCountSw2; index++) {
|
for (int index = 0; index < metadataCountSw2; index++) {
|
||||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(sw2.getId())
|
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(sw2.getId())
|
||||||
.key("key" + index).value("value" + index).targetVisible(false));
|
.key("key" + index).value("value" + index).targetVisible(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,13 +46,13 @@ public class SoftwareModuleTypeManagementSecurityTest
|
|||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void getByKeyPermissionsCheck() {
|
void getByKeyPermissionsCheck() {
|
||||||
assertPermissions(() -> softwareModuleTypeManagement.getByKey("key"), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> softwareModuleTypeManagement.findByKey("key"), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||||
void getByNamePermissionsCheck() {
|
void getByNamePermissionsCheck() {
|
||||||
assertPermissions(() -> softwareModuleTypeManagement.getByName("name"), List.of(SpPermission.READ_REPOSITORY));
|
assertPermissions(() -> softwareModuleTypeManagement.findByName("name"), List.of(SpPermission.READ_REPOSITORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
|||||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||||
|
|
||||||
assertThat(softwareModuleTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
assertThat(softwareModuleTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||||
assertThat(softwareModuleTypeManagement.getByKey(NOT_EXIST_ID)).isNotPresent();
|
assertThat(softwareModuleTypeManagement.findByKey(NOT_EXIST_ID)).isNotPresent();
|
||||||
assertThat(softwareModuleTypeManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
assertThat(softwareModuleTypeManagement.findByName(NOT_EXIST_ID)).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -129,7 +129,7 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
|||||||
// delete assigned
|
// delete assigned
|
||||||
softwareModuleTypeManagement.delete(type.getId());
|
softwareModuleTypeManagement.delete(type.getId());
|
||||||
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
|
assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType);
|
||||||
assertThat(softwareModuleTypeManagement.findByRsql(PAGE, "name==*")).hasSize(3).contains(osType, runtimeType,
|
assertThat(softwareModuleTypeManagement.findByRsql("name==*", PAGE)).hasSize(3).contains(osType, runtimeType,
|
||||||
appType);
|
appType);
|
||||||
assertThat(softwareModuleTypeManagement.count()).isEqualTo(3);
|
assertThat(softwareModuleTypeManagement.count()).isEqualTo(3);
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
|
|||||||
softwareModuleTypeManagement
|
softwareModuleTypeManagement
|
||||||
.create(entityFactory.softwareModuleType().create().key("thetype2").name("anothername"));
|
.create(entityFactory.softwareModuleType().create().key("thetype2").name("anothername"));
|
||||||
|
|
||||||
assertThat(softwareModuleTypeManagement.getByName("thename").get()).as("Type with given name").isEqualTo(found);
|
assertThat(softwareModuleTypeManagement.findByName("thename").get()).as("Type with given name").isEqualTo(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ public class RSQLDistributionSetFieldTest extends AbstractJpaIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntity) {
|
private void assertRSQLQuery(final String rsqlParam, final long expectedEntity) {
|
||||||
final Page<DistributionSet> find = distributionSetManagement.findByRsql(PageRequest.of(0, 100), rsqlParam);
|
final Page<DistributionSet> find = distributionSetManagement.findByRsql(rsqlParam, PageRequest.of(0, 100));
|
||||||
final long countAll = find.getTotalElements();
|
final long countAll = find.getTotalElements();
|
||||||
assertThat(find).as("Found entity is should not be null").isNotNull();
|
assertThat(find).as("Found entity is should not be null").isNotNull();
|
||||||
assertThat(countAll).as("Found entity size is wrong").isEqualTo(expectedEntity);
|
assertThat(countAll).as("Found entity size is wrong").isEqualTo(expectedEntity);
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ public class RSQLDistributionSetMetadataFieldsTest extends AbstractJpaIntegratio
|
|||||||
metadata.add(entityFactory.generateDsMetadata("" + i, "" + i));
|
metadata.add(entityFactory.generateDsMetadata("" + i, "" + i));
|
||||||
}
|
}
|
||||||
|
|
||||||
distributionSetManagement.createMetaData(distributionSetId, metadata);
|
distributionSetManagement.putMetaData(distributionSetId, metadata);
|
||||||
|
|
||||||
distributionSetManagement.createMetaData(distributionSetId,
|
distributionSetManagement.putMetaData(distributionSetId,
|
||||||
Arrays.asList(entityFactory.generateDsMetadata("emptyValueTest", null)));
|
Arrays.asList(entityFactory.generateDsMetadata("emptyValueTest", null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ public class RSQLDistributionSetMetadataFieldsTest extends AbstractJpaIntegratio
|
|||||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
||||||
|
|
||||||
final Page<DistributionSetMetadata> findEnitity = distributionSetManagement
|
final Page<DistributionSetMetadata> findEnitity = distributionSetManagement
|
||||||
.findMetaDataByDistributionSetIdAndRsql(PageRequest.of(0, 100), distributionSetId, rsqlParam);
|
.findMetaDataByDistributionSetIdAndRsql(distributionSetId, rsqlParam, PageRequest.of(0, 100));
|
||||||
final long countAllEntities = findEnitity.getTotalElements();
|
final long countAllEntities = findEnitity.getTotalElements();
|
||||||
assertThat(findEnitity).isNotNull();
|
assertThat(findEnitity).isNotNull();
|
||||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||||
|
|||||||
@@ -51,11 +51,11 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
final SoftwareModuleMetadataCreate softwareModuleMetadata = entityFactory.softwareModuleMetadata()
|
final SoftwareModuleMetadataCreate softwareModuleMetadata = entityFactory.softwareModuleMetadata()
|
||||||
.create(ah.getId()).key("metaKey").value("metaValue");
|
.create(ah.getId()).key("metaKey").value("metaValue");
|
||||||
softwareModuleManagement.createMetaData(softwareModuleMetadata);
|
softwareModuleManagement.updateMetaData(softwareModuleMetadata);
|
||||||
|
|
||||||
final SoftwareModuleMetadataCreate softwareModuleMetadata2 = entityFactory.softwareModuleMetadata()
|
final SoftwareModuleMetadataCreate softwareModuleMetadata2 = entityFactory.softwareModuleMetadata()
|
||||||
.create(ah2.getId()).key("metaKey").value("value");
|
.create(ah2.getId()).key("metaKey").value("value");
|
||||||
softwareModuleManagement.createMetaData(softwareModuleMetadata2);
|
softwareModuleManagement.updateMetaData(softwareModuleMetadata2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -150,7 +150,7 @@ public class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntity) {
|
private void assertRSQLQuery(final String rsqlParam, final long expectedEntity) {
|
||||||
final Page<SoftwareModule> find = softwareModuleManagement.findByRsql(PageRequest.of(0, 100), rsqlParam);
|
final Page<SoftwareModule> find = softwareModuleManagement.findByRsql(rsqlParam, PageRequest.of(0, 100));
|
||||||
final long countAll = find.getTotalElements();
|
final long countAll = find.getTotalElements();
|
||||||
assertThat(find).isNotNull();
|
assertThat(find).isNotNull();
|
||||||
assertThat(countAll).isEqualTo(expectedEntity);
|
assertThat(countAll).isEqualTo(expectedEntity);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegration
|
|||||||
metadata.add(entityFactory.softwareModuleMetadata().create(softwareModule.getId()).key("emptyMd")
|
metadata.add(entityFactory.softwareModuleMetadata().create(softwareModule.getId()).key("emptyMd")
|
||||||
.targetVisible(true));
|
.targetVisible(true));
|
||||||
|
|
||||||
softwareModuleManagement.createMetaData(metadata);
|
softwareModuleManagement.putMetaData(metadata);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegration
|
|||||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
||||||
|
|
||||||
final Page<SoftwareModuleMetadata> findEnitity = softwareModuleManagement
|
final Page<SoftwareModuleMetadata> findEnitity = softwareModuleManagement
|
||||||
.findMetaDataByRsql(PageRequest.of(0, 100), softwareModuleId, rsqlParam);
|
.findMetaDataByRsql(softwareModuleId, rsqlParam, PageRequest.of(0, 100));
|
||||||
final long countAllEntities = findEnitity.getTotalElements();
|
final long countAllEntities = findEnitity.getTotalElements();
|
||||||
assertThat(findEnitity).isNotNull();
|
assertThat(findEnitity).isNotNull();
|
||||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ public class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {
|
||||||
final Page<SoftwareModuleType> find = softwareModuleTypeManagement.findByRsql(PageRequest.of(0, 100),
|
final Page<SoftwareModuleType> find = softwareModuleTypeManagement.findByRsql(rsqlParam, PageRequest.of(0, 100)
|
||||||
rsqlParam);
|
);
|
||||||
final long countAll = find.getTotalElements();
|
final long countAll = find.getTotalElements();
|
||||||
assertThat(find).isNotNull();
|
assertThat(find).isNotNull();
|
||||||
assertThat(countAll).isEqualTo(excpectedEntity);
|
assertThat(countAll).isEqualTo(excpectedEntity);
|
||||||
|
|||||||
@@ -119,8 +119,8 @@ public class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
private void assertRSQLQueryDistributionSet(final String rsqlParam, final long expectedEntities) {
|
private void assertRSQLQueryDistributionSet(final String rsqlParam, final long expectedEntities) {
|
||||||
|
|
||||||
final Page<DistributionSetTag> findEnitity = distributionSetTagManagement.findByRsql(PageRequest.of(0, 100),
|
final Page<DistributionSetTag> findEnitity = distributionSetTagManagement.findByRsql(rsqlParam, PageRequest.of(0, 100)
|
||||||
rsqlParam);
|
);
|
||||||
final long countAllEntities = findEnitity.getTotalElements();
|
final long countAllEntities = findEnitity.getTotalElements();
|
||||||
assertThat(findEnitity).isNotNull();
|
assertThat(findEnitity).isNotNull();
|
||||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ public abstract class AbstractIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected List<DistributionSetMetadata> createDistributionSetMetadata(final long dsId, final List<MetaData> md) {
|
protected List<DistributionSetMetadata> createDistributionSetMetadata(final long dsId, final List<MetaData> md) {
|
||||||
return distributionSetManagement.createMetaData(dsId, md);
|
return distributionSetManagement.putMetaData(dsId, md);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createTargetMetadata(final String controllerId, final MetaData md) {
|
protected void createTargetMetadata(final String controllerId, final MetaData md) {
|
||||||
|
|||||||
@@ -662,7 +662,7 @@ public class TestdataFactory {
|
|||||||
* @return persisted {@link DistributionSetType}
|
* @return persisted {@link DistributionSetType}
|
||||||
*/
|
*/
|
||||||
public DistributionSetType findOrCreateDistributionSetType(final String dsTypeKey, final String dsTypeName) {
|
public DistributionSetType findOrCreateDistributionSetType(final String dsTypeKey, final String dsTypeName) {
|
||||||
return distributionSetTypeManagement.getByKey(dsTypeKey)
|
return distributionSetTypeManagement.findByKey(dsTypeKey)
|
||||||
.orElseGet(() -> distributionSetTypeManagement.create(entityFactory.distributionSetType().create()
|
.orElseGet(() -> distributionSetTypeManagement.create(entityFactory.distributionSetType().create()
|
||||||
.key(dsTypeKey).name(dsTypeName).description(randomDescriptionShort()).colour("black")));
|
.key(dsTypeKey).name(dsTypeName).description(randomDescriptionShort()).colour("black")));
|
||||||
}
|
}
|
||||||
@@ -679,7 +679,7 @@ public class TestdataFactory {
|
|||||||
*/
|
*/
|
||||||
public DistributionSetType findOrCreateDistributionSetType(final String dsTypeKey, final String dsTypeName,
|
public DistributionSetType findOrCreateDistributionSetType(final String dsTypeKey, final String dsTypeName,
|
||||||
final Collection<SoftwareModuleType> mandatory, final Collection<SoftwareModuleType> optional) {
|
final Collection<SoftwareModuleType> mandatory, final Collection<SoftwareModuleType> optional) {
|
||||||
return distributionSetTypeManagement.getByKey(dsTypeKey)
|
return distributionSetTypeManagement.findByKey(dsTypeKey)
|
||||||
.orElseGet(() -> distributionSetTypeManagement.create(entityFactory.distributionSetType().create()
|
.orElseGet(() -> distributionSetTypeManagement.create(entityFactory.distributionSetType().create()
|
||||||
.key(dsTypeKey).name(dsTypeName).description(randomDescriptionShort()).colour("black")
|
.key(dsTypeKey).name(dsTypeName).description(randomDescriptionShort()).colour("black")
|
||||||
.optional(optional.stream().map(SoftwareModuleType::getId).collect(Collectors.toList()))
|
.optional(optional.stream().map(SoftwareModuleType::getId).collect(Collectors.toList()))
|
||||||
@@ -707,7 +707,7 @@ public class TestdataFactory {
|
|||||||
* @return persisted {@link SoftwareModuleType}
|
* @return persisted {@link SoftwareModuleType}
|
||||||
*/
|
*/
|
||||||
public SoftwareModuleType findOrCreateSoftwareModuleType(final String key, final int maxAssignments) {
|
public SoftwareModuleType findOrCreateSoftwareModuleType(final String key, final int maxAssignments) {
|
||||||
return softwareModuleTypeManagement.getByKey(key)
|
return softwareModuleTypeManagement.findByKey(key)
|
||||||
.orElseGet(() -> softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create()
|
.orElseGet(() -> softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create()
|
||||||
.key(key).name(key).description(randomDescriptionShort()).colour("#ffffff")
|
.key(key).name(key).description(randomDescriptionShort()).colour("#ffffff")
|
||||||
.maxAssignments(maxAssignments)));
|
.maxAssignments(maxAssignments)));
|
||||||
@@ -1268,9 +1268,9 @@ public class TestdataFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addTestModuleMetadata(final SoftwareModule module) {
|
private void addTestModuleMetadata(final SoftwareModule module) {
|
||||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(module.getId())
|
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(module.getId())
|
||||||
.key(VISIBLE_SM_MD_KEY).value(VISIBLE_SM_MD_VALUE).targetVisible(true));
|
.key(VISIBLE_SM_MD_KEY).value(VISIBLE_SM_MD_VALUE).targetVisible(true));
|
||||||
softwareModuleManagement.createMetaData(entityFactory.softwareModuleMetadata().create(module.getId())
|
softwareModuleManagement.updateMetaData(entityFactory.softwareModuleMetadata().create(module.getId())
|
||||||
.key(INVISIBLE_SM_MD_KEY).value(INVISIBLE_SM_MD_VALUE).targetVisible(false));
|
.key(INVISIBLE_SM_MD_KEY).value(INVISIBLE_SM_MD_VALUE).targetVisible(false));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user