Complete repository refactoring - method renaming (#575)
* Split Tag management Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Repo method naming schame applied. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * findAll returns slice instead of page. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Complete javadoc. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Allow null values again. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Readability improvements. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Forgot a method. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fixed broken completed filter. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -35,7 +35,6 @@ import org.eclipse.hawkbit.repository.ArtifactManagement;
|
|||||||
import org.eclipse.hawkbit.repository.ControllerManagement;
|
import org.eclipse.hawkbit.repository.ControllerManagement;
|
||||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||||
import org.eclipse.hawkbit.repository.RepositoryConstants;
|
import org.eclipse.hawkbit.repository.RepositoryConstants;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
|
||||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||||
import org.eclipse.hawkbit.repository.builder.ActionStatusCreate;
|
import org.eclipse.hawkbit.repository.builder.ActionStatusCreate;
|
||||||
import org.eclipse.hawkbit.repository.event.remote.DownloadProgressEvent;
|
import org.eclipse.hawkbit.repository.event.remote.DownloadProgressEvent;
|
||||||
@@ -94,9 +93,6 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ControllerManagement controllerManagement;
|
private ControllerManagement controllerManagement;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SoftwareModuleManagement softwareModuleManagement;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ArtifactManagement artifactManagement;
|
private ArtifactManagement artifactManagement;
|
||||||
|
|
||||||
@@ -124,10 +120,10 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
@PathVariable("softwareModuleId") final Long softwareModuleId) {
|
@PathVariable("softwareModuleId") final Long softwareModuleId) {
|
||||||
LOG.debug("getSoftwareModulesArtifacts({})", controllerId);
|
LOG.debug("getSoftwareModulesArtifacts({})", controllerId);
|
||||||
|
|
||||||
final Target target = controllerManagement.findByControllerId(controllerId)
|
final Target target = controllerManagement.getByControllerId(controllerId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||||
|
|
||||||
final SoftwareModule softwareModule = softwareModuleManagement.findSoftwareModuleById(softwareModuleId)
|
final SoftwareModule softwareModule = controllerManagement.getSoftwareModule(softwareModuleId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
return new ResponseEntity<>(
|
||||||
@@ -155,9 +151,9 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
@PathVariable("fileName") final String fileName) {
|
@PathVariable("fileName") final String fileName) {
|
||||||
final ResponseEntity<InputStream> result;
|
final ResponseEntity<InputStream> result;
|
||||||
|
|
||||||
final Target target = controllerManagement.findByControllerId(controllerId)
|
final Target target = controllerManagement.getByControllerId(controllerId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||||
final SoftwareModule module = softwareModuleManagement.findSoftwareModuleById(softwareModuleId)
|
final SoftwareModule module = controllerManagement.getSoftwareModule(softwareModuleId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
|
||||||
|
|
||||||
if (checkModule(fileName, module)) {
|
if (checkModule(fileName, module)) {
|
||||||
@@ -225,10 +221,10 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
@PathVariable("controllerId") final String controllerId,
|
@PathVariable("controllerId") final String controllerId,
|
||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||||
@PathVariable("fileName") final String fileName) {
|
@PathVariable("fileName") final String fileName) {
|
||||||
controllerManagement.findByControllerId(controllerId)
|
controllerManagement.getByControllerId(controllerId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||||
|
|
||||||
final SoftwareModule module = softwareModuleManagement.findSoftwareModuleById(softwareModuleId)
|
final SoftwareModule module = controllerManagement.getSoftwareModule(softwareModuleId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
|
||||||
|
|
||||||
if (checkModule(fileName, module)) {
|
if (checkModule(fileName, module)) {
|
||||||
@@ -259,7 +255,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
@RequestParam(value = "actionHistory", defaultValue = DdiRestConstants.NO_ACTION_HISTORY) final Integer actionHistoryMessageCount) {
|
@RequestParam(value = "actionHistory", defaultValue = DdiRestConstants.NO_ACTION_HISTORY) final Integer actionHistoryMessageCount) {
|
||||||
LOG.debug("getControllerBasedeploymentAction({},{})", controllerId, resource);
|
LOG.debug("getControllerBasedeploymentAction({},{})", controllerId, resource);
|
||||||
|
|
||||||
final Target target = controllerManagement.findByControllerId(controllerId)
|
final Target target = controllerManagement.getByControllerId(controllerId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||||
|
|
||||||
final Action action = findActionWithExceptionIfNotFound(actionId);
|
final Action action = findActionWithExceptionIfNotFound(actionId);
|
||||||
@@ -303,7 +299,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
@PathVariable("actionId") @NotEmpty final Long actionId) {
|
@PathVariable("actionId") @NotEmpty final Long actionId) {
|
||||||
LOG.debug("provideBasedeploymentActionFeedback for target [{},{}]: {}", controllerId, actionId, feedback);
|
LOG.debug("provideBasedeploymentActionFeedback for target [{},{}]: {}", controllerId, actionId, feedback);
|
||||||
|
|
||||||
final Target target = controllerManagement.findByControllerId(controllerId)
|
final Target target = controllerManagement.getByControllerId(controllerId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||||
|
|
||||||
if (!actionId.equals(feedback.getId())) {
|
if (!actionId.equals(feedback.getId())) {
|
||||||
@@ -404,7 +400,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
@PathVariable("actionId") @NotEmpty final Long actionId) {
|
@PathVariable("actionId") @NotEmpty final Long actionId) {
|
||||||
LOG.debug("getControllerCancelAction({})", controllerId);
|
LOG.debug("getControllerCancelAction({})", controllerId);
|
||||||
|
|
||||||
final Target target = controllerManagement.findByControllerId(controllerId)
|
final Target target = controllerManagement.getByControllerId(controllerId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||||
|
|
||||||
final Action action = findActionWithExceptionIfNotFound(actionId);
|
final Action action = findActionWithExceptionIfNotFound(actionId);
|
||||||
@@ -435,7 +431,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
|||||||
@PathVariable("actionId") @NotEmpty final Long actionId) {
|
@PathVariable("actionId") @NotEmpty final Long actionId) {
|
||||||
LOG.debug("provideCancelActionFeedback for target [{}]: {}", controllerId, feedback);
|
LOG.debug("provideCancelActionFeedback for target [{}]: {}", controllerId, feedback);
|
||||||
|
|
||||||
final Target target = controllerManagement.findByControllerId(controllerId)
|
final Target target = controllerManagement.getByControllerId(controllerId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||||
|
|
||||||
if (!actionId.equals(feedback.getId())) {
|
if (!actionId.equals(feedback.getId())) {
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
|||||||
|
|
||||||
// create artifact
|
// create artifact
|
||||||
final byte random[] = RandomUtils.nextBytes(5 * 1024);
|
final byte random[] = RandomUtils.nextBytes(5 * 1024);
|
||||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random),
|
||||||
ds.findFirstModuleByType(osType).get().getId(), "file1", false);
|
ds.findFirstModuleByType(osType).get().getId(), "file1", false);
|
||||||
|
|
||||||
// no artifact available
|
// no artifact available
|
||||||
@@ -160,7 +160,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
|||||||
public void downloadArtifactThroughFileName() throws Exception {
|
public void downloadArtifactThroughFileName() throws Exception {
|
||||||
downLoadProgress = 1;
|
downLoadProgress = 1;
|
||||||
shippedBytes = 0;
|
shippedBytes = 0;
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
|
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(0);
|
||||||
|
|
||||||
// create target
|
// create target
|
||||||
final Target target = testdataFactory.createTarget();
|
final Target target = testdataFactory.createTarget();
|
||||||
@@ -171,7 +171,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
|||||||
|
|
||||||
// create artifact
|
// create artifact
|
||||||
final byte random[] = RandomUtils.nextBytes(ARTIFACT_SIZE);
|
final byte random[] = RandomUtils.nextBytes(ARTIFACT_SIZE);
|
||||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random),
|
||||||
ds.findFirstModuleByType(osType).get().getId(), "file1", false);
|
ds.findFirstModuleByType(osType).get().getId(), "file1", false);
|
||||||
|
|
||||||
// download fails as artifact is not yet assigned
|
// download fails as artifact is not yet assigned
|
||||||
@@ -210,7 +210,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
|||||||
|
|
||||||
// create artifact
|
// create artifact
|
||||||
final byte random[] = RandomUtils.nextBytes(5 * 1024);
|
final byte random[] = RandomUtils.nextBytes(5 * 1024);
|
||||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), getOsModule(ds),
|
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random), getOsModule(ds),
|
||||||
"file1", false);
|
"file1", false);
|
||||||
|
|
||||||
// download
|
// download
|
||||||
@@ -242,7 +242,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
|||||||
|
|
||||||
// create artifact
|
// create artifact
|
||||||
final byte random[] = RandomUtils.nextBytes(resultLength);
|
final byte random[] = RandomUtils.nextBytes(resultLength);
|
||||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), getOsModule(ds),
|
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random), getOsModule(ds),
|
||||||
"file1", false);
|
"file1", false);
|
||||||
|
|
||||||
assertThat(random.length).isEqualTo(resultLength);
|
assertThat(random.length).isEqualTo(resultLength);
|
||||||
|
|||||||
@@ -92,8 +92,9 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.isEqualTo(ds);
|
.isEqualTo(ds);
|
||||||
assertThat(deploymentManagement.getInstalledDistributionSet(TestdataFactory.DEFAULT_CONTROLLER_ID).get())
|
assertThat(deploymentManagement.getInstalledDistributionSet(TestdataFactory.DEFAULT_CONTROLLER_ID).get())
|
||||||
.isEqualTo(ds);
|
.isEqualTo(ds);
|
||||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
assertThat(
|
||||||
.getInstallationDate()).isGreaterThanOrEqualTo(current);
|
targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getInstallationDate())
|
||||||
|
.isGreaterThanOrEqualTo(current);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,10 +118,10 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
|||||||
Thread.sleep(1); // is required: otherwise processing the next line is
|
Thread.sleep(1); // is required: otherwise processing the next line is
|
||||||
// often too fast and
|
// often too fast and
|
||||||
// the following assert will fail
|
// the following assert will fail
|
||||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getLastTargetQuery())
|
||||||
.getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getLastTargetQuery())
|
||||||
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
.isGreaterThanOrEqualTo(current);
|
||||||
|
|
||||||
// Retrieved is reported
|
// Retrieved is reported
|
||||||
|
|
||||||
@@ -150,22 +151,22 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
|||||||
Thread.sleep(1); // is required: otherwise processing the next line is
|
Thread.sleep(1); // is required: otherwise processing the next line is
|
||||||
// often too fast and
|
// often too fast and
|
||||||
// the following assert will fail
|
// the following assert will fail
|
||||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getLastTargetQuery())
|
||||||
.getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getLastTargetQuery())
|
||||||
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
.isGreaterThanOrEqualTo(current);
|
||||||
|
|
||||||
current = System.currentTimeMillis();
|
current = System.currentTimeMillis();
|
||||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getLastTargetQuery())
|
||||||
.getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
|
mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
|
||||||
+ cancelAction.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON))
|
+ cancelAction.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||||
.andExpect(jsonPath("$.id", equalTo(String.valueOf(cancelAction.getId()))))
|
.andExpect(jsonPath("$.id", equalTo(String.valueOf(cancelAction.getId()))))
|
||||||
.andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(actionId))));
|
.andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(actionId))));
|
||||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getLastTargetQuery())
|
||||||
.getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
|
|
||||||
// controller confirmed cancelled action, should not be active anymore
|
// controller confirmed cancelled action, should not be active anymore
|
||||||
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
|
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
|
||||||
|
|||||||
@@ -60,9 +60,9 @@ public class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
|
|||||||
Thread.sleep(1); // is required: otherwise processing the next line is
|
Thread.sleep(1); // is required: otherwise processing the next line is
|
||||||
// often too fast and
|
// often too fast and
|
||||||
// the following assert will fail
|
// the following assert will fail
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getLastTargetQuery())
|
assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
|
||||||
.isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getLastTargetQuery())
|
assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
|
||||||
.isGreaterThanOrEqualTo(current);
|
.isGreaterThanOrEqualTo(current);
|
||||||
|
|
||||||
final Map<String, String> attributes = Maps.newHashMapWithExpectedSize(1);
|
final Map<String, String> attributes = Maps.newHashMapWithExpectedSize(1);
|
||||||
|
|||||||
@@ -111,9 +111,9 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);
|
final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);
|
||||||
|
|
||||||
final byte random[] = RandomUtils.nextBytes(5 * 1024);
|
final byte random[] = RandomUtils.nextBytes(5 * 1024);
|
||||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), getOsModule(ds),
|
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random), getOsModule(ds),
|
||||||
"test1", false);
|
"test1", false);
|
||||||
final Artifact artifactSignature = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
final Artifact artifactSignature = artifactManagement.create(new ByteArrayInputStream(random),
|
||||||
getOsModule(ds), "test1.signature", false);
|
getOsModule(ds), "test1.signature", false);
|
||||||
|
|
||||||
final Target savedTarget = testdataFactory.createTarget("4712");
|
final Target savedTarget = testdataFactory.createTarget("4712");
|
||||||
@@ -147,16 +147,15 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00")))
|
.andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00")))
|
||||||
.andExpect(jsonPath("$._links.deploymentBase.href", startsWith("http://localhost/"
|
.andExpect(jsonPath("$._links.deploymentBase.href", startsWith("http://localhost/"
|
||||||
+ tenantAware.getCurrentTenant() + "/controller/v1/4712/deploymentBase/" + uaction.getId())));
|
+ tenantAware.getCurrentTenant() + "/controller/v1/4712/deploymentBase/" + uaction.getId())));
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getLastTargetQuery())
|
assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
|
||||||
.isGreaterThanOrEqualTo(current);
|
.isGreaterThanOrEqualTo(current);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getLastTargetQuery())
|
assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
|
||||||
.isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2);
|
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2);
|
||||||
|
|
||||||
current = System.currentTimeMillis();
|
current = System.currentTimeMillis();
|
||||||
|
|
||||||
final DistributionSet findDistributionSetByAction = distributionSetManagement
|
final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId()).get();
|
||||||
.findDistributionSetByAction(action.getId()).get();
|
|
||||||
|
|
||||||
mvc.perform(
|
mvc.perform(
|
||||||
get("/{tenant}/controller/v1/4712/deploymentBase/" + uaction.getId(), tenantAware.getCurrentTenant())
|
get("/{tenant}/controller/v1/4712/deploymentBase/" + uaction.getId(), tenantAware.getCurrentTenant())
|
||||||
@@ -268,9 +267,9 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);
|
final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);
|
||||||
|
|
||||||
final byte random[] = RandomUtils.nextBytes(5 * 1024);
|
final byte random[] = RandomUtils.nextBytes(5 * 1024);
|
||||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), getOsModule(ds),
|
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random), getOsModule(ds),
|
||||||
"test1", false);
|
"test1", false);
|
||||||
final Artifact artifactSignature = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
final Artifact artifactSignature = artifactManagement.create(new ByteArrayInputStream(random),
|
||||||
getOsModule(ds), "test1.signature", false);
|
getOsModule(ds), "test1.signature", false);
|
||||||
|
|
||||||
final Target savedTarget = testdataFactory.createTarget("4712");
|
final Target savedTarget = testdataFactory.createTarget("4712");
|
||||||
@@ -305,14 +304,13 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00")))
|
.andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00")))
|
||||||
.andExpect(jsonPath("$._links.deploymentBase.href", startsWith("http://localhost/"
|
.andExpect(jsonPath("$._links.deploymentBase.href", startsWith("http://localhost/"
|
||||||
+ tenantAware.getCurrentTenant() + "/controller/v1/4712/deploymentBase/" + uaction.getId())));
|
+ tenantAware.getCurrentTenant() + "/controller/v1/4712/deploymentBase/" + uaction.getId())));
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getLastTargetQuery())
|
assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
|
||||||
.isGreaterThanOrEqualTo(current);
|
.isGreaterThanOrEqualTo(current);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getLastTargetQuery())
|
assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
|
||||||
.isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2);
|
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2);
|
||||||
|
|
||||||
final DistributionSet findDistributionSetByAction = distributionSetManagement
|
final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId()).get();
|
||||||
.findDistributionSetByAction(action.getId()).get();
|
|
||||||
|
|
||||||
mvc.perform(
|
mvc.perform(
|
||||||
get("/{tenant}/controller/v1/4712/deploymentBase/" + uaction.getId(), tenantAware.getCurrentTenant())
|
get("/{tenant}/controller/v1/4712/deploymentBase/" + uaction.getId(), tenantAware.getCurrentTenant())
|
||||||
@@ -383,9 +381,9 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);
|
final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);
|
||||||
|
|
||||||
final byte random[] = RandomUtils.nextBytes(5 * 1024);
|
final byte random[] = RandomUtils.nextBytes(5 * 1024);
|
||||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), getOsModule(ds),
|
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random), getOsModule(ds),
|
||||||
"test1", false);
|
"test1", false);
|
||||||
final Artifact artifactSignature = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
final Artifact artifactSignature = artifactManagement.create(new ByteArrayInputStream(random),
|
||||||
getOsModule(ds), "test1.signature", false);
|
getOsModule(ds), "test1.signature", false);
|
||||||
|
|
||||||
final Target savedTarget = testdataFactory.createTarget("4712");
|
final Target savedTarget = testdataFactory.createTarget("4712");
|
||||||
@@ -419,16 +417,15 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00")))
|
.andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00")))
|
||||||
.andExpect(jsonPath("$._links.deploymentBase.href", startsWith("http://localhost/"
|
.andExpect(jsonPath("$._links.deploymentBase.href", startsWith("http://localhost/"
|
||||||
+ tenantAware.getCurrentTenant() + "/controller/v1/4712/deploymentBase/" + uaction.getId())));
|
+ tenantAware.getCurrentTenant() + "/controller/v1/4712/deploymentBase/" + uaction.getId())));
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getLastTargetQuery())
|
assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
|
||||||
.isGreaterThanOrEqualTo(current);
|
.isGreaterThanOrEqualTo(current);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getLastTargetQuery())
|
assertThat(targetManagement.getByControllerID("4712").get().getLastTargetQuery())
|
||||||
.isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2);
|
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2);
|
||||||
|
|
||||||
current = System.currentTimeMillis();
|
current = System.currentTimeMillis();
|
||||||
|
|
||||||
final DistributionSet findDistributionSetByAction = distributionSetManagement
|
final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId()).get();
|
||||||
.findDistributionSetByAction(action.getId()).get();
|
|
||||||
|
|
||||||
mvc.perform(get("/{tenant}/controller/v1/4712/deploymentBase/{actionId}", tenantAware.getCurrentTenant(),
|
mvc.perform(get("/{tenant}/controller/v1/4712/deploymentBase/{actionId}", tenantAware.getCurrentTenant(),
|
||||||
uaction.getId()).accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
uaction.getId()).accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||||
@@ -596,13 +593,12 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
final Long actionId2 = assignDistributionSet(ds2.getId(), "4712").getActions().get(0);
|
final Long actionId2 = assignDistributionSet(ds2.getId(), "4712").getActions().get(0);
|
||||||
final Long actionId3 = assignDistributionSet(ds3.getId(), "4712").getActions().get(0);
|
final Long actionId3 = assignDistributionSet(ds3.getId(), "4712").getActions().get(0);
|
||||||
|
|
||||||
Target myT = targetManagement.findTargetByControllerID("4712").get();
|
Target myT = targetManagement.getByControllerID("4712").get();
|
||||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(3);
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(3);
|
||||||
assertThat(deploymentManagement.getAssignedDistributionSet(myT.getControllerId()).get()).isEqualTo(ds3);
|
assertThat(deploymentManagement.getAssignedDistributionSet(myT.getControllerId()).get()).isEqualTo(ds3);
|
||||||
assertThat(deploymentManagement.getInstalledDistributionSet(myT.getControllerId())).isNotPresent();
|
assertThat(deploymentManagement.getInstalledDistributionSet(myT.getControllerId())).isNotPresent();
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.UNKNOWN))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.UNKNOWN)).hasSize(2);
|
||||||
.hasSize(2);
|
|
||||||
|
|
||||||
// action1 done
|
// action1 done
|
||||||
|
|
||||||
@@ -611,7 +607,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.content(JsonBuilder.deploymentActionFeedback(actionId1.toString(), "closed"))
|
.content(JsonBuilder.deploymentActionFeedback(actionId1.toString(), "closed"))
|
||||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
myT = targetManagement.findTargetByControllerID("4712").get();
|
myT = targetManagement.getByControllerID("4712").get();
|
||||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(2);
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(2);
|
||||||
assertThat(deploymentManagement.getAssignedDistributionSet(myT.getControllerId()).get()).isEqualTo(ds3);
|
assertThat(deploymentManagement.getAssignedDistributionSet(myT.getControllerId()).get()).isEqualTo(ds3);
|
||||||
@@ -628,7 +624,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.content(JsonBuilder.deploymentActionFeedback(actionId2.toString(), "closed"))
|
.content(JsonBuilder.deploymentActionFeedback(actionId2.toString(), "closed"))
|
||||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
myT = targetManagement.findTargetByControllerID("4712").get();
|
myT = targetManagement.getByControllerID("4712").get();
|
||||||
|
|
||||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(1);
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(1);
|
||||||
@@ -645,7 +641,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.content(JsonBuilder.deploymentActionFeedback(actionId3.toString(), "closed"))
|
.content(JsonBuilder.deploymentActionFeedback(actionId3.toString(), "closed"))
|
||||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
myT = targetManagement.findTargetByControllerID("4712").get();
|
myT = targetManagement.getByControllerID("4712").get();
|
||||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(0);
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(0);
|
||||||
assertThat(deploymentManagement.getAssignedDistributionSet(myT.getControllerId()).get()).isEqualTo(ds3);
|
assertThat(deploymentManagement.getAssignedDistributionSet(myT.getControllerId()).get()).isEqualTo(ds3);
|
||||||
@@ -666,7 +662,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
final List<Target> toAssign = new ArrayList<>();
|
final List<Target> toAssign = new ArrayList<>();
|
||||||
toAssign.add(savedTarget);
|
toAssign.add(savedTarget);
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus())
|
||||||
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||||
assignDistributionSet(ds, toAssign);
|
assignDistributionSet(ds, toAssign);
|
||||||
final Action action = deploymentManagement.findActionsByDistributionSet(PAGE, ds.getId()).getContent().get(0);
|
final Action action = deploymentManagement.findActionsByDistributionSet(PAGE, ds.getId()).getContent().get(0);
|
||||||
@@ -677,15 +673,12 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
"error message"))
|
"error message"))
|
||||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
Target myT = targetManagement.findTargetByControllerID("4712").get();
|
Target myT = targetManagement.getByControllerID("4712").get();
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus())
|
||||||
.isEqualTo(TargetUpdateStatus.ERROR);
|
.isEqualTo(TargetUpdateStatus.ERROR);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.PENDING))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.PENDING)).hasSize(0);
|
||||||
.hasSize(0);
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR)).hasSize(1);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC)).hasSize(0);
|
||||||
.hasSize(1);
|
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC))
|
|
||||||
.hasSize(0);
|
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(0);
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(0);
|
||||||
assertThat(deploymentManagement.countActionsByTarget(myT.getControllerId())).isEqualTo(1);
|
assertThat(deploymentManagement.countActionsByTarget(myT.getControllerId())).isEqualTo(1);
|
||||||
final Iterable<ActionStatus> actionStatusMessages = deploymentManagement
|
final Iterable<ActionStatus> actionStatusMessages = deploymentManagement
|
||||||
@@ -694,8 +687,8 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
assertThat(actionStatusMessages).haveAtLeast(1, new ActionStatusCondition(Status.ERROR));
|
assertThat(actionStatusMessages).haveAtLeast(1, new ActionStatusCondition(Status.ERROR));
|
||||||
|
|
||||||
// redo
|
// redo
|
||||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
ds = distributionSetManagement.getWithDetails(ds.getId()).get();
|
||||||
assignDistributionSet(ds, Arrays.asList(targetManagement.findTargetByControllerID("4712").get()));
|
assignDistributionSet(ds, Arrays.asList(targetManagement.getByControllerID("4712").get()));
|
||||||
final Action action2 = deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId()).getContent()
|
final Action action2 = deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId()).getContent()
|
||||||
.get(0);
|
.get(0);
|
||||||
|
|
||||||
@@ -705,14 +698,11 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
myT = targetManagement.findTargetByControllerID("4712").get();
|
myT = targetManagement.getByControllerID("4712").get();
|
||||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.PENDING))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.PENDING)).hasSize(0);
|
||||||
.hasSize(0);
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR)).hasSize(0);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC)).hasSize(1);
|
||||||
.hasSize(0);
|
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC))
|
|
||||||
.hasSize(1);
|
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(0);
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(0);
|
||||||
assertThat(deploymentManagement.findInActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(2);
|
assertThat(deploymentManagement.findInActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(2);
|
||||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(4);
|
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(4);
|
||||||
@@ -732,15 +722,15 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
|
|
||||||
final List<Target> toAssign = Arrays.asList(savedTarget);
|
final List<Target> toAssign = Arrays.asList(savedTarget);
|
||||||
|
|
||||||
Target myT = targetManagement.findTargetByControllerID("4712").get();
|
Target myT = targetManagement.getByControllerID("4712").get();
|
||||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.UNKNOWN);
|
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||||
assignDistributionSet(ds, toAssign);
|
assignDistributionSet(ds, toAssign);
|
||||||
final Action action = deploymentManagement.findActionsByDistributionSet(PAGE, ds.getId()).getContent().get(0);
|
final Action action = deploymentManagement.findActionsByDistributionSet(PAGE, ds.getId()).getContent().get(0);
|
||||||
|
|
||||||
myT = targetManagement.findTargetByControllerID("4712").get();
|
myT = targetManagement.getByControllerID("4712").get();
|
||||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
assertThat(targetManagement.findTargetByInstalledDistributionSet(ds.getId(), PAGE)).hasSize(0);
|
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, ds.getId())).hasSize(0);
|
||||||
assertThat(targetManagement.findTargetByAssignedDistributionSet(ds.getId(), PAGE)).hasSize(1);
|
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId())).hasSize(1);
|
||||||
|
|
||||||
// Now valid Feedback
|
// Now valid Feedback
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
@@ -751,14 +741,11 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
myT = targetManagement.findTargetByControllerID("4712").get();
|
myT = targetManagement.getByControllerID("4712").get();
|
||||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.PENDING))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.PENDING)).hasSize(1);
|
||||||
.hasSize(1);
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR)).hasSize(0);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC)).hasSize(0);
|
||||||
.hasSize(0);
|
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC))
|
|
||||||
.hasSize(0);
|
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(1);
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(1);
|
||||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(5);
|
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(5);
|
||||||
assertThat(deploymentManagement.findActionStatusAll(PAGE).getContent()).haveAtLeast(5,
|
assertThat(deploymentManagement.findActionStatusAll(PAGE).getContent()).haveAtLeast(5,
|
||||||
@@ -769,14 +756,11 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.content(JsonBuilder.deploymentActionFeedback(action.getId().toString(), "scheduled"))
|
.content(JsonBuilder.deploymentActionFeedback(action.getId().toString(), "scheduled"))
|
||||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
myT = targetManagement.findTargetByControllerID("4712").get();
|
myT = targetManagement.getByControllerID("4712").get();
|
||||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.PENDING))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.PENDING)).hasSize(1);
|
||||||
.hasSize(1);
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR)).hasSize(0);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC)).hasSize(0);
|
||||||
.hasSize(0);
|
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC))
|
|
||||||
.hasSize(0);
|
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(1);
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(1);
|
||||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(6);
|
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(6);
|
||||||
assertThat(deploymentManagement.findActionStatusAll(PAGE).getContent()).haveAtLeast(5,
|
assertThat(deploymentManagement.findActionStatusAll(PAGE).getContent()).haveAtLeast(5,
|
||||||
@@ -787,14 +771,11 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.content(JsonBuilder.deploymentActionFeedback(action.getId().toString(), "resumed"))
|
.content(JsonBuilder.deploymentActionFeedback(action.getId().toString(), "resumed"))
|
||||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
myT = targetManagement.findTargetByControllerID("4712").get();
|
myT = targetManagement.getByControllerID("4712").get();
|
||||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.PENDING))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.PENDING)).hasSize(1);
|
||||||
.hasSize(1);
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR)).hasSize(0);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC)).hasSize(0);
|
||||||
.hasSize(0);
|
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC))
|
|
||||||
.hasSize(0);
|
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(1);
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(1);
|
||||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(7);
|
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(7);
|
||||||
assertThat(deploymentManagement.findActionStatusAll(PAGE).getContent()).haveAtLeast(6,
|
assertThat(deploymentManagement.findActionStatusAll(PAGE).getContent()).haveAtLeast(6,
|
||||||
@@ -805,15 +786,12 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.content(JsonBuilder.deploymentActionFeedback(action.getId().toString(), "canceled"))
|
.content(JsonBuilder.deploymentActionFeedback(action.getId().toString(), "canceled"))
|
||||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
myT = targetManagement.findTargetByControllerID("4712").get();
|
myT = targetManagement.getByControllerID("4712").get();
|
||||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(1);
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(1);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.PENDING))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.PENDING)).hasSize(1);
|
||||||
.hasSize(1);
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR)).hasSize(0);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC)).hasSize(0);
|
||||||
.hasSize(0);
|
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC))
|
|
||||||
.hasSize(0);
|
|
||||||
|
|
||||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(8);
|
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(8);
|
||||||
assertThat(deploymentManagement.findActionStatusAll(PAGE).getContent()).haveAtLeast(7,
|
assertThat(deploymentManagement.findActionStatusAll(PAGE).getContent()).haveAtLeast(7,
|
||||||
@@ -826,7 +804,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.content(JsonBuilder.deploymentActionFeedback(action.getId().toString(), "rejected"))
|
.content(JsonBuilder.deploymentActionFeedback(action.getId().toString(), "rejected"))
|
||||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
myT = targetManagement.findTargetByControllerID("4712").get();
|
myT = targetManagement.getByControllerID("4712").get();
|
||||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(1);
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(1);
|
||||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(9);
|
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(9);
|
||||||
@@ -842,13 +820,11 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.content(JsonBuilder.deploymentActionFeedback(action.getId().toString(), "closed"))
|
.content(JsonBuilder.deploymentActionFeedback(action.getId().toString(), "closed"))
|
||||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
myT = targetManagement.findTargetByControllerID("4712").get();
|
myT = targetManagement.getByControllerID("4712").get();
|
||||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(0);
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(0);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR))
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR)).hasSize(0);
|
||||||
.hasSize(0);
|
assertThat(targetManagement.findByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC)).hasSize(1);
|
||||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC))
|
|
||||||
.hasSize(1);
|
|
||||||
|
|
||||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(10);
|
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(10);
|
||||||
assertThat(deploymentManagement.findActionStatusAll(PAGE).getContent()).haveAtLeast(7,
|
assertThat(deploymentManagement.findActionStatusAll(PAGE).getContent()).haveAtLeast(7,
|
||||||
@@ -860,8 +836,8 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
|||||||
assertThat(deploymentManagement.findActionStatusAll(PAGE).getContent()).haveAtLeast(1,
|
assertThat(deploymentManagement.findActionStatusAll(PAGE).getContent()).haveAtLeast(1,
|
||||||
new ActionStatusCondition(Status.FINISHED));
|
new ActionStatusCondition(Status.FINISHED));
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetByInstalledDistributionSet(ds.getId(), PAGE)).hasSize(1);
|
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, ds.getId())).hasSize(1);
|
||||||
assertThat(targetManagement.findTargetByAssignedDistributionSet(ds.getId(), PAGE)).hasSize(1);
|
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId())).hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -103,8 +103,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
|||||||
final String knownTargetControllerId = "target1";
|
final String knownTargetControllerId = "target1";
|
||||||
final String knownCreatedBy = "knownPrincipal";
|
final String knownCreatedBy = "knownPrincipal";
|
||||||
testdataFactory.createTarget(knownTargetControllerId);
|
testdataFactory.createTarget(knownTargetControllerId);
|
||||||
final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownTargetControllerId)
|
final Target findTargetByControllerID = targetManagement.getByControllerID(knownTargetControllerId).get();
|
||||||
.get();
|
|
||||||
assertThat(findTargetByControllerID.getCreatedBy()).isEqualTo(knownCreatedBy);
|
assertThat(findTargetByControllerID.getCreatedBy()).isEqualTo(knownCreatedBy);
|
||||||
assertThat(findTargetByControllerID.getCreatedAt()).isNotNull();
|
assertThat(findTargetByControllerID.getCreatedAt()).isNotNull();
|
||||||
|
|
||||||
@@ -117,7 +116,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// verify that audit information has not changed
|
// verify that audit information has not changed
|
||||||
final Target targetVerify = targetManagement.findTargetByControllerID(knownTargetControllerId).get();
|
final Target targetVerify = targetManagement.getByControllerID(knownTargetControllerId).get();
|
||||||
assertThat(targetVerify.getCreatedBy()).isEqualTo(findTargetByControllerID.getCreatedBy());
|
assertThat(targetVerify.getCreatedBy()).isEqualTo(findTargetByControllerID.getCreatedBy());
|
||||||
assertThat(targetVerify.getCreatedAt()).isEqualTo(findTargetByControllerID.getCreatedAt());
|
assertThat(targetVerify.getCreatedAt()).isEqualTo(findTargetByControllerID.getCreatedAt());
|
||||||
assertThat(targetVerify.getLastModifiedBy()).isEqualTo(findTargetByControllerID.getLastModifiedBy());
|
assertThat(targetVerify.getLastModifiedBy()).isEqualTo(findTargetByControllerID.getLastModifiedBy());
|
||||||
@@ -141,10 +140,10 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
|||||||
mvc.perform(get("/default-tenant/controller/v1/4711")).andDo(MockMvcResultPrinter.print())
|
mvc.perform(get("/default-tenant/controller/v1/4711")).andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_HAL_UTF))
|
.andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_HAL_UTF))
|
||||||
.andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00")));
|
.andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00")));
|
||||||
assertThat(targetManagement.findTargetByControllerID("4711").get().getLastTargetQuery())
|
assertThat(targetManagement.getByControllerID("4711").get().getLastTargetQuery())
|
||||||
.isGreaterThanOrEqualTo(current);
|
.isGreaterThanOrEqualTo(current);
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetByControllerID("4711").get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID("4711").get().getUpdateStatus())
|
||||||
.isEqualTo(TargetUpdateStatus.REGISTERED);
|
.isEqualTo(TargetUpdateStatus.REGISTERED);
|
||||||
|
|
||||||
// not allowed methods
|
// not allowed methods
|
||||||
@@ -198,7 +197,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
|||||||
mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()).header("If-None-Match", etag))
|
mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()).header("If-None-Match", etag))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotModified());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotModified());
|
||||||
|
|
||||||
final Target target = targetManagement.findTargetByControllerID("4711").get();
|
final Target target = targetManagement.getByControllerID("4711").get();
|
||||||
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
||||||
|
|
||||||
assignDistributionSet(ds.getId(), "4711");
|
assignDistributionSet(ds.getId(), "4711");
|
||||||
@@ -259,7 +258,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
|||||||
public void rootRsPrecommissioned() throws Exception {
|
public void rootRsPrecommissioned() throws Exception {
|
||||||
final Target target = testdataFactory.createTarget("4711");
|
final Target target = testdataFactory.createTarget("4711");
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetByControllerID("4711").get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID("4711").get().getUpdateStatus())
|
||||||
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||||
|
|
||||||
final long current = System.currentTimeMillis();
|
final long current = System.currentTimeMillis();
|
||||||
@@ -268,12 +267,12 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.andExpect(content().contentType(APPLICATION_JSON_HAL_UTF))
|
.andExpect(content().contentType(APPLICATION_JSON_HAL_UTF))
|
||||||
.andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00")));
|
.andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00")));
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetByControllerID("4711").get().getLastTargetQuery())
|
assertThat(targetManagement.getByControllerID("4711").get().getLastTargetQuery())
|
||||||
.isLessThanOrEqualTo(System.currentTimeMillis());
|
.isLessThanOrEqualTo(System.currentTimeMillis());
|
||||||
assertThat(targetManagement.findTargetByControllerID("4711").get().getLastTargetQuery())
|
assertThat(targetManagement.getByControllerID("4711").get().getLastTargetQuery())
|
||||||
.isGreaterThanOrEqualTo(current);
|
.isGreaterThanOrEqualTo(current);
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetByControllerID("4711").get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID("4711").get().getUpdateStatus())
|
||||||
.isEqualTo(TargetUpdateStatus.REGISTERED);
|
.isEqualTo(TargetUpdateStatus.REGISTERED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +294,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// verify
|
// verify
|
||||||
final Target target = targetManagement.findTargetByControllerID(knownControllerId1).get();
|
final Target target = targetManagement.getByControllerID(knownControllerId1).get();
|
||||||
assertThat(target.getAddress()).isEqualTo(IpUtil.createHttpUri("127.0.0.1"));
|
assertThat(target.getAddress()).isEqualTo(IpUtil.createHttpUri("127.0.0.1"));
|
||||||
assertThat(target.getCreatedBy()).isEqualTo("CONTROLLER_PLUG_AND_PLAY");
|
assertThat(target.getCreatedBy()).isEqualTo("CONTROLLER_PLUG_AND_PLAY");
|
||||||
assertThat(target.getCreatedAt()).isGreaterThanOrEqualTo(create);
|
assertThat(target.getCreatedAt()).isGreaterThanOrEqualTo(create);
|
||||||
@@ -317,7 +316,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
|||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
// verify
|
// verify
|
||||||
final Target target = targetManagement.findTargetByControllerID(knownControllerId1).get();
|
final Target target = targetManagement.getByControllerID(knownControllerId1).get();
|
||||||
assertThat(target.getAddress()).isEqualTo(IpUtil.createHttpUri("***"));
|
assertThat(target.getAddress()).isEqualTo(IpUtil.createHttpUri("***"));
|
||||||
|
|
||||||
securityProperties.getClients().setTrackRemoteIp(true);
|
securityProperties.getClients().setTrackRemoteIp(true);
|
||||||
@@ -336,8 +335,8 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
|||||||
Target savedTarget = testdataFactory.createTarget("911");
|
Target savedTarget = testdataFactory.createTarget("911");
|
||||||
savedTarget = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getAssignedEntity().iterator()
|
savedTarget = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getAssignedEntity().iterator()
|
||||||
.next();
|
.next();
|
||||||
final Action savedAction = deploymentManagement
|
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
|
||||||
.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0);
|
.getContent().get(0);
|
||||||
mvc.perform(post("/{tenant}/controller/v1/911/deploymentBase/" + savedAction.getId() + "/feedback",
|
mvc.perform(post("/{tenant}/controller/v1/911/deploymentBase/" + savedAction.getId() + "/feedback",
|
||||||
tenantAware.getCurrentTenant())
|
tenantAware.getCurrentTenant())
|
||||||
.content(JsonBuilder.deploymentActionFeedback(savedAction.getId().toString(), "proceeding"))
|
.content(JsonBuilder.deploymentActionFeedback(savedAction.getId().toString(), "proceeding"))
|
||||||
|
|||||||
@@ -168,19 +168,19 @@ public class AmqpAuthenticationMessageHandler extends BaseAmqpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fileResource.getSha1() != null) {
|
if (fileResource.getSha1() != null) {
|
||||||
return artifactManagement.findFirstArtifactBySHA1(fileResource.getSha1());
|
return artifactManagement.findFirstBySHA1(fileResource.getSha1());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileResource.getFilename() != null) {
|
if (fileResource.getFilename() != null) {
|
||||||
return artifactManagement.findArtifactByFilename(fileResource.getFilename());
|
return artifactManagement.getByFilename(fileResource.getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileResource.getArtifactId() != null) {
|
if (fileResource.getArtifactId() != null) {
|
||||||
return artifactManagement.findArtifact(fileResource.getArtifactId());
|
return artifactManagement.get(fileResource.getArtifactId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileResource.getSoftwareModuleFilenameResource() != null) {
|
if (fileResource.getSoftwareModuleFilenameResource() != null) {
|
||||||
return artifactManagement.findByFilenameAndSoftwareModule(
|
return artifactManagement.getByFilenameAndSoftwareModule(
|
||||||
fileResource.getSoftwareModuleFilenameResource().getFilename(),
|
fileResource.getSoftwareModuleFilenameResource().getFilename(),
|
||||||
fileResource.getSoftwareModuleFilenameResource().getSoftwareModuleId());
|
fileResource.getSoftwareModuleFilenameResource().getSoftwareModuleId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
|||||||
LOG.debug("targetAssignDistributionSet retrieved for controller {}. I will forward it to DMF broker.",
|
LOG.debug("targetAssignDistributionSet retrieved for controller {}. I will forward it to DMF broker.",
|
||||||
assignedEvent.getControllerId());
|
assignedEvent.getControllerId());
|
||||||
|
|
||||||
targetManagement.findTargetByControllerID(assignedEvent.getControllerId())
|
targetManagement.getByControllerID(assignedEvent.getControllerId())
|
||||||
.ifPresent(target -> sendUpdateMessageToTarget(assignedEvent.getTenant(), target,
|
.ifPresent(target -> sendUpdateMessageToTarget(assignedEvent.getTenant(), target,
|
||||||
assignedEvent.getActionId(), assignedEvent.getModules()));
|
assignedEvent.getActionId(), assignedEvent.getModules()));
|
||||||
|
|
||||||
|
|||||||
@@ -137,8 +137,8 @@ public class AmqpControllerAuthenticationTest {
|
|||||||
.thenReturn(CONFIG_VALUE_FALSE);
|
.thenReturn(CONFIG_VALUE_FALSE);
|
||||||
|
|
||||||
final ControllerManagement controllerManagement = mock(ControllerManagement.class);
|
final ControllerManagement controllerManagement = mock(ControllerManagement.class);
|
||||||
when(controllerManagement.findByControllerId(anyString())).thenReturn(Optional.of(targteMock));
|
when(controllerManagement.getByControllerId(anyString())).thenReturn(Optional.of(targteMock));
|
||||||
when(controllerManagement.findByTargetId(any(Long.class))).thenReturn(Optional.of(targteMock));
|
when(controllerManagement.get(any(Long.class))).thenReturn(Optional.of(targteMock));
|
||||||
|
|
||||||
when(targteMock.getSecurityToken()).thenReturn(CONTROLLER_ID);
|
when(targteMock.getSecurityToken()).thenReturn(CONTROLLER_ID);
|
||||||
when(targteMock.getControllerId()).thenReturn(CONTROLLER_ID);
|
when(targteMock.getControllerId()).thenReturn(CONTROLLER_ID);
|
||||||
@@ -159,8 +159,8 @@ public class AmqpControllerAuthenticationTest {
|
|||||||
new JpaSoftwareModuleType("a key", "a name", null, 1), "a name", null, null, null));
|
new JpaSoftwareModuleType("a key", "a name", null, 1), "a name", null, null, null));
|
||||||
testArtifact.setId(1L);
|
testArtifact.setId(1L);
|
||||||
|
|
||||||
when(artifactManagementMock.findArtifact(ARTIFACT_ID)).thenReturn(Optional.of(testArtifact));
|
when(artifactManagementMock.get(ARTIFACT_ID)).thenReturn(Optional.of(testArtifact));
|
||||||
when(artifactManagementMock.findFirstArtifactBySHA1(SHA1)).thenReturn(Optional.of(testArtifact));
|
when(artifactManagementMock.findFirstBySHA1(SHA1)).thenReturn(Optional.of(testArtifact));
|
||||||
|
|
||||||
final AbstractDbArtifact artifact = new ArtifactFilesystem(new File("does not exist"), SHA1,
|
final AbstractDbArtifact artifact = new ArtifactFilesystem(new File("does not exist"), SHA1,
|
||||||
new DbArtifactHash(SHA1, "md5 test"), ARTIFACT_SIZE, null);
|
new DbArtifactHash(SHA1, "md5 test"), ARTIFACT_SIZE, null);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
|||||||
@Override
|
@Override
|
||||||
public void before() throws Exception {
|
public void before() throws Exception {
|
||||||
super.before();
|
super.before();
|
||||||
testTarget = targetManagement.createTarget(entityFactory.target().create().controllerId(CONTROLLER_ID)
|
testTarget = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)
|
||||||
.securityToken(TEST_TOKEN).address(AMQP_URI.toString()));
|
.securityToken(TEST_TOKEN).address(AMQP_URI.toString()));
|
||||||
|
|
||||||
this.rabbitTemplate = Mockito.mock(RabbitTemplate.class);
|
this.rabbitTemplate = Mockito.mock(RabbitTemplate.class);
|
||||||
@@ -128,8 +128,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Message getCaptureAdressEvent(final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent) {
|
private Message getCaptureAdressEvent(final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent) {
|
||||||
final Target target = targetManagement
|
final Target target = targetManagement.getByControllerID(targetAssignDistributionSetEvent.getControllerId())
|
||||||
.findTargetByControllerID(targetAssignDistributionSetEvent.getControllerId()).get();
|
.get();
|
||||||
final Message sendMessage = createArgumentCapture(target.getAddress());
|
final Message sendMessage = createArgumentCapture(target.getAddress());
|
||||||
return sendMessage;
|
return sendMessage;
|
||||||
}
|
}
|
||||||
@@ -181,8 +181,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
|
|||||||
receivedList.add(new ArtifactFilesystem(new File("./test"), artifact.getSha1Hash(),
|
receivedList.add(new ArtifactFilesystem(new File("./test"), artifact.getSha1Hash(),
|
||||||
new DbArtifactHash(artifact.getSha1Hash(), null), artifact.getSize(), null));
|
new DbArtifactHash(artifact.getSha1Hash(), null), artifact.getSize(), null));
|
||||||
}
|
}
|
||||||
module = softwareModuleManagement.findSoftwareModuleById(module.getId()).get();
|
module = softwareModuleManagement.get(module.getId()).get();
|
||||||
dsA = distributionSetManagement.findDistributionSetById(dsA.getId()).get();
|
dsA = distributionSetManagement.get(dsA.getId()).get();
|
||||||
|
|
||||||
final Action action = createAction(dsA);
|
final Action action = createAction(dsA);
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
public void before() throws Exception {
|
public void before() throws Exception {
|
||||||
messageConverter = new Jackson2JsonMessageConverter();
|
messageConverter = new Jackson2JsonMessageConverter();
|
||||||
when(rabbitTemplate.getMessageConverter()).thenReturn(messageConverter);
|
when(rabbitTemplate.getMessageConverter()).thenReturn(messageConverter);
|
||||||
when(artifactManagementMock.findFirstArtifactBySHA1(SHA1)).thenReturn(Optional.empty());
|
when(artifactManagementMock.findFirstBySHA1(SHA1)).thenReturn(Optional.empty());
|
||||||
|
|
||||||
amqpMessageHandlerService = new AmqpMessageHandlerService(rabbitTemplate, amqpMessageDispatcherServiceMock,
|
amqpMessageHandlerService = new AmqpMessageHandlerService(rabbitTemplate, amqpMessageDispatcherServiceMock,
|
||||||
controllerManagementMock, entityFactoryMock);
|
controllerManagementMock, entityFactoryMock);
|
||||||
@@ -344,7 +344,7 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
messageProperties);
|
messageProperties);
|
||||||
|
|
||||||
final Artifact localArtifactMock = mock(Artifact.class);
|
final Artifact localArtifactMock = mock(Artifact.class);
|
||||||
when(artifactManagementMock.findFirstArtifactBySHA1(anyString())).thenReturn(Optional.of(localArtifactMock));
|
when(artifactManagementMock.findFirstBySHA1(anyString())).thenReturn(Optional.of(localArtifactMock));
|
||||||
when(controllerManagementMock.getActionForDownloadByTargetAndSoftwareModule(anyObject(), anyObject()))
|
when(controllerManagementMock.getActionForDownloadByTargetAndSoftwareModule(anyObject(), anyObject()))
|
||||||
.thenThrow(EntityNotFoundException.class);
|
.thenThrow(EntityNotFoundException.class);
|
||||||
|
|
||||||
@@ -372,7 +372,7 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
when(localArtifactMock.getSha1Hash()).thenReturn(SHA1);
|
when(localArtifactMock.getSha1Hash()).thenReturn(SHA1);
|
||||||
|
|
||||||
final AbstractDbArtifact dbArtifactMock = mock(AbstractDbArtifact.class);
|
final AbstractDbArtifact dbArtifactMock = mock(AbstractDbArtifact.class);
|
||||||
when(artifactManagementMock.findFirstArtifactBySHA1(SHA1)).thenReturn(Optional.of(localArtifactMock));
|
when(artifactManagementMock.findFirstBySHA1(SHA1)).thenReturn(Optional.of(localArtifactMock));
|
||||||
when(controllerManagementMock.hasTargetArtifactAssigned(securityToken.getControllerId(), SHA1))
|
when(controllerManagementMock.hasTargetArtifactAssigned(securityToken.getControllerId(), SHA1))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
when(artifactManagementMock.loadArtifactBinary(anyString())).thenReturn(Optional.of(dbArtifactMock));
|
when(artifactManagementMock.loadArtifactBinary(anyString())).thenReturn(Optional.of(dbArtifactMock));
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ public class AmqpAuthenticationMessageHandlerIntegrationTest extends AbstractAmq
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Target createTarget(final String controllerId) {
|
private Target createTarget(final String controllerId) {
|
||||||
return targetManagement.createTarget(
|
return targetManagement.create(
|
||||||
entityFactory.target().create().controllerId(controllerId).securityToken(TARGET_SECRUITY_TOKEN));
|
entityFactory.target().create().controllerId(controllerId).securityToken(TARGET_SECRUITY_TOKEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,13 +108,13 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AmqpServiceInte
|
|||||||
final String controllerId = TARGET_PREFIX + "sendDeleteMessage";
|
final String controllerId = TARGET_PREFIX + "sendDeleteMessage";
|
||||||
|
|
||||||
registerAndAssertTargetWithExistingTenant(controllerId, 1);
|
registerAndAssertTargetWithExistingTenant(controllerId, 1);
|
||||||
targetManagement.deleteTarget(controllerId);
|
targetManagement.deleteByControllerID(controllerId);
|
||||||
assertDeleteMessage(controllerId);
|
assertDeleteMessage(controllerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitUntilTargetStatusIsPending(final String controllerId) {
|
private void waitUntilTargetStatusIsPending(final String controllerId) {
|
||||||
waitUntil(() -> {
|
waitUntil(() -> {
|
||||||
final Optional<Target> findTargetByControllerID = targetManagement.findTargetByControllerID(controllerId);
|
final Optional<Target> findTargetByControllerID = targetManagement.getByControllerID(controllerId);
|
||||||
return findTargetByControllerID.isPresent()
|
return findTargetByControllerID.isPresent()
|
||||||
&& TargetUpdateStatus.PENDING.equals(findTargetByControllerID.get().getUpdateStatus());
|
&& TargetUpdateStatus.PENDING.equals(findTargetByControllerID.get().getUpdateStatus());
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
|
|||||||
Assert.assertThat(dsModules,
|
Assert.assertThat(dsModules,
|
||||||
SoftwareModuleJsonMatcher.containsExactly(downloadAndUpdateRequest.getSoftwareModules()));
|
SoftwareModuleJsonMatcher.containsExactly(downloadAndUpdateRequest.getSoftwareModules()));
|
||||||
|
|
||||||
final Target updatedTarget = waitUntilIsPresent(() -> targetManagement.findTargetByControllerID(controllerId));
|
final Target updatedTarget = waitUntilIsPresent(() -> targetManagement.getByControllerID(controllerId));
|
||||||
|
|
||||||
assertThat(updatedTarget.getSecurityToken()).isEqualTo(downloadAndUpdateRequest.getTargetSecurityToken());
|
assertThat(updatedTarget.getSecurityToken()).isEqualTo(downloadAndUpdateRequest.getTargetSecurityToken());
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void assertAllTargetsCount(final long expectedTargetsCount) {
|
protected void assertAllTargetsCount(final long expectedTargetsCount) {
|
||||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(expectedTargetsCount);
|
assertThat(targetManagement.count()).isEqualTo(expectedTargetsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Message assertReplyMessageHeader(final EventTopic eventTopic, final String controllerId) {
|
private Message assertReplyMessageHeader(final EventTopic eventTopic, final String controllerId) {
|
||||||
@@ -226,14 +226,14 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
|
|||||||
final int existingTargetsAfterCreation, final TargetUpdateStatus expectedTargetStatus,
|
final int existingTargetsAfterCreation, final TargetUpdateStatus expectedTargetStatus,
|
||||||
final String createdBy) {
|
final String createdBy) {
|
||||||
createAndSendTarget(target, TENANT_EXIST);
|
createAndSendTarget(target, TENANT_EXIST);
|
||||||
final Target registerdTarget = waitUntilIsPresent(() -> targetManagement.findTargetByControllerID(target));
|
final Target registerdTarget = waitUntilIsPresent(() -> targetManagement.getByControllerID(target));
|
||||||
assertAllTargetsCount(existingTargetsAfterCreation);
|
assertAllTargetsCount(existingTargetsAfterCreation);
|
||||||
assertTarget(registerdTarget, expectedTargetStatus, createdBy);
|
assertTarget(registerdTarget, expectedTargetStatus, createdBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerSameTargetAndAssertBasedOnVersion(final String controllerId,
|
protected void registerSameTargetAndAssertBasedOnVersion(final String controllerId,
|
||||||
final int existingTargetsAfterCreation, final TargetUpdateStatus expectedTargetStatus) {
|
final int existingTargetsAfterCreation, final TargetUpdateStatus expectedTargetStatus) {
|
||||||
final int version = controllerManagement.findByControllerId(controllerId).get().getOptLockRevision();
|
final int version = controllerManagement.getByControllerId(controllerId).get().getOptLockRevision();
|
||||||
createAndSendTarget(controllerId, TENANT_EXIST);
|
createAndSendTarget(controllerId, TENANT_EXIST);
|
||||||
final Target registeredTarget = waitUntilIsPresent(() -> findTargetBasedOnNewVersion(controllerId, version));
|
final Target registeredTarget = waitUntilIsPresent(() -> findTargetBasedOnNewVersion(controllerId, version));
|
||||||
assertAllTargetsCount(existingTargetsAfterCreation);
|
assertAllTargetsCount(existingTargetsAfterCreation);
|
||||||
@@ -241,7 +241,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Optional<Target> findTargetBasedOnNewVersion(final String controllerId, final int version) {
|
private Optional<Target> findTargetBasedOnNewVersion(final String controllerId, final int version) {
|
||||||
final Optional<Target> target2 = controllerManagement.findByControllerId(controllerId);
|
final Optional<Target> target2 = controllerManagement.getByControllerId(controllerId);
|
||||||
if (version < target2.get().getOptLockRevision()) {
|
if (version < target2.get().getOptLockRevision()) {
|
||||||
return target2;
|
return target2;
|
||||||
}
|
}
|
||||||
@@ -305,7 +305,7 @@ public abstract class AmqpServiceIntegrationTest extends AbstractAmqpIntegration
|
|||||||
|
|
||||||
protected void assertUpdateAttributes(final String controllerId, final Map<String, String> attributes) {
|
protected void assertUpdateAttributes(final String controllerId, final Map<String, String> attributes) {
|
||||||
final Target findByControllerId = waitUntilIsPresent(
|
final Target findByControllerId = waitUntilIsPresent(
|
||||||
() -> controllerManagement.findByControllerId(controllerId));
|
() -> controllerManagement.getByControllerId(controllerId));
|
||||||
final Map<String, String> controllerAttributes = targetManagement
|
final Map<String, String> controllerAttributes = targetManagement
|
||||||
.getControllerAttributes(findByControllerId.getControllerId());
|
.getControllerAttributes(findByControllerId.getControllerId());
|
||||||
assertThat(controllerAttributes.size()).isEqualTo(attributes.size());
|
assertThat(controllerAttributes.size()).isEqualTo(attributes.size());
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
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.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -97,15 +98,18 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
final Sort sorting = PagingUtility.sanitizeDistributionSetSortParam(sortParam);
|
final Sort sorting = PagingUtility.sanitizeDistributionSetSortParam(sortParam);
|
||||||
|
|
||||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||||
final Page<DistributionSet> findDsPage;
|
final Slice<DistributionSet> findDsPage;
|
||||||
|
final long countModulesAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findDsPage = distributionSetManagement.findDistributionSetsAll(rsqlParam, pageable, false);
|
findDsPage = distributionSetManagement.findByRsql(pageable, rsqlParam);
|
||||||
|
countModulesAll = ((Page<DistributionSet>) findDsPage).getTotalElements();
|
||||||
} else {
|
} else {
|
||||||
findDsPage = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageable, false, null);
|
findDsPage = distributionSetManagement.findAll(pageable);
|
||||||
|
countModulesAll = distributionSetManagement.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<MgmtDistributionSet> rest = MgmtDistributionSetMapper.toResponseFromDsList(findDsPage.getContent());
|
final List<MgmtDistributionSet> rest = MgmtDistributionSetMapper.toResponseFromDsList(findDsPage.getContent());
|
||||||
return ResponseEntity.ok(new PagedList<>(rest, findDsPage.getTotalElements()));
|
return ResponseEntity.ok(new PagedList<>(rest, countModulesAll));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -127,7 +131,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
sets.stream().filter(ds -> ds.getType() == null).forEach(ds -> ds.setType(defaultDsKey));
|
sets.stream().filter(ds -> ds.getType() == null).forEach(ds -> ds.setType(defaultDsKey));
|
||||||
|
|
||||||
final Collection<DistributionSet> createdDSets = distributionSetManagement
|
final Collection<DistributionSet> createdDSets = distributionSetManagement
|
||||||
.createDistributionSets(MgmtDistributionSetMapper.dsFromRequest(sets, entityFactory));
|
.create(MgmtDistributionSetMapper.dsFromRequest(sets, entityFactory));
|
||||||
|
|
||||||
LOG.debug("{} distribution sets created, return status {}", sets.size(), HttpStatus.CREATED);
|
LOG.debug("{} distribution sets created, return status {}", sets.size(), HttpStatus.CREATED);
|
||||||
return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDistributionSets(createdDSets),
|
return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDistributionSets(createdDSets),
|
||||||
@@ -136,7 +140,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Void> deleteDistributionSet(@PathVariable("distributionSetId") final Long distributionSetId) {
|
public ResponseEntity<Void> deleteDistributionSet(@PathVariable("distributionSetId") final Long distributionSetId) {
|
||||||
distributionSetManagement.deleteDistributionSet(distributionSetId);
|
distributionSetManagement.delete(distributionSetId);
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,8 +149,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
@PathVariable("distributionSetId") final Long distributionSetId,
|
@PathVariable("distributionSetId") final Long distributionSetId,
|
||||||
@RequestBody final MgmtDistributionSetRequestBodyPut toUpdate) {
|
@RequestBody final MgmtDistributionSetRequestBodyPut toUpdate) {
|
||||||
|
|
||||||
return ResponseEntity.ok(MgmtDistributionSetMapper
|
return ResponseEntity.ok(
|
||||||
.toResponse(distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
MgmtDistributionSetMapper.toResponse(distributionSetManagement.update(entityFactory.distributionSet()
|
||||||
.update(distributionSetId).name(toUpdate.getName()).description(toUpdate.getDescription())
|
.update(distributionSetId).name(toUpdate.getName()).description(toUpdate.getDescription())
|
||||||
.version(toUpdate.getVersion()).requiredMigrationStep(toUpdate.isRequiredMigrationStep()))));
|
.version(toUpdate.getVersion()).requiredMigrationStep(toUpdate.isRequiredMigrationStep()))));
|
||||||
}
|
}
|
||||||
@@ -166,10 +170,10 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||||
final Page<Target> targetsAssignedDS;
|
final Page<Target> targetsAssignedDS;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
targetsAssignedDS = this.targetManagement.findTargetByAssignedDistributionSet(distributionSetId, rsqlParam,
|
targetsAssignedDS = this.targetManagement.findByAssignedDistributionSetAndRsql(pageable, distributionSetId,
|
||||||
pageable);
|
rsqlParam);
|
||||||
} else {
|
} else {
|
||||||
targetsAssignedDS = this.targetManagement.findTargetByAssignedDistributionSet(distributionSetId, pageable);
|
targetsAssignedDS = this.targetManagement.findByAssignedDistributionSet(pageable, distributionSetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseEntity.ok(new PagedList<>(MgmtTargetMapper.toResponse(targetsAssignedDS.getContent()),
|
return ResponseEntity.ok(new PagedList<>(MgmtTargetMapper.toResponse(targetsAssignedDS.getContent()),
|
||||||
@@ -194,11 +198,10 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||||
final Page<Target> targetsInstalledDS;
|
final Page<Target> targetsInstalledDS;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
targetsInstalledDS = this.targetManagement.findTargetByInstalledDistributionSet(distributionSetId,
|
targetsInstalledDS = this.targetManagement.findByInstalledDistributionSetAndRsql(pageable,
|
||||||
rsqlParam, pageable);
|
distributionSetId, rsqlParam);
|
||||||
} else {
|
} else {
|
||||||
targetsInstalledDS = this.targetManagement.findTargetByInstalledDistributionSet(distributionSetId,
|
targetsInstalledDS = this.targetManagement.findByInstalledDistributionSet(pageable, distributionSetId);
|
||||||
pageable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseEntity.ok(new PagedList<>(MgmtTargetMapper.toResponse(targetsInstalledDS.getContent()),
|
return ResponseEntity.ok(new PagedList<>(MgmtTargetMapper.toResponse(targetsInstalledDS.getContent()),
|
||||||
@@ -218,7 +221,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
|
|
||||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||||
final Page<TargetFilterQuery> targetFilterQueries = targetFilterQueryManagement
|
final Page<TargetFilterQuery> targetFilterQueries = targetFilterQueryManagement
|
||||||
.findTargetFilterQueryByAutoAssignDS(pageable, distributionSetId, rsqlParam);
|
.findByAutoAssignDSAndRsql(pageable, distributionSetId, rsqlParam);
|
||||||
|
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
.ok(new PagedList<>(MgmtTargetFilterQueryMapper.toResponse(targetFilterQueries.getContent()),
|
.ok(new PagedList<>(MgmtTargetFilterQueryMapper.toResponse(targetFilterQueries.getContent()),
|
||||||
@@ -262,11 +265,10 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
final Page<DistributionSetMetadata> metaDataPage;
|
final Page<DistributionSetMetadata> metaDataPage;
|
||||||
|
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
metaDataPage = distributionSetManagement.findDistributionSetMetadataByDistributionSetId(distributionSetId,
|
metaDataPage = distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(pageable, distributionSetId,
|
||||||
rsqlParam, pageable);
|
rsqlParam);
|
||||||
} else {
|
} else {
|
||||||
metaDataPage = distributionSetManagement.findDistributionSetMetadataByDistributionSetId(distributionSetId,
|
metaDataPage = distributionSetManagement.findMetaDataByDistributionSetId(pageable, distributionSetId);
|
||||||
pageable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
@@ -282,7 +284,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
// check if distribution set exists otherwise throw exception
|
// check if distribution set exists otherwise throw exception
|
||||||
// immediately
|
// immediately
|
||||||
final DistributionSetMetadata findOne = distributionSetManagement
|
final DistributionSetMetadata findOne = distributionSetManagement
|
||||||
.findDistributionSetMetadata(distributionSetId, metadataKey)
|
.getMetaDataByDistributionSetId(distributionSetId, metadataKey)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId,
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId,
|
||||||
metadataKey));
|
metadataKey));
|
||||||
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(findOne));
|
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(findOne));
|
||||||
@@ -293,8 +295,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
@PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadata metadata) {
|
@PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadata metadata) {
|
||||||
// check if distribution set exists otherwise throw exception
|
// check if distribution set exists otherwise throw exception
|
||||||
// immediately
|
// immediately
|
||||||
final DistributionSetMetadata updated = distributionSetManagement.updateDistributionSetMetadata(
|
final DistributionSetMetadata updated = distributionSetManagement.updateMetaData(distributionSetId,
|
||||||
distributionSetId, entityFactory.generateMetadata(metadataKey, metadata.getValue()));
|
entityFactory.generateMetadata(metadataKey, metadata.getValue()));
|
||||||
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(updated));
|
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(updated));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,7 +305,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
@PathVariable("metadataKey") final String metadataKey) {
|
@PathVariable("metadataKey") final String metadataKey) {
|
||||||
// check if distribution set exists otherwise throw exception
|
// check if distribution set exists otherwise throw exception
|
||||||
// immediately
|
// immediately
|
||||||
distributionSetManagement.deleteDistributionSetMetadata(distributionSetId, metadataKey);
|
distributionSetManagement.deleteMetaData(distributionSetId, metadataKey);
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,8 +315,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
|||||||
@RequestBody final List<MgmtMetadata> metadataRest) {
|
@RequestBody final List<MgmtMetadata> metadataRest) {
|
||||||
// check if distribution set exists otherwise throw exception
|
// check if distribution set exists otherwise throw exception
|
||||||
// immediately
|
// immediately
|
||||||
final List<DistributionSetMetadata> created = distributionSetManagement.createDistributionSetMetadata(
|
final List<DistributionSetMetadata> created = distributionSetManagement.createMetaData(distributionSetId,
|
||||||
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -347,14 +349,14 @@ 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.findSoftwareModuleByAssignedTo(pageable,
|
final Page<SoftwareModule> softwaremodules = softwareModuleManagement.findByAssignedTo(pageable,
|
||||||
distributionSetId);
|
distributionSetId);
|
||||||
return ResponseEntity.ok(new PagedList<>(MgmtSoftwareModuleMapper.toResponse(softwaremodules.getContent()),
|
return ResponseEntity.ok(new PagedList<>(MgmtSoftwareModuleMapper.toResponse(softwaremodules.getContent()),
|
||||||
softwaremodules.getTotalElements()));
|
softwaremodules.getTotalElements()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSet findDistributionSetWithExceptionIfNotFound(final Long distributionSetId) {
|
private DistributionSet findDistributionSetWithExceptionIfNotFound(final Long distributionSetId) {
|
||||||
return distributionSetManagement.findDistributionSetById(distributionSetId)
|
return distributionSetManagement.get(distributionSetId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, distributionSetId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, distributionSetId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut;
|
|||||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi;
|
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi;
|
||||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||||
|
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||||
import org.eclipse.hawkbit.repository.TagManagement;
|
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
@@ -33,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -50,7 +51,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
|||||||
private static final Logger LOG = LoggerFactory.getLogger(MgmtDistributionSetTagResource.class);
|
private static final Logger LOG = LoggerFactory.getLogger(MgmtDistributionSetTagResource.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TagManagement tagManagement;
|
private DistributionSetTagManagement distributionSetTagManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DistributionSetManagement distributionSetManagement;
|
private DistributionSetManagement distributionSetManagement;
|
||||||
@@ -70,17 +71,21 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
|||||||
final Sort sorting = PagingUtility.sanitizeTagSortParam(sortParam);
|
final Sort sorting = PagingUtility.sanitizeTagSortParam(sortParam);
|
||||||
|
|
||||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||||
final Page<DistributionSetTag> findTargetsAll;
|
final Slice<DistributionSetTag> distributionSetTags;
|
||||||
|
final long count;
|
||||||
if (rsqlParam == null) {
|
if (rsqlParam == null) {
|
||||||
findTargetsAll = tagManagement.findAllDistributionSetTags(pageable);
|
distributionSetTags = distributionSetTagManagement.findAll(pageable);
|
||||||
|
count = distributionSetTagManagement.count();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
findTargetsAll = tagManagement.findAllDistributionSetTags(rsqlParam, pageable);
|
final Page<DistributionSetTag> page = distributionSetTagManagement.findByRsql(pageable, rsqlParam);
|
||||||
|
distributionSetTags = page;
|
||||||
|
count = page.getTotalElements();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<MgmtTag> rest = MgmtTagMapper.toResponseDistributionSetTag(findTargetsAll.getContent());
|
final List<MgmtTag> rest = MgmtTagMapper.toResponseDistributionSetTag(distributionSetTags.getContent());
|
||||||
return ResponseEntity.ok(new PagedList<>(rest, findTargetsAll.getTotalElements()));
|
return ResponseEntity.ok(new PagedList<>(rest, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -95,8 +100,8 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
|||||||
@RequestBody final List<MgmtTagRequestBodyPut> tags) {
|
@RequestBody final List<MgmtTagRequestBodyPut> tags) {
|
||||||
LOG.debug("creating {} ds tags", tags.size());
|
LOG.debug("creating {} ds tags", tags.size());
|
||||||
|
|
||||||
final List<DistributionSetTag> createdTags = this.tagManagement
|
final List<DistributionSetTag> createdTags = distributionSetTagManagement
|
||||||
.createDistributionSetTags(MgmtTagMapper.mapTagFromRequest(entityFactory, tags));
|
.create(MgmtTagMapper.mapTagFromRequest(entityFactory, tags));
|
||||||
|
|
||||||
return new ResponseEntity<>(MgmtTagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED);
|
return new ResponseEntity<>(MgmtTagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
@@ -106,8 +111,8 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
|||||||
@PathVariable("distributionsetTagId") final Long distributionsetTagId,
|
@PathVariable("distributionsetTagId") final Long distributionsetTagId,
|
||||||
@RequestBody final MgmtTagRequestBodyPut restDSTagRest) {
|
@RequestBody final MgmtTagRequestBodyPut restDSTagRest) {
|
||||||
|
|
||||||
return ResponseEntity.ok(MgmtTagMapper.toResponse(tagManagement
|
return ResponseEntity.ok(MgmtTagMapper.toResponse(distributionSetTagManagement
|
||||||
.updateDistributionSetTag(entityFactory.tag().update(distributionsetTagId).name(restDSTagRest.getName())
|
.update(entityFactory.tag().update(distributionsetTagId).name(restDSTagRest.getName())
|
||||||
.description(restDSTagRest.getDescription()).colour(restDSTagRest.getColour()))));
|
.description(restDSTagRest.getDescription()).colour(restDSTagRest.getColour()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +122,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
|||||||
LOG.debug("Delete {} distribution set tag", distributionsetTagId);
|
LOG.debug("Delete {} distribution set tag", distributionsetTagId);
|
||||||
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
|
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
|
||||||
|
|
||||||
this.tagManagement.deleteDistributionSetTag(tag.getName());
|
distributionSetTagManagement.delete(tag.getName());
|
||||||
|
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
@@ -126,7 +131,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
|||||||
public ResponseEntity<List<MgmtDistributionSet>> getAssignedDistributionSets(
|
public ResponseEntity<List<MgmtDistributionSet>> getAssignedDistributionSets(
|
||||||
@PathVariable("distributionsetTagId") final Long distributionsetTagId) {
|
@PathVariable("distributionsetTagId") final Long distributionsetTagId) {
|
||||||
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDistributionSets(distributionSetManagement
|
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDistributionSets(distributionSetManagement
|
||||||
.findDistributionSetsByTag(new PageRequest(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT),
|
.findByTag(new PageRequest(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT),
|
||||||
distributionsetTagId)
|
distributionsetTagId)
|
||||||
.getContent()));
|
.getContent()));
|
||||||
}
|
}
|
||||||
@@ -145,11 +150,10 @@ 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.findDistributionSetsByTag(pageable, distributionsetTagId);
|
findDistrAll = distributionSetManagement.findByTag(pageable, distributionsetTagId);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
findDistrAll = distributionSetManagement.findDistributionSetsByTag(pageable, rsqlParam,
|
findDistrAll = distributionSetManagement.findByRsqlAndTag(pageable, rsqlParam, distributionsetTagId);
|
||||||
distributionsetTagId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<MgmtDistributionSet> rest = MgmtDistributionSetMapper
|
final List<MgmtDistributionSet> rest = MgmtDistributionSetMapper
|
||||||
@@ -202,7 +206,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSetTag findDistributionTagById(final Long distributionsetTagId) {
|
private DistributionSetTag findDistributionTagById(final Long distributionsetTagId) {
|
||||||
return tagManagement.findDistributionSetTagById(distributionsetTagId)
|
return distributionSetTagManagement.get(distributionsetTagId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, distributionsetTagId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, distributionsetTagId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,13 +70,13 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
|
|||||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||||
|
|
||||||
final Slice<DistributionSetType> findModuleTypessAll;
|
final Slice<DistributionSetType> findModuleTypessAll;
|
||||||
Long countModulesAll;
|
long countModulesAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findModuleTypessAll = distributionSetTypeManagement.findDistributionSetTypesAll(rsqlParam, pageable);
|
findModuleTypessAll = distributionSetTypeManagement.findByRsql(pageable, rsqlParam);
|
||||||
countModulesAll = ((Page<DistributionSetType>) findModuleTypessAll).getTotalElements();
|
countModulesAll = ((Page<DistributionSetType>) findModuleTypessAll).getTotalElements();
|
||||||
} else {
|
} else {
|
||||||
findModuleTypessAll = distributionSetTypeManagement.findDistributionSetTypesAll(pageable);
|
findModuleTypessAll = distributionSetTypeManagement.findAll(pageable);
|
||||||
countModulesAll = distributionSetTypeManagement.countDistributionSetTypesAll();
|
countModulesAll = distributionSetTypeManagement.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<MgmtDistributionSetType> rest = MgmtDistributionSetTypeMapper
|
final List<MgmtDistributionSetType> rest = MgmtDistributionSetTypeMapper
|
||||||
@@ -95,7 +95,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
|
|||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Void> deleteDistributionSetType(
|
public ResponseEntity<Void> deleteDistributionSetType(
|
||||||
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId) {
|
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId) {
|
||||||
distributionSetTypeManagement.deleteDistributionSetType(distributionSetTypeId);
|
distributionSetTypeManagement.delete(distributionSetTypeId);
|
||||||
|
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
|
|||||||
@RequestBody final MgmtDistributionSetTypeRequestBodyPut restDistributionSetType) {
|
@RequestBody final MgmtDistributionSetTypeRequestBodyPut restDistributionSetType) {
|
||||||
|
|
||||||
return ResponseEntity.ok(MgmtDistributionSetTypeMapper
|
return ResponseEntity.ok(MgmtDistributionSetTypeMapper
|
||||||
.toResponse(distributionSetTypeManagement.updateDistributionSetType(entityFactory.distributionSetType()
|
.toResponse(distributionSetTypeManagement.update(entityFactory.distributionSetType()
|
||||||
.update(distributionSetTypeId).description(restDistributionSetType.getDescription())
|
.update(distributionSetTypeId).description(restDistributionSetType.getDescription())
|
||||||
.colour(restDistributionSetType.getColour()))));
|
.colour(restDistributionSetType.getColour()))));
|
||||||
}
|
}
|
||||||
@@ -116,15 +116,14 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
|
|||||||
@RequestBody final List<MgmtDistributionSetTypeRequestBodyPost> distributionSetTypes) {
|
@RequestBody final List<MgmtDistributionSetTypeRequestBodyPost> distributionSetTypes) {
|
||||||
|
|
||||||
final List<DistributionSetType> createdSoftwareModules = distributionSetTypeManagement
|
final List<DistributionSetType> createdSoftwareModules = distributionSetTypeManagement
|
||||||
.createDistributionSetTypes(
|
.create(MgmtDistributionSetTypeMapper.smFromRequest(entityFactory, distributionSetTypes));
|
||||||
MgmtDistributionSetTypeMapper.smFromRequest(entityFactory, distributionSetTypes));
|
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.CREATED)
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
.body(MgmtDistributionSetTypeMapper.toTypesResponse(createdSoftwareModules));
|
.body(MgmtDistributionSetTypeMapper.toTypesResponse(createdSoftwareModules));
|
||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final Long distributionSetTypeId) {
|
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final Long distributionSetTypeId) {
|
||||||
return distributionSetTypeManagement.findDistributionSetTypeById(distributionSetTypeId)
|
return distributionSetTypeManagement.get(distributionSetTypeId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypeId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +212,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
|
|||||||
|
|
||||||
private SoftwareModuleType findSoftwareModuleTypeWithExceptionIfNotFound(final Long softwareModuleTypeId) {
|
private SoftwareModuleType findSoftwareModuleTypeWithExceptionIfNotFound(final Long softwareModuleTypeId) {
|
||||||
|
|
||||||
return softwareModuleTypeManagement.findSoftwareModuleTypeById(softwareModuleTypeId)
|
return softwareModuleTypeManagement.get(softwareModuleTypeId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, softwareModuleTypeId));
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, softwareModuleTypeId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class MgmtDownloadArtifactResource implements MgmtDownloadArtifactRestApi
|
|||||||
public ResponseEntity<InputStream> downloadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId,
|
public ResponseEntity<InputStream> downloadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||||
@PathVariable("artifactId") final Long artifactId) {
|
@PathVariable("artifactId") final Long artifactId) {
|
||||||
|
|
||||||
final SoftwareModule module = softwareModuleManagement.findSoftwareModuleById(softwareModuleId)
|
final SoftwareModule module = softwareModuleManagement.get(softwareModuleId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
|
||||||
final Artifact artifact = module.getArtifact(artifactId)
|
final Artifact artifact = module.getArtifact(artifactId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Artifact.class, artifactId));
|
.orElseThrow(() -> new EntityNotFoundException(Artifact.class, artifactId));
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
|||||||
|
|
||||||
final Page<Rollout> findModulesAll;
|
final Page<Rollout> findModulesAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findModulesAll = this.rolloutManagement.findAllByPredicate(rsqlParam, pageable, false);
|
findModulesAll = this.rolloutManagement.findByRsql(pageable, rsqlParam, false);
|
||||||
} else {
|
} else {
|
||||||
findModulesAll = this.rolloutManagement.findAll(pageable, false);
|
findModulesAll = this.rolloutManagement.findAll(pageable, false);
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<MgmtRolloutResponseBody> getRollout(@PathVariable("rolloutId") final Long rolloutId) {
|
public ResponseEntity<MgmtRolloutResponseBody> getRollout(@PathVariable("rolloutId") final Long rolloutId) {
|
||||||
final Rollout findRolloutById = rolloutManagement.findRolloutWithDetailedStatus(rolloutId)
|
final Rollout findRolloutById = rolloutManagement.getWithDetailedStatus(rolloutId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId));
|
.orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId));
|
||||||
|
|
||||||
return ResponseEntity.ok(MgmtRolloutMapper.toResponseRollout(findRolloutById, true));
|
return ResponseEntity.ok(MgmtRolloutMapper.toResponseRollout(findRolloutById, true));
|
||||||
@@ -116,10 +116,10 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
|||||||
final List<RolloutGroupCreate> rolloutGroups = rolloutRequestBody.getGroups().stream()
|
final List<RolloutGroupCreate> rolloutGroups = rolloutRequestBody.getGroups().stream()
|
||||||
.map(mgmtRolloutGroup -> MgmtRolloutMapper.fromRequest(entityFactory, mgmtRolloutGroup))
|
.map(mgmtRolloutGroup -> MgmtRolloutMapper.fromRequest(entityFactory, mgmtRolloutGroup))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
rollout = rolloutManagement.createRollout(create, rolloutGroups, rolloutGroupConditions);
|
rollout = rolloutManagement.create(create, rolloutGroups, rolloutGroupConditions);
|
||||||
|
|
||||||
} else if (rolloutRequestBody.getAmountGroups() != null) {
|
} else if (rolloutRequestBody.getAmountGroups() != null) {
|
||||||
rollout = rolloutManagement.createRollout(create, rolloutRequestBody.getAmountGroups(),
|
rollout = rolloutManagement.create(create, rolloutRequestBody.getAmountGroups(),
|
||||||
rolloutGroupConditions);
|
rolloutGroupConditions);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -131,7 +131,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Void> start(@PathVariable("rolloutId") final Long rolloutId) {
|
public ResponseEntity<Void> start(@PathVariable("rolloutId") final Long rolloutId) {
|
||||||
this.rolloutManagement.startRollout(rolloutId);
|
this.rolloutManagement.start(rolloutId);
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Void> delete(@PathVariable("rolloutId") final Long rolloutId) {
|
public ResponseEntity<Void> delete(@PathVariable("rolloutId") final Long rolloutId) {
|
||||||
this.rolloutManagement.deleteRollout(rolloutId);
|
this.rolloutManagement.delete(rolloutId);
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,9 +168,9 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
|||||||
|
|
||||||
final Page<RolloutGroup> findRolloutGroupsAll;
|
final Page<RolloutGroup> findRolloutGroupsAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findRolloutGroupsAll = this.rolloutGroupManagement.findRolloutGroupsAll(rolloutId, rsqlParam, pageable);
|
findRolloutGroupsAll = this.rolloutGroupManagement.findByRolloutAndRsql(pageable, rolloutId, rsqlParam);
|
||||||
} else {
|
} else {
|
||||||
findRolloutGroupsAll = this.rolloutGroupManagement.findRolloutGroupsByRolloutId(rolloutId, pageable);
|
findRolloutGroupsAll = this.rolloutGroupManagement.findByRollout(pageable, rolloutId);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<MgmtRolloutGroupResponseBody> rest = MgmtRolloutMapper
|
final List<MgmtRolloutGroupResponseBody> rest = MgmtRolloutMapper
|
||||||
@@ -183,7 +183,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
|||||||
@PathVariable("groupId") final Long groupId) {
|
@PathVariable("groupId") final Long groupId) {
|
||||||
findRolloutOrThrowException(rolloutId);
|
findRolloutOrThrowException(rolloutId);
|
||||||
|
|
||||||
final RolloutGroup rolloutGroup = rolloutGroupManagement.findRolloutGroupWithDetailedStatus(groupId)
|
final RolloutGroup rolloutGroup = rolloutGroupManagement.getWithDetailedStatus(groupId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(RolloutGroup.class, rolloutId));
|
.orElseThrow(() -> new EntityNotFoundException(RolloutGroup.class, rolloutId));
|
||||||
return ResponseEntity.ok(MgmtRolloutMapper.toResponseRolloutGroup(rolloutGroup, true));
|
return ResponseEntity.ok(MgmtRolloutMapper.toResponseRolloutGroup(rolloutGroup, true));
|
||||||
}
|
}
|
||||||
@@ -210,9 +210,9 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
|||||||
|
|
||||||
final Page<Target> rolloutGroupTargets;
|
final Page<Target> rolloutGroupTargets;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
rolloutGroupTargets = this.rolloutGroupManagement.findRolloutGroupTargets(groupId, rsqlParam, pageable);
|
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(pageable, groupId, rsqlParam);
|
||||||
} else {
|
} else {
|
||||||
final Page<Target> pageTargets = this.rolloutGroupManagement.findRolloutGroupTargets(groupId, pageable);
|
final Page<Target> pageTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroup(pageable, groupId);
|
||||||
rolloutGroupTargets = pageTargets;
|
rolloutGroupTargets = pageTargets;
|
||||||
}
|
}
|
||||||
final List<MgmtTarget> rest = MgmtTargetMapper.toResponse(rolloutGroupTargets.getContent());
|
final List<MgmtTarget> rest = MgmtTargetMapper.toResponse(rolloutGroupTargets.getContent());
|
||||||
@@ -220,7 +220,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSet findDistributionSetOrThrowException(final MgmtRolloutRestRequestBody rolloutRequestBody) {
|
private DistributionSet findDistributionSetOrThrowException(final MgmtRolloutRestRequestBody rolloutRequestBody) {
|
||||||
return this.distributionSetManagement.findDistributionSetById(rolloutRequestBody.getDistributionSetId())
|
return this.distributionSetManagement.get(rolloutRequestBody.getDistributionSetId())
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class,
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class,
|
||||||
rolloutRequestBody.getDistributionSetId()));
|
rolloutRequestBody.getDistributionSetId()));
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Artifact result = artifactManagement.createArtifact(file.getInputStream(), softwareModuleId, fileName,
|
final Artifact result = artifactManagement.create(file.getInputStream(), softwareModuleId, fileName,
|
||||||
md5Sum == null ? null : md5Sum.toLowerCase(), sha1Sum == null ? null : sha1Sum.toLowerCase(), false,
|
md5Sum == null ? null : md5Sum.toLowerCase(), sha1Sum == null ? null : sha1Sum.toLowerCase(), false,
|
||||||
file.getContentType());
|
file.getContentType());
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(MgmtSoftwareModuleMapper.toResponse(result));
|
return ResponseEntity.status(HttpStatus.CREATED).body(MgmtSoftwareModuleMapper.toResponse(result));
|
||||||
@@ -117,7 +117,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
@PathVariable("artifactId") final Long artifactId) {
|
@PathVariable("artifactId") final Long artifactId) {
|
||||||
|
|
||||||
findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId);
|
findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId);
|
||||||
artifactManagement.deleteArtifact(artifactId);
|
artifactManagement.delete(artifactId);
|
||||||
|
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
@@ -136,13 +136,13 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||||
|
|
||||||
final Slice<SoftwareModule> findModulesAll;
|
final Slice<SoftwareModule> findModulesAll;
|
||||||
Long countModulesAll;
|
long countModulesAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findModulesAll = softwareModuleManagement.findSoftwareModulesByPredicate(rsqlParam, pageable);
|
findModulesAll = softwareModuleManagement.findByRsql(pageable, rsqlParam);
|
||||||
countModulesAll = ((Page<SoftwareModule>) findModulesAll).getTotalElements();
|
countModulesAll = ((Page<SoftwareModule>) findModulesAll).getTotalElements();
|
||||||
} else {
|
} else {
|
||||||
findModulesAll = softwareModuleManagement.findSoftwareModulesAll(pageable);
|
findModulesAll = softwareModuleManagement.findAll(pageable);
|
||||||
countModulesAll = softwareModuleManagement.countSoftwareModulesAll();
|
countModulesAll = softwareModuleManagement.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<MgmtSoftwareModule> rest = MgmtSoftwareModuleMapper.toResponse(findModulesAll.getContent());
|
final List<MgmtSoftwareModule> rest = MgmtSoftwareModuleMapper.toResponse(findModulesAll.getContent());
|
||||||
@@ -163,7 +163,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
|
|
||||||
LOG.debug("creating {} softwareModules", softwareModules.size());
|
LOG.debug("creating {} softwareModules", softwareModules.size());
|
||||||
final Collection<SoftwareModule> createdSoftwareModules = softwareModuleManagement
|
final Collection<SoftwareModule> createdSoftwareModules = softwareModuleManagement
|
||||||
.createSoftwareModule(MgmtSoftwareModuleMapper.smFromRequest(entityFactory, softwareModules));
|
.create(MgmtSoftwareModuleMapper.smFromRequest(entityFactory, softwareModules));
|
||||||
LOG.debug("{} softwareModules created, return status {}", softwareModules.size(), HttpStatus.CREATED);
|
LOG.debug("{} softwareModules created, return status {}", softwareModules.size(), HttpStatus.CREATED);
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.CREATED)
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
@@ -175,8 +175,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||||
@RequestBody final MgmtSoftwareModuleRequestBodyPut restSoftwareModule) {
|
@RequestBody final MgmtSoftwareModuleRequestBodyPut restSoftwareModule) {
|
||||||
|
|
||||||
return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponse(
|
return ResponseEntity.ok(MgmtSoftwareModuleMapper
|
||||||
softwareModuleManagement.updateSoftwareModule(entityFactory.softwareModule().update(softwareModuleId)
|
.toResponse(softwareModuleManagement.update(entityFactory.softwareModule().update(softwareModuleId)
|
||||||
.description(restSoftwareModule.getDescription()).vendor(restSoftwareModule.getVendor()))));
|
.description(restSoftwareModule.getDescription()).vendor(restSoftwareModule.getVendor()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
public ResponseEntity<Void> deleteSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId) {
|
public ResponseEntity<Void> deleteSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId) {
|
||||||
|
|
||||||
final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
||||||
softwareModuleManagement.deleteSoftwareModule(module.getId());
|
softwareModuleManagement.delete(module.getId());
|
||||||
|
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
@@ -208,11 +208,9 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
final Page<SoftwareModuleMetadata> metaDataPage;
|
final Page<SoftwareModuleMetadata> metaDataPage;
|
||||||
|
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
metaDataPage = softwareModuleManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId,
|
metaDataPage = softwareModuleManagement.findMetaDataByRsql(pageable, softwareModuleId, rsqlParam);
|
||||||
rsqlParam, pageable);
|
|
||||||
} else {
|
} else {
|
||||||
metaDataPage = softwareModuleManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId,
|
metaDataPage = softwareModuleManagement.findMetaDataBySoftwareModuleId(pageable, softwareModuleId);
|
||||||
pageable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseEntity
|
return ResponseEntity
|
||||||
@@ -224,8 +222,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
public ResponseEntity<MgmtMetadata> getMetadataValue(@PathVariable("softwareModuleId") final Long softwareModuleId,
|
public ResponseEntity<MgmtMetadata> getMetadataValue(@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||||
@PathVariable("metadataKey") final String metadataKey) {
|
@PathVariable("metadataKey") final String metadataKey) {
|
||||||
|
|
||||||
final SoftwareModuleMetadata findOne = softwareModuleManagement
|
final SoftwareModuleMetadata findOne = softwareModuleManagement.getMetaDataBySoftwareModuleId(softwareModuleId, metadataKey)
|
||||||
.findSoftwareModuleMetadata(softwareModuleId, metadataKey).orElseThrow(
|
.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));
|
||||||
@@ -234,7 +232,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
@Override
|
@Override
|
||||||
public ResponseEntity<MgmtMetadata> updateMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
|
public ResponseEntity<MgmtMetadata> updateMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||||
@PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadata metadata) {
|
@PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadata metadata) {
|
||||||
final SoftwareModuleMetadata updated = softwareModuleManagement.updateSoftwareModuleMetadata(softwareModuleId,
|
final SoftwareModuleMetadata updated = softwareModuleManagement.updateMetaData(softwareModuleId,
|
||||||
entityFactory.generateMetadata(metadataKey, metadata.getValue()));
|
entityFactory.generateMetadata(metadataKey, metadata.getValue()));
|
||||||
|
|
||||||
return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(updated));
|
return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(updated));
|
||||||
@@ -243,7 +241,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Void> deleteMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
|
public ResponseEntity<Void> deleteMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||||
@PathVariable("metadataKey") final String metadataKey) {
|
@PathVariable("metadataKey") final String metadataKey) {
|
||||||
softwareModuleManagement.deleteSoftwareModuleMetadata(softwareModuleId, metadataKey);
|
softwareModuleManagement.deleteMetaData(softwareModuleId, metadataKey);
|
||||||
|
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
@@ -253,8 +251,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||||
@RequestBody final List<MgmtMetadata> metadataRest) {
|
@RequestBody final List<MgmtMetadata> metadataRest) {
|
||||||
|
|
||||||
final List<SoftwareModuleMetadata> created = softwareModuleManagement.createSoftwareModuleMetadata(
|
final List<SoftwareModuleMetadata> created = softwareModuleManagement.createMetaData(softwareModuleId,
|
||||||
softwareModuleId, MgmtSoftwareModuleMapper.fromRequestSwMetadata(entityFactory, metadataRest));
|
MgmtSoftwareModuleMapper.fromRequestSwMetadata(entityFactory, metadataRest));
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(MgmtSoftwareModuleMapper.toResponseSwMetadata(created));
|
return ResponseEntity.status(HttpStatus.CREATED).body(MgmtSoftwareModuleMapper.toResponseSwMetadata(created));
|
||||||
}
|
}
|
||||||
@@ -262,7 +260,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
|||||||
private SoftwareModule findSoftwareModuleWithExceptionIfNotFound(final Long softwareModuleId,
|
private SoftwareModule findSoftwareModuleWithExceptionIfNotFound(final Long softwareModuleId,
|
||||||
final Long artifactId) {
|
final Long artifactId) {
|
||||||
|
|
||||||
final SoftwareModule module = softwareModuleManagement.findSoftwareModuleById(softwareModuleId)
|
final SoftwareModule module = softwareModuleManagement.get(softwareModuleId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
|
||||||
|
|
||||||
if (artifactId != null && !module.getArtifact(artifactId).isPresent()) {
|
if (artifactId != null && !module.getArtifact(artifactId).isPresent()) {
|
||||||
|
|||||||
@@ -64,11 +64,11 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
|
|||||||
final Slice<SoftwareModuleType> findModuleTypessAll;
|
final Slice<SoftwareModuleType> findModuleTypessAll;
|
||||||
Long countModulesAll;
|
Long countModulesAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
findModuleTypessAll = softwareModuleTypeManagement.findSoftwareModuleTypesAll(rsqlParam, pageable);
|
findModuleTypessAll = softwareModuleTypeManagement.findByRsql(pageable, rsqlParam);
|
||||||
countModulesAll = ((Page<SoftwareModuleType>) findModuleTypessAll).getTotalElements();
|
countModulesAll = ((Page<SoftwareModuleType>) findModuleTypessAll).getTotalElements();
|
||||||
} else {
|
} else {
|
||||||
findModuleTypessAll = softwareModuleTypeManagement.findSoftwareModuleTypesAll(pageable);
|
findModuleTypessAll = softwareModuleTypeManagement.findAll(pageable);
|
||||||
countModulesAll = softwareModuleTypeManagement.countSoftwareModuleTypesAll();
|
countModulesAll = softwareModuleTypeManagement.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<MgmtSoftwareModuleType> rest = MgmtSoftwareModuleTypeMapper
|
final List<MgmtSoftwareModuleType> rest = MgmtSoftwareModuleTypeMapper
|
||||||
@@ -87,7 +87,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
|
|||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Void> deleteSoftwareModuleType(
|
public ResponseEntity<Void> deleteSoftwareModuleType(
|
||||||
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) {
|
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) {
|
||||||
softwareModuleTypeManagement.deleteSoftwareModuleType(softwareModuleTypeId);
|
softwareModuleTypeManagement.delete(softwareModuleTypeId);
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
|
|||||||
@RequestBody final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType) {
|
@RequestBody final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType) {
|
||||||
|
|
||||||
final SoftwareModuleType updatedSoftwareModuleType = softwareModuleTypeManagement
|
final SoftwareModuleType updatedSoftwareModuleType = softwareModuleTypeManagement
|
||||||
.updateSoftwareModuleType(entityFactory.softwareModuleType().update(softwareModuleTypeId)
|
.update(entityFactory.softwareModuleType().update(softwareModuleTypeId)
|
||||||
.description(restSoftwareModuleType.getDescription())
|
.description(restSoftwareModuleType.getDescription())
|
||||||
.colour(restSoftwareModuleType.getColour()));
|
.colour(restSoftwareModuleType.getColour()));
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
|
|||||||
public ResponseEntity<List<MgmtSoftwareModuleType>> createSoftwareModuleTypes(
|
public ResponseEntity<List<MgmtSoftwareModuleType>> createSoftwareModuleTypes(
|
||||||
@RequestBody final List<MgmtSoftwareModuleTypeRequestBodyPost> softwareModuleTypes) {
|
@RequestBody final List<MgmtSoftwareModuleTypeRequestBodyPost> softwareModuleTypes) {
|
||||||
|
|
||||||
final List<SoftwareModuleType> createdSoftwareModules = softwareModuleTypeManagement.createSoftwareModuleType(
|
final List<SoftwareModuleType> createdSoftwareModules = softwareModuleTypeManagement.create(
|
||||||
MgmtSoftwareModuleTypeMapper.smFromRequest(entityFactory, softwareModuleTypes));
|
MgmtSoftwareModuleTypeMapper.smFromRequest(entityFactory, softwareModuleTypes));
|
||||||
|
|
||||||
return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules),
|
return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules),
|
||||||
@@ -116,7 +116,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SoftwareModuleType findSoftwareModuleTypeWithExceptionIfNotFound(final Long softwareModuleTypeId) {
|
private SoftwareModuleType findSoftwareModuleTypeWithExceptionIfNotFound(final Long softwareModuleTypeId) {
|
||||||
return softwareModuleTypeManagement.findSoftwareModuleTypeById(softwareModuleTypeId)
|
return softwareModuleTypeManagement.get(softwareModuleTypeId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, softwareModuleTypeId));
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, softwareModuleTypeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,13 +74,13 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
|
|||||||
final Slice<TargetFilterQuery> findTargetFiltersAll;
|
final Slice<TargetFilterQuery> findTargetFiltersAll;
|
||||||
final Long countTargetsAll;
|
final Long countTargetsAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
final Page<TargetFilterQuery> findFilterPage = filterManagement.findTargetFilterQueryByFilter(pageable,
|
final Page<TargetFilterQuery> findFilterPage = filterManagement.findByRsql(pageable,
|
||||||
rsqlParam);
|
rsqlParam);
|
||||||
countTargetsAll = findFilterPage.getTotalElements();
|
countTargetsAll = findFilterPage.getTotalElements();
|
||||||
findTargetFiltersAll = findFilterPage;
|
findTargetFiltersAll = findFilterPage;
|
||||||
} else {
|
} else {
|
||||||
findTargetFiltersAll = filterManagement.findAllTargetFilterQuery(pageable);
|
findTargetFiltersAll = filterManagement.findAll(pageable);
|
||||||
countTargetsAll = filterManagement.countAllTargetFilterQuery();
|
countTargetsAll = filterManagement.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<MgmtTargetFilterQuery> rest = MgmtTargetFilterQueryMapper
|
final List<MgmtTargetFilterQuery> rest = MgmtTargetFilterQueryMapper
|
||||||
@@ -92,7 +92,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
|
|||||||
public ResponseEntity<MgmtTargetFilterQuery> createFilter(
|
public ResponseEntity<MgmtTargetFilterQuery> createFilter(
|
||||||
@RequestBody final MgmtTargetFilterQueryRequestBody filter) {
|
@RequestBody final MgmtTargetFilterQueryRequestBody filter) {
|
||||||
final TargetFilterQuery createdTarget = filterManagement
|
final TargetFilterQuery createdTarget = filterManagement
|
||||||
.createTargetFilterQuery(MgmtTargetFilterQueryMapper.fromRequest(entityFactory, filter));
|
.create(MgmtTargetFilterQueryMapper.fromRequest(entityFactory, filter));
|
||||||
|
|
||||||
return new ResponseEntity<>(MgmtTargetFilterQueryMapper.toResponse(createdTarget), HttpStatus.CREATED);
|
return new ResponseEntity<>(MgmtTargetFilterQueryMapper.toResponse(createdTarget), HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
|
|||||||
LOG.debug("updating target filter query {}", filterId);
|
LOG.debug("updating target filter query {}", filterId);
|
||||||
|
|
||||||
final TargetFilterQuery updateFilter = filterManagement
|
final TargetFilterQuery updateFilter = filterManagement
|
||||||
.updateTargetFilterQuery(entityFactory.targetFilterQuery().update(filterId)
|
.update(entityFactory.targetFilterQuery().update(filterId)
|
||||||
.name(targetFilterRest.getName()).query(targetFilterRest.getQuery()));
|
.name(targetFilterRest.getName()).query(targetFilterRest.getQuery()));
|
||||||
|
|
||||||
return ResponseEntity.ok(MgmtTargetFilterQueryMapper.toResponse(updateFilter));
|
return ResponseEntity.ok(MgmtTargetFilterQueryMapper.toResponse(updateFilter));
|
||||||
@@ -111,7 +111,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Void> deleteFilter(@PathVariable("filterId") final Long filterId) {
|
public ResponseEntity<Void> deleteFilter(@PathVariable("filterId") final Long filterId) {
|
||||||
filterManagement.deleteTargetFilterQuery(filterId);
|
filterManagement.delete(filterId);
|
||||||
LOG.debug("{} target filter query deleted, return status {}", filterId, HttpStatus.OK);
|
LOG.debug("{} target filter query deleted, return status {}", filterId, HttpStatus.OK);
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
|
|||||||
public ResponseEntity<MgmtTargetFilterQuery> postAssignedDistributionSet(
|
public ResponseEntity<MgmtTargetFilterQuery> postAssignedDistributionSet(
|
||||||
@PathVariable("filterId") final Long filterId, @RequestBody final MgmtId dsId) {
|
@PathVariable("filterId") final Long filterId, @RequestBody final MgmtId dsId) {
|
||||||
|
|
||||||
final TargetFilterQuery updateFilter = filterManagement.updateTargetFilterQueryAutoAssignDS(filterId,
|
final TargetFilterQuery updateFilter = filterManagement.updateAutoAssignDS(filterId,
|
||||||
dsId.getId());
|
dsId.getId());
|
||||||
|
|
||||||
return ResponseEntity.ok(MgmtTargetFilterQueryMapper.toResponse(updateFilter));
|
return ResponseEntity.ok(MgmtTargetFilterQueryMapper.toResponse(updateFilter));
|
||||||
@@ -138,13 +138,13 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Void> deleteAssignedDistributionSet(@PathVariable("filterId") final Long filterId) {
|
public ResponseEntity<Void> deleteAssignedDistributionSet(@PathVariable("filterId") final Long filterId) {
|
||||||
filterManagement.updateTargetFilterQueryAutoAssignDS(filterId, null);
|
filterManagement.updateAutoAssignDS(filterId, null);
|
||||||
|
|
||||||
return ResponseEntity.noContent().build();
|
return ResponseEntity.noContent().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private TargetFilterQuery findFilterWithExceptionIfNotFound(final Long filterId) {
|
private TargetFilterQuery findFilterWithExceptionIfNotFound(final Long filterId) {
|
||||||
return filterManagement.findTargetFilterQueryById(filterId)
|
return filterManagement.get(filterId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, filterId));
|
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, filterId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,14 +91,14 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
|||||||
|
|
||||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||||
final Slice<Target> findTargetsAll;
|
final Slice<Target> findTargetsAll;
|
||||||
final Long countTargetsAll;
|
final long countTargetsAll;
|
||||||
if (rsqlParam != null) {
|
if (rsqlParam != null) {
|
||||||
final Page<Target> findTargetPage = this.targetManagement.findTargetsAll(rsqlParam, pageable);
|
final Page<Target> findTargetPage = this.targetManagement.findByRsql(pageable, rsqlParam);
|
||||||
countTargetsAll = findTargetPage.getTotalElements();
|
countTargetsAll = findTargetPage.getTotalElements();
|
||||||
findTargetsAll = findTargetPage;
|
findTargetsAll = findTargetPage;
|
||||||
} else {
|
} else {
|
||||||
findTargetsAll = this.targetManagement.findTargetsAll(pageable);
|
findTargetsAll = this.targetManagement.findAll(pageable);
|
||||||
countTargetsAll = this.targetManagement.countTargetsAll();
|
countTargetsAll = this.targetManagement.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<MgmtTarget> rest = MgmtTargetMapper.toResponse(findTargetsAll.getContent());
|
final List<MgmtTarget> rest = MgmtTargetMapper.toResponse(findTargetsAll.getContent());
|
||||||
@@ -109,7 +109,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
|||||||
public ResponseEntity<List<MgmtTarget>> createTargets(@RequestBody final List<MgmtTargetRequestBody> targets) {
|
public ResponseEntity<List<MgmtTarget>> createTargets(@RequestBody final List<MgmtTargetRequestBody> targets) {
|
||||||
LOG.debug("creating {} targets", targets.size());
|
LOG.debug("creating {} targets", targets.size());
|
||||||
final Collection<Target> createdTargets = this.targetManagement
|
final Collection<Target> createdTargets = this.targetManagement
|
||||||
.createTargets(MgmtTargetMapper.fromRequest(entityFactory, targets));
|
.create(MgmtTargetMapper.fromRequest(entityFactory, targets));
|
||||||
LOG.debug("{} targets created, return status {}", targets.size(), HttpStatus.CREATED);
|
LOG.debug("{} targets created, return status {}", targets.size(), HttpStatus.CREATED);
|
||||||
return new ResponseEntity<>(MgmtTargetMapper.toResponse(createdTargets), HttpStatus.CREATED);
|
return new ResponseEntity<>(MgmtTargetMapper.toResponse(createdTargets), HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
|||||||
public ResponseEntity<MgmtTarget> updateTarget(@PathVariable("controllerId") final String controllerId,
|
public ResponseEntity<MgmtTarget> updateTarget(@PathVariable("controllerId") final String controllerId,
|
||||||
@RequestBody final MgmtTargetRequestBody targetRest) {
|
@RequestBody final MgmtTargetRequestBody targetRest) {
|
||||||
|
|
||||||
final Target updateTarget = this.targetManagement.updateTarget(entityFactory.target().update(controllerId)
|
final Target updateTarget = this.targetManagement.update(entityFactory.target().update(controllerId)
|
||||||
.name(targetRest.getName()).description(targetRest.getDescription()).address(targetRest.getAddress())
|
.name(targetRest.getName()).description(targetRest.getDescription()).address(targetRest.getAddress())
|
||||||
.securityToken(targetRest.getSecurityToken()));
|
.securityToken(targetRest.getSecurityToken()));
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Void> deleteTarget(@PathVariable("controllerId") final String controllerId) {
|
public ResponseEntity<Void> deleteTarget(@PathVariable("controllerId") final String controllerId) {
|
||||||
this.targetManagement.deleteTarget(controllerId);
|
this.targetManagement.deleteByControllerID(controllerId);
|
||||||
LOG.debug("{} target deleted, return status {}", controllerId, HttpStatus.OK);
|
LOG.debug("{} target deleted, return status {}", controllerId, HttpStatus.OK);
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Target findTargetWithExceptionIfNotFound(final String controllerId) {
|
private Target findTargetWithExceptionIfNotFound(final String controllerId) {
|
||||||
return targetManagement.findTargetByControllerID(controllerId)
|
return targetManagement.getByControllerID(controllerId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
|||||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi;
|
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi;
|
||||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||||
import org.eclipse.hawkbit.repository.TagManagement;
|
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
@@ -50,7 +50,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
|||||||
private static final Logger LOG = LoggerFactory.getLogger(MgmtTargetTagResource.class);
|
private static final Logger LOG = LoggerFactory.getLogger(MgmtTargetTagResource.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TagManagement tagManagement;
|
private TargetTagManagement tagManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TargetManagement targetManagement;
|
private TargetManagement targetManagement;
|
||||||
@@ -72,10 +72,10 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
|||||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||||
Page<TargetTag> findTargetsAll;
|
Page<TargetTag> findTargetsAll;
|
||||||
if (rsqlParam == null) {
|
if (rsqlParam == null) {
|
||||||
findTargetsAll = this.tagManagement.findAllTargetTags(pageable);
|
findTargetsAll = this.tagManagement.findAll(pageable);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
findTargetsAll = this.tagManagement.findAllTargetTags(rsqlParam, pageable);
|
findTargetsAll = this.tagManagement.findByRsql(pageable, rsqlParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<MgmtTag> rest = MgmtTagMapper.toResponse(findTargetsAll.getContent());
|
final List<MgmtTag> rest = MgmtTagMapper.toResponse(findTargetsAll.getContent());
|
||||||
@@ -92,7 +92,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
|||||||
public ResponseEntity<List<MgmtTag>> createTargetTags(@RequestBody final List<MgmtTagRequestBodyPut> tags) {
|
public ResponseEntity<List<MgmtTag>> createTargetTags(@RequestBody final List<MgmtTagRequestBodyPut> tags) {
|
||||||
LOG.debug("creating {} target tags", tags.size());
|
LOG.debug("creating {} target tags", tags.size());
|
||||||
final List<TargetTag> createdTargetTags = this.tagManagement
|
final List<TargetTag> createdTargetTags = this.tagManagement
|
||||||
.createTargetTags(MgmtTagMapper.mapTagFromRequest(entityFactory, tags));
|
.create(MgmtTagMapper.mapTagFromRequest(entityFactory, tags));
|
||||||
return new ResponseEntity<>(MgmtTagMapper.toResponse(createdTargetTags), HttpStatus.CREATED);
|
return new ResponseEntity<>(MgmtTagMapper.toResponse(createdTargetTags), HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
|||||||
LOG.debug("update {} target tag", restTargetTagRest);
|
LOG.debug("update {} target tag", restTargetTagRest);
|
||||||
|
|
||||||
final TargetTag updateTargetTag = tagManagement
|
final TargetTag updateTargetTag = tagManagement
|
||||||
.updateTargetTag(entityFactory.tag().update(targetTagId).name(restTargetTagRest.getName())
|
.update(entityFactory.tag().update(targetTagId).name(restTargetTagRest.getName())
|
||||||
.description(restTargetTagRest.getDescription()).colour(restTargetTagRest.getColour()));
|
.description(restTargetTagRest.getDescription()).colour(restTargetTagRest.getColour()));
|
||||||
|
|
||||||
LOG.debug("target tag updated");
|
LOG.debug("target tag updated");
|
||||||
@@ -115,7 +115,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
|||||||
LOG.debug("Delete {} target tag", targetTagId);
|
LOG.debug("Delete {} target tag", targetTagId);
|
||||||
final TargetTag targetTag = findTargetTagById(targetTagId);
|
final TargetTag targetTag = findTargetTagById(targetTagId);
|
||||||
|
|
||||||
this.tagManagement.deleteTargetTag(targetTag.getName());
|
this.tagManagement.delete(targetTag.getName());
|
||||||
|
|
||||||
return ResponseEntity.ok().build();
|
return ResponseEntity.ok().build();
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
|||||||
public ResponseEntity<List<MgmtTarget>> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId) {
|
public ResponseEntity<List<MgmtTarget>> getAssignedTargets(@PathVariable("targetTagId") final Long targetTagId) {
|
||||||
|
|
||||||
return ResponseEntity.ok(MgmtTargetMapper.toResponse(targetManagement
|
return ResponseEntity.ok(MgmtTargetMapper.toResponse(targetManagement
|
||||||
.findTargetsByTag(new PageRequest(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), targetTagId)
|
.findByTag(new PageRequest(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), targetTagId)
|
||||||
.getContent()));
|
.getContent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,10 +142,10 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
|||||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||||
Page<Target> findTargetsAll;
|
Page<Target> findTargetsAll;
|
||||||
if (rsqlParam == null) {
|
if (rsqlParam == null) {
|
||||||
findTargetsAll = targetManagement.findTargetsByTag(pageable, targetTagId);
|
findTargetsAll = targetManagement.findByTag(pageable, targetTagId);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
findTargetsAll = targetManagement.findTargetsByTag(pageable, rsqlParam, targetTagId);
|
findTargetsAll = targetManagement.findByRsqlAndTag(pageable, rsqlParam, targetTagId);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Long countTargetsAll = findTargetsAll.getTotalElements();
|
final Long countTargetsAll = findTargetsAll.getTotalElements();
|
||||||
@@ -188,7 +188,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TargetTag findTargetTagById(final Long targetTagId) {
|
private TargetTag findTargetTagById(final Long targetTagId) {
|
||||||
return tagManagement.findTargetTagById(targetTagId)
|
return tagManagement.get(targetTagId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(TargetTag.class, targetTagId));
|
.orElseThrow(() -> new EntityNotFoundException(TargetTag.class, targetTagId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
.andExpect(jsonPath("$.alreadyAssigned", equalTo(1)))
|
.andExpect(jsonPath("$.alreadyAssigned", equalTo(1)))
|
||||||
.andExpect(jsonPath("$.total", equalTo(targets.size())));
|
.andExpect(jsonPath("$.total", equalTo(targets.size())));
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetByAssignedDistributionSet(createdDs.getId(), PAGE).getContent())
|
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, createdDs.getId()).getContent())
|
||||||
.as("Five targets in repository have DS assigned").hasSize(5);
|
.as("Five targets in repository have DS assigned").hasSize(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,11 +241,10 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
.andExpect(jsonPath("$.alreadyAssigned", equalTo(1)))
|
.andExpect(jsonPath("$.alreadyAssigned", equalTo(1)))
|
||||||
.andExpect(jsonPath("$.total", equalTo(targets.size())));
|
.andExpect(jsonPath("$.total", equalTo(targets.size())));
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetByAssignedDistributionSet(createdDs.getId(), PAGE).getContent())
|
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, createdDs.getId()).getContent())
|
||||||
.as("Five targets in repository have DS assigned").hasSize(5);
|
.as("Five targets in repository have DS assigned").hasSize(5);
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetByInstalledDistributionSet(createdDs.getId(), PAGE).getContent())
|
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, createdDs.getId()).getContent()).hasSize(4);
|
||||||
.hasSize(4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -306,16 +305,14 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
|
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
|
||||||
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
|
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
|
||||||
|
|
||||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(
|
targetFilterQueryManagement.updateAutoAssignDS(
|
||||||
targetFilterQueryManagement.createTargetFilterQuery(
|
targetFilterQueryManagement
|
||||||
entityFactory.targetFilterQuery().create().name(knownFilterName).query("x==y")).getId(),
|
.create(entityFactory.targetFilterQuery().create().name(knownFilterName).query("x==y")).getId(),
|
||||||
createdDs.getId());
|
createdDs.getId());
|
||||||
|
|
||||||
// create some dummy target filter queries
|
// create some dummy target filter queries
|
||||||
targetFilterQueryManagement
|
targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("b").query("x==y"));
|
||||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("b").query("x==y"));
|
targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("c").query("x==y"));
|
||||||
targetFilterQueryManagement
|
|
||||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name("c").query("x==y"));
|
|
||||||
|
|
||||||
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId()
|
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId()
|
||||||
+ "/autoAssignTargetFilters")).andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(1)))
|
+ "/autoAssignTargetFilters")).andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(1)))
|
||||||
@@ -369,21 +366,17 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
|
|
||||||
private void prepareTestFilters(final String filterNamePrefix, final DistributionSet createdDs) {
|
private void prepareTestFilters(final String filterNamePrefix, final DistributionSet createdDs) {
|
||||||
// create target filter queries that should be found
|
// create target filter queries that should be found
|
||||||
targetFilterQueryManagement
|
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQueryManagement
|
||||||
.updateTargetFilterQueryAutoAssignDS(targetFilterQueryManagement
|
.create(entityFactory.targetFilterQuery().create().name(filterNamePrefix + "1").query("x==y")).getId(),
|
||||||
.createTargetFilterQuery(
|
createdDs.getId());
|
||||||
entityFactory.targetFilterQuery().create().name(filterNamePrefix + "1").query("x==y"))
|
targetFilterQueryManagement.updateAutoAssignDS(targetFilterQueryManagement
|
||||||
.getId(), createdDs.getId());
|
.create(entityFactory.targetFilterQuery().create().name(filterNamePrefix + "2").query("x==y")).getId(),
|
||||||
targetFilterQueryManagement
|
createdDs.getId());
|
||||||
.updateTargetFilterQueryAutoAssignDS(targetFilterQueryManagement
|
|
||||||
.createTargetFilterQuery(
|
|
||||||
entityFactory.targetFilterQuery().create().name(filterNamePrefix + "2").query("x==y"))
|
|
||||||
.getId(), createdDs.getId());
|
|
||||||
// create some dummy target filter queries
|
// create some dummy target filter queries
|
||||||
targetFilterQueryManagement.createTargetFilterQuery(
|
targetFilterQueryManagement
|
||||||
entityFactory.targetFilterQuery().create().name(filterNamePrefix + "b").query("x==y"));
|
.create(entityFactory.targetFilterQuery().create().name(filterNamePrefix + "b").query("x==y"));
|
||||||
targetFilterQueryManagement.createTargetFilterQuery(
|
targetFilterQueryManagement
|
||||||
entityFactory.targetFilterQuery().create().name(filterNamePrefix + "c").query("x==y"));
|
.create(entityFactory.targetFilterQuery().create().name(filterNamePrefix + "c").query("x==y"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -433,16 +426,16 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
@Description("Ensures that multiple DS requested are listed with expected payload.")
|
@Description("Ensures that multiple DS requested are listed with expected payload.")
|
||||||
public void getDistributionSets() throws Exception {
|
public void getDistributionSets() throws Exception {
|
||||||
// prepare test data
|
// prepare test data
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
|
||||||
|
|
||||||
DistributionSet set = testdataFactory.createDistributionSet("one");
|
DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||||
set = distributionSetManagement.updateDistributionSet(entityFactory.distributionSet().update(set.getId())
|
set = distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||||
.version("anotherVersion").requiredMigrationStep(true));
|
.version("anotherVersion").requiredMigrationStep(true));
|
||||||
|
|
||||||
// load also lazy stuff
|
// load also lazy stuff
|
||||||
set = distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).get();
|
set = distributionSetManagement.getWithDetails(set.getId()).get();
|
||||||
|
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(1);
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1);
|
||||||
|
|
||||||
// perform request
|
// perform request
|
||||||
mvc.perform(get("/rest/v1/distributionsets").accept(MediaType.APPLICATION_JSON))
|
mvc.perform(get("/rest/v1/distributionsets").accept(MediaType.APPLICATION_JSON))
|
||||||
@@ -505,7 +498,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||||
@Description("Ensures that multipe DS posted to API are created in the repository.")
|
@Description("Ensures that multipe DS posted to API are created in the repository.")
|
||||||
public void createDistributionSets() throws Exception {
|
public void createDistributionSets() throws Exception {
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
|
||||||
|
|
||||||
final SoftwareModule ah = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_APP);
|
final SoftwareModule ah = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_APP);
|
||||||
final SoftwareModule jvm = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_RT);
|
final SoftwareModule jvm = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_RT);
|
||||||
@@ -522,14 +515,15 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
|
|
||||||
final MvcResult mvcResult = executeMgmtTargetPost(one, two, three);
|
final MvcResult mvcResult = executeMgmtTargetPost(one, two, three);
|
||||||
|
|
||||||
one = distributionSetManagement.findDistributionSetByIdWithDetails(
|
one = distributionSetManagement
|
||||||
distributionSetManagement.findDistributionSetsAll("name==one", PAGE, false).getContent().get(0).getId())
|
.getWithDetails(distributionSetManagement.findByRsql(PAGE, "name==one").getContent().get(0).getId())
|
||||||
.get();
|
.get();
|
||||||
two = distributionSetManagement.findDistributionSetByIdWithDetails(
|
two = distributionSetManagement
|
||||||
distributionSetManagement.findDistributionSetsAll("name==two", PAGE, false).getContent().get(0).getId())
|
.getWithDetails(distributionSetManagement.findByRsql(PAGE, "name==two").getContent().get(0).getId())
|
||||||
|
.get();
|
||||||
|
three = distributionSetManagement
|
||||||
|
.getWithDetails(distributionSetManagement.findByRsql(PAGE, "name==three").getContent().get(0).getId())
|
||||||
.get();
|
.get();
|
||||||
three = distributionSetManagement.findDistributionSetByIdWithDetails(distributionSetManagement
|
|
||||||
.findDistributionSetsAll("name==three", PAGE, false).getContent().get(0).getId()).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())
|
||||||
@@ -560,7 +554,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
.isEqualTo(String.valueOf(three.getId()));
|
.isEqualTo(String.valueOf(three.getId()));
|
||||||
|
|
||||||
// check in database
|
// check in database
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(3);
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(3);
|
||||||
assertThat(one.isRequiredMigrationStep()).isEqualTo(false);
|
assertThat(one.isRequiredMigrationStep()).isEqualTo(false);
|
||||||
assertThat(two.isRequiredMigrationStep()).isEqualTo(false);
|
assertThat(two.isRequiredMigrationStep()).isEqualTo(false);
|
||||||
assertThat(three.isRequiredMigrationStep()).isEqualTo(true);
|
assertThat(three.isRequiredMigrationStep()).isEqualTo(true);
|
||||||
@@ -624,19 +618,19 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
@Description("Ensures that DS deletion request to API is reflected by the repository.")
|
@Description("Ensures that DS deletion request to API is reflected by the repository.")
|
||||||
public void deleteUnassignedistributionSet() throws Exception {
|
public void deleteUnassignedistributionSet() throws Exception {
|
||||||
// prepare test data
|
// prepare test data
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
|
||||||
|
|
||||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||||
|
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(1);
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1);
|
||||||
|
|
||||||
// perform request
|
// perform request
|
||||||
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print())
|
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
// check repository content
|
// check repository content
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).isEmpty();
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty();
|
||||||
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(0);
|
assertThat(distributionSetManagement.count()).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -650,21 +644,20 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
@Description("Ensures that assigned DS deletion request to API is reflected by the repository by means of deleted flag set.")
|
@Description("Ensures that assigned DS deletion request to API is reflected by the repository by means of deleted flag set.")
|
||||||
public void deleteAssignedDistributionSet() throws Exception {
|
public void deleteAssignedDistributionSet() throws Exception {
|
||||||
// prepare test data
|
// prepare test data
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
|
||||||
|
|
||||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||||
testdataFactory.createTarget("test");
|
testdataFactory.createTarget("test");
|
||||||
assignDistributionSet(set.getId(), "test");
|
assignDistributionSet(set.getId(), "test");
|
||||||
|
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(1);
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1);
|
||||||
|
|
||||||
// perform request
|
// perform request
|
||||||
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print())
|
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
// check repository content
|
// check repository content
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, true, true)).hasSize(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -672,18 +665,18 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
public void updateDistributionSet() throws Exception {
|
public void updateDistributionSet() throws Exception {
|
||||||
|
|
||||||
// prepare test data
|
// prepare test data
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
|
||||||
|
|
||||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||||
|
|
||||||
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
|
assertThat(distributionSetManagement.count()).isEqualTo(1);
|
||||||
|
|
||||||
mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId())
|
mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId())
|
||||||
.content("{\"version\":\"anotherVersion\",\"requiredMigrationStep\":\"true\"}")
|
.content("{\"version\":\"anotherVersion\",\"requiredMigrationStep\":\"true\"}")
|
||||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
final DistributionSet setupdated = distributionSetManagement.findDistributionSetById(set.getId()).get();
|
final DistributionSet setupdated = distributionSetManagement.get(set.getId()).get();
|
||||||
|
|
||||||
assertThat(setupdated.isRequiredMigrationStep()).isEqualTo(true);
|
assertThat(setupdated.isRequiredMigrationStep()).isEqualTo(true);
|
||||||
assertThat(setupdated.getVersion()).isEqualTo("anotherVersion");
|
assertThat(setupdated.getVersion()).isEqualTo("anotherVersion");
|
||||||
@@ -695,20 +688,20 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
public void updateRequiredMigrationStepFailsIfDistributionSetisInUse() throws Exception {
|
public void updateRequiredMigrationStepFailsIfDistributionSetisInUse() throws Exception {
|
||||||
|
|
||||||
// prepare test data
|
// prepare test data
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true)).hasSize(0);
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
|
||||||
|
|
||||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||||
deploymentManagement.assignDistributionSet(set.getId(),
|
deploymentManagement.assignDistributionSet(set.getId(),
|
||||||
Arrays.asList(new TargetWithActionType(testdataFactory.createTarget().getControllerId())));
|
Arrays.asList(new TargetWithActionType(testdataFactory.createTarget().getControllerId())));
|
||||||
|
|
||||||
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
|
assertThat(distributionSetManagement.count()).isEqualTo(1);
|
||||||
|
|
||||||
mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId())
|
mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId())
|
||||||
.content("{\"version\":\"anotherVersion\",\"requiredMigrationStep\":\"true\"}")
|
.content("{\"version\":\"anotherVersion\",\"requiredMigrationStep\":\"true\"}")
|
||||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden());
|
||||||
|
|
||||||
final DistributionSet setupdated = distributionSetManagement.findDistributionSetById(set.getId()).get();
|
final DistributionSet setupdated = distributionSetManagement.get(set.getId()).get();
|
||||||
|
|
||||||
assertThat(setupdated.isRequiredMigrationStep()).isEqualTo(false);
|
assertThat(setupdated.isRequiredMigrationStep()).isEqualTo(false);
|
||||||
assertThat(setupdated.getVersion()).isEqualTo(set.getVersion());
|
assertThat(setupdated.getVersion()).isEqualTo(set.getVersion());
|
||||||
@@ -790,9 +783,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
|
||||||
.findDistributionSetMetadata(testDS.getId(), knownKey1).get();
|
.getMetaDataByDistributionSetId(testDS.getId(), knownKey1).get();
|
||||||
final DistributionSetMetadata metaKey2 = distributionSetManagement
|
final DistributionSetMetadata metaKey2 = distributionSetManagement
|
||||||
.findDistributionSetMetadata(testDS.getId(), knownKey2).get();
|
.getMetaDataByDistributionSetId(testDS.getId(), knownKey2).get();
|
||||||
|
|
||||||
assertThat(metaKey1.getValue()).isEqualTo(knownValue1);
|
assertThat(metaKey1.getValue()).isEqualTo(knownValue1);
|
||||||
assertThat(metaKey2.getValue()).isEqualTo(knownValue2);
|
assertThat(metaKey2.getValue()).isEqualTo(knownValue2);
|
||||||
@@ -818,7 +811,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
|
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
|
||||||
|
|
||||||
final DistributionSetMetadata assertDS = distributionSetManagement
|
final DistributionSetMetadata assertDS = distributionSetManagement
|
||||||
.findDistributionSetMetadata(testDS.getId(), knownKey).get();
|
.getMetaDataByDistributionSetId(testDS.getId(), knownKey).get();
|
||||||
assertThat(assertDS.getValue()).isEqualTo(updateValue);
|
assertThat(assertDS.getValue()).isEqualTo(updateValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -836,7 +829,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
mvc.perform(delete("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
|
mvc.perform(delete("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(distributionSetManagement.findDistributionSetMetadata(testDS.getId(), knownKey)).isNotPresent();
|
assertThat(distributionSetManagement.getMetaDataByDistributionSetId(testDS.getId(), knownKey)).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -855,7 +848,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
mvc.perform(delete("/rest/v1/distributionsets/1234/metadata/{key}", knownKey))
|
mvc.perform(delete("/rest/v1/distributionsets/1234/metadata/{key}", knownKey))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
||||||
|
|
||||||
assertThat(distributionSetManagement.findDistributionSetMetadata(testDS.getId(), knownKey)).isPresent();
|
assertThat(distributionSetManagement.getMetaDataByDistributionSetId(testDS.getId(), knownKey)).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -918,8 +911,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
public void filterDistributionSetComplete() throws Exception {
|
public void filterDistributionSetComplete() throws Exception {
|
||||||
final int amount = 10;
|
final int amount = 10;
|
||||||
testdataFactory.createDistributionSets(amount);
|
testdataFactory.createDistributionSets(amount);
|
||||||
distributionSetManagement.createDistributionSet(
|
distributionSetManagement
|
||||||
entityFactory.distributionSet().create().name("incomplete").version("2").type("os"));
|
.create(entityFactory.distributionSet().create().name("incomplete").version("2").type("os"));
|
||||||
|
|
||||||
final String rsqlFindLikeDs1OrDs2 = "complete==" + Boolean.TRUE;
|
final String rsqlFindLikeDs1OrDs2 = "complete==" + Boolean.TRUE;
|
||||||
|
|
||||||
@@ -937,8 +930,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
|||||||
// prepare targets
|
// prepare targets
|
||||||
final Collection<String> knownTargetIds = Arrays.asList("1", "2", "3", "4", "5");
|
final Collection<String> knownTargetIds = Arrays.asList("1", "2", "3", "4", "5");
|
||||||
|
|
||||||
knownTargetIds.forEach(controllerId -> targetManagement
|
knownTargetIds.forEach(
|
||||||
.createTarget(entityFactory.target().create().controllerId(controllerId)));
|
controllerId -> targetManagement.create(entityFactory.target().create().controllerId(controllerId)));
|
||||||
|
|
||||||
// assign already one target to DS
|
// assign already one target to DS
|
||||||
assignDistributionSet(createdDs.getId(), knownTargetIds.iterator().next());
|
assignDistributionSet(createdDs.getId(), knownTargetIds.iterator().next());
|
||||||
|
|||||||
@@ -113,11 +113,11 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
|
|
||||||
final Tag createdOne = tagManagement.findAllDistributionSetTags("name==thetest1", PAGE).getContent().get(0);
|
final Tag createdOne = distributionSetTagManagement.findByRsql(PAGE, "name==thetest1").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 = tagManagement.findAllDistributionSetTags("name==thetest2", PAGE).getContent().get(0);
|
final Tag createdTwo = distributionSetTagManagement.findByRsql(PAGE, "name==thetest2").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());
|
||||||
@@ -143,7 +143,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
|
|
||||||
final Tag updated = tagManagement.findAllDistributionSetTags("name==updatedName", PAGE).getContent().get(0);
|
final Tag updated = distributionSetTagManagement.findByRsql(PAGE, "name==updatedName").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());
|
||||||
@@ -162,7 +162,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()))
|
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(tagManagement.findDistributionSetTagById(original.getId())).isNotPresent();
|
assertThat(distributionSetTagManagement.get(original.getId())).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -242,8 +242,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
// 2 DistributionSetUpdateEvent
|
// 2 DistributionSetUpdateEvent
|
||||||
ResultActions result = toggle(tag, sets);
|
ResultActions result = toggle(tag, sets);
|
||||||
|
|
||||||
List<DistributionSet> updated = distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId())
|
List<DistributionSet> updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent();
|
||||||
.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()));
|
||||||
@@ -254,12 +253,12 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
// 2 DistributionSetUpdateEvent
|
// 2 DistributionSetUpdateEvent
|
||||||
result = toggle(tag, sets);
|
result = toggle(tag, sets);
|
||||||
|
|
||||||
updated = distributionSetManagement.findDistributionSetsAll(PAGE, false).getContent();
|
updated = distributionSetManagement.findAll(PAGE).getContent();
|
||||||
|
|
||||||
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.findDistributionSetsByTag(PAGE, tag.getId())).isEmpty();
|
assertThat(distributionSetManagement.findByTag(PAGE, tag.getId())).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResultActions toggle(final DistributionSetTag tag, final List<DistributionSet> sets) throws Exception {
|
private ResultActions toggle(final DistributionSetTag tag, final List<DistributionSet> sets) throws Exception {
|
||||||
@@ -291,8 +290,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
|
|
||||||
final List<DistributionSet> updated = distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId())
|
final List<DistributionSet> updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent();
|
||||||
.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()));
|
||||||
@@ -319,8 +317,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
|
|||||||
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/"
|
mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/"
|
||||||
+ unassigned.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
+ unassigned.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
final List<DistributionSet> updated = distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId())
|
final List<DistributionSet> updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent();
|
||||||
.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());
|
||||||
|
|||||||
@@ -59,9 +59,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
public void getDistributionSetTypes() throws Exception {
|
public void getDistributionSetTypes() throws Exception {
|
||||||
|
|
||||||
DistributionSetType testType = distributionSetTypeManagement
|
DistributionSetType testType = distributionSetTypeManagement
|
||||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
.create(entityFactory.distributionSetType().create().key("test123")
|
||||||
.name("TestName123").description("Desc123").colour("col12"));
|
.name("TestName123").description("Desc123").colour("col12"));
|
||||||
testType = distributionSetTypeManagement.updateDistributionSetType(
|
testType = distributionSetTypeManagement.update(
|
||||||
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
|
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
|
||||||
|
|
||||||
// 4 types overall (2 hawkbit tenant default, 1 test default and 1
|
// 4 types overall (2 hawkbit tenant default, 1 test default and 1
|
||||||
@@ -100,9 +100,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
public void getDistributionSetTypesSortedByKey() throws Exception {
|
public void getDistributionSetTypesSortedByKey() throws Exception {
|
||||||
|
|
||||||
DistributionSetType testType = distributionSetTypeManagement
|
DistributionSetType testType = distributionSetTypeManagement
|
||||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("zzzzz").name("TestName123")
|
.create(entityFactory.distributionSetType().create().key("zzzzz").name("TestName123")
|
||||||
.description("Desc123").colour("col12"));
|
.description("Desc123").colour("col12"));
|
||||||
testType = distributionSetTypeManagement.updateDistributionSetType(
|
testType = distributionSetTypeManagement.update(
|
||||||
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
|
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
|
||||||
|
|
||||||
// descending
|
// descending
|
||||||
@@ -148,11 +148,11 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
|
|
||||||
@Step
|
@Step
|
||||||
private void verifyCreatedDistributionSetTypes(final MvcResult mvcResult) throws UnsupportedEncodingException {
|
private void verifyCreatedDistributionSetTypes(final MvcResult mvcResult) throws UnsupportedEncodingException {
|
||||||
final DistributionSetType created1 = distributionSetTypeManagement.findDistributionSetTypeByKey("testKey1")
|
final DistributionSetType created1 = distributionSetTypeManagement.getByKey("testKey1")
|
||||||
.get();
|
.get();
|
||||||
final DistributionSetType created2 = distributionSetTypeManagement.findDistributionSetTypeByKey("testKey2")
|
final DistributionSetType created2 = distributionSetTypeManagement.getByKey("testKey2")
|
||||||
.get();
|
.get();
|
||||||
final DistributionSetType created3 = distributionSetTypeManagement.findDistributionSetTypeByKey("testKey3")
|
final DistributionSetType created3 = distributionSetTypeManagement.getByKey("testKey3")
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
assertThat(created1.getMandatoryModuleTypes()).containsOnly(osType);
|
assertThat(created1.getMandatoryModuleTypes()).containsOnly(osType);
|
||||||
@@ -190,7 +190,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
.toString()).isEqualTo(
|
.toString()).isEqualTo(
|
||||||
"http://localhost/rest/v1/distributionsettypes/" + created3.getId() + "/optionalmoduletypes");
|
"http://localhost/rest/v1/distributionsettypes/" + created3.getId() + "/optionalmoduletypes");
|
||||||
|
|
||||||
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(6);
|
assertThat(distributionSetTypeManagement.count()).isEqualTo(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Step
|
@Step
|
||||||
@@ -217,7 +217,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
|
|
||||||
@Step
|
@Step
|
||||||
private List<DistributionSetType> createTestDistributionSetTestTypes() {
|
private List<DistributionSetType> createTestDistributionSetTestTypes() {
|
||||||
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES);
|
assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES);
|
||||||
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
entityFactory.distributionSetType().create().key("testKey1").name("TestName1").description("Desc1")
|
entityFactory.distributionSetType().create().key("testKey1").name("TestName1").description("Desc1")
|
||||||
@@ -235,7 +235,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes POST requests.")
|
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes POST requests.")
|
||||||
public void addMandatoryModuleToDistributionSetType() throws Exception {
|
public void addMandatoryModuleToDistributionSetType() throws Exception {
|
||||||
DistributionSetType testType = distributionSetTypeManagement
|
DistributionSetType testType = distributionSetTypeManagement
|
||||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
.create(entityFactory.distributionSetType().create().key("test123")
|
||||||
.name("TestName123").description("Desc123").colour("col12"));
|
.name("TestName123").description("Desc123").colour("col12"));
|
||||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
.content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON))
|
.content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
testType = distributionSetTypeManagement.findDistributionSetTypeById(testType.getId()).get();
|
testType = distributionSetTypeManagement.get(testType.getId()).get();
|
||||||
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
|
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
|
||||||
assertThat(testType.getOptLockRevision()).isEqualTo(2);
|
assertThat(testType.getOptLockRevision()).isEqualTo(2);
|
||||||
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
|
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
|
||||||
@@ -255,7 +255,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes POST requests.")
|
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes POST requests.")
|
||||||
public void addOptionalModuleToDistributionSetType() throws Exception {
|
public void addOptionalModuleToDistributionSetType() throws Exception {
|
||||||
DistributionSetType testType = distributionSetTypeManagement
|
DistributionSetType testType = distributionSetTypeManagement
|
||||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
.create(entityFactory.distributionSetType().create().key("test123")
|
||||||
.name("TestName123").description("Desc123").colour("col12"));
|
.name("TestName123").description("Desc123").colour("col12"));
|
||||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
.content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON))
|
.content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
testType = distributionSetTypeManagement.findDistributionSetTypeById(testType.getId()).get();
|
testType = distributionSetTypeManagement.get(testType.getId()).get();
|
||||||
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
|
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
|
||||||
assertThat(testType.getOptLockRevision()).isEqualTo(2);
|
assertThat(testType.getOptLockRevision()).isEqualTo(2);
|
||||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(osType);
|
assertThat(testType.getOptionalModuleTypes()).containsExactly(osType);
|
||||||
@@ -318,7 +318,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSetType generateTestType() {
|
private DistributionSetType generateTestType() {
|
||||||
final DistributionSetType testType = distributionSetTypeManagement.createDistributionSetType(entityFactory
|
final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory
|
||||||
.distributionSetType().create().key("test123").name("TestName123").description("Desc123").colour("col")
|
.distributionSetType().create().key("test123").name("TestName123").description("Desc123").colour("col")
|
||||||
.mandatory(Arrays.asList(osType.getId())).optional(Arrays.asList(appType.getId())));
|
.mandatory(Arrays.asList(osType.getId())).optional(Arrays.asList(appType.getId())));
|
||||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||||
@@ -354,7 +354,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
osType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
osType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
testType = distributionSetTypeManagement.findDistributionSetTypeById(testType.getId()).get();
|
testType = distributionSetTypeManagement.get(testType.getId()).get();
|
||||||
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
|
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
|
||||||
assertThat(testType.getOptLockRevision()).isEqualTo(2);
|
assertThat(testType.getOptLockRevision()).isEqualTo(2);
|
||||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||||
@@ -371,7 +371,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
appType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
appType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
testType = distributionSetTypeManagement.findDistributionSetTypeById(testType.getId()).get();
|
testType = distributionSetTypeManagement.get(testType.getId()).get();
|
||||||
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
|
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
|
||||||
assertThat(testType.getOptLockRevision()).isEqualTo(2);
|
assertThat(testType.getOptLockRevision()).isEqualTo(2);
|
||||||
assertThat(testType.getOptionalModuleTypes()).isEmpty();
|
assertThat(testType.getOptionalModuleTypes()).isEmpty();
|
||||||
@@ -384,9 +384,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
public void getDistributionSetType() throws Exception {
|
public void getDistributionSetType() throws Exception {
|
||||||
|
|
||||||
DistributionSetType testType = distributionSetTypeManagement
|
DistributionSetType testType = distributionSetTypeManagement
|
||||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
.create(entityFactory.distributionSetType().create().key("test123")
|
||||||
.name("TestName123").description("Desc123").colour("col12"));
|
.name("TestName123").description("Desc123").colour("col12"));
|
||||||
testType = distributionSetTypeManagement.updateDistributionSetType(
|
testType = distributionSetTypeManagement.update(
|
||||||
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
|
entityFactory.distributionSetType().update(testType.getId()).description("Desc1234"));
|
||||||
|
|
||||||
mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId()).accept(MediaType.APPLICATION_JSON))
|
mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId()).accept(MediaType.APPLICATION_JSON))
|
||||||
@@ -404,15 +404,15 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (hard delete scenario).")
|
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (hard delete scenario).")
|
||||||
public void deleteDistributionSetTypeUnused() throws Exception {
|
public void deleteDistributionSetTypeUnused() throws Exception {
|
||||||
final DistributionSetType testType = distributionSetTypeManagement
|
final DistributionSetType testType = distributionSetTypeManagement
|
||||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
.create(entityFactory.distributionSetType().create().key("test123")
|
||||||
.name("TestName123").description("Desc123").colour("col12"));
|
.name("TestName123").description("Desc123").colour("col12"));
|
||||||
|
|
||||||
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES + 1);
|
assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES + 1);
|
||||||
|
|
||||||
mvc.perform(delete("/rest/v1/distributionsettypes/{dsId}", testType.getId()))
|
mvc.perform(delete("/rest/v1/distributionsettypes/{dsId}", testType.getId()))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES);
|
assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -427,27 +427,27 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (soft delete scenario).")
|
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (soft delete scenario).")
|
||||||
public void deleteDistributionSetTypeUsed() throws Exception {
|
public void deleteDistributionSetTypeUsed() throws Exception {
|
||||||
final DistributionSetType testType = distributionSetTypeManagement
|
final DistributionSetType testType = distributionSetTypeManagement
|
||||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
.create(entityFactory.distributionSetType().create().key("test123")
|
||||||
.name("TestName123").description("Desc123").colour("col12"));
|
.name("TestName123").description("Desc123").colour("col12"));
|
||||||
|
|
||||||
distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create().name("sdfsd")
|
distributionSetManagement.create(entityFactory.distributionSet().create().name("sdfsd")
|
||||||
.description("dsfsdf").version("1").type(testType));
|
.description("dsfsdf").version("1").type(testType));
|
||||||
|
|
||||||
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES + 1);
|
assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES + 1);
|
||||||
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
|
assertThat(distributionSetManagement.count()).isEqualTo(1);
|
||||||
|
|
||||||
mvc.perform(delete("/rest/v1/distributionsettypes/{smId}", testType.getId()))
|
mvc.perform(delete("/rest/v1/distributionsettypes/{smId}", testType.getId()))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
|
assertThat(distributionSetManagement.count()).isEqualTo(1);
|
||||||
assertThat(distributionSetTypeManagement.countDistributionSetTypesAll()).isEqualTo(DEFAULT_DS_TYPES);
|
assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID} PUT requests.")
|
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID} PUT requests.")
|
||||||
public void updateDistributionSetTypeOnlyDescriptionAndNameUntouched() throws Exception {
|
public void updateDistributionSetTypeOnlyDescriptionAndNameUntouched() throws Exception {
|
||||||
final DistributionSetType testType = distributionSetTypeManagement
|
final DistributionSetType testType = distributionSetTypeManagement
|
||||||
.createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
.create(entityFactory.distributionSetType().create().key("test123")
|
||||||
.name("TestName123").description("Desc123").colour("col"));
|
.name("TestName123").description("Desc123").colour("col"));
|
||||||
|
|
||||||
final String body = new JSONObject().put("id", testType.getId()).put("description", "foobardesc")
|
final String body = new JSONObject().put("id", testType.getId()).put("description", "foobardesc")
|
||||||
@@ -510,7 +510,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
// .createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
// .createDistributionSetType(entityFactory.distributionSetType().create().key("test123")
|
||||||
// .name("TestName123").description("Desc123").colour("col"));
|
// .name("TestName123").description("Desc123").colour("col"));
|
||||||
|
|
||||||
final SoftwareModuleType testSmType = softwareModuleTypeManagement.createSoftwareModuleType(
|
final SoftwareModuleType testSmType = softwareModuleTypeManagement.create(
|
||||||
entityFactory.softwareModuleType().create().key("test123").name("TestName123"));
|
entityFactory.softwareModuleType().create().key("test123").name("TestName123"));
|
||||||
|
|
||||||
// DST does not exist
|
// DST does not exist
|
||||||
@@ -598,9 +598,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
@Test
|
@Test
|
||||||
@Description("Search erquest of software module types.")
|
@Description("Search erquest of software module types.")
|
||||||
public void searchDistributionSetTypeRsql() throws Exception {
|
public void searchDistributionSetTypeRsql() throws Exception {
|
||||||
distributionSetTypeManagement.createDistributionSetType(
|
distributionSetTypeManagement.create(
|
||||||
entityFactory.distributionSetType().create().key("test123").name("TestName123"));
|
entityFactory.distributionSetType().create().key("test123").name("TestName123"));
|
||||||
distributionSetTypeManagement.createDistributionSetType(
|
distributionSetTypeManagement.create(
|
||||||
entityFactory.distributionSetType().create().key("test1234").name("TestName1234"));
|
entityFactory.distributionSetType().create().key("test1234").name("TestName1234"));
|
||||||
|
|
||||||
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
|
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
|
||||||
@@ -615,7 +615,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
|||||||
char character = 'a';
|
char character = 'a';
|
||||||
for (int index = 0; index < amount; index++) {
|
for (int index = 0; index < amount; index++) {
|
||||||
final String str = String.valueOf(character);
|
final String str = String.valueOf(character);
|
||||||
softwareModuleManagement.createSoftwareModule(
|
softwareModuleManagement.create(
|
||||||
entityFactory.softwareModule().create().name(str).description(str).vendor(str).version(str));
|
entityFactory.softwareModule().create().name(str).description(str).vendor(str).version(str));
|
||||||
character++;
|
character++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||||
|
|
||||||
// create rollout including the created targets with prefix 'rollout'
|
// create rollout including the created targets with prefix 'rollout'
|
||||||
final Rollout rollout = rolloutManagement.createRollout(
|
final Rollout rollout = rolloutManagement.create(
|
||||||
entityFactory.rollout().create().name("rollout1").set(dsA.getId())
|
entityFactory.rollout().create().name("rollout1").set(dsA.getId())
|
||||||
.targetFilterQuery("controllerId==rollout*"),
|
.targetFilterQuery("controllerId==rollout*"),
|
||||||
4, new RolloutGroupConditionBuilder().withDefaults()
|
4, new RolloutGroupConditionBuilder().withDefaults()
|
||||||
@@ -254,7 +254,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
|
|
||||||
@Step
|
@Step
|
||||||
private void retrieveAndVerifyRolloutInStarting(final Rollout rollout) throws Exception {
|
private void retrieveAndVerifyRolloutInStarting(final Rollout rollout) throws Exception {
|
||||||
rolloutManagement.startRollout(rollout.getId());
|
rolloutManagement.start(rollout.getId());
|
||||||
|
|
||||||
mvc.perform(get("/rest/v1/rollouts/" + rollout.getId()).accept(MediaType.APPLICATION_JSON))
|
mvc.perform(get("/rest/v1/rollouts/" + rollout.getId()).accept(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||||
@@ -592,17 +592,17 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||||
|
|
||||||
// create rollout including the created targets with prefix 'rollout'
|
// create rollout including the created targets with prefix 'rollout'
|
||||||
final Rollout rollout = rolloutManagement.createRollout(
|
final Rollout rollout = rolloutManagement.create(
|
||||||
entityFactory.rollout().create().name("rollout1").set(dsA.getId())
|
entityFactory.rollout().create().name("rollout1").set(dsA.getId())
|
||||||
.targetFilterQuery("controllerId==rollout*"),
|
.targetFilterQuery("controllerId==rollout*"),
|
||||||
4, new RolloutGroupConditionBuilder().withDefaults()
|
4, new RolloutGroupConditionBuilder().withDefaults()
|
||||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build());
|
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build());
|
||||||
|
|
||||||
final RolloutGroup firstGroup = rolloutGroupManagement
|
final RolloutGroup firstGroup = rolloutGroupManagement
|
||||||
.findRolloutGroupsByRolloutId(rollout.getId(), new PageRequest(0, 1, Direction.ASC, "id")).getContent()
|
.findByRollout(new PageRequest(0, 1, Direction.ASC, "id"), rollout.getId()).getContent()
|
||||||
.get(0);
|
.get(0);
|
||||||
final RolloutGroup secondGroup = rolloutGroupManagement
|
final RolloutGroup secondGroup = rolloutGroupManagement
|
||||||
.findRolloutGroupsByRolloutId(rollout.getId(), new PageRequest(1, 1, Direction.ASC, "id")).getContent()
|
.findByRollout(new PageRequest(1, 1, Direction.ASC, "id"), rollout.getId()).getContent()
|
||||||
.get(0);
|
.get(0);
|
||||||
|
|
||||||
retrieveAndVerifyRolloutGroupInCreating(rollout, firstGroup);
|
retrieveAndVerifyRolloutGroupInCreating(rollout, firstGroup);
|
||||||
@@ -613,7 +613,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
@Step
|
@Step
|
||||||
private void retrieveAndVerifyRolloutGroupInRunningAndScheduled(final Rollout rollout,
|
private void retrieveAndVerifyRolloutGroupInRunningAndScheduled(final Rollout rollout,
|
||||||
final RolloutGroup firstGroup, final RolloutGroup secondGroup) throws Exception {
|
final RolloutGroup firstGroup, final RolloutGroup secondGroup) throws Exception {
|
||||||
rolloutManagement.startRollout(rollout.getId());
|
rolloutManagement.start(rollout.getId());
|
||||||
rolloutManagement.handleRollouts();
|
rolloutManagement.handleRollouts();
|
||||||
mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout.getId(), firstGroup.getId())
|
mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout.getId(), firstGroup.getId())
|
||||||
.accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
.accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||||
@@ -696,7 +696,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*");
|
final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*");
|
||||||
|
|
||||||
final RolloutGroup firstGroup = rolloutGroupManagement
|
final RolloutGroup firstGroup = rolloutGroupManagement
|
||||||
.findRolloutGroupsByRolloutId(rollout.getId(), new PageRequest(0, 1, Direction.ASC, "id")).getContent()
|
.findByRollout(new PageRequest(0, 1, Direction.ASC, "id"), rollout.getId()).getContent()
|
||||||
.get(0);
|
.get(0);
|
||||||
|
|
||||||
// retrieve targets from the first rollout group with known ID
|
// retrieve targets from the first rollout group with known ID
|
||||||
@@ -720,10 +720,10 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*");
|
final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*");
|
||||||
|
|
||||||
final RolloutGroup firstGroup = rolloutGroupManagement
|
final RolloutGroup firstGroup = rolloutGroupManagement
|
||||||
.findRolloutGroupsByRolloutId(rollout.getId(), new PageRequest(0, 1, Direction.ASC, "id")).getContent()
|
.findByRollout(new PageRequest(0, 1, Direction.ASC, "id"), rollout.getId()).getContent()
|
||||||
.get(0);
|
.get(0);
|
||||||
|
|
||||||
final String targetInGroup = rolloutGroupManagement.findRolloutGroupTargets(firstGroup.getId(), PAGE)
|
final String targetInGroup = rolloutGroupManagement.findTargetsOfRolloutGroup(PAGE, firstGroup.getId())
|
||||||
.getContent().get(0).getControllerId();
|
.getContent().get(0).getControllerId();
|
||||||
|
|
||||||
// retrieve targets from the first rollout group with known ID
|
// retrieve targets from the first rollout group with known ID
|
||||||
@@ -746,13 +746,13 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
// create rollout including the created targets with prefix 'rollout'
|
// create rollout including the created targets with prefix 'rollout'
|
||||||
final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*");
|
final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*");
|
||||||
|
|
||||||
rolloutManagement.startRollout(rollout.getId());
|
rolloutManagement.start(rollout.getId());
|
||||||
|
|
||||||
// Run here, because scheduler is disabled during tests
|
// Run here, because scheduler is disabled during tests
|
||||||
rolloutManagement.handleRollouts();
|
rolloutManagement.handleRollouts();
|
||||||
|
|
||||||
final RolloutGroup firstGroup = rolloutGroupManagement
|
final RolloutGroup firstGroup = rolloutGroupManagement
|
||||||
.findRolloutGroupsByRolloutId(rollout.getId(), new PageRequest(0, 1, Direction.ASC, "id")).getContent()
|
.findByRollout(new PageRequest(0, 1, Direction.ASC, "id"), rollout.getId()).getContent()
|
||||||
.get(0);
|
.get(0);
|
||||||
|
|
||||||
// retrieve targets from the first rollout group with known ID
|
// retrieve targets from the first rollout group with known ID
|
||||||
@@ -945,7 +945,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
|
|
||||||
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId,
|
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId,
|
||||||
final String targetFilterQuery) {
|
final String targetFilterQuery) {
|
||||||
final Rollout rollout = rolloutManagement.createRollout(
|
final Rollout rollout = rolloutManagement.create(
|
||||||
entityFactory.rollout().create().name(name).set(distributionSetId).targetFilterQuery(targetFilterQuery),
|
entityFactory.rollout().create().name(name).set(distributionSetId).targetFilterQuery(targetFilterQuery),
|
||||||
amountGroups, new RolloutGroupConditionBuilder().withDefaults()
|
amountGroups, new RolloutGroupConditionBuilder().withDefaults()
|
||||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build());
|
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build());
|
||||||
@@ -953,7 +953,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
// Run here, because Scheduler is disabled during tests
|
// Run here, because Scheduler is disabled during tests
|
||||||
rolloutManagement.handleRollouts();
|
rolloutManagement.handleRollouts();
|
||||||
|
|
||||||
return rolloutManagement.findRolloutById(rollout.getId()).get();
|
return rolloutManagement.get(rollout.getId()).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean success(final Rollout result) {
|
protected boolean success(final Rollout result) {
|
||||||
@@ -961,7 +961,7 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Rollout getRollout(final Long rolloutId) throws Exception {
|
public Rollout getRollout(final Long rolloutId) throws Exception {
|
||||||
return rolloutManagement.findRolloutById(rolloutId).get();
|
return rolloutManagement.get(rolloutId).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void assertPreparationOfRepo() {
|
public void assertPreparationOfRepo() {
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("no softwaremodule should be founded")
|
assertThat(softwareModuleManagement.findAll(PAGE)).as("no softwaremodule should be founded")
|
||||||
.hasSize(0);
|
.hasSize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
final String updateDescription = "newDescription1";
|
final String updateDescription = "newDescription1";
|
||||||
|
|
||||||
SoftwareModule sm = softwareModuleManagement
|
SoftwareModule sm = softwareModuleManagement
|
||||||
.createSoftwareModule(entityFactory.softwareModule().create().type(osType).name(knownSWName)
|
.create(entityFactory.softwareModule().create().type(osType).name(knownSWName)
|
||||||
.version(knownSWVersion).description(knownSWDescription).vendor(knownSWVendor));
|
.version(knownSWVersion).description(knownSWDescription).vendor(knownSWVendor));
|
||||||
|
|
||||||
assertThat(sm.getName()).as("Wrong name of the software module").isEqualTo(knownSWName);
|
assertThat(sm.getName()).as("Wrong name of the software module").isEqualTo(knownSWName);
|
||||||
@@ -108,7 +108,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
.andExpect(jsonPath("$.description", equalTo(updateDescription)))
|
.andExpect(jsonPath("$.description", equalTo(updateDescription)))
|
||||||
.andExpect(jsonPath("$.name", equalTo(knownSWName))).andReturn();
|
.andExpect(jsonPath("$.name", equalTo(knownSWName))).andReturn();
|
||||||
|
|
||||||
sm = softwareModuleManagement.findSoftwareModuleById(sm.getId()).get();
|
sm = softwareModuleManagement.get(sm.getId()).get();
|
||||||
assertThat(sm.getName()).isEqualTo(knownSWName);
|
assertThat(sm.getName()).isEqualTo(knownSWName);
|
||||||
assertThat(sm.getVendor()).isEqualTo(updateVendor);
|
assertThat(sm.getVendor()).isEqualTo(updateVendor);
|
||||||
assertThat(sm.getLastModifiedBy()).isEqualTo("smUpdateTester");
|
assertThat(sm.getLastModifiedBy()).isEqualTo("smUpdateTester");
|
||||||
@@ -141,7 +141,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
// check rest of response compared to DB
|
// check rest of response compared to DB
|
||||||
final MgmtArtifact artResult = ResourceUtility
|
final MgmtArtifact artResult = ResourceUtility
|
||||||
.convertArtifactResponse(mvcResult.getResponse().getContentAsString());
|
.convertArtifactResponse(mvcResult.getResponse().getContentAsString());
|
||||||
final Long artId = softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0)
|
final Long artId = softwareModuleManagement.get(sm.getId()).get().getArtifacts().get(0)
|
||||||
.getId();
|
.getId();
|
||||||
assertThat(artResult.getArtifactId()).as("Wrong artifact id").isEqualTo(artId);
|
assertThat(artResult.getArtifactId()).as("Wrong artifact id").isEqualTo(artId);
|
||||||
assertThat(JsonPath.compile("$._links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
assertThat(JsonPath.compile("$._links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||||
@@ -157,34 +157,34 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
private void assertArtifact(final SoftwareModule sm, final byte[] random) throws IOException {
|
private void assertArtifact(final SoftwareModule sm, final byte[] random) throws IOException {
|
||||||
// check result in db...
|
// check result in db...
|
||||||
// repo
|
// repo
|
||||||
assertThat(artifactManagement.countArtifactsAll()).as("Wrong artifact size").isEqualTo(1);
|
assertThat(artifactManagement.count()).as("Wrong artifact size").isEqualTo(1);
|
||||||
|
|
||||||
// binary
|
// binary
|
||||||
try (InputStream fileInputStream = artifactManagement.loadArtifactBinary(
|
try (InputStream fileInputStream = artifactManagement.loadArtifactBinary(
|
||||||
softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0).getSha1Hash())
|
softwareModuleManagement.get(sm.getId()).get().getArtifacts().get(0).getSha1Hash())
|
||||||
.get().getFileInputStream()) {
|
.get().getFileInputStream()) {
|
||||||
assertTrue("Wrong artifact content",
|
assertTrue("Wrong artifact content",
|
||||||
IOUtils.contentEquals(new ByteArrayInputStream(random), fileInputStream));
|
IOUtils.contentEquals(new ByteArrayInputStream(random), fileInputStream));
|
||||||
}
|
}
|
||||||
|
|
||||||
// hashes
|
// hashes
|
||||||
assertThat(artifactManagement.findArtifactByFilename("origFilename").get().getSha1Hash()).as("Wrong sha1 hash")
|
assertThat(artifactManagement.getByFilename("origFilename").get().getSha1Hash()).as("Wrong sha1 hash")
|
||||||
.isEqualTo(HashGeneratorUtils.generateSHA1(random));
|
.isEqualTo(HashGeneratorUtils.generateSHA1(random));
|
||||||
|
|
||||||
assertThat(artifactManagement.findArtifactByFilename("origFilename").get().getMd5Hash()).as("Wrong md5 hash")
|
assertThat(artifactManagement.getByFilename("origFilename").get().getMd5Hash()).as("Wrong md5 hash")
|
||||||
.isEqualTo(HashGeneratorUtils.generateMD5(random));
|
.isEqualTo(HashGeneratorUtils.generateMD5(random));
|
||||||
|
|
||||||
// metadata
|
// metadata
|
||||||
assertThat(
|
assertThat(
|
||||||
softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts().get(0).getFilename())
|
softwareModuleManagement.get(sm.getId()).get().getArtifacts().get(0).getFilename())
|
||||||
.as("wrong metadata of the filename").isEqualTo("origFilename");
|
.as("wrong metadata of the filename").isEqualTo("origFilename");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verfies that the system does not accept empty artifact uploads. Expected response: BAD REQUEST")
|
@Description("Verfies that the system does not accept empty artifact uploads. Expected response: BAD REQUEST")
|
||||||
public void emptyUploadArtifact() throws Exception {
|
public void emptyUploadArtifact() throws Exception {
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
|
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(0);
|
||||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(0);
|
assertThat(artifactManagement.count()).isEqualTo(0);
|
||||||
|
|
||||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
@Description("verfies that option to upload artifacts with a custom defined by metadata, i.e. not the file name of the binary itself.")
|
@Description("verfies that option to upload artifacts with a custom defined by metadata, i.e. not the file name of the binary itself.")
|
||||||
public void uploadArtifactWithCustomName() throws Exception {
|
public void uploadArtifactWithCustomName() throws Exception {
|
||||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(0);
|
assertThat(artifactManagement.count()).isEqualTo(0);
|
||||||
|
|
||||||
// create test file
|
// create test file
|
||||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||||
@@ -235,10 +235,10 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
|
|
||||||
// check result in db...
|
// check result in db...
|
||||||
// repo
|
// repo
|
||||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
|
assertThat(artifactManagement.count()).isEqualTo(1);
|
||||||
|
|
||||||
// hashes
|
// hashes
|
||||||
assertThat(artifactManagement.findArtifactByFilename("customFilename")).as("Local artifact is wrong")
|
assertThat(artifactManagement.getByFilename("customFilename")).as("Local artifact is wrong")
|
||||||
.isPresent();
|
.isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,7 +246,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
@Description("Verfies that the system refuses upload of an artifact where the provided hash sums do not match. Expected result: BAD REQUEST")
|
@Description("Verfies that the system refuses upload of an artifact where the provided hash sums do not match. Expected result: BAD REQUEST")
|
||||||
public void uploadArtifactWithHashCheck() throws Exception {
|
public void uploadArtifactWithHashCheck() throws Exception {
|
||||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(0);
|
assertThat(artifactManagement.count()).isEqualTo(0);
|
||||||
|
|
||||||
// create test file
|
// create test file
|
||||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||||
@@ -292,16 +292,16 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
|
|
||||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||||
|
|
||||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
|
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(),
|
||||||
"file1", false);
|
"file1", false);
|
||||||
final Artifact artifact2 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
|
final Artifact artifact2 = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(),
|
||||||
"file2", false);
|
"file2", false);
|
||||||
|
|
||||||
downloadAndVerify(sm, random, artifact);
|
downloadAndVerify(sm, random, artifact);
|
||||||
downloadAndVerify(sm, random, artifact2);
|
downloadAndVerify(sm, random, artifact2);
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Softwaremodule size is wrong").hasSize(1);
|
assertThat(softwareModuleManagement.findAll(PAGE)).as("Softwaremodule size is wrong").hasSize(1);
|
||||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(2);
|
assertThat(artifactManagement.count()).isEqualTo(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadAndVerify(final SoftwareModule sm, final byte[] random, final Artifact artifact)
|
private void downloadAndVerify(final SoftwareModule sm, final byte[] random, final Artifact artifact)
|
||||||
@@ -322,7 +322,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||||
|
|
||||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
|
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(),
|
||||||
"file1", false);
|
"file1", false);
|
||||||
|
|
||||||
// perform test
|
// perform test
|
||||||
@@ -348,9 +348,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
|
|
||||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||||
|
|
||||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
|
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(),
|
||||||
"file1", false);
|
"file1", false);
|
||||||
final Artifact artifact2 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
|
final Artifact artifact2 = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(),
|
||||||
"file2", false);
|
"file2", false);
|
||||||
|
|
||||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).accept(MediaType.APPLICATION_JSON))
|
mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).accept(MediaType.APPLICATION_JSON))
|
||||||
@@ -394,7 +394,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
||||||
|
|
||||||
// SM does not exist
|
// SM does not exist
|
||||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
||||||
mvc.perform(get("/rest/v1/softwaremodules/1234567890/artifacts")).andDo(MockMvcResultPrinter.print())
|
mvc.perform(get("/rest/v1/softwaremodules/1234567890/artifacts")).andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isNotFound());
|
.andExpect(status().isNotFound());
|
||||||
|
|
||||||
@@ -548,7 +548,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")]._links.self.href",
|
.andExpect(jsonPath("$.content.[?(@.id==" + app.getId() + ")]._links.self.href",
|
||||||
contains("http://localhost/rest/v1/softwaremodules/" + app.getId())));
|
contains("http://localhost/rest/v1/softwaremodules/" + app.getId())));
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Softwaremodule size is wrong").hasSize(2);
|
assertThat(softwareModuleManagement.findAll(PAGE)).as("Softwaremodule size is wrong").hasSize(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -559,7 +559,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
testdataFactory.createSoftwareModuleOs("2");
|
testdataFactory.createSoftwareModuleOs("2");
|
||||||
final SoftwareModule app2 = testdataFactory.createSoftwareModuleApp("2");
|
final SoftwareModule app2 = testdataFactory.createSoftwareModuleApp("2");
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(4);
|
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(4);
|
||||||
|
|
||||||
// only by name, only one exists per name
|
// only by name, only one exists per name
|
||||||
mvc.perform(get("/rest/v1/softwaremodules?q=name==" + os1.getName()).accept(MediaType.APPLICATION_JSON))
|
mvc.perform(get("/rest/v1/softwaremodules?q=name==" + os1.getName()).accept(MediaType.APPLICATION_JSON))
|
||||||
@@ -649,7 +649,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
.andExpect(jsonPath("$._links.artifacts.href",
|
.andExpect(jsonPath("$._links.artifacts.href",
|
||||||
equalTo("http://localhost/rest/v1/softwaremodules/" + os.getId() + "/artifacts")));
|
equalTo("http://localhost/rest/v1/softwaremodules/" + os.getId() + "/artifacts")));
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Softwaremodule size is wrong").hasSize(1);
|
assertThat(softwareModuleManagement.findAll(PAGE)).as("Softwaremodule size is wrong").hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -684,9 +684,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
.andExpect(jsonPath("[1].createdAt", not(equalTo(0)))).andReturn();
|
.andExpect(jsonPath("[1].createdAt", not(equalTo(0)))).andReturn();
|
||||||
|
|
||||||
final SoftwareModule osCreated = softwareModuleManagement
|
final SoftwareModule osCreated = softwareModuleManagement
|
||||||
.findSoftwareModuleByNameAndVersion("name1", "version1", osType.getId()).get();
|
.getByNameAndVersionAndType("name1", "version1", osType.getId()).get();
|
||||||
final SoftwareModule appCreated = softwareModuleManagement
|
final SoftwareModule appCreated = softwareModuleManagement
|
||||||
.findSoftwareModuleByNameAndVersion("name3", "version3", appType.getId()).get();
|
.getByNameAndVersionAndType("name3", "version3", appType.getId()).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())
|
||||||
@@ -704,16 +704,16 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
.toString()).as("Response contains invalid artifacts href")
|
.toString()).as("Response contains invalid artifacts href")
|
||||||
.isEqualTo("http://localhost/rest/v1/softwaremodules/" + appCreated.getId() + "/artifacts");
|
.isEqualTo("http://localhost/rest/v1/softwaremodules/" + appCreated.getId() + "/artifacts");
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Wrong softwaremodule size").hasSize(2);
|
assertThat(softwareModuleManagement.findAll(PAGE)).as("Wrong softwaremodule size").hasSize(2);
|
||||||
assertThat(
|
assertThat(
|
||||||
softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0).getName())
|
softwareModuleManagement.findByType(PAGE, osType.getId()).getContent().get(0).getName())
|
||||||
.as("Softwaremoudle name is wrong").isEqualTo(os.getName());
|
.as("Softwaremoudle name is wrong").isEqualTo(os.getName());
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0)
|
assertThat(softwareModuleManagement.findByType(PAGE, osType.getId()).getContent().get(0)
|
||||||
.getCreatedBy()).as("Softwaremoudle created by is wrong").isEqualTo("uploadTester");
|
.getCreatedBy()).as("Softwaremoudle created by is wrong").isEqualTo("uploadTester");
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesByType(PAGE, osType.getId()).getContent().get(0)
|
assertThat(softwareModuleManagement.findByType(PAGE, osType.getId()).getContent().get(0)
|
||||||
.getCreatedAt()).as("Softwaremoudle created at is wrong").isGreaterThanOrEqualTo(current);
|
.getCreatedAt()).as("Softwaremoudle created at is wrong").isGreaterThanOrEqualTo(current);
|
||||||
assertThat(
|
assertThat(
|
||||||
softwareModuleManagement.findSoftwareModulesByType(PAGE, appType.getId()).getContent().get(0).getName())
|
softwareModuleManagement.findByType(PAGE, appType.getId()).getContent().get(0).getName())
|
||||||
.as("Softwaremoudle name is wrong").isEqualTo(ah.getName());
|
.as("Softwaremoudle name is wrong").isEqualTo(ah.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -725,17 +725,17 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
|
|
||||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||||
|
|
||||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("Softwaremoudle size is wrong").hasSize(1);
|
assertThat(softwareModuleManagement.findAll(PAGE)).as("Softwaremoudle size is wrong").hasSize(1);
|
||||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
|
assertThat(artifactManagement.count()).isEqualTo(1);
|
||||||
|
|
||||||
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", sm.getId())).andDo(MockMvcResultPrinter.print())
|
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", sm.getId())).andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE))
|
assertThat(softwareModuleManagement.findAll(PAGE))
|
||||||
.as("After delete no softwarmodule should be available").isEmpty();
|
.as("After delete no softwarmodule should be available").isEmpty();
|
||||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(0);
|
assertThat(artifactManagement.count()).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -745,11 +745,11 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
|
|
||||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||||
|
|
||||||
artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
artifactManagement.create(new ByteArrayInputStream(random),
|
||||||
ds1.findFirstModuleByType(appType).get().getId(), "file1", false);
|
ds1.findFirstModuleByType(appType).get().getId(), "file1", false);
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(3);
|
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(3);
|
||||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
|
assertThat(artifactManagement.count()).isEqualTo(1);
|
||||||
|
|
||||||
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", ds1.findFirstModuleByType(appType).get().getId()))
|
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", ds1.findFirstModuleByType(appType).get().getId()))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
@@ -759,9 +759,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
// all 3 are now marked as deleted
|
// all 3 are now marked as deleted
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE).getNumber())
|
assertThat(softwareModuleManagement.findAll(PAGE).getNumber())
|
||||||
.as("After delete no softwarmodule should be available").isEqualTo(0);
|
.as("After delete no softwarmodule should be available").isEqualTo(0);
|
||||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
|
assertThat(artifactManagement.count()).isEqualTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -773,25 +773,25 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||||
|
|
||||||
// Create 2 artifacts
|
// Create 2 artifacts
|
||||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
|
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(),
|
||||||
"file1", false);
|
"file1", false);
|
||||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file2", false);
|
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file2", false);
|
||||||
|
|
||||||
// check repo before delete
|
// check repo before delete
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(1);
|
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(1);
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts()).hasSize(2);
|
assertThat(softwareModuleManagement.get(sm.getId()).get().getArtifacts()).hasSize(2);
|
||||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(2);
|
assertThat(artifactManagement.count()).isEqualTo(2);
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
mvc.perform(delete("/rest/v1/softwaremodules/{smId}/artifacts/{artId}", sm.getId(), artifact.getId()))
|
mvc.perform(delete("/rest/v1/softwaremodules/{smId}/artifacts/{artId}", sm.getId(), artifact.getId()))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
// check that only one artifact is still alive and still assigned
|
// check that only one artifact is still alive and still assigned
|
||||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).as("After the sm should be marked as deleted")
|
assertThat(softwareModuleManagement.findAll(PAGE)).as("After the sm should be marked as deleted")
|
||||||
.hasSize(1);
|
.hasSize(1);
|
||||||
assertThat(artifactManagement.countArtifactsAll()).isEqualTo(1);
|
assertThat(artifactManagement.count()).isEqualTo(1);
|
||||||
assertThat(softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts())
|
assertThat(softwareModuleManagement.get(sm.getId()).get().getArtifacts())
|
||||||
.as("After delete artifact should available for marked as deleted sm's").hasSize(1);
|
.as("After delete artifact should available for marked as deleted sm's").hasSize(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -820,9 +820,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
|
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
|
||||||
|
|
||||||
final SoftwareModuleMetadata metaKey1 = softwareModuleManagement
|
final SoftwareModuleMetadata metaKey1 = softwareModuleManagement
|
||||||
.findSoftwareModuleMetadata(sm.getId(), knownKey1).get();
|
.getMetaDataBySoftwareModuleId(sm.getId(), knownKey1).get();
|
||||||
final SoftwareModuleMetadata metaKey2 = softwareModuleManagement
|
final SoftwareModuleMetadata metaKey2 = softwareModuleManagement
|
||||||
.findSoftwareModuleMetadata(sm.getId(), knownKey2).get();
|
.getMetaDataBySoftwareModuleId(sm.getId(), knownKey2).get();
|
||||||
|
|
||||||
assertThat(metaKey1.getValue()).as("Metadata key is wrong").isEqualTo(knownValue1);
|
assertThat(metaKey1.getValue()).as("Metadata key is wrong").isEqualTo(knownValue1);
|
||||||
assertThat(metaKey2.getValue()).as("Metadata key is wrong").isEqualTo(knownValue2);
|
assertThat(metaKey2.getValue()).as("Metadata key is wrong").isEqualTo(knownValue2);
|
||||||
@@ -837,7 +837,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
final String updateValue = "valueForUpdate";
|
final String updateValue = "valueForUpdate";
|
||||||
|
|
||||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||||
softwareModuleManagement.createSoftwareModuleMetadata(sm.getId(),
|
softwareModuleManagement.createMetaData(sm.getId(),
|
||||||
entityFactory.generateMetadata(knownKey, knownValue));
|
entityFactory.generateMetadata(knownKey, knownValue));
|
||||||
|
|
||||||
final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue);
|
final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue);
|
||||||
@@ -849,7 +849,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
|
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
|
||||||
|
|
||||||
final SoftwareModuleMetadata assertDS = softwareModuleManagement
|
final SoftwareModuleMetadata assertDS = softwareModuleManagement
|
||||||
.findSoftwareModuleMetadata(sm.getId(), knownKey).get();
|
.getMetaDataBySoftwareModuleId(sm.getId(), knownKey).get();
|
||||||
assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue);
|
assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -861,13 +861,13 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
final String knownValue = "knownValue";
|
final String knownValue = "knownValue";
|
||||||
|
|
||||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||||
softwareModuleManagement.createSoftwareModuleMetadata(sm.getId(),
|
softwareModuleManagement.createMetaData(sm.getId(),
|
||||||
entityFactory.generateMetadata(knownKey, knownValue));
|
entityFactory.generateMetadata(knownKey, 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()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findSoftwareModuleMetadata(sm.getId(), knownKey)).isNotPresent();
|
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(sm.getId(), knownKey)).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -878,7 +878,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
final String knownValue = "knownValue";
|
final String knownValue = "knownValue";
|
||||||
|
|
||||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||||
softwareModuleManagement.createSoftwareModuleMetadata(sm.getId(),
|
softwareModuleManagement.createMetaData(sm.getId(),
|
||||||
entityFactory.generateMetadata(knownKey, knownValue));
|
entityFactory.generateMetadata(knownKey, 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))
|
||||||
@@ -887,7 +887,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
mvc.perform(delete("/rest/v1/softwaremodules/1234/metadata/{key}", knownKey))
|
mvc.perform(delete("/rest/v1/softwaremodules/1234/metadata/{key}", knownKey))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findSoftwareModuleMetadata(sm.getId(), knownKey)).isPresent();
|
assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(sm.getId(), knownKey)).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -906,7 +906,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
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.createSoftwareModuleMetadata(sm.getId(),
|
softwareModuleManagement.createMetaData(sm.getId(),
|
||||||
entityFactory.generateMetadata(knownKeyPrefix + index, knownValuePrefix + index));
|
entityFactory.generateMetadata(knownKeyPrefix + index, knownValuePrefix + index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -922,7 +922,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
|||||||
char character = 'a';
|
char character = 'a';
|
||||||
for (int index = 0; index < amount; index++) {
|
for (int index = 0; index < amount; index++) {
|
||||||
final String str = String.valueOf(character);
|
final String str = String.valueOf(character);
|
||||||
softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule().create().type(osType).name(str)
|
softwareModuleManagement.create(entityFactory.softwareModule().create().type(osType).name(str)
|
||||||
.description(str).vendor(str).version(str));
|
.description(str).vendor(str).version(str));
|
||||||
character++;
|
character++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
|||||||
|
|
||||||
private SoftwareModuleType createTestType() {
|
private SoftwareModuleType createTestType() {
|
||||||
SoftwareModuleType testType = softwareModuleTypeManagement
|
SoftwareModuleType testType = softwareModuleTypeManagement
|
||||||
.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("test123").name("TestName123")
|
.create(entityFactory.softwareModuleType().create().key("test123").name("TestName123")
|
||||||
.description("Desc123").maxAssignments(5));
|
.description("Desc123").maxAssignments(5));
|
||||||
testType = softwareModuleTypeManagement.updateSoftwareModuleType(
|
testType = softwareModuleTypeManagement.update(
|
||||||
entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234"));
|
entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234"));
|
||||||
return testType;
|
return testType;
|
||||||
}
|
}
|
||||||
@@ -190,9 +190,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
|||||||
.andExpect(jsonPath("[2].createdAt", not(equalTo(0))))
|
.andExpect(jsonPath("[2].createdAt", not(equalTo(0))))
|
||||||
.andExpect(jsonPath("[2].maxAssignments", equalTo(3))).andReturn();
|
.andExpect(jsonPath("[2].maxAssignments", equalTo(3))).andReturn();
|
||||||
|
|
||||||
final SoftwareModuleType created1 = softwareModuleTypeManagement.findSoftwareModuleTypeByKey("test1").get();
|
final SoftwareModuleType created1 = softwareModuleTypeManagement.getByKey("test1").get();
|
||||||
final SoftwareModuleType created2 = softwareModuleTypeManagement.findSoftwareModuleTypeByKey("test2").get();
|
final SoftwareModuleType created2 = softwareModuleTypeManagement.getByKey("test2").get();
|
||||||
final SoftwareModuleType created3 = softwareModuleTypeManagement.findSoftwareModuleTypeByKey("test3").get();
|
final SoftwareModuleType created3 = softwareModuleTypeManagement.getByKey("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())
|
||||||
@@ -204,7 +204,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
|||||||
JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||||
.isEqualTo("http://localhost/rest/v1/softwaremoduletypes/" + created3.getId());
|
.isEqualTo("http://localhost/rest/v1/softwaremoduletypes/" + created3.getId());
|
||||||
|
|
||||||
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(6);
|
assertThat(softwareModuleTypeManagement.count()).isEqualTo(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -231,12 +231,12 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
|||||||
public void deleteSoftwareModuleTypeUnused() throws Exception {
|
public void deleteSoftwareModuleTypeUnused() throws Exception {
|
||||||
final SoftwareModuleType testType = createTestType();
|
final SoftwareModuleType testType = createTestType();
|
||||||
|
|
||||||
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
|
assertThat(softwareModuleTypeManagement.count()).isEqualTo(4);
|
||||||
|
|
||||||
mvc.perform(delete("/rest/v1/softwaremoduletypes/{smId}", testType.getId())).andDo(MockMvcResultPrinter.print())
|
mvc.perform(delete("/rest/v1/softwaremoduletypes/{smId}", testType.getId())).andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(3);
|
assertThat(softwareModuleTypeManagement.count()).isEqualTo(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -251,15 +251,15 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
|||||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} DELETE requests (soft delete scenario).")
|
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} DELETE requests (soft delete scenario).")
|
||||||
public void deleteSoftwareModuleTypeUsed() throws Exception {
|
public void deleteSoftwareModuleTypeUsed() throws Exception {
|
||||||
final SoftwareModuleType testType = createTestType();
|
final SoftwareModuleType testType = createTestType();
|
||||||
softwareModuleManagement.createSoftwareModule(
|
softwareModuleManagement.create(
|
||||||
entityFactory.softwareModule().create().type(testType).name("name").version("version"));
|
entityFactory.softwareModule().create().type(testType).name("name").version("version"));
|
||||||
|
|
||||||
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
|
assertThat(softwareModuleTypeManagement.count()).isEqualTo(4);
|
||||||
|
|
||||||
mvc.perform(delete("/rest/v1/softwaremoduletypes/{smId}", testType.getId())).andDo(MockMvcResultPrinter.print())
|
mvc.perform(delete("/rest/v1/softwaremoduletypes/{smId}", testType.getId())).andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(softwareModuleTypeManagement.countSoftwareModuleTypesAll()).isEqualTo(3);
|
assertThat(softwareModuleTypeManagement.count()).isEqualTo(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -370,9 +370,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
|||||||
@Test
|
@Test
|
||||||
@Description("Search erquest of software module types.")
|
@Description("Search erquest of software module types.")
|
||||||
public void searchSoftwareModuleTypeRsql() throws Exception {
|
public void searchSoftwareModuleTypeRsql() throws Exception {
|
||||||
softwareModuleTypeManagement.createSoftwareModuleType(entityFactory.softwareModuleType().create().key("test123")
|
softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("test123")
|
||||||
.name("TestName123").description("Desc123").maxAssignments(5));
|
.name("TestName123").description("Desc123").maxAssignments(5));
|
||||||
softwareModuleTypeManagement.createSoftwareModuleType(entityFactory.softwareModuleType().create()
|
softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create()
|
||||||
.key("test1234").name("TestName1234").description("Desc1234").maxAssignments(5));
|
.key("test1234").name("TestName1234").description("Desc1234").maxAssignments(5));
|
||||||
|
|
||||||
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
|
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
|
||||||
@@ -388,7 +388,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
|||||||
char character = 'a';
|
char character = 'a';
|
||||||
for (int index = 0; index < amount; index++) {
|
for (int index = 0; index < amount; index++) {
|
||||||
final String str = String.valueOf(character);
|
final String str = String.valueOf(character);
|
||||||
softwareModuleManagement.createSoftwareModule(entityFactory.softwareModule().create().type(osType).name(str)
|
softwareModuleManagement.create(entityFactory.softwareModule().create().type(osType).name(str)
|
||||||
.description(str).vendor(str).version(str));
|
.description(str).vendor(str).version(str));
|
||||||
character++;
|
character++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
|||||||
mvc.perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId()))
|
mvc.perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId()))
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(targetFilterQueryManagement.findTargetFilterQueryById(filterQuery.getId())).isNotPresent();
|
assertThat(targetFilterQueryManagement.get(filterQuery.getId())).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -112,7 +112,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
|||||||
.andExpect(jsonPath("$.query", equalTo(filterQuery2)))
|
.andExpect(jsonPath("$.query", equalTo(filterQuery2)))
|
||||||
.andExpect(jsonPath("$.name", equalTo(filterName)));
|
.andExpect(jsonPath("$.name", equalTo(filterName)));
|
||||||
|
|
||||||
final TargetFilterQuery tfqCheck = targetFilterQueryManagement.findTargetFilterQueryById(tfq.getId()).get();
|
final TargetFilterQuery tfqCheck = targetFilterQueryManagement.get(tfq.getId()).get();
|
||||||
assertThat(tfqCheck.getQuery()).isEqualTo(filterQuery2);
|
assertThat(tfqCheck.getQuery()).isEqualTo(filterQuery2);
|
||||||
assertThat(tfqCheck.getName()).isEqualTo(filterName);
|
assertThat(tfqCheck.getName()).isEqualTo(filterName);
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
|||||||
final String body = new JSONObject().put("name", filterName2).toString();
|
final String body = new JSONObject().put("name", filterName2).toString();
|
||||||
|
|
||||||
// prepare
|
// prepare
|
||||||
final TargetFilterQuery tfq = targetFilterQueryManagement.createTargetFilterQuery(
|
final TargetFilterQuery tfq = targetFilterQueryManagement.create(
|
||||||
entityFactory.targetFilterQuery().create().name(filterName).query(filterQuery));
|
entityFactory.targetFilterQuery().create().name(filterName).query(filterQuery));
|
||||||
|
|
||||||
mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId()).content(body)
|
mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId()).content(body)
|
||||||
@@ -135,7 +135,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
|||||||
.andExpect(jsonPath("$.query", equalTo(filterQuery)))
|
.andExpect(jsonPath("$.query", equalTo(filterQuery)))
|
||||||
.andExpect(jsonPath("$.name", equalTo(filterName2)));
|
.andExpect(jsonPath("$.name", equalTo(filterName2)));
|
||||||
|
|
||||||
final TargetFilterQuery tfqCheck = targetFilterQueryManagement.findTargetFilterQueryById(tfq.getId()).get();
|
final TargetFilterQuery tfqCheck = targetFilterQueryManagement.get(tfq.getId()).get();
|
||||||
assertThat(tfqCheck.getQuery()).isEqualTo(filterQuery);
|
assertThat(tfqCheck.getQuery()).isEqualTo(filterQuery);
|
||||||
assertThat(tfqCheck.getName()).isEqualTo(filterName2);
|
assertThat(tfqCheck.getName()).isEqualTo(filterName2);
|
||||||
}
|
}
|
||||||
@@ -270,7 +270,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
|||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
|
||||||
|
|
||||||
assertThat(targetFilterQueryManagement.countAllTargetFilterQuery()).isEqualTo(0);
|
assertThat(targetFilterQueryManagement.count()).isEqualTo(0);
|
||||||
|
|
||||||
// verify response json exception message
|
// verify response json exception message
|
||||||
final ExceptionInfo exceptionInfo = ResourceUtility
|
final ExceptionInfo exceptionInfo = ResourceUtility
|
||||||
@@ -293,7 +293,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
|||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
targetFilterQueryManagement.findTargetFilterQueryById(tfq.getId()).get().getAutoAssignDistributionSet())
|
targetFilterQueryManagement.get(tfq.getId()).get().getAutoAssignDistributionSet())
|
||||||
.isEqualTo(set);
|
.isEqualTo(set);
|
||||||
|
|
||||||
final String hrefPrefix = "http://localhost" + MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/"
|
final String hrefPrefix = "http://localhost" + MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/"
|
||||||
@@ -317,10 +317,10 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
|||||||
|
|
||||||
final DistributionSet set = testdataFactory.createDistributionSet(dsName);
|
final DistributionSet set = testdataFactory.createDistributionSet(dsName);
|
||||||
final TargetFilterQuery tfq = createSingleTargetFilterQuery(knownName, knownQuery);
|
final TargetFilterQuery tfq = createSingleTargetFilterQuery(knownName, knownQuery);
|
||||||
targetFilterQueryManagement.updateTargetFilterQueryAutoAssignDS(tfq.getId(), set.getId());
|
targetFilterQueryManagement.updateAutoAssignDS(tfq.getId(), set.getId());
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
targetFilterQueryManagement.findTargetFilterQueryById(tfq.getId()).get().getAutoAssignDistributionSet())
|
targetFilterQueryManagement.get(tfq.getId()).get().getAutoAssignDistributionSet())
|
||||||
.isEqualTo(set);
|
.isEqualTo(set);
|
||||||
|
|
||||||
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS"))
|
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS"))
|
||||||
@@ -330,7 +330,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
|||||||
.andExpect(status().isNoContent());
|
.andExpect(status().isNoContent());
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
targetFilterQueryManagement.findTargetFilterQueryById(tfq.getId()).get().getAutoAssignDistributionSet())
|
targetFilterQueryManagement.get(tfq.getId()).get().getAutoAssignDistributionSet())
|
||||||
.isNull();
|
.isNull();
|
||||||
|
|
||||||
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS"))
|
mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS"))
|
||||||
@@ -340,7 +340,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
|
|||||||
|
|
||||||
private TargetFilterQuery createSingleTargetFilterQuery(final String name, final String query) {
|
private TargetFilterQuery createSingleTargetFilterQuery(final String name, final String query) {
|
||||||
return targetFilterQueryManagement
|
return targetFilterQueryManagement
|
||||||
.createTargetFilterQuery(entityFactory.targetFilterQuery().create().name(name).query(query));
|
.create(entityFactory.targetFilterQuery().create().name(name).query(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createTarget(final String controllerId) {
|
private void createTarget(final String controllerId) {
|
||||||
targetManagement.createTarget(entityFactory.target().create().controllerId(controllerId)
|
targetManagement.create(entityFactory.target().create().controllerId(controllerId)
|
||||||
.address(IpUtil.createHttpUri("127.0.0.1").toString()));
|
.address(IpUtil.createHttpUri("127.0.0.1").toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,7 +311,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId))
|
mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId))
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetByControllerID(knownControllerId)).isNotPresent();
|
assertThat(targetManagement.getByControllerID(knownControllerId)).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -341,8 +341,8 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
final String body = new JSONObject().put("description", knownNewDescription).toString();
|
final String body = new JSONObject().put("description", knownNewDescription).toString();
|
||||||
|
|
||||||
// prepare
|
// prepare
|
||||||
targetManagement.createTarget(entityFactory.target().create().controllerId(knownControllerId)
|
targetManagement.create(entityFactory.target().create().controllerId(knownControllerId).name(knownNameNotModiy)
|
||||||
.name(knownNameNotModiy).description("old description"));
|
.description("old description"));
|
||||||
|
|
||||||
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
|
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
|
||||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||||
@@ -350,7 +350,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
.andExpect(jsonPath("$.description", equalTo(knownNewDescription)))
|
.andExpect(jsonPath("$.description", equalTo(knownNewDescription)))
|
||||||
.andExpect(jsonPath("$.name", equalTo(knownNameNotModiy)));
|
.andExpect(jsonPath("$.name", equalTo(knownNameNotModiy)));
|
||||||
|
|
||||||
final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownControllerId).get();
|
final Target findTargetByControllerID = targetManagement.getByControllerID(knownControllerId).get();
|
||||||
assertThat(findTargetByControllerID.getDescription()).isEqualTo(knownNewDescription);
|
assertThat(findTargetByControllerID.getDescription()).isEqualTo(knownNewDescription);
|
||||||
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModiy);
|
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModiy);
|
||||||
}
|
}
|
||||||
@@ -364,14 +364,14 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
final String body = new JSONObject().put("description", knownNewDescription).toString();
|
final String body = new JSONObject().put("description", knownNewDescription).toString();
|
||||||
|
|
||||||
// prepare
|
// prepare
|
||||||
targetManagement.createTarget(entityFactory.target().create().controllerId(knownControllerId)
|
targetManagement.create(entityFactory.target().create().controllerId(knownControllerId).name(knownNameNotModiy)
|
||||||
.name(knownNameNotModiy).description("old description"));
|
.description("old description"));
|
||||||
|
|
||||||
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
|
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
|
||||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().isBadRequest());
|
.andExpect(status().isBadRequest());
|
||||||
|
|
||||||
final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownControllerId).get();
|
final Target findTargetByControllerID = targetManagement.getByControllerID(knownControllerId).get();
|
||||||
assertThat(findTargetByControllerID.getDescription()).isEqualTo("old description");
|
assertThat(findTargetByControllerID.getDescription()).isEqualTo("old description");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
|
|
||||||
// prepare
|
// prepare
|
||||||
targetManagement
|
targetManagement
|
||||||
.createTarget(entityFactory.target().create().controllerId(knownControllerId).name(knownNameNotModiy));
|
.create(entityFactory.target().create().controllerId(knownControllerId).name(knownNameNotModiy));
|
||||||
|
|
||||||
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
|
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
|
||||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||||
@@ -393,7 +393,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
.andExpect(jsonPath("$.securityToken", equalTo(knownNewToken)))
|
.andExpect(jsonPath("$.securityToken", equalTo(knownNewToken)))
|
||||||
.andExpect(jsonPath("$.name", equalTo(knownNameNotModiy)));
|
.andExpect(jsonPath("$.name", equalTo(knownNameNotModiy)));
|
||||||
|
|
||||||
final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownControllerId).get();
|
final Target findTargetByControllerID = targetManagement.getByControllerID(knownControllerId).get();
|
||||||
assertThat(findTargetByControllerID.getSecurityToken()).isEqualTo(knownNewToken);
|
assertThat(findTargetByControllerID.getSecurityToken()).isEqualTo(knownNewToken);
|
||||||
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModiy);
|
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModiy);
|
||||||
}
|
}
|
||||||
@@ -407,8 +407,8 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
final String body = new JSONObject().put("address", knownNewAddress).toString();
|
final String body = new JSONObject().put("address", knownNewAddress).toString();
|
||||||
|
|
||||||
// prepare
|
// prepare
|
||||||
targetManagement.createTarget(entityFactory.target().create().controllerId(knownControllerId)
|
targetManagement.create(entityFactory.target().create().controllerId(knownControllerId).name(knownNameNotModiy)
|
||||||
.name(knownNameNotModiy).address(knownNewAddress));
|
.address(knownNewAddress));
|
||||||
|
|
||||||
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
|
mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body)
|
||||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||||
@@ -416,7 +416,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
.andExpect(jsonPath("$.address", equalTo(knownNewAddress)))
|
.andExpect(jsonPath("$.address", equalTo(knownNewAddress)))
|
||||||
.andExpect(jsonPath("$.name", equalTo(knownNameNotModiy)));
|
.andExpect(jsonPath("$.name", equalTo(knownNameNotModiy)));
|
||||||
|
|
||||||
final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownControllerId).get();
|
final Target findTargetByControllerID = targetManagement.getByControllerID(knownControllerId).get();
|
||||||
assertThat(findTargetByControllerID.getAddress().toString()).isEqualTo(knownNewAddress);
|
assertThat(findTargetByControllerID.getAddress().toString()).isEqualTo(knownNewAddress);
|
||||||
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModiy);
|
assertThat(findTargetByControllerID.getName()).isEqualTo(knownNameNotModiy);
|
||||||
}
|
}
|
||||||
@@ -665,7 +665,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).contentType(MediaType.APPLICATION_JSON))
|
.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).contentType(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
|
||||||
|
|
||||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
|
assertThat(targetManagement.count()).isEqualTo(0);
|
||||||
|
|
||||||
// verify response json exception message
|
// verify response json exception message
|
||||||
final ExceptionInfo exceptionInfo = ResourceUtility
|
final ExceptionInfo exceptionInfo = ResourceUtility
|
||||||
@@ -684,7 +684,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
|
||||||
|
|
||||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
|
assertThat(targetManagement.count()).isEqualTo(0);
|
||||||
|
|
||||||
// verify response json exception message
|
// verify response json exception message
|
||||||
final ExceptionInfo exceptionInfo = ResourceUtility
|
final ExceptionInfo exceptionInfo = ResourceUtility
|
||||||
@@ -701,7 +701,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
|
||||||
|
|
||||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
|
assertThat(targetManagement.count()).isEqualTo(0);
|
||||||
|
|
||||||
// verify response json exception message
|
// verify response json exception message
|
||||||
final ExceptionInfo exceptionInfo = ResourceUtility
|
final ExceptionInfo exceptionInfo = ResourceUtility
|
||||||
@@ -720,7 +720,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
.content(JsonBuilder.targets(Arrays.asList(test1), true)).contentType(MediaType.APPLICATION_JSON))
|
.content(JsonBuilder.targets(Arrays.asList(test1), true)).contentType(MediaType.APPLICATION_JSON))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn();
|
||||||
|
|
||||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(0);
|
assertThat(targetManagement.count()).isEqualTo(0);
|
||||||
|
|
||||||
// verify response json exception message
|
// verify response json exception message
|
||||||
final ExceptionInfo exceptionInfo = ResourceUtility
|
final ExceptionInfo exceptionInfo = ResourceUtility
|
||||||
@@ -775,18 +775,18 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||||
.isEqualTo("http://localhost/rest/v1/targets/id3");
|
.isEqualTo("http://localhost/rest/v1/targets/id3");
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetByControllerID("id1")).isNotNull();
|
assertThat(targetManagement.getByControllerID("id1")).isNotNull();
|
||||||
assertThat(targetManagement.findTargetByControllerID("id1").get().getName()).isEqualTo("testname1");
|
assertThat(targetManagement.getByControllerID("id1").get().getName()).isEqualTo("testname1");
|
||||||
assertThat(targetManagement.findTargetByControllerID("id1").get().getDescription()).isEqualTo("testid1");
|
assertThat(targetManagement.getByControllerID("id1").get().getDescription()).isEqualTo("testid1");
|
||||||
assertThat(targetManagement.findTargetByControllerID("id1").get().getSecurityToken()).isEqualTo("token");
|
assertThat(targetManagement.getByControllerID("id1").get().getSecurityToken()).isEqualTo("token");
|
||||||
assertThat(targetManagement.findTargetByControllerID("id1").get().getAddress().toString())
|
assertThat(targetManagement.getByControllerID("id1").get().getAddress().toString())
|
||||||
.isEqualTo("amqp://test123/foobar");
|
.isEqualTo("amqp://test123/foobar");
|
||||||
assertThat(targetManagement.findTargetByControllerID("id2")).isNotNull();
|
assertThat(targetManagement.getByControllerID("id2")).isNotNull();
|
||||||
assertThat(targetManagement.findTargetByControllerID("id2").get().getName()).isEqualTo("testname2");
|
assertThat(targetManagement.getByControllerID("id2").get().getName()).isEqualTo("testname2");
|
||||||
assertThat(targetManagement.findTargetByControllerID("id2").get().getDescription()).isEqualTo("testid2");
|
assertThat(targetManagement.getByControllerID("id2").get().getDescription()).isEqualTo("testid2");
|
||||||
assertThat(targetManagement.findTargetByControllerID("id3")).isNotNull();
|
assertThat(targetManagement.getByControllerID("id3")).isNotNull();
|
||||||
assertThat(targetManagement.findTargetByControllerID("id3").get().getName()).isEqualTo("testname3");
|
assertThat(targetManagement.getByControllerID("id3").get().getName()).isEqualTo("testname3");
|
||||||
assertThat(targetManagement.findTargetByControllerID("id3").get().getDescription()).isEqualTo("testid3");
|
assertThat(targetManagement.getByControllerID("id3").get().getDescription()).isEqualTo("testid3");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -801,9 +801,9 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||||
.andExpect(status().is2xxSuccessful());
|
.andExpect(status().is2xxSuccessful());
|
||||||
|
|
||||||
final Slice<Target> findTargetsAll = targetManagement.findTargetsAll(new PageRequest(0, 100));
|
final Slice<Target> findTargetsAll = targetManagement.findAll(new PageRequest(0, 100));
|
||||||
final Target target = findTargetsAll.getContent().get(0);
|
final Target target = findTargetsAll.getContent().get(0);
|
||||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(1);
|
assertThat(targetManagement.count()).isEqualTo(1);
|
||||||
assertThat(target.getControllerId()).isEqualTo(knownControllerId);
|
assertThat(target.getControllerId()).isEqualTo(knownControllerId);
|
||||||
assertThat(target.getName()).isEqualTo(knownName);
|
assertThat(target.getName()).isEqualTo(knownName);
|
||||||
assertThat(target.getDescription()).isEqualTo(knownDescription);
|
assertThat(target.getDescription()).isEqualTo(knownDescription);
|
||||||
@@ -829,7 +829,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
.andExpect(status().is(HttpStatus.CONFLICT.value())).andReturn();
|
.andExpect(status().is(HttpStatus.CONFLICT.value())).andReturn();
|
||||||
|
|
||||||
// verify only one entry
|
// verify only one entry
|
||||||
assertThat(targetManagement.countTargetsAll()).isEqualTo(1);
|
assertThat(targetManagement.count()).isEqualTo(1);
|
||||||
|
|
||||||
// verify response json exception message
|
// verify response json exception message
|
||||||
final ExceptionInfo exceptionInfo = ResourceUtility
|
final ExceptionInfo exceptionInfo = ResourceUtility
|
||||||
@@ -1151,7 +1151,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
.andExpect(jsonPath("total", equalTo(1)));
|
.andExpect(jsonPath("total", equalTo(1)));
|
||||||
|
|
||||||
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
||||||
target = targetManagement.findTargetByControllerID(target.getControllerId()).get();
|
target = targetManagement.getByControllerID(target.getControllerId()).get();
|
||||||
|
|
||||||
// repeating DS assignment leads again to OK
|
// repeating DS assignment leads again to OK
|
||||||
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS")
|
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS")
|
||||||
@@ -1161,7 +1161,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
.andExpect(jsonPath("total", equalTo(1)));
|
.andExpect(jsonPath("total", equalTo(1)));
|
||||||
|
|
||||||
// ...but does not change the target
|
// ...but does not change the target
|
||||||
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).get()).isEqualTo(target);
|
assertThat(targetManagement.getByControllerID(target.getControllerId()).get()).isEqualTo(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1181,7 +1181,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
|
|
||||||
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
||||||
assertThat(deploymentManagement.getInstalledDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
assertThat(deploymentManagement.getInstalledDistributionSet(target.getControllerId()).get()).isEqualTo(set);
|
||||||
target = targetManagement.findTargetByControllerID(target.getControllerId()).get();
|
target = targetManagement.getByControllerID(target.getControllerId()).get();
|
||||||
assertThat(target.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
assertThat(target.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
|
|
||||||
// repeating DS assignment leads again to OK
|
// repeating DS assignment leads again to OK
|
||||||
@@ -1193,7 +1193,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
.andExpect(jsonPath("total", equalTo(1)));
|
.andExpect(jsonPath("total", equalTo(1)));
|
||||||
|
|
||||||
// ...but does not change the target
|
// ...but does not change the target
|
||||||
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).get()).isEqualTo(target);
|
assertThat(targetManagement.getByControllerID(target.getControllerId()).get()).isEqualTo(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1359,7 +1359,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Target createSingleTarget(final String controllerId, final String name) {
|
private Target createSingleTarget(final String controllerId, final String name) {
|
||||||
targetManagement.createTarget(entityFactory.target().create().controllerId(controllerId).name(name)
|
targetManagement.create(entityFactory.target().create().controllerId(controllerId).name(name)
|
||||||
.description(TARGET_DESCRIPTION_TEST));
|
.description(TARGET_DESCRIPTION_TEST));
|
||||||
return controllerManagement.findOrRegisterTargetIfItDoesNotexist(controllerId, LOCALHOST);
|
return controllerManagement.findOrRegisterTargetIfItDoesNotexist(controllerId, LOCALHOST);
|
||||||
}
|
}
|
||||||
@@ -1376,7 +1376,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
char character = 'a';
|
char character = 'a';
|
||||||
for (int index = 0; index < amount; index++) {
|
for (int index = 0; index < amount; index++) {
|
||||||
final String str = String.valueOf(character);
|
final String str = String.valueOf(character);
|
||||||
targetManagement.createTarget(entityFactory.target().create().controllerId(str).name(str).description(str));
|
targetManagement.create(entityFactory.target().create().controllerId(str).name(str).description(str));
|
||||||
controllerManagement.findOrRegisterTargetIfItDoesNotexist(str, LOCALHOST);
|
controllerManagement.findOrRegisterTargetIfItDoesNotexist(str, LOCALHOST);
|
||||||
character++;
|
character++;
|
||||||
}
|
}
|
||||||
@@ -1396,6 +1396,6 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
|||||||
// verify active action
|
// verify active action
|
||||||
final Slice<Action> actionsByTarget = deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE);
|
final Slice<Action> actionsByTarget = deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE);
|
||||||
assertThat(actionsByTarget.getContent()).hasSize(1);
|
assertThat(actionsByTarget.getContent()).hasSize(1);
|
||||||
return targetManagement.findTargetByControllerID(tA.getControllerId()).get();
|
return targetManagement.getByControllerID(tA.getControllerId()).get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,11 +113,11 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
|||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
|
|
||||||
final Tag createdOne = tagManagement.findAllTargetTags("name==thetest1", PAGE).getContent().get(0);
|
final Tag createdOne = targetTagManagement.findByRsql(PAGE, "name==thetest1").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 = tagManagement.findAllTargetTags("name==thetest2", PAGE).getContent().get(0);
|
final Tag createdTwo = targetTagManagement.findByRsql(PAGE, "name==thetest2").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());
|
||||||
@@ -143,7 +143,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
|||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
|
|
||||||
final Tag updated = tagManagement.findAllTargetTags("name==updatedName", PAGE).getContent().get(0);
|
final Tag updated = targetTagManagement.findByRsql(PAGE, "name==updatedName").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());
|
||||||
@@ -162,7 +162,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
|||||||
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()))
|
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()))
|
||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
assertThat(tagManagement.findTargetTagById(original.getId())).isNotPresent();
|
assertThat(targetTagManagement.get(original.getId())).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -237,7 +237,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
|||||||
|
|
||||||
ResultActions result = toggle(tag, targets);
|
ResultActions result = toggle(tag, targets);
|
||||||
|
|
||||||
List<Target> updated = targetManagement.findTargetsByTag(PAGE, tag.getId()).getContent();
|
List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
|
||||||
|
|
||||||
assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
||||||
.containsAll(targets.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
.containsAll(targets.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||||
@@ -247,12 +247,12 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
|||||||
|
|
||||||
result = toggle(tag, targets);
|
result = toggle(tag, targets);
|
||||||
|
|
||||||
updated = targetManagement.findTargetsAll(PAGE).getContent();
|
updated = targetManagement.findAll(PAGE).getContent();
|
||||||
|
|
||||||
result.andExpect(applyTargetEntityMatcherOnArrayResult(updated.get(0), "unassignedTargets"))
|
result.andExpect(applyTargetEntityMatcherOnArrayResult(updated.get(0), "unassignedTargets"))
|
||||||
.andExpect(applyTargetEntityMatcherOnArrayResult(updated.get(1), "unassignedTargets"));
|
.andExpect(applyTargetEntityMatcherOnArrayResult(updated.get(1), "unassignedTargets"));
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetsByTag(PAGE, tag.getId())).isEmpty();
|
assertThat(targetManagement.findByTag(PAGE, tag.getId())).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResultActions toggle(final TargetTag tag, final List<Target> targets) throws Exception {
|
private ResultActions toggle(final TargetTag tag, final List<Target> targets) throws Exception {
|
||||||
@@ -283,7 +283,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
|||||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
|
|
||||||
final List<Target> updated = targetManagement.findTargetsByTag(PAGE, tag.getId()).getContent();
|
final List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
|
||||||
|
|
||||||
assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
||||||
.containsAll(targets.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
.containsAll(targets.stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||||
@@ -309,7 +309,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
|
|||||||
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/"
|
mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/"
|
||||||
+ unassigned.getControllerId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
+ unassigned.getControllerId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||||
|
|
||||||
final List<Target> updated = targetManagement.findTargetsByTag(PAGE, tag.getId()).getContent();
|
final List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
|
||||||
|
|
||||||
assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList()))
|
||||||
.containsOnly(assigned.getControllerId());
|
.containsOnly(assigned.getControllerId());
|
||||||
|
|||||||
@@ -3,4 +3,48 @@
|
|||||||
API for repository access. Contains:
|
API for repository access. Contains:
|
||||||
|
|
||||||
- Entity Model
|
- Entity Model
|
||||||
- Management service API
|
- Management service API
|
||||||
|
|
||||||
|
## Method naming concept (example target management)
|
||||||
|
|
||||||
|
```
|
||||||
|
// Count all targets
|
||||||
|
Long count()
|
||||||
|
|
||||||
|
// Count by filter parameter (example)
|
||||||
|
Long countByTargetFilterQuery(@NotEmpty String targetFilterQuery);
|
||||||
|
|
||||||
|
//Create entity
|
||||||
|
List<Target> create(@NotEmpty Collection<TargetCreate> create)
|
||||||
|
Target create(@NotNull TargetCreate create)
|
||||||
|
|
||||||
|
//Delete entities (throws EntityNotFoundException if one element does not exist (at least one not found in collection case))
|
||||||
|
void delete(@NotEmpty Collection<Long> targetIDs);
|
||||||
|
void delete(@NotNull Long targetID);
|
||||||
|
void deleteByControllerId(@NotEmpty String controllerId);
|
||||||
|
void deleteByControllerId(@NotEmpty Collection<String> controllerId);
|
||||||
|
|
||||||
|
//Update Target (throws EntityNotFoundException if one element does not exist (at least one not found in collection case))
|
||||||
|
List<Target> update(@NotEmpty Collection<TargetUpdate> update);
|
||||||
|
Target update(@NotNull TargetUpdate update);
|
||||||
|
|
||||||
|
//Exist
|
||||||
|
boolean exists(@NotNull Long targetId)
|
||||||
|
boolean existsByAssignedDistributionSet(@NotNull Long distributionSetID);
|
||||||
|
|
||||||
|
// Read methods
|
||||||
|
// Find one on technical ID (Optional, no EntityNotFoundException)
|
||||||
|
Optional<Target> get(@NotNull Long targetId);
|
||||||
|
List<Target> get(@NotEmpty Collection<Long> targetId);
|
||||||
|
|
||||||
|
// Find one on non-ID but unique constraint (Optional, no EntityNotFoundException)
|
||||||
|
Optional<Target> getByControllerID(@NotEmpty String controllerId);
|
||||||
|
List<Target> getByControllerID(@NotEmpty Collection<String> controllerId);
|
||||||
|
|
||||||
|
// Find one on non-ID but and non unique constraint (Optional, no EntityNotFoundException)
|
||||||
|
Optional<Target> findFirstByDescription(@NotEmpty String description);
|
||||||
|
|
||||||
|
// Query/search repository (page might be empty, no EntityNotFoundException) (note: pageReq always first in signature)
|
||||||
|
Page<Target> findByAssignedDistributionSet(@NotNull Pageable pageReq, @NotNull Long distributionSetID);
|
||||||
|
|
||||||
|
```
|
||||||
@@ -39,7 +39,7 @@ public interface ArtifactManagement {
|
|||||||
* management
|
* management
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Long countArtifactsAll();
|
long count();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persists artifact binary as provided by given InputStream. assign the
|
* Persists artifact binary as provided by given InputStream. assign the
|
||||||
@@ -63,7 +63,7 @@ public interface ArtifactManagement {
|
|||||||
* if given software module does not exist
|
* if given software module does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
Artifact createArtifact(@NotNull InputStream inputStream, @NotNull Long moduleId, final String filename,
|
Artifact create(@NotNull InputStream inputStream, @NotNull Long moduleId, final String filename,
|
||||||
final boolean overrideExisting);
|
final boolean overrideExisting);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -99,7 +99,7 @@ public interface ArtifactManagement {
|
|||||||
* if check against provided SHA1 checksum failed
|
* if check against provided SHA1 checksum failed
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
Artifact createArtifact(@NotNull InputStream stream, @NotNull Long moduleId, @NotEmpty String filename,
|
Artifact create(@NotNull InputStream stream, @NotNull Long moduleId, @NotEmpty String filename,
|
||||||
String providedMd5Sum, String providedSha1Sum, boolean overrideExisting, String contentType);
|
String providedMd5Sum, String providedSha1Sum, boolean overrideExisting, String contentType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -129,7 +129,7 @@ public interface ArtifactManagement {
|
|||||||
* if artifact with given ID does not exist
|
* if artifact with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
void deleteArtifact(@NotNull Long id);
|
void delete(@NotNull Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for {@link Artifact} with given {@link Identifiable}.
|
* Searches for {@link Artifact} with given {@link Identifiable}.
|
||||||
@@ -140,7 +140,7 @@ public interface ArtifactManagement {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
||||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||||
Optional<Artifact> findArtifact(@NotNull Long id);
|
Optional<Artifact> get(@NotNull Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find by artifact by software module id and filename.
|
* Find by artifact by software module id and filename.
|
||||||
@@ -156,7 +156,7 @@ public interface ArtifactManagement {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
||||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||||
Optional<Artifact> findByFilenameAndSoftwareModule(@NotNull String filename, @NotNull Long softwareModuleId);
|
Optional<Artifact> getByFilenameAndSoftwareModule(@NotNull String filename, @NotNull Long softwareModuleId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find all local artifact by sha1 and return the first artifact.
|
* Find all local artifact by sha1 and return the first artifact.
|
||||||
@@ -167,7 +167,7 @@ public interface ArtifactManagement {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
||||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||||
Optional<Artifact> findFirstArtifactBySHA1(@NotNull String sha1);
|
Optional<Artifact> findFirstBySHA1(@NotNull String sha1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for {@link Artifact} with given file name.
|
* Searches for {@link Artifact} with given file name.
|
||||||
@@ -178,13 +178,13 @@ public interface ArtifactManagement {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
||||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||||
Optional<Artifact> findArtifactByFilename(@NotNull String filename);
|
Optional<Artifact> getByFilename(@NotNull String filename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get local artifact for a base software module.
|
* Get local artifact for a base software module.
|
||||||
*
|
*
|
||||||
* @param pageReq
|
* @param pageReq
|
||||||
* Pageable
|
* Pageable parameter
|
||||||
* @param swId
|
* @param swId
|
||||||
* software module id
|
* software module id
|
||||||
* @return Page<Artifact>
|
* @return Page<Artifact>
|
||||||
@@ -193,7 +193,7 @@ public interface ArtifactManagement {
|
|||||||
* if software module with given ID does not exist
|
* if software module with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<Artifact> findArtifactBySoftwareModule(@NotNull Pageable pageReq, @NotNull Long swId);
|
Page<Artifact> findBySoftwareModule(@NotNull Pageable pageReq, @NotNull Long swId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads {@link AbstractDbArtifact} from store for given {@link Artifact}.
|
* Loads {@link AbstractDbArtifact} from store for given {@link Artifact}.
|
||||||
|
|||||||
@@ -64,6 +64,16 @@ public interface ControllerManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||||
Action addCancelActionStatus(@NotNull ActionStatusCreate create);
|
Action addCancelActionStatus(@NotNull ActionStatusCreate create);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves assigned {@link SoftwareModule} of a target.
|
||||||
|
*
|
||||||
|
* @param moduleId
|
||||||
|
* of the {@link SoftwareModule}
|
||||||
|
* @return {@link SoftwareModule} identified by ID
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||||
|
Optional<SoftwareModule> getSoftwareModule(@NotNull final Long moduleId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple addition of a new {@link ActionStatus} entry to the {@link Action}
|
* Simple addition of a new {@link ActionStatus} entry to the {@link Action}
|
||||||
* . No state changes.
|
* . No state changes.
|
||||||
@@ -282,7 +292,7 @@ public interface ControllerManagement {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER + SpringEvalExpressions.HAS_AUTH_OR
|
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER + SpringEvalExpressions.HAS_AUTH_OR
|
||||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||||
Optional<Target> findByControllerId(@NotEmpty String controllerId);
|
Optional<Target> getByControllerId(@NotEmpty String controllerId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds {@link Target} based on given ID returns found Target without
|
* Finds {@link Target} based on given ID returns found Target without
|
||||||
@@ -296,7 +306,7 @@ public interface ControllerManagement {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER + SpringEvalExpressions.HAS_AUTH_OR
|
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER + SpringEvalExpressions.HAS_AUTH_OR
|
||||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||||
Optional<Target> findByTargetId(@NotNull Long targetId);
|
Optional<Target> get(@NotNull Long targetId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the specified number of messages from action history of the
|
* Retrieves the specified number of messages from action history of the
|
||||||
|
|||||||
@@ -187,19 +187,19 @@ public interface DeploymentManagement {
|
|||||||
* if target with given ID does not exist
|
* if target with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Long countActionsByTarget(@NotNull String rsqlParam, @NotEmpty String controllerId);
|
long countActionsByTarget(@NotNull String rsqlParam, @NotEmpty String controllerId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the total amount of stored action status
|
* @return the total amount of stored action status
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Long countActionStatusAll();
|
long countActionStatusAll();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the total amount of stored actions
|
* @return the total amount of stored actions
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Long countActionsAll();
|
long countActionsAll();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* counts all actions associated to a specific target.
|
* counts all actions associated to a specific target.
|
||||||
@@ -212,7 +212,7 @@ public interface DeploymentManagement {
|
|||||||
* if target with given ID does not exist
|
* if target with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Long countActionsByTarget(@NotEmpty String controllerId);
|
long countActionsByTarget(@NotEmpty String controllerId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link Action} entity for given actionId.
|
* Get the {@link Action} entity for given actionId.
|
||||||
|
|||||||
@@ -12,20 +12,17 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.validation.ConstraintViolationException;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||||
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
|
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
|
||||||
import org.eclipse.hawkbit.repository.builder.DistributionSetUpdate;
|
import org.eclipse.hawkbit.repository.builder.DistributionSetUpdate;
|
||||||
import org.eclipse.hawkbit.repository.exception.DistributionSetCreationFailedMissingMandatoryModuleException;
|
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||||
import org.eclipse.hawkbit.repository.exception.UnsupportedSoftwareModuleForThisDistributionSetException;
|
import org.eclipse.hawkbit.repository.exception.UnsupportedSoftwareModuleForThisDistributionSetException;
|
||||||
import org.eclipse.hawkbit.repository.model.Action;
|
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
|
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||||
@@ -45,7 +42,8 @@ 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> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigns {@link SoftwareModule} to existing {@link DistributionSet}.
|
* Assigns {@link SoftwareModule} to existing {@link DistributionSet}.
|
||||||
@@ -66,8 +64,6 @@ public interface DistributionSetManagement {
|
|||||||
* @throws UnsupportedSoftwareModuleForThisDistributionSetException
|
* @throws UnsupportedSoftwareModuleForThisDistributionSetException
|
||||||
* is {@link SoftwareModule#getType()} is not supported by this
|
* is {@link SoftwareModule#getType()} is not supported by this
|
||||||
* {@link DistributionSet#getType()}.
|
* {@link DistributionSet#getType()}.
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
DistributionSet assignSoftwareModules(@NotNull Long setId, @NotEmpty Collection<Long> moduleIds);
|
DistributionSet assignSoftwareModules(@NotNull Long setId, @NotEmpty Collection<Long> moduleIds);
|
||||||
@@ -76,7 +72,7 @@ public interface DistributionSetManagement {
|
|||||||
* Assign a {@link DistributionSetTag} assignment to given
|
* Assign a {@link DistributionSetTag} assignment to given
|
||||||
* {@link DistributionSet}s.
|
* {@link DistributionSet}s.
|
||||||
*
|
*
|
||||||
* @param dsIds
|
* @param setIds
|
||||||
* to assign for
|
* to assign for
|
||||||
* @param tagId
|
* @param tagId
|
||||||
* to assign
|
* to assign
|
||||||
@@ -87,42 +83,12 @@ public interface DistributionSetManagement {
|
|||||||
* distribution sets.
|
* distribution sets.
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
List<DistributionSet> assignTag(@NotEmpty Collection<Long> dsIds, @NotNull Long tagId);
|
List<DistributionSet> assignTag(@NotEmpty Collection<Long> setIds, @NotNull Long tagId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Count all {@link DistributionSet}s in the repository that are not marked
|
|
||||||
* as deleted.
|
|
||||||
*
|
|
||||||
* @return number of {@link DistributionSet}s
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Long countDistributionSetsAll();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new {@link DistributionSet}.
|
|
||||||
*
|
|
||||||
* @param create
|
|
||||||
* {@link DistributionSet} to be created
|
|
||||||
* @return the new persisted {@link DistributionSet}
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if a provided linked entity does not exists (
|
|
||||||
* {@link DistributionSet#getModules()} or
|
|
||||||
* {@link DistributionSet#getType()})
|
|
||||||
* @throws DistributionSetCreationFailedMissingMandatoryModuleException
|
|
||||||
* is {@link DistributionSet} does not contain mandatory
|
|
||||||
* {@link SoftwareModule}s.
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link DistributionSetCreate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
|
||||||
DistributionSet createDistributionSet(@NotNull DistributionSetCreate create);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a list of distribution set meta data entries.
|
* creates a list of distribution set meta data entries.
|
||||||
*
|
*
|
||||||
* @param dsId
|
* @param setId
|
||||||
* if the {@link DistributionSet} the metadata has to be created
|
* if the {@link DistributionSet} the metadata has to be created
|
||||||
* for
|
* for
|
||||||
* @param metadata
|
* @param metadata
|
||||||
@@ -136,69 +102,12 @@ public interface DistributionSetManagement {
|
|||||||
* specific key
|
* specific key
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
List<DistributionSetMetadata> createDistributionSetMetadata(@NotNull Long dsId,
|
List<DistributionSetMetadata> createMetaData(@NotNull Long setId, @NotEmpty Collection<MetaData> metadata);
|
||||||
@NotEmpty Collection<MetaData> metadata);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates multiple {@link DistributionSet}s.
|
|
||||||
*
|
|
||||||
* @param creates
|
|
||||||
* to be created
|
|
||||||
* @return the new {@link DistributionSet}s
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if a provided linked entity does not exists (
|
|
||||||
* {@link DistributionSet#getModules()} or
|
|
||||||
* {@link DistributionSet#getType()})
|
|
||||||
* @throws DistributionSetCreationFailedMissingMandatoryModuleException
|
|
||||||
* is {@link DistributionSet} does not contain mandatory
|
|
||||||
* {@link SoftwareModule}s.
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link DistributionSetCreate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
|
||||||
List<DistributionSet> createDistributionSets(@NotNull Collection<DistributionSetCreate> creates);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* {@link DistributionSet} can be deleted/erased from the repository if they
|
|
||||||
* have never been assigned to any {@link Action} or {@link Target}.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* If they have been assigned that need to be marked as deleted which as a
|
|
||||||
* result means that they cannot be assigned anymore to any targets. (define
|
|
||||||
* e.g. findByDeletedFalse())
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param setId
|
|
||||||
* to delete
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if given {@link DistributionSet} does not exist
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
|
||||||
void deleteDistributionSet(@NotNull Long setId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deleted {@link DistributionSet}s by their IDs. That is either a soft
|
|
||||||
* delete of the entities have been linked to an {@link Action} before or a
|
|
||||||
* hard delete if not.
|
|
||||||
*
|
|
||||||
* @param dsIds
|
|
||||||
* to be deleted
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if (at least one) given distribution set does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
|
||||||
void deleteDistributionSet(@NotEmpty Collection<Long> dsIds);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deletes a distribution set meta data entry.
|
* deletes a distribution set meta data entry.
|
||||||
*
|
*
|
||||||
* @param dsId
|
* @param setId
|
||||||
* where meta data has to be deleted
|
* where meta data has to be deleted
|
||||||
* @param key
|
* @param key
|
||||||
* of the meta data element
|
* of the meta data element
|
||||||
@@ -207,7 +116,7 @@ public interface DistributionSetManagement {
|
|||||||
* if given set does not exist
|
* if given set does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
void deleteDistributionSetMetadata(@NotNull final Long dsId, @NotEmpty final String key);
|
void deleteMetaData(@NotNull Long setId, @NotEmpty String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieves the distribution set for a given action.
|
* retrieves the distribution set for a given action.
|
||||||
@@ -220,33 +129,21 @@ public interface DistributionSetManagement {
|
|||||||
* if action with given ID does not exist
|
* if action with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<DistributionSet> findDistributionSetByAction(@NotNull Long actionId);
|
Optional<DistributionSet> getByAction(@NotNull Long actionId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Find {@link DistributionSet} based on given ID without details, e.g.
|
|
||||||
* {@link DistributionSet#getModules()}.
|
|
||||||
*
|
|
||||||
* @param distid
|
|
||||||
* to look for.
|
|
||||||
* @return {@link DistributionSet}
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Optional<DistributionSet> findDistributionSetById(@NotNull Long distid);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find {@link DistributionSet} based on given ID including (lazy loaded)
|
* Find {@link DistributionSet} based on given ID including (lazy loaded)
|
||||||
* details, e.g. {@link DistributionSet#getModules()}.
|
* details, e.g. {@link DistributionSet#getModules()}.
|
||||||
*
|
*
|
||||||
* Note: for performance reasons it is recommended to use
|
* Note: for performance reasons it is recommended to use {@link #get(Long)}
|
||||||
* {@link #findDistributionSetById(Long)} if details are not necessary.
|
* if details are not necessary.
|
||||||
*
|
*
|
||||||
* @param distid
|
* @param setId
|
||||||
* to look for.
|
* to look for.
|
||||||
* @return {@link DistributionSet}
|
* @return {@link DistributionSet}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<DistributionSet> findDistributionSetByIdWithDetails(@NotNull Long distid);
|
Optional<DistributionSet> getWithDetails(@NotNull Long setId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find distribution set by name and version.
|
* Find distribution set by name and version.
|
||||||
@@ -258,16 +155,16 @@ public interface DistributionSetManagement {
|
|||||||
* @return the page with the found {@link DistributionSet}
|
* @return the page with the found {@link DistributionSet}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<DistributionSet> findDistributionSetByNameAndVersion(@NotEmpty String distributionName,
|
Optional<DistributionSet> getByNameAndVersion(@NotEmpty String distributionName, @NotEmpty String version);
|
||||||
@NotEmpty String version);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds all meta data by the given distribution set id.
|
* finds all meta data by the given distribution set id.
|
||||||
*
|
*
|
||||||
* @param distributionSetId
|
|
||||||
* the distribution set id to retrieve the meta data from
|
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* the page request to page the result
|
* the page request to page the result
|
||||||
|
* @param setId
|
||||||
|
* 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
|
||||||
*
|
*
|
||||||
@@ -275,18 +172,18 @@ public interface DistributionSetManagement {
|
|||||||
* if distribution set with given ID does not exist
|
* if distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(@NotNull Long distributionSetId,
|
Page<DistributionSetMetadata> findMetaDataByDistributionSetId(@NotNull Pageable pageable, @NotNull Long setId);
|
||||||
@NotNull Pageable pageable);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds all meta data by the given distribution set id.
|
* finds all meta data by the given distribution set id.
|
||||||
*
|
*
|
||||||
* @param distributionSetId
|
* @param pageable
|
||||||
|
* the page request to page the result
|
||||||
|
* @param setId
|
||||||
* the distribution set id to retrieve the meta data from
|
* the distribution set id to retrieve the meta data from
|
||||||
* @param rsqlParam
|
* @param rsqlParam
|
||||||
* rsql query string
|
* rsql query string
|
||||||
* @param pageable
|
*
|
||||||
* the page request to page the result
|
|
||||||
* @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
|
||||||
*
|
*
|
||||||
@@ -300,19 +197,14 @@ public interface DistributionSetManagement {
|
|||||||
* of distribution set with given ID does not exist
|
* of distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(@NotNull Long distributionSetId,
|
Page<DistributionSetMetadata> findMetaDataByDistributionSetIdAndRsql(@NotNull Pageable pageable,
|
||||||
@NotNull String rsqlParam, @NotNull Pageable pageable);
|
@NotNull Long setId, @NotNull String rsqlParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds all {@link DistributionSet}s.
|
* finds all {@link DistributionSet}s.
|
||||||
*
|
*
|
||||||
* @param pageReq
|
* @param pageable
|
||||||
* the pagination parameter
|
* the pagination parameter
|
||||||
* @param deleted
|
|
||||||
* if TRUE, {@link DistributionSet}s marked as deleted are
|
|
||||||
* returned. If FALSE, on {@link DistributionSet}s with
|
|
||||||
* {@link DistributionSet#isDeleted()} == FALSE are returned.
|
|
||||||
* <code>null</code> if both are to be returned
|
|
||||||
* @param complete
|
* @param complete
|
||||||
* to <code>true</code> for returning only completed distribution
|
* 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
|
||||||
@@ -322,47 +214,7 @@ public interface DistributionSetManagement {
|
|||||||
* @return all found {@link DistributionSet}s
|
* @return all found {@link DistributionSet}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<DistributionSet> findDistributionSetsByDeletedAndOrCompleted(@NotNull Pageable pageReq, Boolean deleted,
|
Page<DistributionSet> findByCompleted(@NotNull Pageable pageable, Boolean complete);
|
||||||
Boolean complete);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* finds all {@link DistributionSet}s.
|
|
||||||
*
|
|
||||||
* @param rsqlParam
|
|
||||||
* rsql query string
|
|
||||||
* @param pageReq
|
|
||||||
* the pagination parameter
|
|
||||||
* @param deleted
|
|
||||||
* if TRUE, {@link DistributionSet}s marked as deleted are
|
|
||||||
* returned. If FALSE, on {@link DistributionSet}s not marked as
|
|
||||||
* deleted are returned. <code>null</code> if both are to be
|
|
||||||
* returned
|
|
||||||
* @return all found {@link DistributionSet}s
|
|
||||||
*
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<DistributionSet> findDistributionSetsAll(@NotNull String rsqlParam, @NotNull Pageable pageReq,
|
|
||||||
Boolean deleted);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* finds all {@link DistributionSet}s.
|
|
||||||
*
|
|
||||||
* @param pageReq
|
|
||||||
* the pagination parameter
|
|
||||||
* @param deleted
|
|
||||||
* if TRUE, {@link DistributionSet}s marked as deleted are
|
|
||||||
* returned. If FALSE, on {@link DistributionSet}s not marked as
|
|
||||||
* deleted are returned. <code>null</code> if both are to be
|
|
||||||
* returned
|
|
||||||
* @return all found {@link DistributionSet}s
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<DistributionSet> findDistributionSetsAll(@NotNull Pageable pageReq, Boolean deleted);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* method retrieves all {@link DistributionSet}s from the repository in the
|
* method retrieves all {@link DistributionSet}s from the repository in the
|
||||||
@@ -386,7 +238,7 @@ public interface DistributionSetManagement {
|
|||||||
* @return {@link DistributionSet}s
|
* @return {@link DistributionSet}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<DistributionSet> findDistributionSetsAllOrderedByLinkTarget(@NotNull Pageable pageable,
|
Page<DistributionSet> findByFilterAndAssignedInstalledDsOrderedByLinkTarget(@NotNull Pageable pageable,
|
||||||
@NotNull DistributionSetFilterBuilder distributionSetFilterBuilder, @NotEmpty String assignedOrInstalled);
|
@NotNull DistributionSetFilterBuilder distributionSetFilterBuilder, @NotEmpty String assignedOrInstalled);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -399,7 +251,7 @@ public interface DistributionSetManagement {
|
|||||||
* @return the page of found {@link DistributionSet}
|
* @return the page of found {@link DistributionSet}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<DistributionSet> findDistributionSetsByFilters(@NotNull Pageable pageable,
|
Page<DistributionSet> findByDistributionSetFilter(@NotNull Pageable pageable,
|
||||||
@NotNull DistributionSetFilter distributionSetFilter);
|
@NotNull DistributionSetFilter distributionSetFilter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -421,7 +273,7 @@ public interface DistributionSetManagement {
|
|||||||
* of distribution set tag with given ID does not exist
|
* of distribution set tag with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<DistributionSet> findDistributionSetsByTag(@NotNull final Pageable pageable, @NotNull final Long tagId);
|
Page<DistributionSet> findByTag(@NotNull Pageable pageable, @NotNull Long tagId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieves {@link DistributionSet}s by filtering on the given parameters.
|
* retrieves {@link DistributionSet}s by filtering on the given parameters.
|
||||||
@@ -438,8 +290,7 @@ public interface DistributionSetManagement {
|
|||||||
* of distribution set tag with given ID does not exist
|
* of distribution set tag with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<DistributionSet> findDistributionSetsByTag(@NotNull final Pageable pageable, @NotNull String rsqlParam,
|
Page<DistributionSet> findByRsqlAndTag(@NotNull Pageable pageable, @NotNull String rsqlParam, @NotNull Long tagId);
|
||||||
@NotNull final Long tagId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds a single distribution set meta data by its id.
|
* finds a single distribution set meta data by its id.
|
||||||
@@ -454,7 +305,7 @@ public interface DistributionSetManagement {
|
|||||||
* is set with given ID does not exist
|
* is set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<DistributionSetMetadata> findDistributionSetMetadata(@NotNull Long setId, @NotEmpty String key);
|
Optional<DistributionSetMetadata> getMetaDataByDistributionSetId(@NotNull Long setId, @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
|
||||||
@@ -466,7 +317,7 @@ public interface DistributionSetManagement {
|
|||||||
* @return <code>true</code> if in use
|
* @return <code>true</code> if in use
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
boolean isDistributionSetInUse(@NotNull Long setId);
|
boolean isInUse(@NotNull Long setId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles {@link DistributionSetTag} assignment to given
|
* Toggles {@link DistributionSetTag} assignment to given
|
||||||
@@ -474,7 +325,7 @@ public interface DistributionSetManagement {
|
|||||||
* the list have the {@link Tag} not yet assigned, they will be. If all of
|
* the list have the {@link Tag} not yet assigned, they will be. If all of
|
||||||
* theme have the tag already assigned they will be removed instead.
|
* theme have the tag already assigned they will be removed instead.
|
||||||
*
|
*
|
||||||
* @param dsIds
|
* @param setIds
|
||||||
* to toggle for
|
* to toggle for
|
||||||
* @param tagName
|
* @param tagName
|
||||||
* to toggle
|
* to toggle
|
||||||
@@ -485,7 +336,7 @@ public interface DistributionSetManagement {
|
|||||||
* if given tag does not exist or (at least one) module
|
* if given tag does not exist or (at least one) module
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<Long> dsIds, @NotNull String tagName);
|
DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<Long> setIds, @NotNull String tagName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unassigns a {@link SoftwareModule} form an existing
|
* Unassigns a {@link SoftwareModule} form an existing
|
||||||
@@ -511,7 +362,7 @@ public interface DistributionSetManagement {
|
|||||||
* Unassign a {@link DistributionSetTag} assignment to given
|
* Unassign a {@link DistributionSetTag} assignment to given
|
||||||
* {@link DistributionSet}.
|
* {@link DistributionSet}.
|
||||||
*
|
*
|
||||||
* @param dsId
|
* @param setId
|
||||||
* to unassign for
|
* to unassign for
|
||||||
* @param tagId
|
* @param tagId
|
||||||
* to unassign
|
* to unassign
|
||||||
@@ -521,34 +372,14 @@ public interface DistributionSetManagement {
|
|||||||
* if set or tag with given ID does not exist
|
* if set or tag with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
DistributionSet unAssignTag(@NotNull Long dsId, @NotNull Long tagId);
|
DistributionSet unAssignTag(@NotNull Long setId, @NotNull Long tagId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates existing {@link DistributionSet}.
|
|
||||||
*
|
|
||||||
* @param update
|
|
||||||
* to update
|
|
||||||
*
|
|
||||||
* @return the saved entity.
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if given set does not exist
|
|
||||||
* @throws EntityReadOnlyException
|
|
||||||
* if user tries to change requiredMigrationStep or type on a DS
|
|
||||||
* that is already assigned to targets
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link DistributionSetUpdate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
|
||||||
DistributionSet updateDistributionSet(@NotNull DistributionSetUpdate update);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updates a distribution set meta data value if corresponding entry exists.
|
* updates a distribution set meta data value if corresponding entry exists.
|
||||||
*
|
*
|
||||||
* @param dsId
|
* @param setId
|
||||||
* {@link DistributionSet} of the meta data entry to be updated
|
* {@link DistributionSet} of the meta data entry to be updated
|
||||||
* @param md
|
* @param metadata
|
||||||
* meta data entry to be updated
|
* meta data entry to be updated
|
||||||
* @return the updated meta data entry
|
* @return the updated meta data entry
|
||||||
*
|
*
|
||||||
@@ -557,16 +388,21 @@ public interface DistributionSetManagement {
|
|||||||
* updated
|
* updated
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
DistributionSetMetadata updateDistributionSetMetadata(@NotNull Long dsId, @NotNull MetaData md);
|
DistributionSetMetadata updateMetaData(@NotNull Long setId, @NotNull MetaData metadata);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all distribution set without details.
|
* Count all {@link DistributionSet}s in the repository that are not marked
|
||||||
|
* as deleted.
|
||||||
|
*
|
||||||
|
* @param typeId
|
||||||
|
* to look for
|
||||||
*
|
*
|
||||||
* @param ids
|
* @return number of {@link DistributionSet}s
|
||||||
* the ids to for
|
*
|
||||||
* @return the found {@link DistributionSet}s
|
* @throws EntityNotFoundException
|
||||||
|
* if type with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
List<DistributionSet> findDistributionSetsById(@NotEmpty Collection<Long> ids);
|
long countByTypeId(@NotNull Long typeId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||||
|
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||||
|
import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Management service for {@link DistributionSetTag}s.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* to look for.
|
||||||
|
* @return {@link DistributionSet}
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Optional<DistributionSetTag> getByName(@NotEmpty String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds all {@link TargetTag} assigned to given {@link Target}.
|
||||||
|
*
|
||||||
|
* @param pageable
|
||||||
|
* information for page size, offset and sort order.
|
||||||
|
*
|
||||||
|
* @param setId
|
||||||
|
* of the {@link DistributionSet}
|
||||||
|
* @return page of the found {@link TargetTag}s
|
||||||
|
*
|
||||||
|
* @throws EntityNotFoundException
|
||||||
|
* if {@link DistributionSet} with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Page<DistributionSetTag> findByDistributionSet(@NotNull Pageable pageable, @NotNull Long setId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,10 +9,8 @@
|
|||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.validation.ConstraintViolationException;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||||
@@ -20,84 +18,18 @@ import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate;
|
|||||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeUpdate;
|
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeUpdate;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Management service for {@link DistributionSetType}s.
|
* Management service for {@link DistributionSetType}s.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface DistributionSetTypeManagement {
|
public interface DistributionSetTypeManagement
|
||||||
|
extends RepositoryManagement<DistributionSetType, DistributionSetTypeCreate, DistributionSetTypeUpdate> {
|
||||||
/**
|
|
||||||
* Creates new {@link DistributionSetType}.
|
|
||||||
*
|
|
||||||
* @param create
|
|
||||||
* to create
|
|
||||||
* @return created entity
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if a provided linked entity does not exists (
|
|
||||||
* {@link DistributionSetType#getMandatoryModuleTypes()} or
|
|
||||||
* {@link DistributionSetType#getOptionalModuleTypes()}
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link DistributionSetTypeCreate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
|
||||||
DistributionSetType createDistributionSetType(@NotNull DistributionSetTypeCreate create);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates multiple {@link DistributionSetType}s.
|
|
||||||
*
|
|
||||||
* @param creates
|
|
||||||
* to create
|
|
||||||
* @return created entity
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if a provided linked entity does not exists (
|
|
||||||
* {@link DistributionSetType#getMandatoryModuleTypes()} or
|
|
||||||
* {@link DistributionSetType#getOptionalModuleTypes()}
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link DistributionSetTypeCreate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
|
||||||
List<DistributionSetType> createDistributionSetTypes(@NotNull Collection<DistributionSetTypeCreate> creates);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 countDistributionSetsByType(@NotNull Long typeId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes or mark as delete in case the type is in use.
|
|
||||||
*
|
|
||||||
* @param typeId
|
|
||||||
* to delete
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if given set does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
|
||||||
void deleteDistributionSetType(@NotNull Long typeId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param key
|
* @param key
|
||||||
@@ -106,7 +38,7 @@ public interface DistributionSetTypeManagement {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<DistributionSetType> findDistributionSetTypeByKey(@NotEmpty String key);
|
Optional<DistributionSetType> getByKey(@NotEmpty String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
@@ -114,66 +46,7 @@ public interface DistributionSetTypeManagement {
|
|||||||
* @return {@link DistributionSetType}
|
* @return {@link DistributionSetType}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<DistributionSetType> findDistributionSetTypeByName(@NotEmpty String name);
|
Optional<DistributionSetType> getByName(@NotEmpty String name);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param pageable
|
|
||||||
* parameter
|
|
||||||
* @return all {@link DistributionSetType}s in the repository.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<DistributionSetType> findDistributionSetTypesAll(@NotNull Pageable pageable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generic predicate based query for {@link DistributionSetType}.
|
|
||||||
*
|
|
||||||
* @param rsqlParam
|
|
||||||
* rsql query string
|
|
||||||
* @param pageable
|
|
||||||
* parameter for paging
|
|
||||||
*
|
|
||||||
* @return the found {@link SoftwareModuleType}s
|
|
||||||
*
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<DistributionSetType> findDistributionSetTypesAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param id
|
|
||||||
* as {@link DistributionSetType#getId()}
|
|
||||||
* @return {@link DistributionSetType}
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Optional<DistributionSetType> findDistributionSetTypeById(@NotNull Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates existing {@link DistributionSetType}. Resets assigned
|
|
||||||
* {@link SoftwareModuleType}s as well and sets as provided.
|
|
||||||
*
|
|
||||||
* @param update
|
|
||||||
* to update
|
|
||||||
*
|
|
||||||
* @return updated entity
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* in case the {@link DistributionSetType} does not exists and
|
|
||||||
* cannot be updated
|
|
||||||
*
|
|
||||||
* @throws EntityReadOnlyException
|
|
||||||
* if the {@link DistributionSetType} is already in use by a
|
|
||||||
* {@link DistributionSet} and user tries to change list of
|
|
||||||
* {@link SoftwareModuleType}s
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link DistributionSetTypeUpdate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
|
||||||
DistributionSetType updateDistributionSetType(@NotNull DistributionSetTypeUpdate update);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assigns {@link DistributionSetType#getMandatoryModuleTypes()}.
|
* Assigns {@link DistributionSetType#getMandatoryModuleTypes()}.
|
||||||
@@ -238,10 +111,4 @@ public interface DistributionSetTypeManagement {
|
|||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
DistributionSetType unassignSoftwareModuleType(@NotNull Long dsTypeId, @NotNull Long softwareModuleId);
|
DistributionSetType unassignSoftwareModuleType(@NotNull Long dsTypeId, @NotNull Long softwareModuleId);
|
||||||
|
|
||||||
/**
|
|
||||||
* @return number of {@link DistributionSetType}s in the repository.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Long countDistributionSetTypesAll();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,17 +21,17 @@ import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
|||||||
*/
|
*/
|
||||||
public class FilterParams {
|
public class FilterParams {
|
||||||
|
|
||||||
private Collection<TargetUpdateStatus> filterByStatus;
|
private final Collection<TargetUpdateStatus> filterByStatus;
|
||||||
private Boolean overdueState;
|
private final Boolean overdueState;
|
||||||
private String filterBySearchText;
|
private final String filterBySearchText;
|
||||||
private Boolean selectTargetWithNoTag;
|
private final Boolean selectTargetWithNoTag;
|
||||||
private String[] filterByTagNames;
|
private final String[] filterByTagNames;
|
||||||
private Long filterByDistributionId;
|
private final Long filterByDistributionId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param filterByDistributionId
|
* @param filterByInstalledOrAssignedDistributionSetId
|
||||||
* if set, a filter is added for the given
|
* if set, a filter is added for the given
|
||||||
* {@link DistributionSet#getId()}
|
* {@link DistributionSet#getId()}
|
||||||
* @param filterByStatus
|
* @param filterByStatus
|
||||||
@@ -47,13 +47,13 @@ public class FilterParams {
|
|||||||
* if tag-filtering is enabled, a filter is added for the given
|
* if tag-filtering is enabled, a filter is added for the given
|
||||||
* tag-names
|
* tag-names
|
||||||
*/
|
*/
|
||||||
public FilterParams(Long filterByDistributionId, Collection<TargetUpdateStatus> filterByStatus,
|
public FilterParams(final Collection<TargetUpdateStatus> filterByStatus, final Boolean overdueState,
|
||||||
Boolean overdueState, String filterBySearchText, Boolean selectTargetWithNoTag,
|
final String filterBySearchText, final Long filterByInstalledOrAssignedDistributionSetId,
|
||||||
String... filterByTagNames) {
|
final Boolean selectTargetWithNoTag, final String... filterByTagNames) {
|
||||||
this.filterByStatus = filterByStatus;
|
this.filterByStatus = filterByStatus;
|
||||||
this.overdueState = overdueState;
|
this.overdueState = overdueState;
|
||||||
this.filterBySearchText = filterBySearchText;
|
this.filterBySearchText = filterBySearchText;
|
||||||
this.filterByDistributionId = filterByDistributionId;
|
this.filterByDistributionId = filterByInstalledOrAssignedDistributionSetId;
|
||||||
this.selectTargetWithNoTag = selectTargetWithNoTag;
|
this.selectTargetWithNoTag = selectTargetWithNoTag;
|
||||||
this.filterByTagNames = filterByTagNames;
|
this.filterByTagNames = filterByTagNames;
|
||||||
}
|
}
|
||||||
@@ -68,16 +68,6 @@ public class FilterParams {
|
|||||||
return filterByDistributionId;
|
return filterByDistributionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets {@link DistributionSet#getId()} to filter the result.
|
|
||||||
*
|
|
||||||
* @param filterByDistributionId
|
|
||||||
* the distribution set id
|
|
||||||
*/
|
|
||||||
public void setFilterByDistributionId(Long filterByDistributionId) {
|
|
||||||
this.filterByDistributionId = filterByDistributionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a collection of target states to filter for. <br>
|
* Gets a collection of target states to filter for. <br>
|
||||||
* If set to <code>null</code> this filter is disabled.
|
* If set to <code>null</code> this filter is disabled.
|
||||||
@@ -88,16 +78,6 @@ public class FilterParams {
|
|||||||
return filterByStatus;
|
return filterByStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the collection of target states to filter for.
|
|
||||||
*
|
|
||||||
* @param filterByStatus
|
|
||||||
* collection of target update status
|
|
||||||
*/
|
|
||||||
public void setFilterByStatus(Collection<TargetUpdateStatus> filterByStatus) {
|
|
||||||
this.filterByStatus = filterByStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the flag for overdue filter; if set to <code>true</code>, the
|
* Gets the flag for overdue filter; if set to <code>true</code>, the
|
||||||
* overdue filter is activated. Overdued targets a targets that did not
|
* overdue filter is activated. Overdued targets a targets that did not
|
||||||
@@ -110,17 +90,6 @@ public class FilterParams {
|
|||||||
return overdueState;
|
return overdueState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the flag for overdue filter; if set to <code>true</code>, the
|
|
||||||
* overdue filter is activated.
|
|
||||||
*
|
|
||||||
* @param overdueState
|
|
||||||
* if the overdue filter should be activates
|
|
||||||
*/
|
|
||||||
public void setOverdueState(Boolean overdueState) {
|
|
||||||
this.overdueState = overdueState;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the search text to filter for. This is used to find targets having
|
* Gets the search text to filter for. This is used to find targets having
|
||||||
* the text anywhere in name or description <br>
|
* the text anywhere in name or description <br>
|
||||||
@@ -132,16 +101,6 @@ public class FilterParams {
|
|||||||
return filterBySearchText;
|
return filterBySearchText;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the search text to filter for.
|
|
||||||
*
|
|
||||||
* @param filterBySearchText
|
|
||||||
* search text
|
|
||||||
*/
|
|
||||||
public void setFilterBySearchText(String filterBySearchText) {
|
|
||||||
this.filterBySearchText = filterBySearchText;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the flag indicating if tagging filter is used. <br>
|
* Gets the flag indicating if tagging filter is used. <br>
|
||||||
* If set to <code>null</code> this filter is disabled.
|
* If set to <code>null</code> this filter is disabled.
|
||||||
@@ -152,16 +111,6 @@ public class FilterParams {
|
|||||||
return selectTargetWithNoTag;
|
return selectTargetWithNoTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the flag indicating if tagging filter is used.
|
|
||||||
*
|
|
||||||
* @param selectTargetWithNoTag
|
|
||||||
* should the tagging filter be used?
|
|
||||||
*/
|
|
||||||
public void setSelectTargetWithNoTag(Boolean selectTargetWithNoTag) {
|
|
||||||
this.selectTargetWithNoTag = selectTargetWithNoTag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the tags that are used to filter for. The activation of this filter
|
* Gets the tags that are used to filter for. The activation of this filter
|
||||||
* is done by {@link #setSelectTargetWithNoTag(Boolean)}.
|
* is done by {@link #setSelectTargetWithNoTag(Boolean)}.
|
||||||
@@ -171,14 +120,4 @@ public class FilterParams {
|
|||||||
public String[] getFilterByTagNames() {
|
public String[] getFilterByTagNames() {
|
||||||
return filterByTagNames;
|
return filterByTagNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the tags that are used to filter for.
|
|
||||||
*
|
|
||||||
* @param filterByTagNames
|
|
||||||
* array of tag names
|
|
||||||
*/
|
|
||||||
public void setFilterByTagNames(String[] filterByTagNames) {
|
|
||||||
this.filterByTagNames = filterByTagNames;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,183 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.validation.ConstraintViolationException;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||||
|
import org.eclipse.hawkbit.repository.model.BaseEntity;
|
||||||
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Slice;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic management methods common to (software) repository content.
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
* type of the {@link BaseEntity}
|
||||||
|
* @param <C>
|
||||||
|
* entity create builder
|
||||||
|
* @param <U>
|
||||||
|
* entity update builder
|
||||||
|
*/
|
||||||
|
public interface RepositoryManagement<T, C, U> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates multiple {@link BaseEntity}s.
|
||||||
|
*
|
||||||
|
* @param creates
|
||||||
|
* to create
|
||||||
|
* @return created Entity
|
||||||
|
*
|
||||||
|
* @throws ConstraintViolationException
|
||||||
|
* if fields are not filled as specified. Check
|
||||||
|
* {@link BaseEntity} for field constraints.
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
|
List<T> create(@NotNull Collection<C> creates);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new {@link SoftwareModuleType}.
|
||||||
|
*
|
||||||
|
* @param create
|
||||||
|
* to create
|
||||||
|
* @return created Entity
|
||||||
|
*
|
||||||
|
* @throws ConstraintViolationException
|
||||||
|
* if fields are not filled as specified. Check
|
||||||
|
* {@link BaseEntity} for field constraints.
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||||
|
T create(@NotNull C create);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates existing {@link BaseEntity}.
|
||||||
|
*
|
||||||
|
* @param update
|
||||||
|
* to update
|
||||||
|
*
|
||||||
|
* @return updated Entity
|
||||||
|
*
|
||||||
|
* @throws EntityReadOnlyException
|
||||||
|
* if the {@link BaseEntity} cannot be updated (e.g. is already
|
||||||
|
* in use)
|
||||||
|
* @throws EntityNotFoundException
|
||||||
|
* in case the {@link BaseEntity} does not exists and cannot be
|
||||||
|
* updated
|
||||||
|
* @throws ConstraintViolationException
|
||||||
|
* if fields are not filled as specified. Check
|
||||||
|
* {@link BaseEntity} for field constraints.
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
|
T update(@NotNull 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.
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* to delete
|
||||||
|
*
|
||||||
|
* @throws EntityNotFoundException
|
||||||
|
* BaseEntity with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
|
void delete(@NotNull Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 delete
|
||||||
|
* if not.
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* to be deleted
|
||||||
|
*
|
||||||
|
* @throws EntityNotFoundException
|
||||||
|
* if (at least one) given distribution set does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||||
|
void delete(@NotEmpty Collection<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all {@link BaseEntity}s without details.
|
||||||
|
*
|
||||||
|
* @param ids
|
||||||
|
* the ids to for
|
||||||
|
* @return the found {@link BaseEntity}s
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
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(@NotNull Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve {@link BaseEntity}
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* to search for
|
||||||
|
* @return {@link BaseEntity} in the repository with given
|
||||||
|
* {@link BaseEntity#getId()}
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Optional<T> get(@NotNull Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves {@link Page} of all {@link BaseEntity} of given type.
|
||||||
|
*
|
||||||
|
* @param pageable
|
||||||
|
* paging parameter
|
||||||
|
* @return all {@link BaseEntity}s in the repository.
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Slice<T> findAll(@NotNull Pageable pageable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all {@link BaseEntity}s with a given specification.
|
||||||
|
*
|
||||||
|
* @param pageable
|
||||||
|
* pagination parameter
|
||||||
|
* @param rsqlParam
|
||||||
|
* filter definition in RSQL syntax
|
||||||
|
*
|
||||||
|
* @return the found {@link BaseEntity}s
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
|
Page<T> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam);
|
||||||
|
}
|
||||||
@@ -34,17 +34,18 @@ public interface RolloutGroupManagement {
|
|||||||
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
||||||
* {@link Rollout} with the detailed status.
|
* {@link Rollout} with the detailed status.
|
||||||
*
|
*
|
||||||
* @param rolloutId
|
|
||||||
* the ID of the rollout to filter the {@link RolloutGroup}s
|
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* the page request to sort and limit the result
|
* the page request to sort and limit the result
|
||||||
|
* @param rolloutId
|
||||||
|
* the ID of the rollout to filter the {@link RolloutGroup}s
|
||||||
|
*
|
||||||
* @return a page of found {@link RolloutGroup}s
|
* @return a page of found {@link RolloutGroup}s
|
||||||
*
|
*
|
||||||
* @throws EntityNotFoundException
|
* @throws EntityNotFoundException
|
||||||
* of rollout with given ID does not exist
|
* of rollout with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Page<RolloutGroup> findAllRolloutGroupsWithDetailedStatus(@NotNull Long rolloutId, @NotNull Pageable pageable);
|
Page<RolloutGroup> findByRolloutWithDetailedStatus(@NotNull Pageable pageable, @NotNull Long rolloutId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -63,7 +64,7 @@ public interface RolloutGroupManagement {
|
|||||||
* if rollout group with given ID does not exist
|
* if rollout group with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||||
Page<TargetWithActionStatus> findAllTargetsWithActionStatus(@NotNull Pageable pageable,
|
Page<TargetWithActionStatus> findAllTargetsOfRolloutGroupWithActionStatus(@NotNull Pageable pageable,
|
||||||
@NotNull Long rolloutGroupId);
|
@NotNull Long rolloutGroupId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,19 +77,20 @@ public interface RolloutGroupManagement {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Optional<RolloutGroup> findRolloutGroupById(@NotNull Long rolloutGroupId);
|
Optional<RolloutGroup> get(@NotNull Long rolloutGroupId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
||||||
* {@link Rollout} and the an rsql filter.
|
* {@link Rollout} and the an rsql filter.
|
||||||
*
|
*
|
||||||
|
* @param pageable
|
||||||
|
* the page request to sort and limit the result
|
||||||
* @param rolloutId
|
* @param rolloutId
|
||||||
* the rollout to filter the {@link RolloutGroup}s
|
* the rollout to filter the {@link RolloutGroup}s
|
||||||
* @param rsqlParam
|
* @param rsqlParam
|
||||||
* the specification to filter the result set based on attributes
|
* the specification to filter the result set based on attributes
|
||||||
* of the {@link RolloutGroup}
|
* of the {@link RolloutGroup}
|
||||||
* @param pageable
|
*
|
||||||
* the page request to sort and limit the result
|
|
||||||
* @return a page of found {@link RolloutGroup}s
|
* @return a page of found {@link RolloutGroup}s
|
||||||
*
|
*
|
||||||
* @throws RSQLParameterUnsupportedFieldException
|
* @throws RSQLParameterUnsupportedFieldException
|
||||||
@@ -98,8 +100,22 @@ public interface RolloutGroupManagement {
|
|||||||
* if the RSQL syntax is wrong
|
* if the RSQL syntax is wrong
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Page<RolloutGroup> findRolloutGroupsAll(@NotNull Long rolloutId, @NotNull String rsqlParam,
|
Page<RolloutGroup> findByRolloutAndRsql(@NotNull Pageable pageable, @NotNull Long rolloutId,
|
||||||
@NotNull Pageable pageable);
|
@NotNull String rsqlParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
||||||
|
* {@link Rollout}.
|
||||||
|
*
|
||||||
|
* @param pageable
|
||||||
|
* the page request to sort and limit the result
|
||||||
|
* @param rolloutId
|
||||||
|
* the ID of the rollout to filter the {@link RolloutGroup}s
|
||||||
|
*
|
||||||
|
* @return a page of found {@link RolloutGroup}s
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
|
Page<RolloutGroup> findByRollout(@NotNull Pageable pageable, @NotNull Long rolloutId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
||||||
@@ -112,28 +128,15 @@ public interface RolloutGroupManagement {
|
|||||||
* @return a page of found {@link RolloutGroup}s
|
* @return a page of found {@link RolloutGroup}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Page<RolloutGroup> findRolloutGroupsByRolloutId(@NotNull Long rolloutId, @NotNull Pageable pageable);
|
long countByRollout(@NotNull Long rolloutId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
|
||||||
* {@link Rollout}.
|
|
||||||
*
|
|
||||||
* @param rolloutId
|
|
||||||
* the ID of the rollout to filter the {@link RolloutGroup}s
|
|
||||||
* @param pageable
|
|
||||||
* the page request to sort and limit the result
|
|
||||||
* @return a page of found {@link RolloutGroup}s
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
|
||||||
long countRolloutGroupsByRolloutId(@NotNull Long rolloutId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get targets of specified rollout group.
|
* Get targets of specified rollout group.
|
||||||
*
|
*
|
||||||
|
* @param pageable
|
||||||
|
* the page request to sort and limit the result
|
||||||
* @param rolloutGroupId
|
* @param rolloutGroupId
|
||||||
* rollout group
|
* rollout group
|
||||||
* @param page
|
|
||||||
* the page request to sort and limit the result
|
|
||||||
*
|
*
|
||||||
* @return Page<Target> list of targets of a rollout group
|
* @return Page<Target> list of targets of a rollout group
|
||||||
*
|
*
|
||||||
@@ -141,17 +144,17 @@ public interface RolloutGroupManagement {
|
|||||||
* if group with ID does not exist
|
* if group with ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||||
Page<Target> findRolloutGroupTargets(@NotNull Long rolloutGroupId, @NotNull Pageable page);
|
Page<Target> findTargetsOfRolloutGroup(@NotNull Pageable pageable, @NotNull Long rolloutGroupId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get targets of specified rollout group.
|
* Get targets of specified rollout group.
|
||||||
*
|
*
|
||||||
|
* @param pageable
|
||||||
|
* the page request to sort and limit the result
|
||||||
* @param rolloutGroupId
|
* @param rolloutGroupId
|
||||||
* rollout group
|
* rollout group
|
||||||
* @param rsqlParam
|
* @param rsqlParam
|
||||||
* the specification for filtering the targets of a rollout group
|
* the specification for filtering the targets of a rollout group
|
||||||
* @param pageable
|
|
||||||
* the page request to sort and limit the result
|
|
||||||
*
|
*
|
||||||
* @return Page<Target> list of targets of a rollout group
|
* @return Page<Target> list of targets of a rollout group
|
||||||
*
|
*
|
||||||
@@ -162,8 +165,8 @@ public interface RolloutGroupManagement {
|
|||||||
* if the RSQL syntax is wrong
|
* if the RSQL syntax is wrong
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||||
Page<Target> findRolloutGroupTargets(@NotNull Long rolloutGroupId, @NotNull String rsqlParam,
|
Page<Target> findTargetsOfRolloutGroupByRsql(@NotNull Pageable pageable, @NotNull Long rolloutGroupId,
|
||||||
@NotNull Pageable pageable);
|
@NotNull String rsqlParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get {@link RolloutGroup} by Id.
|
* Get {@link RolloutGroup} by Id.
|
||||||
@@ -174,7 +177,7 @@ public interface RolloutGroupManagement {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Optional<RolloutGroup> findRolloutGroupWithDetailedStatus(@NotNull Long rolloutGroupId);
|
Optional<RolloutGroup> getWithDetailedStatus(@NotNull Long rolloutGroupId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count targets of rollout group.
|
* Count targets of rollout group.
|
||||||
@@ -187,5 +190,5 @@ public interface RolloutGroupManagement {
|
|||||||
* if rollout group with given ID does not exist
|
* if rollout group with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Long countTargetsOfRolloutsGroup(@NotNull Long rolloutGroupId);
|
long countTargetsOfRolloutsGroup(@NotNull Long rolloutGroupId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public interface RolloutManagement {
|
|||||||
* For {@link RolloutStatus#READY} that means switching to
|
* For {@link RolloutStatus#READY} that means switching to
|
||||||
* {@link RolloutStatus#STARTING} if the {@link Rollout#getStartAt()} is set
|
* {@link RolloutStatus#STARTING} if the {@link Rollout#getStartAt()} is set
|
||||||
* and time of calling this method is beyond this point in time. This auto
|
* and time of calling this method is beyond this point in time. This auto
|
||||||
* start mechanism is optional. Call {@link #startRollout(Long)} otherwise.
|
* start mechanism is optional. Call {@link #start(Long)} otherwise.
|
||||||
*
|
*
|
||||||
* For {@link RolloutStatus#STARTING} that means starting the first
|
* For {@link RolloutStatus#STARTING} that means starting the first
|
||||||
* {@link RolloutGroup}s in line and when finished switch to
|
* {@link RolloutGroup}s in line and when finished switch to
|
||||||
@@ -81,7 +81,7 @@ public interface RolloutManagement {
|
|||||||
* @return number of roll outs
|
* @return number of roll outs
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Long countRolloutsAll();
|
long count();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count rollouts by given text in name or description.
|
* Count rollouts by given text in name or description.
|
||||||
@@ -91,7 +91,7 @@ public interface RolloutManagement {
|
|||||||
* @return total count rollouts for specified filter text.
|
* @return total count rollouts for specified filter text.
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Long countRolloutsAllByFilters(@NotEmpty String searchText);
|
long countByFilters(@NotEmpty String searchText);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persists a new rollout entity. The filter within the
|
* Persists a new rollout entity. The filter within the
|
||||||
@@ -107,7 +107,7 @@ public interface RolloutManagement {
|
|||||||
* The RolloutScheduler will start to assign targets to the groups. Once all
|
* The RolloutScheduler will start to assign targets to the groups. Once all
|
||||||
* targets have been assigned to the groups, the rollout status is changed
|
* targets have been assigned to the groups, the rollout status is changed
|
||||||
* to {@link RolloutStatus#READY} so it can be started with
|
* to {@link RolloutStatus#READY} so it can be started with
|
||||||
* {@link #startRollout(Rollout)}.
|
* {@link #start(Rollout)}.
|
||||||
*
|
*
|
||||||
* @param create
|
* @param create
|
||||||
* the rollout entity to create
|
* the rollout entity to create
|
||||||
@@ -124,7 +124,7 @@ public interface RolloutManagement {
|
|||||||
* if rollout or group parameters are invalid.
|
* if rollout or group parameters are invalid.
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||||
Rollout createRollout(@NotNull RolloutCreate create, int amountGroup, @NotNull RolloutGroupConditions conditions);
|
Rollout create(@NotNull RolloutCreate create, int amountGroup, @NotNull RolloutGroupConditions conditions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persists a new rollout entity. The filter within the
|
* Persists a new rollout entity. The filter within the
|
||||||
@@ -140,7 +140,7 @@ public interface RolloutManagement {
|
|||||||
* The RolloutScheduler will start to assign targets to the groups. Once all
|
* The RolloutScheduler will start to assign targets to the groups. Once all
|
||||||
* targets have been assigned to the groups, the rollout status is changed
|
* targets have been assigned to the groups, the rollout status is changed
|
||||||
* to {@link RolloutStatus#READY} so it can be started with
|
* to {@link RolloutStatus#READY} so it can be started with
|
||||||
* {@link #startRollout(Rollout)}.
|
* {@link #start(Rollout)}.
|
||||||
*
|
*
|
||||||
* @param rollout
|
* @param rollout
|
||||||
* the rollout entity to create
|
* the rollout entity to create
|
||||||
@@ -158,7 +158,7 @@ public interface RolloutManagement {
|
|||||||
* if rollout or group parameters are invalid
|
* if rollout or group parameters are invalid
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||||
Rollout createRollout(@NotNull RolloutCreate rollout, @NotNull List<RolloutGroupCreate> groups,
|
Rollout create(@NotNull RolloutCreate rollout, @NotNull List<RolloutGroupCreate> groups,
|
||||||
RolloutGroupConditions conditions);
|
RolloutGroupConditions conditions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -205,17 +205,18 @@ public interface RolloutManagement {
|
|||||||
* statuses
|
* statuses
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Page<Rollout> findAllRolloutsWithDetailedStatus(@NotNull Pageable pageable, boolean deleted);
|
Page<Rollout> findAllWithDetailedStatus(@NotNull Pageable pageable, boolean deleted);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all rollouts found by the given specification.
|
* Retrieves all rollouts found by the given specification.
|
||||||
*
|
*
|
||||||
* @param rsqlParam
|
|
||||||
* the specification to filter rollouts
|
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* the page request to sort and limit the result
|
* the page request to sort and limit the result
|
||||||
|
* @param rsqlParam
|
||||||
|
* the specification to filter rollouts
|
||||||
* @param deleted
|
* @param deleted
|
||||||
* flag if deleted rollouts should be included
|
* flag if deleted rollouts should be included
|
||||||
|
*
|
||||||
* @return a page of found rollouts
|
* @return a page of found rollouts
|
||||||
*
|
*
|
||||||
* @throws RSQLParameterUnsupportedFieldException
|
* @throws RSQLParameterUnsupportedFieldException
|
||||||
@@ -225,7 +226,7 @@ public interface RolloutManagement {
|
|||||||
* if the RSQL syntax is wrong
|
* if the RSQL syntax is wrong
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Page<Rollout> findAllByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable, boolean deleted);
|
Page<Rollout> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam, boolean deleted);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds rollouts by given text in name or description.
|
* Finds rollouts by given text in name or description.
|
||||||
@@ -240,7 +241,7 @@ public interface RolloutManagement {
|
|||||||
* not exists
|
* not exists
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Slice<Rollout> findRolloutWithDetailedStatusByFilters(@NotNull Pageable pageable, @NotEmpty String searchText,
|
Slice<Rollout> findByFiltersWithDetailedStatus(@NotNull Pageable pageable, @NotEmpty String searchText,
|
||||||
boolean deleted);
|
boolean deleted);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -252,7 +253,7 @@ public interface RolloutManagement {
|
|||||||
* not exists
|
* not exists
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Optional<Rollout> findRolloutById(@NotNull Long rolloutId);
|
Optional<Rollout> get(@NotNull Long rolloutId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a specific rollout by its name.
|
* Retrieves a specific rollout by its name.
|
||||||
@@ -263,7 +264,7 @@ public interface RolloutManagement {
|
|||||||
* does not exists
|
* does not exists
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Optional<Rollout> findRolloutByName(@NotEmpty String rolloutName);
|
Optional<Rollout> getByName(@NotEmpty String rolloutName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get count of targets in different status in rollout.
|
* Get count of targets in different status in rollout.
|
||||||
@@ -277,7 +278,7 @@ public interface RolloutManagement {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||||
Optional<Rollout> findRolloutWithDetailedStatus(@NotNull Long rolloutId);
|
Optional<Rollout> getWithDetailedStatus(@NotNull Long rolloutId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if rollout with given ID exists.
|
* Checks if rollout with given ID exists.
|
||||||
@@ -350,7 +351,7 @@ public interface RolloutManagement {
|
|||||||
* ready rollouts can be started.
|
* ready rollouts can be started.
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||||
Rollout startRollout(@NotNull Long rolloutId);
|
Rollout start(@NotNull Long rolloutId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update rollout details.
|
* Update rollout details.
|
||||||
@@ -368,7 +369,7 @@ public interface RolloutManagement {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||||
Rollout updateRollout(@NotNull RolloutUpdate update);
|
Rollout update(@NotNull RolloutUpdate update);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a rollout. A rollout might be deleted asynchronously by
|
* Deletes a rollout. A rollout might be deleted asynchronously by
|
||||||
@@ -379,6 +380,6 @@ public interface RolloutManagement {
|
|||||||
* the ID of the rollout to be deleted
|
* the ID of the rollout to be deleted
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||||
void deleteRollout(long rolloutId);
|
void delete(@NotNull Long rolloutId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.validation.ConstraintViolationException;
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||||
@@ -38,7 +37,8 @@ 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> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts {@link SoftwareModule}s with given
|
* Counts {@link SoftwareModule}s with given
|
||||||
@@ -55,51 +55,7 @@ public interface SoftwareModuleManagement {
|
|||||||
* if software module type with given ID does not exist
|
* if software module type with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Long countSoftwareModuleByFilters(String searchText, Long typeId);
|
long countByTextAndType(String searchText, Long typeId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Count all {@link SoftwareModule}s in the repository that are not marked
|
|
||||||
* as deleted.
|
|
||||||
*
|
|
||||||
* @return number of {@link SoftwareModule}s
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Long countSoftwareModulesAll();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create {@link SoftwareModule}s in the repository.
|
|
||||||
*
|
|
||||||
* @param creates
|
|
||||||
* {@link SoftwareModule}s to create
|
|
||||||
* @return SoftwareModule
|
|
||||||
*
|
|
||||||
* @throws EntityAlreadyExistsException
|
|
||||||
* if a given entity already exists
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* of given software module type does not exist
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link SoftwareModuleCreate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
|
||||||
List<SoftwareModule> createSoftwareModule(@NotNull Collection<SoftwareModuleCreate> creates);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param create
|
|
||||||
* SoftwareModule to create
|
|
||||||
* @return SoftwareModule
|
|
||||||
*
|
|
||||||
* @throws EntityAlreadyExistsException
|
|
||||||
* if a given entity already exists
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* of given software module type does not exist
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link SoftwareModuleCreate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
|
||||||
SoftwareModule createSoftwareModule(@NotNull SoftwareModuleCreate create);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a list of software module meta data entries.
|
* creates a list of software module meta data entries.
|
||||||
@@ -116,8 +72,7 @@ public interface SoftwareModuleManagement {
|
|||||||
* if software module with given ID does not exist
|
* if software module with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
List<SoftwareModuleMetadata> createSoftwareModuleMetadata(@NotNull Long moduleId,
|
List<SoftwareModuleMetadata> createMetaData(@NotNull Long moduleId, @NotNull Collection<MetaData> metadata);
|
||||||
@NotNull Collection<MetaData> metadata);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates or updates a single software module meta data entry.
|
* creates or updates a single software module meta data entry.
|
||||||
@@ -134,16 +89,7 @@ public interface SoftwareModuleManagement {
|
|||||||
* if software module with given ID does not exist
|
* if software module with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
SoftwareModuleMetadata createSoftwareModuleMetadata(@NotNull Long moduleId, @NotNull MetaData metadata);
|
SoftwareModuleMetadata createMetaData(@NotNull Long moduleId, @NotNull MetaData metadata);
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes the given {@link SoftwareModule} Entity.
|
|
||||||
*
|
|
||||||
* @param moduleId
|
|
||||||
* is the {@link SoftwareModule} to be deleted
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
|
||||||
void deleteSoftwareModule(@NotNull Long moduleId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deletes a software module meta data entry.
|
* deletes a software module meta data entry.
|
||||||
@@ -157,19 +103,7 @@ public interface SoftwareModuleManagement {
|
|||||||
* of module or metadata entry does not exist
|
* of module or metadata entry does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
void deleteSoftwareModuleMetadata(@NotNull Long moduleId, @NotEmpty String key);
|
void deleteMetaData(@NotNull Long moduleId, @NotEmpty String key);
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes {@link SoftwareModule}s which is any if the given ids.
|
|
||||||
*
|
|
||||||
* @param moduleIds
|
|
||||||
* of the Software Modules to be deleted
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if (at least one) module with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
|
||||||
void deleteSoftwareModules(@NotNull Collection<Long> moduleIds);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param pageable
|
* @param pageable
|
||||||
@@ -183,7 +117,7 @@ public interface SoftwareModuleManagement {
|
|||||||
* if distribution set with given ID does not exist
|
* if distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<SoftwareModule> findSoftwareModuleByAssignedTo(@NotNull Pageable pageable, @NotNull Long setId);
|
Page<SoftwareModule> findByAssignedTo(@NotNull Pageable pageable, @NotNull Long setId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter {@link SoftwareModule}s with given
|
* Filter {@link SoftwareModule}s with given
|
||||||
@@ -202,30 +136,7 @@ public interface SoftwareModuleManagement {
|
|||||||
* if given software module type does not exist
|
* if given software module type does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Slice<SoftwareModule> findSoftwareModuleByFilters(@NotNull Pageable pageable, String searchText, Long typeId);
|
Slice<SoftwareModule> findByTextAndType(@NotNull Pageable pageable, String searchText, Long typeId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds {@link SoftwareModuleType} by given id.
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
* to search for
|
|
||||||
* @return the found {@link SoftwareModuleType}s
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
|
||||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
|
||||||
List<SoftwareModuleType> findSoftwareModuleTypesById(@NotEmpty Collection<Long> ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds {@link SoftwareModule} by given id.
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* to search for
|
|
||||||
* @return the found {@link SoftwareModule}s
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
|
||||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
|
||||||
Optional<SoftwareModule> findSoftwareModuleById(@NotNull Long id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieves {@link SoftwareModule} by their name AND version AND type..
|
* retrieves {@link SoftwareModule} by their name AND version AND type..
|
||||||
@@ -242,7 +153,7 @@ public interface SoftwareModuleManagement {
|
|||||||
* if software module type with given ID does not exist
|
* if software module type with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<SoftwareModule> findSoftwareModuleByNameAndVersion(@NotEmpty String name, @NotEmpty String version,
|
Optional<SoftwareModule> getByNameAndVersionAndType(@NotEmpty String name, @NotEmpty String version,
|
||||||
@NotNull Long typeId);
|
@NotNull Long typeId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -258,15 +169,16 @@ public interface SoftwareModuleManagement {
|
|||||||
* is module with given ID does not exist
|
* is module with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<SoftwareModuleMetadata> findSoftwareModuleMetadata(@NotNull Long moduleId, @NotEmpty String key);
|
Optional<SoftwareModuleMetadata> getMetaDataBySoftwareModuleId(@NotNull Long moduleId, @NotEmpty String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds all meta data by the given software module id.
|
* finds all meta data by the given software module id.
|
||||||
*
|
*
|
||||||
* @param swId
|
|
||||||
* the software module id to retrieve the meta data from
|
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* the page request to page the result
|
* the page request to page the result
|
||||||
|
* @param moduleId
|
||||||
|
* the software module id to retrieve the meta data from
|
||||||
|
*
|
||||||
* @return a paged result of all meta data entries for a given software
|
* @return a paged result of all meta data entries for a given software
|
||||||
* module id
|
* module id
|
||||||
*
|
*
|
||||||
@@ -274,18 +186,18 @@ public interface SoftwareModuleManagement {
|
|||||||
* if software module with given ID does not exist
|
* if software module with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long swId,
|
Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleId(@NotNull Pageable pageable, @NotNull Long moduleId);
|
||||||
@NotNull Pageable pageable);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds all meta data by the given software module id.
|
* finds all meta data by the given software module id.
|
||||||
*
|
*
|
||||||
|
* @param pageable
|
||||||
|
* the page request to page the result
|
||||||
* @param moduleId
|
* @param moduleId
|
||||||
* the software module id to retrieve the meta data from
|
* the software module id to retrieve the meta data from
|
||||||
* @param rsqlParam
|
* @param rsqlParam
|
||||||
* filter definition in RSQL syntax
|
* 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
|
* @return a paged result of all meta data entries for a given software
|
||||||
* module id
|
* module id
|
||||||
*
|
*
|
||||||
@@ -298,25 +210,8 @@ public interface SoftwareModuleManagement {
|
|||||||
* if software module with given ID does not exist
|
* if software module with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long moduleId,
|
Page<SoftwareModuleMetadata> findMetaDataByRsql(@NotNull Pageable pageable, @NotNull Long moduleId,
|
||||||
@NotNull String rsqlParam, @NotNull Pageable pageable);
|
@NotNull String rsqlParam);
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds all meta data by the given software module id.
|
|
||||||
*
|
|
||||||
* @param pageable
|
|
||||||
* pagination parameter
|
|
||||||
*
|
|
||||||
* @param moduleId
|
|
||||||
* the software module id to retrieve the meta data from
|
|
||||||
* @return page with found software module metadata
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* of software module with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Pageable pageable,
|
|
||||||
@NotNull Long moduleId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter {@link SoftwareModule}s with given
|
* Filter {@link SoftwareModule}s with given
|
||||||
@@ -342,48 +237,9 @@ public interface SoftwareModuleManagement {
|
|||||||
* if given software module type does not exist
|
* if given software module type does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Slice<AssignedSoftwareModule> findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
Slice<AssignedSoftwareModule> findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
||||||
@NotNull Pageable pageable, @NotNull Long orderByDistributionId, String searchText, Long typeId);
|
@NotNull Pageable pageable, @NotNull Long orderByDistributionId, String searchText, Long typeId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves all software modules. Deleted ones are filtered.
|
|
||||||
*
|
|
||||||
* @param pageable
|
|
||||||
* pagination parameter
|
|
||||||
* @return the found {@link SoftwareModule}s
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Slice<SoftwareModule> findSoftwareModulesAll(@NotNull Pageable pageable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves all software modules with a given list of ids
|
|
||||||
* {@link SoftwareModule#getId()}.
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
* to search for
|
|
||||||
* @return {@link List} of found {@link SoftwareModule}s
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
List<SoftwareModule> findSoftwareModulesById(@NotEmpty Collection<Long> ids);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves all {@link SoftwareModule}s with a given specification.
|
|
||||||
*
|
|
||||||
* @param rsqlParam
|
|
||||||
* filter definition in RSQL syntax
|
|
||||||
* @param pageable
|
|
||||||
* pagination parameter
|
|
||||||
* @return the found {@link SoftwareModule}s
|
|
||||||
*
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<SoftwareModule> findSoftwareModulesByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieves the {@link SoftwareModule}s by their {@link SoftwareModuleType}
|
* retrieves the {@link SoftwareModule}s by their {@link SoftwareModuleType}
|
||||||
* .
|
* .
|
||||||
@@ -398,29 +254,7 @@ public interface SoftwareModuleManagement {
|
|||||||
* if software module type with given ID does not exist
|
* if software module type with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Slice<SoftwareModule> findSoftwareModulesByType(@NotNull Pageable pageable, @NotNull Long typeId);
|
Slice<SoftwareModule> findByType(@NotNull Pageable pageable, @NotNull Long typeId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates existing {@link SoftwareModule}. Update-able values are
|
|
||||||
* {@link SoftwareModule#getDescription()}
|
|
||||||
* {@link SoftwareModule#getVendor()}.
|
|
||||||
*
|
|
||||||
* @param update
|
|
||||||
* contains properties to update
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if given module does not exist
|
|
||||||
*
|
|
||||||
* @return the saved Entity.
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if given {@link SoftwareModule} does not exist
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link SoftwareModuleUpdate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
|
||||||
SoftwareModule updateSoftwareModule(@NotNull SoftwareModuleUpdate update);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updates a distribution set meta data value if corresponding entry exists.
|
* updates a distribution set meta data value if corresponding entry exists.
|
||||||
@@ -437,5 +271,5 @@ public interface SoftwareModuleManagement {
|
|||||||
* updated
|
* updated
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||||
SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull Long moduleId, @NotNull MetaData metadata);
|
SoftwareModuleMetadata updateMetaData(@NotNull Long moduleId, @NotNull MetaData metadata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,86 +8,21 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository;
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.validation.ConstraintViolationException;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate;
|
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate;
|
||||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeUpdate;
|
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeUpdate;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for managing {@link SoftwareModuleType}s.
|
* Service for managing {@link SoftwareModuleType}s.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface SoftwareModuleTypeManagement {
|
public interface SoftwareModuleTypeManagement
|
||||||
|
extends RepositoryManagement<SoftwareModuleType, SoftwareModuleTypeCreate, SoftwareModuleTypeUpdate> {
|
||||||
/**
|
|
||||||
* @return number of {@link SoftwareModuleType}s in the repository.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Long countSoftwareModuleTypesAll();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates multiple {@link SoftwareModuleType}s.
|
|
||||||
*
|
|
||||||
* @param creates
|
|
||||||
* to create
|
|
||||||
* @return created Entity
|
|
||||||
*
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link SoftwareModuleTypeCreate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
|
||||||
List<SoftwareModuleType> createSoftwareModuleType(@NotNull Collection<SoftwareModuleTypeCreate> creates);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates new {@link SoftwareModuleType}.
|
|
||||||
*
|
|
||||||
* @param create
|
|
||||||
* to create
|
|
||||||
* @return created Entity
|
|
||||||
*
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link SoftwareModuleTypeCreate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
|
||||||
SoftwareModuleType createSoftwareModuleType(@NotNull SoftwareModuleTypeCreate create);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes or marks as delete in case the type is in use.
|
|
||||||
*
|
|
||||||
* @param typeId
|
|
||||||
* to delete
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* not found is type with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
|
||||||
void deleteSoftwareModuleType(@NotNull Long typeId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* to search for
|
|
||||||
* @return {@link SoftwareModuleType} in the repository with given
|
|
||||||
* {@link SoftwareModuleType#getId()}
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Optional<SoftwareModuleType> findSoftwareModuleTypeById(@NotNull Long id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -97,7 +32,7 @@ public interface SoftwareModuleTypeManagement {
|
|||||||
* {@link SoftwareModuleType#getKey()}
|
* {@link SoftwareModuleType#getKey()}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<SoftwareModuleType> findSoftwareModuleTypeByKey(@NotEmpty String key);
|
Optional<SoftwareModuleType> getByKey(@NotEmpty String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -107,50 +42,5 @@ public interface SoftwareModuleTypeManagement {
|
|||||||
* {@link SoftwareModuleType#getName()}
|
* {@link SoftwareModuleType#getName()}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Optional<SoftwareModuleType> findSoftwareModuleTypeByName(@NotEmpty String name);
|
Optional<SoftwareModuleType> getByName(@NotEmpty String name);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param pageable
|
|
||||||
* parameter
|
|
||||||
* @return all {@link SoftwareModuleType}s in the repository.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull Pageable pageable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves all {@link SoftwareModuleType}s with a given specification.
|
|
||||||
*
|
|
||||||
* @param rsqlParam
|
|
||||||
* filter definition in RSQL syntax
|
|
||||||
* @param pageable
|
|
||||||
* pagination parameter
|
|
||||||
* @return the found {@link SoftwareModuleType}s
|
|
||||||
*
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates existing {@link SoftwareModuleType}.
|
|
||||||
*
|
|
||||||
* @param update
|
|
||||||
* to update
|
|
||||||
*
|
|
||||||
* @return updated Entity
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* in case the {@link SoftwareModuleType} does not exists and
|
|
||||||
* cannot be updated
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link SoftwareModuleTypeUpdate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
|
||||||
SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleTypeUpdate update);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,303 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
|
||||||
*
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*/
|
|
||||||
package org.eclipse.hawkbit.repository;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import javax.validation.ConstraintViolationException;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
|
||||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
|
||||||
import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
|
||||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
|
||||||
import org.eclipse.hawkbit.repository.model.Tag;
|
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Management service for {@link Tag}s.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface TagManagement {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* count {@link TargetTag}s.
|
|
||||||
*
|
|
||||||
* @return size of {@link TargetTag}s
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
|
||||||
long countTargetTags();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a {@link DistributionSet}.
|
|
||||||
*
|
|
||||||
* @param create
|
|
||||||
* to be created.
|
|
||||||
* @return the new {@link DistributionSet}
|
|
||||||
*
|
|
||||||
* @throws EntityAlreadyExistsException
|
|
||||||
* if distributionSetTag already exists
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link TagCreate} for field constraints.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
|
||||||
DistributionSetTag createDistributionSetTag(@NotNull TagCreate create);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates multiple {@link DistributionSetTag}s.
|
|
||||||
*
|
|
||||||
* @param creates
|
|
||||||
* to be created
|
|
||||||
* @return the new {@link DistributionSetTag}
|
|
||||||
*
|
|
||||||
* @throws EntityAlreadyExistsException
|
|
||||||
* if a given entity already exists
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link TagCreate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
|
||||||
List<DistributionSetTag> createDistributionSetTags(@NotNull Collection<TagCreate> creates);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new {@link TargetTag}.
|
|
||||||
*
|
|
||||||
* @param create
|
|
||||||
* to be created
|
|
||||||
*
|
|
||||||
* @return the new created {@link TargetTag}
|
|
||||||
*
|
|
||||||
* @throws EntityAlreadyExistsException
|
|
||||||
* if given object already exists
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link TagCreate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
|
||||||
TargetTag createTargetTag(@NotNull TagCreate create);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* created multiple {@link TargetTag}s.
|
|
||||||
*
|
|
||||||
* @param creates
|
|
||||||
* to be created
|
|
||||||
* @return the new created {@link TargetTag}s
|
|
||||||
*
|
|
||||||
* @throws EntityAlreadyExistsException
|
|
||||||
* if given object has already an ID.
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link TagCreate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
|
||||||
List<TargetTag> createTargetTags(@NotNull Collection<TagCreate> creates);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 deleteDistributionSetTag(@NotEmpty String tagName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes {@link TargetTag} with given name.
|
|
||||||
*
|
|
||||||
* @param targetTagName
|
|
||||||
* tag name of the {@link TargetTag} to be deleted
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if tag with given name does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
|
||||||
void deleteTargetTag(@NotEmpty String targetTagName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns all {@link DistributionSetTag}s.
|
|
||||||
*
|
|
||||||
* @param pageReq
|
|
||||||
* page parameter
|
|
||||||
* @return all {@link DistributionSetTag}s
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<DistributionSetTag> findAllDistributionSetTags(@NotNull Pageable pageReq);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves all DistributionSet tags based on the given specification.
|
|
||||||
*
|
|
||||||
* @param rsqlParam
|
|
||||||
* rsql query string
|
|
||||||
* @param pageable
|
|
||||||
* pagination parameter
|
|
||||||
* @return the found {@link DistributionSetTag}s, never {@code null}
|
|
||||||
*
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<DistributionSetTag> findAllDistributionSetTags(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns all {@link TargetTag}s.
|
|
||||||
*
|
|
||||||
* @param pageable
|
|
||||||
* page parameter
|
|
||||||
*
|
|
||||||
* @return all {@link TargetTag}s
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
|
||||||
Page<TargetTag> findAllTargetTags(@NotNull Pageable pageable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all {@link TargetTag}s assigned to {@link Target} with given ID.
|
|
||||||
*
|
|
||||||
* @param pageable
|
|
||||||
* page parameter
|
|
||||||
* @param controllerId
|
|
||||||
*
|
|
||||||
* @return {@link TargetTag}s assigned to {@link Target} with given ID
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if target with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
|
||||||
Page<TargetTag> findAllTargetTags(@NotNull Pageable pageable, @NotEmpty String controllerId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves all target tags based on the given specification.
|
|
||||||
*
|
|
||||||
* @param rsqlParam
|
|
||||||
* rsql query string
|
|
||||||
* @param pageable
|
|
||||||
* pagination parameter
|
|
||||||
* @return the found {@link Target}s, never {@code null}
|
|
||||||
*
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
|
||||||
Page<TargetTag> findAllTargetTags(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find {@link DistributionSet} based on given name.
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* to look for.
|
|
||||||
* @return {@link DistributionSet}
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Optional<DistributionSetTag> findDistributionSetTag(@NotEmpty String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds {@link DistributionSetTag} by given id.
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* to search for
|
|
||||||
* @return the found {@link DistributionSetTag}
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Optional<DistributionSetTag> findDistributionSetTagById(@NotNull Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find {@link TargetTag} based on given Name.
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* to look for.
|
|
||||||
* @return {@link TargetTag}
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
|
||||||
Optional<TargetTag> findTargetTag(@NotEmpty String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds {@link TargetTag} by given id.
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* to search for
|
|
||||||
* @return the found {@link TargetTag}
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
|
||||||
Optional<TargetTag> findTargetTagById(@NotNull Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds all {@link TargetTag} assigned to given {@link Target}.
|
|
||||||
*
|
|
||||||
* @param pageable
|
|
||||||
* information for page size, offset and sort order.
|
|
||||||
*
|
|
||||||
* @param setId
|
|
||||||
* of the {@link DistributionSet}
|
|
||||||
* @return page of the found {@link TargetTag}s
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* if {@link DistributionSet} with given ID does not exist
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
|
||||||
Page<DistributionSetTag> findDistributionSetTagsByDistributionSet(@NotNull Pageable pageable, @NotNull Long setId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates an existing {@link DistributionSetTag}.
|
|
||||||
*
|
|
||||||
* @param update
|
|
||||||
* to be updated
|
|
||||||
*
|
|
||||||
* @return the updated {@link DistributionSet}
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* in case the {@link DistributionSetTag} does not exists and
|
|
||||||
* cannot be updated
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link TagUpdate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
|
||||||
DistributionSetTag updateDistributionSetTag(@NotNull TagUpdate update);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* updates the {@link TargetTag}.
|
|
||||||
*
|
|
||||||
* @param update
|
|
||||||
* the {@link TargetTag} with updated values
|
|
||||||
* @return the updated {@link TargetTag}
|
|
||||||
*
|
|
||||||
* @throws EntityNotFoundException
|
|
||||||
* in case the {@link TargetTag} does not exists and cannot be
|
|
||||||
* updated
|
|
||||||
* @throws ConstraintViolationException
|
|
||||||
* if fields are not filled as specified. Check
|
|
||||||
* {@link TagUpdate} for field constraints.
|
|
||||||
*/
|
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
|
||||||
TargetTag updateTargetTag(@NotNull TagUpdate update);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -41,7 +41,7 @@ public interface TargetFilterQueryManagement {
|
|||||||
* {@link TargetFilterQueryCreate} for field constraints.
|
* {@link TargetFilterQueryCreate} for field constraints.
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||||
TargetFilterQuery createTargetFilterQuery(@NotNull TargetFilterQueryCreate create);
|
TargetFilterQuery create(@NotNull TargetFilterQueryCreate create);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete target filter query.
|
* Delete target filter query.
|
||||||
@@ -53,7 +53,7 @@ public interface TargetFilterQueryManagement {
|
|||||||
* if filter with given ID does not exist
|
* if filter with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||||
void deleteTargetFilterQuery(@NotNull Long targetFilterQueryId);
|
void delete(@NotNull Long targetFilterQueryId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies provided filter syntax.
|
* Verifies provided filter syntax.
|
||||||
@@ -81,7 +81,7 @@ public interface TargetFilterQueryManagement {
|
|||||||
* @return the found {@link TargetFilterQuery}s
|
* @return the found {@link TargetFilterQuery}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Page<TargetFilterQuery> findAllTargetFilterQuery(@NotNull Pageable pageable);
|
Page<TargetFilterQuery> findAll(@NotNull Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts all target filter queries
|
* Counts all target filter queries
|
||||||
@@ -89,7 +89,7 @@ public interface TargetFilterQueryManagement {
|
|||||||
* @return the number of all target filter queries
|
* @return the number of all target filter queries
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Long countAllTargetFilterQuery();
|
long count();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||||
@@ -102,7 +102,7 @@ public interface TargetFilterQueryManagement {
|
|||||||
* @return the page with the found {@link TargetFilterQuery}
|
* @return the page with the found {@link TargetFilterQuery}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Page<TargetFilterQuery> findTargetFilterQueryByName(@NotNull Pageable pageable, @NotNull String name);
|
Page<TargetFilterQuery> findByName(@NotNull Pageable pageable, @NotNull String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||||
@@ -115,7 +115,7 @@ public interface TargetFilterQueryManagement {
|
|||||||
* @return the page with the found {@link TargetFilterQuery}
|
* @return the page with the found {@link TargetFilterQuery}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Page<TargetFilterQuery> findTargetFilterQueryByFilter(@NotNull Pageable pageable, @NotNull String rsqlFilter);
|
Page<TargetFilterQuery> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlFilter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all target filter query which have exactly the provided query.
|
* Retrieves all target filter query which have exactly the provided query.
|
||||||
@@ -127,7 +127,7 @@ public interface TargetFilterQueryManagement {
|
|||||||
* @return the page with the found {@link TargetFilterQuery}
|
* @return the page with the found {@link TargetFilterQuery}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Page<TargetFilterQuery> findTargetFilterQueryByQuery(@NotNull Pageable pageable, @NotNull String query);
|
Page<TargetFilterQuery> findByQuery(@NotNull Pageable pageable, @NotNull String query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||||
@@ -145,7 +145,7 @@ public interface TargetFilterQueryManagement {
|
|||||||
* if DS with given ID does not exist
|
* if DS with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(@NotNull Pageable pageable, @NotNull Long setId,
|
Page<TargetFilterQuery> findByAutoAssignDSAndRsql(@NotNull Pageable pageable, @NotNull Long setId,
|
||||||
String rsqlParam);
|
String rsqlParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,7 +157,7 @@ public interface TargetFilterQueryManagement {
|
|||||||
* @param pageable
|
* @param pageable
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Page<TargetFilterQuery> findTargetFilterQueryWithAutoAssignDS(@NotNull Pageable pageable);
|
Page<TargetFilterQuery> findWithAutoAssignDS(@NotNull Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find target filter query by id.
|
* Find target filter query by id.
|
||||||
@@ -168,7 +168,7 @@ public interface TargetFilterQueryManagement {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Optional<TargetFilterQuery> findTargetFilterQueryById(@NotNull Long targetFilterQueryId);
|
Optional<TargetFilterQuery> get(@NotNull Long targetFilterQueryId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find target filter query by name.
|
* Find target filter query by name.
|
||||||
@@ -179,7 +179,7 @@ public interface TargetFilterQueryManagement {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Optional<TargetFilterQuery> findTargetFilterQueryByName(@NotNull String targetFilterQueryName);
|
Optional<TargetFilterQuery> getByName(@NotNull String targetFilterQueryName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updates the {@link TargetFilterQuery}.
|
* updates the {@link TargetFilterQuery}.
|
||||||
@@ -197,7 +197,7 @@ public interface TargetFilterQueryManagement {
|
|||||||
* {@link TargetFilterQueryUpdate} for field constraints.
|
* {@link TargetFilterQueryUpdate} for field constraints.
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||||
TargetFilterQuery updateTargetFilterQuery(@NotNull TargetFilterQueryUpdate update);
|
TargetFilterQuery update(@NotNull TargetFilterQueryUpdate update);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updates the {@link TargetFilterQuery#getAutoAssignDistributionSet()}.
|
* updates the {@link TargetFilterQuery#getAutoAssignDistributionSet()}.
|
||||||
@@ -213,6 +213,6 @@ public interface TargetFilterQueryManagement {
|
|||||||
* provided but not found
|
* provided but not found
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||||
TargetFilterQuery updateTargetFilterQueryAutoAssignDS(@NotNull Long queryId, Long dsId);
|
TargetFilterQuery updateAutoAssignDS(@NotNull Long queryId, Long dsId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public interface TargetManagement {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||||
+ SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
+ SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Long countTargetByAssignedDistributionSet(@NotNull Long distId);
|
long countByAssignedDistributionSet(@NotNull Long distId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count {@link Target}s for all the given filter parameters.
|
* Count {@link Target}s for all the given filter parameters.
|
||||||
@@ -104,7 +104,7 @@ public interface TargetManagement {
|
|||||||
* if distribution set with given ID does not exist
|
* if distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Long countTargetByFilters(Collection<TargetUpdateStatus> status, Boolean overdueState, String searchText,
|
long countByFilters(Collection<TargetUpdateStatus> status, Boolean overdueState, String searchText,
|
||||||
Long installedOrAssignedDistributionSetId, Boolean selectTargetWithNoTag, String... tagNames);
|
Long installedOrAssignedDistributionSetId, Boolean selectTargetWithNoTag, String... tagNames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,7 +120,7 @@ public interface TargetManagement {
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||||
+ SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
+ SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
Long countTargetByInstalledDistributionSet(@NotNull Long distId);
|
long countByInstalledDistributionSet(@NotNull Long distId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count {@link TargetFilterQuery}s for given target filter query.
|
* Count {@link TargetFilterQuery}s for given target filter query.
|
||||||
@@ -130,7 +130,7 @@ public interface TargetManagement {
|
|||||||
* @return the found number {@link Target}s
|
* @return the found number {@link Target}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Long countTargetByTargetFilterQuery(@NotEmpty String rsqlParam);
|
long countByRsql(@NotEmpty String rsqlParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count {@link TargetFilterQuery}s for given target filter query.
|
* Count {@link TargetFilterQuery}s for given target filter query.
|
||||||
@@ -143,7 +143,7 @@ public interface TargetManagement {
|
|||||||
* if {@link TargetFilterQuery} with given ID does not exist
|
* if {@link TargetFilterQuery} with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Long countTargetByTargetFilterQuery(@NotNull Long targetFilterQueryId);
|
long countByTargetFilterQuery(@NotNull Long targetFilterQueryId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts all {@link Target}s in the repository.
|
* Counts all {@link Target}s in the repository.
|
||||||
@@ -151,7 +151,7 @@ public interface TargetManagement {
|
|||||||
* @return number of targets
|
* @return number of targets
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Long countTargetsAll();
|
long count();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creating a new {@link Target}.
|
* creating a new {@link Target}.
|
||||||
@@ -167,9 +167,8 @@ public interface TargetManagement {
|
|||||||
* {@link TargetCreate} for field constraints.
|
* {@link TargetCreate} for field constraints.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
Target create(@NotNull TargetCreate create);
|
||||||
Target createTarget(@NotNull TargetCreate create);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates multiple {@link Target}s. If some of the given {@link Target}s
|
* creates multiple {@link Target}s. If some of the given {@link Target}s
|
||||||
@@ -188,7 +187,7 @@ public interface TargetManagement {
|
|||||||
* {@link TargetCreate} for field constraints.
|
* {@link TargetCreate} for field constraints.
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||||
List<Target> createTargets(@NotNull Collection<TargetCreate> creates);
|
List<Target> create(@NotNull Collection<TargetCreate> creates);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all targets with the given IDs.
|
* Deletes all targets with the given IDs.
|
||||||
@@ -200,7 +199,7 @@ public interface TargetManagement {
|
|||||||
* if (at least one) of the given target IDs does not exist
|
* if (at least one) of the given target IDs does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||||
void deleteTargets(@NotEmpty Collection<Long> targetIDs);
|
void delete(@NotEmpty Collection<Long> targetIDs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes target with the given IDs.
|
* Deletes target with the given IDs.
|
||||||
@@ -212,7 +211,7 @@ public interface TargetManagement {
|
|||||||
* if target with given ID does not exist
|
* if target with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||||
void deleteTarget(@NotEmpty String controllerID);
|
void deleteByControllerID(@NotEmpty String controllerID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
||||||
@@ -231,8 +230,8 @@ public interface TargetManagement {
|
|||||||
* if distribution set with given ID does not exist
|
* if distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Page<Target> findAllTargetsByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest,
|
Page<Target> findByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest, @NotNull Long distributionSetId,
|
||||||
@NotNull Long distributionSetId, @NotNull String rsqlParam);
|
@NotNull String rsqlParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts all targets for all the given parameter {@link TargetFilterQuery}
|
* Counts all targets for all the given parameter {@link TargetFilterQuery}
|
||||||
@@ -249,7 +248,7 @@ public interface TargetManagement {
|
|||||||
* if distribution set with given ID does not exist
|
* if distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Long countTargetsByTargetFilterQueryAndNonDS(@NotNull Long distributionSetId, @NotNull String rsqlParam);
|
long countByRsqlAndNonDS(@NotNull Long distributionSetId, @NotNull String rsqlParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
||||||
@@ -264,7 +263,7 @@ public interface TargetManagement {
|
|||||||
* @return a page of the found {@link Target}s
|
* @return a page of the found {@link Target}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Page<Target> findAllTargetsByTargetFilterQueryAndNotInRolloutGroups(@NotNull Pageable pageRequest,
|
Page<Target> findByTargetFilterQueryAndNotInRolloutGroups(@NotNull Pageable pageRequest,
|
||||||
@NotEmpty Collection<Long> groups, @NotNull String rsqlParam);
|
@NotEmpty Collection<Long> groups, @NotNull String rsqlParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -278,8 +277,7 @@ public interface TargetManagement {
|
|||||||
* @return count of the found {@link Target}s
|
* @return count of the found {@link Target}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Long countAllTargetsByTargetFilterQueryAndNotInRolloutGroups(@NotEmpty Collection<Long> groups,
|
long countByRsqlAndNotInRolloutGroups(@NotEmpty Collection<Long> groups, @NotNull String rsqlParam);
|
||||||
@NotNull String rsqlParam);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all targets of the provided {@link RolloutGroup} that have no
|
* Finds all targets of the provided {@link RolloutGroup} that have no
|
||||||
@@ -295,37 +293,36 @@ public interface TargetManagement {
|
|||||||
* if rollout group with given ID does not exist
|
* if rollout group with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Page<Target> findAllTargetsInRolloutGroupWithoutAction(@NotNull Pageable pageRequest, @NotNull Long group);
|
Page<Target> findByInRolloutGroupWithoutAction(@NotNull Pageable pageRequest, @NotNull Long group);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
* retrieves {@link Target}s by the assigned {@link DistributionSet}.
|
||||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
*
|
||||||
* possible.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param distributionSetID
|
|
||||||
* the ID of the {@link DistributionSet}
|
|
||||||
* @param pageReq
|
* @param pageReq
|
||||||
* page parameter
|
* page parameter
|
||||||
|
* @param distributionSetID
|
||||||
|
* the ID of the {@link DistributionSet}
|
||||||
|
*
|
||||||
|
*
|
||||||
* @return the found {@link Target}s
|
* @return the found {@link Target}s
|
||||||
*
|
*
|
||||||
* @throws EntityNotFoundException
|
* @throws EntityNotFoundException
|
||||||
* if distribution set with given ID does not exist
|
* if distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||||
Page<Target> findTargetByAssignedDistributionSet(@NotNull Long distributionSetID, @NotNull Pageable pageReq);
|
Page<Target> findByAssignedDistributionSet(@NotNull Pageable pageReq, @NotNull Long distributionSetID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
* Retrieves {@link Target}s by the assigned {@link DistributionSet}
|
||||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
|
||||||
* possible including additional filtering based on the given {@code spec}.
|
* possible including additional filtering based on the given {@code spec}.
|
||||||
*
|
*
|
||||||
|
* @param pageReq
|
||||||
|
* page parameter
|
||||||
* @param distributionSetID
|
* @param distributionSetID
|
||||||
* the ID of the {@link DistributionSet}
|
* the ID of the {@link DistributionSet}
|
||||||
* @param rsqlParam
|
* @param rsqlParam
|
||||||
* the specification to filter the result set
|
* the specification to filter the result set
|
||||||
* @param pageReq
|
*
|
||||||
* page parameter
|
|
||||||
* @return the found {@link Target}s, never {@code null}
|
* @return the found {@link Target}s, never {@code null}
|
||||||
* @throws RSQLParameterUnsupportedFieldException
|
* @throws RSQLParameterUnsupportedFieldException
|
||||||
* if a field in the RSQL string is used but not provided by the
|
* if a field in the RSQL string is used but not provided by the
|
||||||
@@ -336,20 +333,18 @@ public interface TargetManagement {
|
|||||||
* if distribution set with given ID does not exist
|
* if distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||||
Page<Target> findTargetByAssignedDistributionSet(@NotNull Long distributionSetID, @NotNull String rsqlParam,
|
Page<Target> findByAssignedDistributionSetAndRsql(@NotNull Pageable pageReq, @NotNull Long distributionSetID,
|
||||||
@NotNull Pageable pageReq);
|
@NotNull String rsqlParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find {@link Target}s based a given IDs. The returned target will not
|
* Find {@link Target}s based a given IDs.
|
||||||
* contain details (e.g {@link Target#getTags()} and
|
|
||||||
* {@link Target#getActions()})
|
|
||||||
*
|
*
|
||||||
* @param controllerIDs
|
* @param controllerIDs
|
||||||
* to look for.
|
* to look for.
|
||||||
* @return List of found{@link Target}s
|
* @return List of found{@link Target}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
List<Target> findTargetsByControllerID(@NotEmpty Collection<String> controllerIDs);
|
List<Target> getByControllerID(@NotEmpty Collection<String> controllerIDs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a {@link Target} based a given ID.
|
* Find a {@link Target} based a given ID.
|
||||||
@@ -359,7 +354,7 @@ public interface TargetManagement {
|
|||||||
* @return {@link Target}
|
* @return {@link Target}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Optional<Target> findTargetByControllerID(@NotEmpty String controllerId);
|
Optional<Target> getByControllerID(@NotEmpty String controllerId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter {@link Target}s for all the given parameters. If all parameters
|
* Filter {@link Target}s for all the given parameters. If all parameters
|
||||||
@@ -367,25 +362,9 @@ public interface TargetManagement {
|
|||||||
*
|
*
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* page parameters
|
* page parameters
|
||||||
* @param status
|
* @param filterParams
|
||||||
* find targets having this {@link TargetUpdateStatus}s. Set to
|
* the filters to apply; only filters are enabled that have
|
||||||
* <code>null</code> in case this is not required.
|
* non-null value; filters are AND-gated
|
||||||
* @param overdueState
|
|
||||||
* find targets that are overdue (targets that did not respond
|
|
||||||
* during the configured intervals: poll_itvl + overdue_itvl).
|
|
||||||
* @param searchText
|
|
||||||
* to find targets having the text anywhere in name or
|
|
||||||
* description. Set <code>null</code> in case this is not
|
|
||||||
* required.
|
|
||||||
* @param installedOrAssignedDistributionSetId
|
|
||||||
* to find targets having the {@link DistributionSet} as
|
|
||||||
* installed or assigned. Set to <code>null</code> in case this
|
|
||||||
* is not required.
|
|
||||||
* @param tagNames
|
|
||||||
* to find targets which are having any one in this tag names.
|
|
||||||
* Set <code>null</code> in case this is not required.
|
|
||||||
* @param selectTargetWithNoTag
|
|
||||||
* flag to select targets with no tag assigned
|
|
||||||
*
|
*
|
||||||
* @return the found {@link Target}s
|
* @return the found {@link Target}s
|
||||||
*
|
*
|
||||||
@@ -393,38 +372,35 @@ public interface TargetManagement {
|
|||||||
* if distribution set with given ID does not exist
|
* if distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Slice<Target> findTargetByFilters(@NotNull Pageable pageable, Collection<TargetUpdateStatus> status,
|
Slice<Target> findByFilters(@NotNull Pageable pageable, @NotNull FilterParams filterParams);
|
||||||
Boolean overdueState, String searchText, Long installedOrAssignedDistributionSetId,
|
|
||||||
Boolean selectTargetWithNoTag, String... tagNames);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieves {@link Target}s by the installed {@link DistributionSet}without
|
* retrieves {@link Target}s by the installed {@link DistributionSet}.
|
||||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
*
|
||||||
* possible.
|
|
||||||
*
|
|
||||||
* @param distributionSetID
|
|
||||||
* the ID of the {@link DistributionSet}
|
|
||||||
* @param pageReq
|
* @param pageReq
|
||||||
* page parameter
|
* page parameter
|
||||||
|
* @param distributionSetID
|
||||||
|
* the ID of the {@link DistributionSet}
|
||||||
|
*
|
||||||
* @return the found {@link Target}s
|
* @return the found {@link Target}s
|
||||||
*
|
*
|
||||||
* @throws EntityNotFoundException
|
* @throws EntityNotFoundException
|
||||||
* if distribution set with given ID does not exist
|
* if distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||||
Page<Target> findTargetByInstalledDistributionSet(@NotNull Long distributionSetID, @NotNull Pageable pageReq);
|
Page<Target> findByInstalledDistributionSet(@NotNull Pageable pageReq, @NotNull Long distributionSetID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieves {@link Target}s by the installed {@link DistributionSet}without
|
* retrieves {@link Target}s by the installed {@link DistributionSet}
|
||||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
* including additional filtering based on the given {@code spec}.
|
||||||
* possible including additional filtering based on the given {@code spec}.
|
*
|
||||||
*
|
* @param pageReq
|
||||||
|
* page parameter
|
||||||
* @param distributionSetId
|
* @param distributionSetId
|
||||||
* the ID of the {@link DistributionSet}
|
* the ID of the {@link DistributionSet}
|
||||||
* @param rsqlParam
|
* @param rsqlParam
|
||||||
* the specification to filter the result
|
* the specification to filter the result
|
||||||
* @param pageReq
|
*
|
||||||
* page parameter
|
|
||||||
* @return the found {@link Target}s, never {@code null}
|
* @return the found {@link Target}s, never {@code null}
|
||||||
*
|
*
|
||||||
* @throws RSQLParameterUnsupportedFieldException
|
* @throws RSQLParameterUnsupportedFieldException
|
||||||
@@ -437,13 +413,12 @@ public interface TargetManagement {
|
|||||||
* if distribution set with given ID does not exist
|
* if distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||||
Page<Target> findTargetByInstalledDistributionSet(@NotNull Long distributionSetId, @NotNull String rsqlParam,
|
Page<Target> findByInstalledDistributionSetAndRsql(@NotNull Pageable pageReq, @NotNull Long distributionSetId,
|
||||||
@NotNull Pageable pageReq);
|
@NotNull String rsqlParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the {@link Target} which have a certain
|
* Retrieves the {@link Target} which have a certain
|
||||||
* {@link TargetUpdateStatus} without details, i.e. NO
|
* {@link TargetUpdateStatus}.
|
||||||
* {@link Target#getTags()} and {@link Target#getActions()} possible.
|
|
||||||
*
|
*
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* page parameter
|
* page parameter
|
||||||
@@ -452,29 +427,25 @@ public interface TargetManagement {
|
|||||||
* @return the found {@link Target}s
|
* @return the found {@link Target}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Page<Target> findTargetByUpdateStatus(@NotNull Pageable pageable, @NotNull TargetUpdateStatus status);
|
Page<Target> findByUpdateStatus(@NotNull Pageable pageable, @NotNull TargetUpdateStatus status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
|
* Retrieves all targets.
|
||||||
* and {@link Target#getActions()} possible
|
|
||||||
*
|
*
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* pagination parameter
|
* pagination parameter
|
||||||
* @return the found {@link Target}s
|
* @return the found {@link Target}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Slice<Target> findTargetsAll(@NotNull Pageable pageable);
|
Slice<Target> findAll(@NotNull Pageable pageable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
|
* Retrieves all targets.
|
||||||
* and {@link Target#getActions()} possible based on
|
|
||||||
* {@link TargetFilterQuery#getQuery()}
|
|
||||||
*
|
|
||||||
* @param rsqlParam
|
|
||||||
* in RSQL notation
|
|
||||||
*
|
*
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* pagination parameter
|
* pagination parameter
|
||||||
|
* @param rsqlParam
|
||||||
|
* in RSQL notation
|
||||||
*
|
*
|
||||||
* @return the found {@link Target}s, never {@code null}
|
* @return the found {@link Target}s, never {@code null}
|
||||||
*
|
*
|
||||||
@@ -486,17 +457,15 @@ public interface TargetManagement {
|
|||||||
* if the RSQL syntax is wrong
|
* if the RSQL syntax is wrong
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Page<Target> findTargetsAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
Page<Target> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
|
* Retrieves all target based on {@link TargetFilterQuery}.
|
||||||
* and {@link Target#getActions()} possible based on
|
*
|
||||||
* {@link TargetFilterQuery#getQuery()}
|
|
||||||
*
|
|
||||||
* @param targetFilterQueryId
|
|
||||||
* {@link TargetFilterQuery#getId()}
|
|
||||||
* @param pageable
|
* @param pageable
|
||||||
* pagination parameter
|
* pagination parameter
|
||||||
|
* @param targetFilterQueryId
|
||||||
|
* {@link TargetFilterQuery#getId()}
|
||||||
*
|
*
|
||||||
* @return the found {@link Target}s, never {@code null}
|
* @return the found {@link Target}s, never {@code null}
|
||||||
*
|
*
|
||||||
@@ -509,7 +478,7 @@ public interface TargetManagement {
|
|||||||
* if the RSQL syntax is wrong
|
* if the RSQL syntax is wrong
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Slice<Target> findTargetsByTargetFilterQuery(@NotNull Long targetFilterQueryId, @NotNull Pageable pageable);
|
Slice<Target> findByTargetFilterQuery(@NotNull Pageable pageable, @NotNull Long targetFilterQueryId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* method retrieves all {@link Target}s from the repo in the following
|
* method retrieves all {@link Target}s from the repo in the following
|
||||||
@@ -538,8 +507,8 @@ public interface TargetManagement {
|
|||||||
* if distribution set with given ID does not exist
|
* if distribution set with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Slice<Target> findTargetsAllOrderByLinkedDistributionSet(@NotNull Pageable pageable,
|
Slice<Target> findByFilterOrderByLinkedDistributionSet(@NotNull Pageable pageable,
|
||||||
@NotNull Long orderByDistributionId, FilterParams filterParams);
|
@NotNull Long orderByDistributionId, @NotNull FilterParams filterParams);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find targets by tag name.
|
* Find targets by tag name.
|
||||||
@@ -554,7 +523,7 @@ public interface TargetManagement {
|
|||||||
* if target tag with given ID does not exist
|
* if target tag with given ID does not exist
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Page<Target> findTargetsByTag(@NotNull Pageable pageable, @NotNull Long tagId);
|
Page<Target> findByTag(@NotNull Pageable pageable, @NotNull Long tagId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find targets by tag name.
|
* Find targets by tag name.
|
||||||
@@ -577,7 +546,7 @@ public interface TargetManagement {
|
|||||||
* if the RSQL syntax is wrong
|
* if the RSQL syntax is wrong
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Page<Target> findTargetsByTag(@NotNull Pageable pageable, @NotNull String rsqlParam, @NotNull Long tagId);
|
Page<Target> findByRsqlAndTag(@NotNull Pageable pageable, @NotNull String rsqlParam, @NotNull Long tagId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles {@link TargetTag} assignment to given {@link Target}s by means
|
* Toggles {@link TargetTag} assignment to given {@link Target}s by means
|
||||||
@@ -626,32 +595,28 @@ public interface TargetManagement {
|
|||||||
* if fields are not filled as specified. Check
|
* if fields are not filled as specified. Check
|
||||||
* {@link TargetUpdate} for field constraints.
|
* {@link TargetUpdate} for field constraints.
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
Target update(@NotNull TargetUpdate update);
|
||||||
Target updateTarget(@NotNull TargetUpdate update);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a {@link Target} based a given ID. The returned target will not
|
* Find a {@link Target} based a given ID.
|
||||||
* contain details (e.g {@link Target#getTags()} and
|
|
||||||
* {@link Target#getActions()})
|
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* to look for
|
* to look for
|
||||||
* @return {@link Target}
|
* @return {@link Target}
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
Optional<Target> findTargetById(Long id);
|
Optional<Target> get(@NotNull Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
|
* Retrieves all targets.
|
||||||
* and {@link Target#getActions()} possible
|
|
||||||
*
|
*
|
||||||
* @param ids
|
* @param ids
|
||||||
* the ids to for
|
* the ids to for
|
||||||
* @return the found {@link Target}s
|
* @return the found {@link Target}s
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
List<Target> findTargetsById(@NotNull Collection<Long> ids);
|
List<Target> get(@NotNull Collection<Long> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get controller attributes of given {@link Target}.
|
* Get controller attributes of given {@link Target}.
|
||||||
|
|||||||
@@ -0,0 +1,173 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.repository;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.validation.ConstraintViolationException;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||||
|
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||||
|
import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterSyntaxException;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||||
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Management service for {@link TargetTag}s.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface TargetTagManagement {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* count {@link TargetTag}s.
|
||||||
|
*
|
||||||
|
* @return size of {@link TargetTag}s
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
|
long count();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link TargetTag}.
|
||||||
|
*
|
||||||
|
* @param create
|
||||||
|
* to be created
|
||||||
|
*
|
||||||
|
* @return the new created {@link TargetTag}
|
||||||
|
*
|
||||||
|
* @throws EntityAlreadyExistsException
|
||||||
|
* if given object already exists
|
||||||
|
* @throws ConstraintViolationException
|
||||||
|
* if fields are not filled as specified. Check
|
||||||
|
* {@link TagCreate} for field constraints.
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||||
|
TargetTag create(@NotNull TagCreate create);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* created multiple {@link TargetTag}s.
|
||||||
|
*
|
||||||
|
* @param creates
|
||||||
|
* to be created
|
||||||
|
* @return the new created {@link TargetTag}s
|
||||||
|
*
|
||||||
|
* @throws EntityAlreadyExistsException
|
||||||
|
* if given object has already an ID.
|
||||||
|
* @throws ConstraintViolationException
|
||||||
|
* if fields are not filled as specified. Check
|
||||||
|
* {@link TagCreate} for field constraints.
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||||
|
List<TargetTag> create(@NotNull Collection<TagCreate> creates);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes {@link TargetTag} with given name.
|
||||||
|
*
|
||||||
|
* @param targetTagName
|
||||||
|
* tag name of the {@link TargetTag} to be deleted
|
||||||
|
*
|
||||||
|
* @throws EntityNotFoundException
|
||||||
|
* if tag with given name does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||||
|
void delete(@NotEmpty String targetTagName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns all {@link TargetTag}s.
|
||||||
|
*
|
||||||
|
* @param pageable
|
||||||
|
* page parameter
|
||||||
|
*
|
||||||
|
* @return all {@link TargetTag}s
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
|
Page<TargetTag> findAll(@NotNull Pageable pageable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all {@link TargetTag}s assigned to {@link Target} with given ID.
|
||||||
|
*
|
||||||
|
* @param pageable
|
||||||
|
* page parameter
|
||||||
|
* @param controllerId
|
||||||
|
* of the assigned target
|
||||||
|
*
|
||||||
|
* @return {@link TargetTag}s assigned to {@link Target} with given ID
|
||||||
|
*
|
||||||
|
* @throws EntityNotFoundException
|
||||||
|
* if target with given ID does not exist
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
|
Page<TargetTag> findByTarget(@NotNull Pageable pageable, @NotEmpty String controllerId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves all target tags based on the given specification.
|
||||||
|
* @param pageable
|
||||||
|
* pagination parameter
|
||||||
|
* @param rsqlParam
|
||||||
|
* rsql query string
|
||||||
|
*
|
||||||
|
* @return the found {@link Target}s, never {@code null}
|
||||||
|
*
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
|
Page<TargetTag> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find {@link TargetTag} based on given Name.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* to look for.
|
||||||
|
* @return {@link TargetTag}
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
|
Optional<TargetTag> getByName(@NotEmpty String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds {@link TargetTag} by given id.
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* to search for
|
||||||
|
* @return the found {@link TargetTag}
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||||
|
Optional<TargetTag> get(@NotNull Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updates the {@link TargetTag}.
|
||||||
|
*
|
||||||
|
* @param update
|
||||||
|
* the {@link TargetTag} with updated values
|
||||||
|
* @return the updated {@link TargetTag}
|
||||||
|
*
|
||||||
|
* @throws EntityNotFoundException
|
||||||
|
* in case the {@link TargetTag} does not exists and cannot be
|
||||||
|
* updated
|
||||||
|
* @throws ConstraintViolationException
|
||||||
|
* if fields are not filled as specified. Check
|
||||||
|
* {@link TagUpdate} for field constraints.
|
||||||
|
*/
|
||||||
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||||
|
TargetTag update(@NotNull TagUpdate update);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
|
||||||
*
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*/
|
|
||||||
package org.eclipse.hawkbit.repository.exception;
|
|
||||||
|
|
||||||
import org.eclipse.hawkbit.exception.AbstractServerRtException;
|
|
||||||
import org.eclipse.hawkbit.exception.SpServerError;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Thrown if DS creation failed.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public final class DistributionSetCreationFailedMissingMandatoryModuleException extends AbstractServerRtException {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new FileUploadFailedException with
|
|
||||||
* {@link SpServerError#SP_DS_CREATION_FAILED_MISSING_MODULE} error.
|
|
||||||
*/
|
|
||||||
public DistributionSetCreationFailedMissingMandatoryModuleException() {
|
|
||||||
super(SpServerError.SP_DS_CREATION_FAILED_MISSING_MODULE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param cause
|
|
||||||
* for the exception
|
|
||||||
*/
|
|
||||||
public DistributionSetCreationFailedMissingMandatoryModuleException(final Throwable cause) {
|
|
||||||
super(SpServerError.SP_DS_CREATION_FAILED_MISSING_MODULE, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param message
|
|
||||||
* of the error
|
|
||||||
*/
|
|
||||||
public DistributionSetCreationFailedMissingMandatoryModuleException(final String message) {
|
|
||||||
super(message, SpServerError.SP_DS_CREATION_FAILED_MISSING_MODULE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -70,7 +70,7 @@ public class DistributionSetAssignmentResult extends AssignmentResult<Target> {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return targetManagement.findTargetsByControllerID(assignedTargets);
|
return targetManagement.getByControllerID(assignedTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public abstract class AbstractRolloutManagement implements RolloutManagement {
|
|||||||
final List<Long> groupTargetCounts = new ArrayList<>(groups.size());
|
final List<Long> groupTargetCounts = new ArrayList<>(groups.size());
|
||||||
final Map<String, Long> targetFilterCounts = groups.stream()
|
final Map<String, Long> targetFilterCounts = groups.stream()
|
||||||
.map(group -> RolloutHelper.getGroupTargetFilter(baseFilter, group)).distinct()
|
.map(group -> RolloutHelper.getGroupTargetFilter(baseFilter, group)).distinct()
|
||||||
.collect(Collectors.toMap(Function.identity(), targetManagement::countTargetByTargetFilterQuery));
|
.collect(Collectors.toMap(Function.identity(), targetManagement::countByRsql));
|
||||||
|
|
||||||
long unusedTargetsCount = 0;
|
long unusedTargetsCount = 0;
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ public abstract class AbstractRolloutManagement implements RolloutManagement {
|
|||||||
if (targetFilterCounts.containsKey(overlappingTargetsFilter)) {
|
if (targetFilterCounts.containsKey(overlappingTargetsFilter)) {
|
||||||
return targetFilterCounts.get(overlappingTargetsFilter);
|
return targetFilterCounts.get(overlappingTargetsFilter);
|
||||||
} else {
|
} else {
|
||||||
final long overlappingTargets = targetManagement.countTargetByTargetFilterQuery(overlappingTargetsFilter);
|
final long overlappingTargets = targetManagement.countByRsql(overlappingTargetsFilter);
|
||||||
targetFilterCounts.put(overlappingTargetsFilter, overlappingTargets);
|
targetFilterCounts.put(overlappingTargetsFilter, overlappingTargets);
|
||||||
return overlappingTargets;
|
return overlappingTargets;
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ public abstract class AbstractRolloutManagement implements RolloutManagement {
|
|||||||
protected long calculateRemainingTargets(final List<RolloutGroup> groups, final String targetFilter,
|
protected long calculateRemainingTargets(final List<RolloutGroup> groups, final String targetFilter,
|
||||||
final Long createdAt) {
|
final Long createdAt) {
|
||||||
final String baseFilter = RolloutHelper.getTargetFilterQuery(targetFilter, createdAt);
|
final String baseFilter = RolloutHelper.getTargetFilterQuery(targetFilter, createdAt);
|
||||||
final long totalTargets = targetManagement.countTargetByTargetFilterQuery(baseFilter);
|
final long totalTargets = targetManagement.countByRsql(baseFilter);
|
||||||
if (totalTargets == 0) {
|
if (totalTargets == 0) {
|
||||||
throw new ConstraintDeclarationException("Rollout target filter does not match any targets");
|
throw new ConstraintDeclarationException("Rollout target filter does not match any targets");
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ public abstract class AbstractRolloutManagement implements RolloutManagement {
|
|||||||
final String targetFilter, final Long createdAt) {
|
final String targetFilter, final Long createdAt) {
|
||||||
|
|
||||||
final String baseFilter = RolloutHelper.getTargetFilterQuery(targetFilter, createdAt);
|
final String baseFilter = RolloutHelper.getTargetFilterQuery(targetFilter, createdAt);
|
||||||
final long totalTargets = targetManagement.countTargetByTargetFilterQuery(baseFilter);
|
final long totalTargets = targetManagement.countByRsql(baseFilter);
|
||||||
if (totalTargets == 0) {
|
if (totalTargets == 0) {
|
||||||
throw new ConstraintDeclarationException("Rollout target filter does not match any targets");
|
throw new ConstraintDeclarationException("Rollout target filter does not match any targets");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,22 +47,9 @@ public interface DistributionSetRepository
|
|||||||
* to be found
|
* to be found
|
||||||
* @return list of found {@link DistributionSet}s
|
* @return list of found {@link DistributionSet}s
|
||||||
*/
|
*/
|
||||||
@Query(value = "Select Distinct ds from JpaDistributionSet ds join ds.tags dst where dst.id = :tag")
|
@Query(value = "Select Distinct ds from JpaDistributionSet ds join ds.tags dst where dst.id = :tag and ds.deleted = 0")
|
||||||
Page<JpaDistributionSet> findByTag(Pageable pageable, @Param("tag") final Long tagId);
|
Page<JpaDistributionSet> findByTag(Pageable pageable, @Param("tag") final Long tagId);
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds {@link DistributionSet}s by assigned {@link Tag}.
|
|
||||||
*
|
|
||||||
* @param pageable
|
|
||||||
* paging and sorting information
|
|
||||||
*
|
|
||||||
* @param tagId
|
|
||||||
* to be found
|
|
||||||
* @return page of found {@link DistributionSet}s
|
|
||||||
*/
|
|
||||||
@Query(value = "Select Distinct ds from JpaDistributionSet ds join ds.tags dst where dst.id = :tagId")
|
|
||||||
Page<JpaDistributionSet> findByTagId(Pageable pageable, @Param("tagId") final Long tagId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deletes the {@link DistributionSet}s with the given IDs.
|
* deletes the {@link DistributionSet}s with the given IDs.
|
||||||
*
|
*
|
||||||
@@ -175,4 +162,5 @@ public interface DistributionSetRepository
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Query("DELETE FROM JpaDistributionSet t WHERE t.tenant = :tenant")
|
@Query("DELETE FROM JpaDistributionSet t WHERE t.tenant = :tenant")
|
||||||
void deleteByTenant(@Param("tenant") String tenant);
|
void deleteByTenant(@Param("tenant") String tenant);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,4 +82,9 @@ public interface DistributionSetTagRepository
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Query("DELETE FROM JpaDistributionSetTag t WHERE t.tenant = :tenant")
|
@Query("DELETE FROM JpaDistributionSetTag t WHERE t.tenant = :tenant")
|
||||||
void deleteByTenant(@Param("tenant") String tenant);
|
void deleteByTenant(@Param("tenant") String tenant);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
|
||||||
|
@Query("SELECT d FROM JpaDistributionSetTag d WHERE d.id IN ?1")
|
||||||
|
List<JpaDistributionSetTag> findAll(Iterable<Long> ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa;
|
package org.eclipse.hawkbit.repository.jpa;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
|
||||||
@@ -48,7 +50,7 @@ public interface DistributionSetTypeRepository
|
|||||||
* count or all undeleted.
|
* count or all undeleted.
|
||||||
* @return number of {@link DistributionSetType}s in the repository.
|
* @return number of {@link DistributionSetType}s in the repository.
|
||||||
*/
|
*/
|
||||||
Long countByDeleted(boolean isDeleted);
|
long countByDeleted(boolean isDeleted);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counts all distribution set type where a specific software module type is
|
* Counts all distribution set type where a specific software module type is
|
||||||
@@ -60,7 +62,7 @@ public interface DistributionSetTypeRepository
|
|||||||
* @return the number of {@link DistributionSetType}s in the repository
|
* @return the number of {@link DistributionSetType}s in the repository
|
||||||
* assigned to the given software module type
|
* assigned to the given software module type
|
||||||
*/
|
*/
|
||||||
Long countByElementsSmType(JpaSoftwareModuleType softwareModuleType);
|
long countByElementsSmType(JpaSoftwareModuleType softwareModuleType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all {@link TenantAwareBaseEntity} of a given tenant. For safety
|
* Deletes all {@link TenantAwareBaseEntity} of a given tenant. For safety
|
||||||
@@ -75,4 +77,9 @@ public interface DistributionSetTypeRepository
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Query("DELETE FROM JpaDistributionSetType t WHERE t.tenant = :tenant")
|
@Query("DELETE FROM JpaDistributionSetType t WHERE t.tenant = :tenant")
|
||||||
void deleteByTenant(@Param("tenant") String tenant);
|
void deleteByTenant(@Param("tenant") String tenant);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
|
||||||
|
@Query("SELECT d FROM JpaDistributionSetType d WHERE d.id IN ?1")
|
||||||
|
List<JpaDistributionSetType> findAll(Iterable<Long> ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Artifact createArtifact(final InputStream stream, final Long moduleId, final String filename,
|
public Artifact create(final InputStream stream, final Long moduleId, final String filename,
|
||||||
final String providedMd5Sum, final String providedSha1Sum, final boolean overrideExisting,
|
final String providedMd5Sum, final String providedSha1Sum, final boolean overrideExisting,
|
||||||
final String contentType) {
|
final String contentType) {
|
||||||
AbstractDbArtifact result = null;
|
AbstractDbArtifact result = null;
|
||||||
@@ -137,8 +137,8 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteArtifact(final Long id) {
|
public void delete(final Long id) {
|
||||||
final JpaArtifact existing = (JpaArtifact) findArtifact(id)
|
final JpaArtifact existing = (JpaArtifact) get(id)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Artifact.class, id));
|
.orElseThrow(() -> new EntityNotFoundException(Artifact.class, id));
|
||||||
|
|
||||||
clearArtifactBinary(existing.getSha1Hash(), existing.getSoftwareModule().getId());
|
clearArtifactBinary(existing.getSha1Hash(), existing.getSoftwareModule().getId());
|
||||||
@@ -149,29 +149,29 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Artifact> findArtifact(final Long id) {
|
public Optional<Artifact> get(final Long id) {
|
||||||
return Optional.ofNullable(localArtifactRepository.findOne(id));
|
return Optional.ofNullable(localArtifactRepository.findOne(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Artifact> findByFilenameAndSoftwareModule(final String filename, final Long softwareModuleId) {
|
public Optional<Artifact> getByFilenameAndSoftwareModule(final String filename, final Long softwareModuleId) {
|
||||||
throwExceptionIfSoftwareModuleDoesNotExist(softwareModuleId);
|
throwExceptionIfSoftwareModuleDoesNotExist(softwareModuleId);
|
||||||
|
|
||||||
return localArtifactRepository.findFirstByFilenameAndSoftwareModuleId(filename, softwareModuleId);
|
return localArtifactRepository.findFirstByFilenameAndSoftwareModuleId(filename, softwareModuleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Artifact> findFirstArtifactBySHA1(final String sha1Hash) {
|
public Optional<Artifact> findFirstBySHA1(final String sha1Hash) {
|
||||||
return localArtifactRepository.findFirstBySha1Hash(sha1Hash);
|
return localArtifactRepository.findFirstBySha1Hash(sha1Hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Artifact> findArtifactByFilename(final String filename) {
|
public Optional<Artifact> getByFilename(final String filename) {
|
||||||
return localArtifactRepository.findFirstByFilename(filename);
|
return localArtifactRepository.findFirstByFilename(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Artifact> findArtifactBySoftwareModule(final Pageable pageReq, final Long swId) {
|
public Page<Artifact> findBySoftwareModule(final Pageable pageReq, final Long swId) {
|
||||||
throwExceptionIfSoftwareModuleDoesNotExist(swId);
|
throwExceptionIfSoftwareModuleDoesNotExist(swId);
|
||||||
|
|
||||||
return localArtifactRepository.findBySoftwareModuleId(pageReq, swId);
|
return localArtifactRepository.findBySoftwareModuleId(pageReq, swId);
|
||||||
@@ -206,13 +206,13 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Artifact createArtifact(final InputStream inputStream, final Long moduleId, final String filename,
|
public Artifact create(final InputStream inputStream, final Long moduleId, final String filename,
|
||||||
final boolean overrideExisting) {
|
final boolean overrideExisting) {
|
||||||
return createArtifact(inputStream, moduleId, filename, null, null, overrideExisting, null);
|
return create(inputStream, moduleId, filename, null, null, overrideExisting, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countArtifactsAll() {
|
public long count() {
|
||||||
return localArtifactRepository.count();
|
return localArtifactRepository.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -483,12 +483,12 @@ public class JpaControllerManagement implements ControllerManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Target> findByControllerId(final String controllerId) {
|
public Optional<Target> getByControllerId(final String controllerId) {
|
||||||
return targetRepository.findByControllerId(controllerId);
|
return targetRepository.findByControllerId(controllerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Target> findByTargetId(final Long targetId) {
|
public Optional<Target> get(final Long targetId) {
|
||||||
return Optional.ofNullable(targetRepository.findOne(targetId));
|
return Optional.ofNullable(targetRepository.findOne(targetId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,4 +522,9 @@ public class JpaControllerManagement implements ControllerManagement {
|
|||||||
|
|
||||||
return messages.getContent();
|
return messages.getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<SoftwareModule> getSoftwareModule(final Long id) {
|
||||||
|
return Optional.ofNullable(softwareModuleRepository.findOne(id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -496,14 +496,14 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countActionsByTarget(final String controllerId) {
|
public long countActionsByTarget(final String controllerId) {
|
||||||
throwExceptionIfTargetDoesNotExist(controllerId);
|
throwExceptionIfTargetDoesNotExist(controllerId);
|
||||||
|
|
||||||
return actionRepository.countByTargetControllerId(controllerId);
|
return actionRepository.countByTargetControllerId(controllerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countActionsByTarget(final String rsqlParam, final String controllerId) {
|
public long countActionsByTarget(final String rsqlParam, final String controllerId) {
|
||||||
throwExceptionIfTargetDoesNotExist(controllerId);
|
throwExceptionIfTargetDoesNotExist(controllerId);
|
||||||
|
|
||||||
return actionRepository.count(createSpecificationFor(controllerId, rsqlParam));
|
return actionRepository.count(createSpecificationFor(controllerId, rsqlParam));
|
||||||
@@ -578,12 +578,12 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countActionStatusAll() {
|
public long countActionStatusAll() {
|
||||||
return actionStatusRepository.count();
|
return actionStatusRepository.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countActionsAll() {
|
public long countActionsAll() {
|
||||||
return actionRepository.count();
|
return actionRepository.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ import javax.persistence.EntityManager;
|
|||||||
import org.eclipse.hawkbit.repository.DistributionSetFields;
|
import org.eclipse.hawkbit.repository.DistributionSetFields;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetMetadataFields;
|
import org.eclipse.hawkbit.repository.DistributionSetMetadataFields;
|
||||||
|
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||||
import org.eclipse.hawkbit.repository.TagManagement;
|
|
||||||
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
|
import org.eclipse.hawkbit.repository.builder.DistributionSetCreate;
|
||||||
import org.eclipse.hawkbit.repository.builder.DistributionSetUpdate;
|
import org.eclipse.hawkbit.repository.builder.DistributionSetUpdate;
|
||||||
import org.eclipse.hawkbit.repository.builder.GenericDistributionSetUpdate;
|
import org.eclipse.hawkbit.repository.builder.GenericDistributionSetUpdate;
|
||||||
@@ -63,6 +63,7 @@ import org.springframework.dao.ConcurrencyFailureException;
|
|||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageImpl;
|
import org.springframework.data.domain.PageImpl;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.retry.annotation.Backoff;
|
import org.springframework.retry.annotation.Backoff;
|
||||||
import org.springframework.retry.annotation.Retryable;
|
import org.springframework.retry.annotation.Retryable;
|
||||||
@@ -88,7 +89,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
private DistributionSetRepository distributionSetRepository;
|
private DistributionSetRepository distributionSetRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TagManagement tagManagement;
|
private DistributionSetTagManagement distributionSetTagManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SystemManagement systemManagement;
|
private SystemManagement systemManagement;
|
||||||
@@ -105,6 +106,9 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ActionRepository actionRepository;
|
private ActionRepository actionRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private NoCountPagingRepository criteriaNoCountDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEventPublisher eventPublisher;
|
private ApplicationEventPublisher eventPublisher;
|
||||||
|
|
||||||
@@ -127,13 +131,17 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
private AfterTransactionCommitExecutor afterCommit;
|
private AfterTransactionCommitExecutor afterCommit;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSet> findDistributionSetByIdWithDetails(final Long distid) {
|
public Optional<DistributionSet> getWithDetails(final Long distid) {
|
||||||
return Optional.ofNullable(distributionSetRepository.findOne(DistributionSetSpecification.byId(distid)));
|
return Optional.ofNullable(distributionSetRepository.findOne(DistributionSetSpecification.byId(distid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSet> findDistributionSetById(final Long distid) {
|
public long countByTypeId(final Long typeId) {
|
||||||
return Optional.ofNullable(distributionSetRepository.findOne(distid));
|
if (!distributionSetTypeManagement.exists(typeId)) {
|
||||||
|
throw new EntityNotFoundException(DistributionSetType.class, typeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return distributionSetRepository.countByTypeId(typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -148,7 +156,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
sets.stream().map(DistributionSet::getId).collect(Collectors.toList()));
|
sets.stream().map(DistributionSet::getId).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
final DistributionSetTag myTag = tagManagement.findDistributionSetTag(tagName)
|
final DistributionSetTag myTag = distributionSetTagManagement.getByName(tagName)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, tagName));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, tagName));
|
||||||
|
|
||||||
DistributionSetTagAssignmentResult result;
|
DistributionSetTagAssignmentResult result;
|
||||||
@@ -189,7 +197,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSet updateDistributionSet(final DistributionSetUpdate u) {
|
public DistributionSet update(final DistributionSetUpdate u) {
|
||||||
final GenericDistributionSetUpdate update = (GenericDistributionSetUpdate) u;
|
final GenericDistributionSetUpdate update = (GenericDistributionSetUpdate) u;
|
||||||
|
|
||||||
final JpaDistributionSet set = findDistributionSetAndThrowExceptionIfNotFound(update.getId());
|
final JpaDistributionSet set = findDistributionSetAndThrowExceptionIfNotFound(update.getId());
|
||||||
@@ -217,13 +225,13 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private JpaDistributionSetType findDistributionSetTypeAndThrowExceptionIfNotFound(final String key) {
|
private JpaDistributionSetType findDistributionSetTypeAndThrowExceptionIfNotFound(final String key) {
|
||||||
return (JpaDistributionSetType) distributionSetTypeManagement.findDistributionSetTypeByKey(key)
|
return (JpaDistributionSetType) distributionSetTypeManagement.getByKey(key)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, key));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, key));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JpaDistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
private JpaDistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
||||||
return (JpaDistributionSet) findDistributionSetById(setId)
|
return (JpaDistributionSet) get(setId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,8 +244,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteDistributionSet(final Collection<Long> distributionSetIDs) {
|
public void delete(final Collection<Long> distributionSetIDs) {
|
||||||
final List<DistributionSet> setsFound = findDistributionSetsById(distributionSetIDs);
|
final List<DistributionSet> setsFound = get(distributionSetIDs);
|
||||||
|
|
||||||
if (setsFound.size() < distributionSetIDs.size()) {
|
if (setsFound.size() < distributionSetIDs.size()) {
|
||||||
throw new EntityNotFoundException(DistributionSet.class, distributionSetIDs,
|
throw new EntityNotFoundException(DistributionSet.class, distributionSetIDs,
|
||||||
@@ -275,7 +283,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSet createDistributionSet(final DistributionSetCreate c) {
|
public DistributionSet create(final DistributionSetCreate c) {
|
||||||
final JpaDistributionSetCreate create = (JpaDistributionSetCreate) c;
|
final JpaDistributionSetCreate create = (JpaDistributionSetCreate) c;
|
||||||
if (create.getType() == null) {
|
if (create.getType() == null) {
|
||||||
create.type(systemManagement.getTenantMetadata().getDefaultDsType().getKey());
|
create.type(systemManagement.getTenantMetadata().getDefaultDsType().getKey());
|
||||||
@@ -288,8 +296,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<DistributionSet> createDistributionSets(final Collection<DistributionSetCreate> creates) {
|
public List<DistributionSet> create(final Collection<DistributionSetCreate> creates) {
|
||||||
return creates.stream().map(this::createDistributionSet).collect(Collectors.toList());
|
return creates.stream().map(this::create).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -329,7 +337,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSet> findDistributionSetsByFilters(final Pageable pageable,
|
public Page<DistributionSet> findByDistributionSetFilter(final Pageable pageable,
|
||||||
final DistributionSetFilter distributionSetFilter) {
|
final DistributionSetFilter distributionSetFilter) {
|
||||||
final List<Specification<JpaDistributionSet>> specList = buildDistributionSetSpecifications(
|
final List<Specification<JpaDistributionSet>> specList = buildDistributionSetSpecifications(
|
||||||
distributionSetFilter);
|
distributionSetFilter);
|
||||||
@@ -341,6 +349,11 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Slice<DistributionSet> convertDsPage(final Slice<JpaDistributionSet> findAll,
|
||||||
|
final Pageable pageable) {
|
||||||
|
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param distributionSetFilter
|
* @param distributionSetFilter
|
||||||
@@ -359,52 +372,21 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSet> findDistributionSetsByDeletedAndOrCompleted(final Pageable pageReq,
|
public Page<DistributionSet> findByCompleted(final Pageable pageReq, final Boolean complete) {
|
||||||
final Boolean deleted, final Boolean complete) {
|
|
||||||
final List<Specification<JpaDistributionSet>> specList = new ArrayList<>(2);
|
|
||||||
|
|
||||||
if (deleted != null) {
|
|
||||||
final Specification<JpaDistributionSet> spec = DistributionSetSpecification.isDeleted(deleted);
|
|
||||||
specList.add(spec);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
List<Specification<JpaDistributionSet>> specList;
|
||||||
if (complete != null) {
|
if (complete != null) {
|
||||||
final Specification<JpaDistributionSet> spec = DistributionSetSpecification.isCompleted(complete);
|
specList = Arrays.asList(DistributionSetSpecification.isDeleted(false),
|
||||||
specList.add(spec);
|
DistributionSetSpecification.isCompleted(complete));
|
||||||
|
} else {
|
||||||
|
specList = Arrays.asList(DistributionSetSpecification.isDeleted(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
return convertDsPage(findByCriteriaAPI(pageReq, specList), pageReq);
|
return convertDsPage(findByCriteriaAPI(pageReq, specList), pageReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSet> findDistributionSetsAll(final String rsqlParam, final Pageable pageReq,
|
public Page<DistributionSet> findByFilterAndAssignedInstalledDsOrderedByLinkTarget(final Pageable pageable,
|
||||||
final Boolean deleted) {
|
|
||||||
|
|
||||||
final Specification<JpaDistributionSet> spec = RSQLUtility.parse(rsqlParam, DistributionSetFields.class,
|
|
||||||
virtualPropertyReplacer);
|
|
||||||
|
|
||||||
final List<Specification<JpaDistributionSet>> specList = new ArrayList<>(2);
|
|
||||||
if (deleted != null) {
|
|
||||||
specList.add(DistributionSetSpecification.isDeleted(deleted));
|
|
||||||
}
|
|
||||||
specList.add(spec);
|
|
||||||
|
|
||||||
return convertDsPage(findByCriteriaAPI(pageReq, specList), pageReq);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<DistributionSet> findDistributionSetsAll(final Pageable pageReq, final Boolean deleted) {
|
|
||||||
|
|
||||||
final List<Specification<JpaDistributionSet>> specList = new ArrayList<>(1);
|
|
||||||
if (deleted != null) {
|
|
||||||
specList.add(DistributionSetSpecification.isDeleted(deleted));
|
|
||||||
}
|
|
||||||
|
|
||||||
return convertDsPage(findByCriteriaAPI(pageReq, specList), pageReq);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<DistributionSet> findDistributionSetsAllOrderedByLinkTarget(final Pageable pageable,
|
|
||||||
final DistributionSetFilterBuilder distributionSetFilterBuilder, final String assignedOrInstalled) {
|
final DistributionSetFilterBuilder distributionSetFilterBuilder, final String assignedOrInstalled) {
|
||||||
|
|
||||||
final DistributionSetFilter filterWithInstalledTargets = distributionSetFilterBuilder
|
final DistributionSetFilter filterWithInstalledTargets = distributionSetFilterBuilder
|
||||||
@@ -421,7 +403,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
.setAssignedTargetId(null).build();
|
.setAssignedTargetId(null).build();
|
||||||
// first fine the distribution sets filtered by the given filter
|
// first fine the distribution sets filtered by the given filter
|
||||||
// parameters
|
// parameters
|
||||||
final Page<DistributionSet> findDistributionSetsByFilters = findDistributionSetsByFilters(pageable,
|
final Page<DistributionSet> findDistributionSetsByFilters = findByDistributionSetFilter(pageable,
|
||||||
dsFilterWithNoTargetLinked);
|
dsFilterWithNoTargetLinked);
|
||||||
|
|
||||||
final List<DistributionSet> resultSet = new ArrayList<>(findDistributionSetsByFilters.getContent());
|
final List<DistributionSet> resultSet = new ArrayList<>(findDistributionSetsByFilters.getContent());
|
||||||
@@ -446,8 +428,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSet> findDistributionSetByNameAndVersion(final String distributionName,
|
public Optional<DistributionSet> getByNameAndVersion(final String distributionName, final String version) {
|
||||||
final String version) {
|
|
||||||
final Specification<JpaDistributionSet> spec = DistributionSetSpecification
|
final Specification<JpaDistributionSet> spec = DistributionSetSpecification
|
||||||
.equalsNameAndVersionIgnoreCase(distributionName, version);
|
.equalsNameAndVersionIgnoreCase(distributionName, version);
|
||||||
return Optional.ofNullable(distributionSetRepository.findOne(spec));
|
return Optional.ofNullable(distributionSetRepository.findOne(spec));
|
||||||
@@ -455,7 +436,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countDistributionSetsAll() {
|
public long count() {
|
||||||
final Specification<JpaDistributionSet> spec = DistributionSetSpecification.isDeleted(Boolean.FALSE);
|
final Specification<JpaDistributionSet> spec = DistributionSetSpecification.isDeleted(Boolean.FALSE);
|
||||||
|
|
||||||
return distributionSetRepository.count(SpecificationsBuilder.combineWithAnd(Arrays.asList(spec)));
|
return distributionSetRepository.count(SpecificationsBuilder.combineWithAnd(Arrays.asList(spec)));
|
||||||
@@ -465,7 +446,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<DistributionSetMetadata> createDistributionSetMetadata(final Long dsId, final Collection<MetaData> md) {
|
public List<DistributionSetMetadata> createMetaData(final Long dsId, final Collection<MetaData> md) {
|
||||||
|
|
||||||
md.forEach(meta -> checkAndThrowAlreadyIfDistributionSetMetadataExists(
|
md.forEach(meta -> checkAndThrowAlreadyIfDistributionSetMetadataExists(
|
||||||
new DsMetadataCompositeKey(dsId, meta.getKey())));
|
new DsMetadataCompositeKey(dsId, meta.getKey())));
|
||||||
@@ -482,10 +463,10 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetMetadata updateDistributionSetMetadata(final Long dsId, final MetaData md) {
|
public DistributionSetMetadata updateMetaData(final Long dsId, final MetaData md) {
|
||||||
|
|
||||||
// check if exists otherwise throw entity not found exception
|
// check if exists otherwise throw entity not found exception
|
||||||
final JpaDistributionSetMetadata toUpdate = (JpaDistributionSetMetadata) findDistributionSetMetadata(dsId,
|
final JpaDistributionSetMetadata toUpdate = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId(dsId,
|
||||||
md.getKey()).orElseThrow(
|
md.getKey()).orElseThrow(
|
||||||
() -> new EntityNotFoundException(DistributionSetMetadata.class, dsId, md.getKey()));
|
() -> new EntityNotFoundException(DistributionSetMetadata.class, dsId, md.getKey()));
|
||||||
toUpdate.setValue(md.getValue());
|
toUpdate.setValue(md.getValue());
|
||||||
@@ -499,8 +480,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteDistributionSetMetadata(final Long distributionSetId, final String key) {
|
public void deleteMetaData(final Long distributionSetId, final String key) {
|
||||||
final JpaDistributionSetMetadata metadata = (JpaDistributionSetMetadata) findDistributionSetMetadata(
|
final JpaDistributionSetMetadata metadata = (JpaDistributionSetMetadata) getMetaDataByDistributionSetId(
|
||||||
distributionSetId, key).orElseThrow(
|
distributionSetId, key).orElseThrow(
|
||||||
() -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId, key));
|
() -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId, key));
|
||||||
|
|
||||||
@@ -535,13 +516,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
* of the DS to touch
|
* of the DS to touch
|
||||||
*/
|
*/
|
||||||
private JpaDistributionSet touch(final Long distId) {
|
private JpaDistributionSet touch(final Long distId) {
|
||||||
return touch(findDistributionSetById(distId)
|
return touch(get(distId).orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, distId)));
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, distId)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(final Long distributionSetId,
|
public Page<DistributionSetMetadata> findMetaDataByDistributionSetId(final Pageable pageable,
|
||||||
final Pageable pageable) {
|
final Long distributionSetId) {
|
||||||
throwExceptionIfDistributionSetDoesNotExist(distributionSetId);
|
throwExceptionIfDistributionSetDoesNotExist(distributionSetId);
|
||||||
|
|
||||||
return convertMdPage(distributionSetMetadataRepository
|
return convertMdPage(distributionSetMetadataRepository
|
||||||
@@ -552,8 +532,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(final Long distributionSetId,
|
public Page<DistributionSetMetadata> findMetaDataByDistributionSetIdAndRsql(final Pageable pageable,
|
||||||
final String rsqlParam, final Pageable pageable) {
|
final Long distributionSetId, final String rsqlParam) {
|
||||||
|
|
||||||
throwExceptionIfDistributionSetDoesNotExist(distributionSetId);
|
throwExceptionIfDistributionSetDoesNotExist(distributionSetId);
|
||||||
|
|
||||||
@@ -575,14 +555,14 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSetMetadata> findDistributionSetMetadata(final Long setId, final String key) {
|
public Optional<DistributionSetMetadata> getMetaDataByDistributionSetId(final Long setId, final String key) {
|
||||||
throwExceptionIfDistributionSetDoesNotExist(setId);
|
throwExceptionIfDistributionSetDoesNotExist(setId);
|
||||||
|
|
||||||
return Optional.ofNullable(distributionSetMetadataRepository.findOne(new DsMetadataCompositeKey(setId, key)));
|
return Optional.ofNullable(distributionSetMetadataRepository.findOne(new DsMetadataCompositeKey(setId, key)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSet> findDistributionSetByAction(final Long actionId) {
|
public Optional<DistributionSet> getByAction(final Long actionId) {
|
||||||
if (!actionRepository.exists(actionId)) {
|
if (!actionRepository.exists(actionId)) {
|
||||||
throw new EntityNotFoundException(Action.class, actionId);
|
throw new EntityNotFoundException(Action.class, actionId);
|
||||||
}
|
}
|
||||||
@@ -591,7 +571,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDistributionSetInUse(final Long setId) {
|
public boolean isInUse(final Long setId) {
|
||||||
throwExceptionIfDistributionSetDoesNotExist(setId);
|
throwExceptionIfDistributionSetDoesNotExist(setId);
|
||||||
|
|
||||||
return actionRepository.countByDistributionSetId(setId) > 0;
|
return actionRepository.countByDistributionSetId(setId) > 0;
|
||||||
@@ -693,7 +673,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
allDs.stream().map(DistributionSet::getId).collect(Collectors.toList()));
|
allDs.stream().map(DistributionSet::getId).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
final DistributionSetTag distributionSetTag = tagManagement.findDistributionSetTagById(dsTagId)
|
final DistributionSetTag distributionSetTag = distributionSetTagManagement.get(dsTagId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, dsTagId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, dsTagId));
|
||||||
|
|
||||||
allDs.forEach(ds -> ds.addTag(distributionSetTag));
|
allDs.forEach(ds -> ds.addTag(distributionSetTag));
|
||||||
@@ -711,10 +691,10 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSet unAssignTag(final Long dsId, final Long dsTagId) {
|
public DistributionSet unAssignTag(final Long dsId, final Long dsTagId) {
|
||||||
final JpaDistributionSet set = (JpaDistributionSet) findDistributionSetByIdWithDetails(dsId)
|
final JpaDistributionSet set = (JpaDistributionSet) getWithDetails(dsId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, dsId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, dsId));
|
||||||
|
|
||||||
final DistributionSetTag distributionSetTag = tagManagement.findDistributionSetTagById(dsTagId)
|
final DistributionSetTag distributionSetTag = distributionSetTagManagement.get(dsTagId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, dsTagId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetTag.class, dsTagId));
|
||||||
|
|
||||||
set.removeTag(distributionSetTag);
|
set.removeTag(distributionSetTag);
|
||||||
@@ -730,10 +710,10 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteDistributionSet(final Long setId) {
|
public void delete(final Long setId) {
|
||||||
throwExceptionIfDistributionSetDoesNotExist(setId);
|
throwExceptionIfDistributionSetDoesNotExist(setId);
|
||||||
|
|
||||||
deleteDistributionSet(Arrays.asList(setId));
|
delete(Arrays.asList(setId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void throwExceptionIfDistributionSetDoesNotExist(final Long setId) {
|
private void throwExceptionIfDistributionSetDoesNotExist(final Long setId) {
|
||||||
@@ -743,12 +723,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DistributionSet> findDistributionSetsById(final Collection<Long> ids) {
|
public List<DistributionSet> get(final Collection<Long> ids) {
|
||||||
return Collections.unmodifiableList(distributionSetRepository.findAll(ids));
|
return Collections.unmodifiableList(distributionSetRepository.findAll(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSet> findDistributionSetsByTag(final Pageable pageable, final Long tagId) {
|
public Page<DistributionSet> findByTag(final Pageable pageable, final Long tagId) {
|
||||||
throwEntityNotFoundExceptionIfDsTagDoesNotExist(tagId);
|
throwEntityNotFoundExceptionIfDsTagDoesNotExist(tagId);
|
||||||
|
|
||||||
return convertDsPage(distributionSetRepository.findByTag(pageable, tagId), pageable);
|
return convertDsPage(distributionSetRepository.findByTag(pageable, tagId), pageable);
|
||||||
@@ -762,17 +742,40 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSet> findDistributionSetsByTag(final Pageable pageable, final String rsqlParam,
|
public Page<DistributionSet> findByRsqlAndTag(final Pageable pageable, final String rsqlParam, final Long tagId) {
|
||||||
final Long tagId) {
|
|
||||||
throwEntityNotFoundExceptionIfDsTagDoesNotExist(tagId);
|
throwEntityNotFoundExceptionIfDsTagDoesNotExist(tagId);
|
||||||
|
|
||||||
final Specification<JpaDistributionSet> spec = RSQLUtility.parse(rsqlParam, DistributionSetFields.class,
|
final Specification<JpaDistributionSet> spec = RSQLUtility.parse(rsqlParam, DistributionSetFields.class,
|
||||||
virtualPropertyReplacer);
|
virtualPropertyReplacer);
|
||||||
|
|
||||||
return convertDsPage(distributionSetRepository.findAll((Specification<JpaDistributionSet>) (root, query,
|
return convertDsPage(findByCriteriaAPI(pageable, Arrays.asList(spec, DistributionSetSpecification.hasTag(tagId),
|
||||||
cb) -> cb.and(DistributionSetSpecification.hasTag(tagId).toPredicate(root, query, cb),
|
DistributionSetSpecification.isDeleted(false))), pageable);
|
||||||
spec.toPredicate(root, query, cb)),
|
}
|
||||||
pageable), pageable);
|
|
||||||
|
@Override
|
||||||
|
public Slice<DistributionSet> findAll(final Pageable pageable) {
|
||||||
|
return convertDsPage(criteriaNoCountDao.findAll(DistributionSetSpecification.isDeleted(false), pageable,
|
||||||
|
JpaDistributionSet.class), pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<DistributionSet> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||||
|
final Specification<JpaDistributionSet> spec = RSQLUtility.parse(rsqlParam, DistributionSetFields.class,
|
||||||
|
virtualPropertyReplacer);
|
||||||
|
|
||||||
|
return convertDsPage(
|
||||||
|
findByCriteriaAPI(pageable, Arrays.asList(spec, DistributionSetSpecification.isDeleted(false))),
|
||||||
|
pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<DistributionSet> get(final Long id) {
|
||||||
|
return Optional.ofNullable(distributionSetRepository.findOne(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean exists(final Long id) {
|
||||||
|
return distributionSetRepository.exists(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||||
import org.eclipse.hawkbit.repository.TagFields;
|
import org.eclipse.hawkbit.repository.TagFields;
|
||||||
import org.eclipse.hawkbit.repository.TagManagement;
|
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||||
import org.eclipse.hawkbit.repository.builder.GenericTagUpdate;
|
import org.eclipse.hawkbit.repository.builder.GenericTagUpdate;
|
||||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||||
import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
||||||
@@ -23,19 +24,16 @@ import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.builder.JpaTagCreate;
|
import org.eclipse.hawkbit.repository.jpa.builder.JpaTagCreate;
|
||||||
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.TagSpecification;
|
import org.eclipse.hawkbit.repository.jpa.specifications.TagSpecification;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.dao.ConcurrencyFailureException;
|
import org.springframework.dao.ConcurrencyFailureException;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageImpl;
|
import org.springframework.data.domain.PageImpl;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.retry.annotation.Backoff;
|
import org.springframework.retry.annotation.Backoff;
|
||||||
import org.springframework.retry.annotation.Retryable;
|
import org.springframework.retry.annotation.Retryable;
|
||||||
@@ -43,111 +41,35 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JP>A implementation of {@link TagManagement}.
|
* JPA implementation of {@link TargetTagManagement}.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@Validated
|
@Validated
|
||||||
public class JpaTagManagement implements TagManagement {
|
public class JpaDistributionSetTagManagement implements DistributionSetTagManagement {
|
||||||
|
|
||||||
@Autowired
|
private final DistributionSetTagRepository distributionSetTagRepository;
|
||||||
private TargetTagRepository targetTagRepository;
|
|
||||||
|
|
||||||
@Autowired
|
private final DistributionSetRepository distributionSetRepository;
|
||||||
private TargetRepository targetRepository;
|
|
||||||
|
|
||||||
@Autowired
|
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
||||||
private DistributionSetTagRepository distributionSetTagRepository;
|
|
||||||
|
|
||||||
@Autowired
|
private final NoCountPagingRepository criteriaNoCountDao;
|
||||||
private DistributionSetRepository distributionSetRepository;
|
|
||||||
|
|
||||||
@Autowired
|
JpaDistributionSetTagManagement(final DistributionSetTagRepository distributionSetTagRepository,
|
||||||
private VirtualPropertyReplacer virtualPropertyReplacer;
|
final DistributionSetRepository distributionSetRepository,
|
||||||
|
final VirtualPropertyReplacer virtualPropertyReplacer, final NoCountPagingRepository criteriaNoCountDao) {
|
||||||
@Override
|
this.distributionSetTagRepository = distributionSetTagRepository;
|
||||||
public Optional<TargetTag> findTargetTag(final String name) {
|
this.distributionSetRepository = distributionSetRepository;
|
||||||
return targetTagRepository.findByNameEquals(name);
|
this.virtualPropertyReplacer = virtualPropertyReplacer;
|
||||||
|
this.criteriaNoCountDao = criteriaNoCountDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TargetTag createTargetTag(final TagCreate c) {
|
public DistributionSetTag update(final TagUpdate u) {
|
||||||
final JpaTagCreate create = (JpaTagCreate) c;
|
|
||||||
|
|
||||||
return targetTagRepository.save(create.buildTargetTag());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@Retryable(include = {
|
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
|
||||||
public List<TargetTag> createTargetTags(final Collection<TagCreate> tt) {
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
||||||
final Collection<JpaTagCreate> targetTags = (Collection) tt;
|
|
||||||
|
|
||||||
return Collections.unmodifiableList(targetTags.stream()
|
|
||||||
.map(ttc -> targetTagRepository.save(ttc.buildTargetTag())).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@Retryable(include = {
|
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
|
||||||
public void deleteTargetTag(final String targetTagName) {
|
|
||||||
if (!targetTagRepository.existsByName(targetTagName)) {
|
|
||||||
throw new EntityNotFoundException(TargetTag.class, targetTagName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// finally delete the tag itself
|
|
||||||
targetTagRepository.deleteByName(targetTagName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<TargetTag> findAllTargetTags(final String rsqlParam, final Pageable pageable) {
|
|
||||||
|
|
||||||
final Specification<JpaTargetTag> spec = RSQLUtility.parse(rsqlParam, TagFields.class, virtualPropertyReplacer);
|
|
||||||
return convertTPage(targetTagRepository.findAll(spec, pageable), pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Page<TargetTag> convertTPage(final Page<JpaTargetTag> findAll, final Pageable pageable) {
|
|
||||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Page<DistributionSetTag> convertDsPage(final Page<JpaDistributionSetTag> findAll,
|
|
||||||
final Pageable pageable) {
|
|
||||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long countTargetTags() {
|
|
||||||
return targetTagRepository.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@Retryable(include = {
|
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
|
||||||
public TargetTag updateTargetTag(final TagUpdate u) {
|
|
||||||
final GenericTagUpdate update = (GenericTagUpdate) u;
|
|
||||||
|
|
||||||
final JpaTargetTag tag = targetTagRepository.findById(update.getId())
|
|
||||||
.orElseThrow(() -> new EntityNotFoundException(TargetTag.class, update.getId()));
|
|
||||||
|
|
||||||
update.getName().ifPresent(tag::setName);
|
|
||||||
update.getDescription().ifPresent(tag::setDescription);
|
|
||||||
update.getColour().ifPresent(tag::setColour);
|
|
||||||
|
|
||||||
return targetTagRepository.save(tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
@Retryable(include = {
|
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
|
||||||
public DistributionSetTag updateDistributionSetTag(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())
|
||||||
@@ -161,7 +83,7 @@ public class JpaTagManagement implements TagManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSetTag> findDistributionSetTag(final String name) {
|
public Optional<DistributionSetTag> getByName(final String name) {
|
||||||
return distributionSetTagRepository.findByNameEquals(name);
|
return distributionSetTagRepository.findByNameEquals(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +91,7 @@ public class JpaTagManagement implements TagManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetTag createDistributionSetTag(final TagCreate c) {
|
public DistributionSetTag create(final TagCreate c) {
|
||||||
final JpaTagCreate create = (JpaTagCreate) c;
|
final JpaTagCreate create = (JpaTagCreate) c;
|
||||||
return distributionSetTagRepository.save(create.buildDistributionSetTag());
|
return distributionSetTagRepository.save(create.buildDistributionSetTag());
|
||||||
}
|
}
|
||||||
@@ -178,7 +100,7 @@ public class JpaTagManagement implements TagManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<DistributionSetTag> createDistributionSetTags(final Collection<TagCreate> dst) {
|
public List<DistributionSetTag> create(final Collection<TagCreate> dst) {
|
||||||
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
final Collection<JpaTagCreate> creates = (Collection) dst;
|
final Collection<JpaTagCreate> creates = (Collection) dst;
|
||||||
@@ -192,7 +114,7 @@ public class JpaTagManagement implements TagManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteDistributionSetTag(final String tagName) {
|
public void delete(final String tagName) {
|
||||||
if (!distributionSetTagRepository.existsByName(tagName)) {
|
if (!distributionSetTagRepository.existsByName(tagName)) {
|
||||||
throw new EntityNotFoundException(DistributionSetTag.class, tagName);
|
throw new EntityNotFoundException(DistributionSetTag.class, tagName);
|
||||||
}
|
}
|
||||||
@@ -201,27 +123,12 @@ public class JpaTagManagement implements TagManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<TargetTag> findTargetTagById(final Long id) {
|
public Slice<DistributionSetTag> findAll(final Pageable pageable) {
|
||||||
return Optional.ofNullable(targetTagRepository.findOne(id));
|
return convertDsPage(criteriaNoCountDao.findAll(pageable, JpaDistributionSetTag.class), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSetTag> findDistributionSetTagById(final Long id) {
|
public Page<DistributionSetTag> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||||
return Optional.ofNullable(distributionSetTagRepository.findOne(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<TargetTag> findAllTargetTags(final Pageable pageable) {
|
|
||||||
return convertTPage(targetTagRepository.findAll(pageable), pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<DistributionSetTag> findAllDistributionSetTags(final Pageable pageable) {
|
|
||||||
return convertDsPage(distributionSetTagRepository.findAll(pageable), pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<DistributionSetTag> findAllDistributionSetTags(final String rsqlParam, final Pageable pageable) {
|
|
||||||
final Specification<JpaDistributionSetTag> spec = RSQLUtility.parse(rsqlParam, TagFields.class,
|
final Specification<JpaDistributionSetTag> spec = RSQLUtility.parse(rsqlParam, TagFields.class,
|
||||||
virtualPropertyReplacer);
|
virtualPropertyReplacer);
|
||||||
|
|
||||||
@@ -229,17 +136,7 @@ public class JpaTagManagement implements TagManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<TargetTag> findAllTargetTags(final Pageable pageable, final String controllerId) {
|
public Page<DistributionSetTag> findByDistributionSet(final Pageable pageable, final Long setId) {
|
||||||
if (!targetRepository.existsByControllerId(controllerId)) {
|
|
||||||
throw new EntityNotFoundException(Target.class, controllerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return convertTPage(targetTagRepository.findAll(TagSpecification.ofTarget(controllerId), pageable), pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<DistributionSetTag> findDistributionSetTagsByDistributionSet(final Pageable pageable,
|
|
||||||
final Long setId) {
|
|
||||||
if (!distributionSetRepository.exists(setId)) {
|
if (!distributionSetRepository.exists(setId)) {
|
||||||
throw new EntityNotFoundException(DistributionSet.class, setId);
|
throw new EntityNotFoundException(DistributionSet.class, setId);
|
||||||
}
|
}
|
||||||
@@ -247,4 +144,58 @@ public class JpaTagManagement implements TagManagement {
|
|||||||
return convertDsPage(distributionSetTagRepository.findAll(TagSpecification.ofDistributionSet(setId), pageable),
|
return convertDsPage(distributionSetTagRepository.findAll(TagSpecification.ofDistributionSet(setId), pageable),
|
||||||
pageable);
|
pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Page<DistributionSetTag> convertDsPage(final Page<JpaDistributionSetTag> findAll,
|
||||||
|
final Pageable pageable) {
|
||||||
|
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Slice<DistributionSetTag> convertDsPage(final Slice<JpaDistributionSetTag> findAll,
|
||||||
|
final Pageable pageable) {
|
||||||
|
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(include = {
|
||||||
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public void delete(final Collection<Long> ids) {
|
||||||
|
final List<JpaDistributionSetTag> setsFound = distributionSetTagRepository.findAll(ids);
|
||||||
|
|
||||||
|
if (setsFound.size() < ids.size()) {
|
||||||
|
throw new EntityNotFoundException(DistributionSetTag.class, ids,
|
||||||
|
setsFound.stream().map(DistributionSetTag::getId).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
distributionSetTagRepository.delete(setsFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DistributionSetTag> get(final Collection<Long> ids) {
|
||||||
|
return Collections.unmodifiableList(distributionSetTagRepository.findAll(ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<DistributionSetTag> get(final Long id) {
|
||||||
|
return Optional.ofNullable(distributionSetTagRepository.findOne(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(include = {
|
||||||
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public void delete(final Long id) {
|
||||||
|
distributionSetTagRepository.delete(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean exists(final Long id) {
|
||||||
|
return distributionSetTagRepository.exists(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long count() {
|
||||||
|
return distributionSetTagRepository.count();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa;
|
package org.eclipse.hawkbit.repository.jpa;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -27,6 +28,7 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
||||||
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetTypeSpecification;
|
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetTypeSpecification;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.specifications.SpecificationsBuilder;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
@@ -34,10 +36,12 @@ import org.springframework.dao.ConcurrencyFailureException;
|
|||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageImpl;
|
import org.springframework.data.domain.PageImpl;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.retry.annotation.Backoff;
|
import org.springframework.retry.annotation.Backoff;
|
||||||
import org.springframework.retry.annotation.Retryable;
|
import org.springframework.retry.annotation.Retryable;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,21 +60,24 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
|
|
||||||
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
||||||
|
|
||||||
|
private final NoCountPagingRepository criteriaNoCountDao;
|
||||||
|
|
||||||
JpaDistributionSetTypeManagement(final DistributionSetTypeRepository distributionSetTypeRepository,
|
JpaDistributionSetTypeManagement(final DistributionSetTypeRepository distributionSetTypeRepository,
|
||||||
final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
||||||
final DistributionSetRepository distributionSetRepository,
|
final DistributionSetRepository distributionSetRepository,
|
||||||
final VirtualPropertyReplacer virtualPropertyReplacer) {
|
final VirtualPropertyReplacer virtualPropertyReplacer, final NoCountPagingRepository criteriaNoCountDao) {
|
||||||
this.distributionSetTypeRepository = distributionSetTypeRepository;
|
this.distributionSetTypeRepository = distributionSetTypeRepository;
|
||||||
this.softwareModuleTypeRepository = softwareModuleTypeRepository;
|
this.softwareModuleTypeRepository = softwareModuleTypeRepository;
|
||||||
this.distributionSetRepository = distributionSetRepository;
|
this.distributionSetRepository = distributionSetRepository;
|
||||||
this.virtualPropertyReplacer = virtualPropertyReplacer;
|
this.virtualPropertyReplacer = virtualPropertyReplacer;
|
||||||
|
this.criteriaNoCountDao = criteriaNoCountDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetType updateDistributionSetType(final DistributionSetTypeUpdate u) {
|
public DistributionSetType update(final DistributionSetTypeUpdate u) {
|
||||||
final GenericDistributionSetTypeUpdate update = (GenericDistributionSetTypeUpdate) u;
|
final GenericDistributionSetTypeUpdate update = (GenericDistributionSetTypeUpdate) u;
|
||||||
|
|
||||||
final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(update.getId());
|
final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(update.getId());
|
||||||
@@ -82,9 +89,9 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(update.getId());
|
checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(update.getId());
|
||||||
|
|
||||||
update.getMandatory().ifPresent(
|
update.getMandatory().ifPresent(
|
||||||
mand -> softwareModuleTypeRepository.findByIdIn(mand).forEach(type::addMandatoryModuleType));
|
mand -> softwareModuleTypeRepository.findAll(mand).forEach(type::addMandatoryModuleType));
|
||||||
update.getOptional().ifPresent(
|
update.getOptional()
|
||||||
opt -> softwareModuleTypeRepository.findByIdIn(opt).forEach(type::addOptionalModuleType));
|
.ifPresent(opt -> softwareModuleTypeRepository.findAll(opt).forEach(type::addOptionalModuleType));
|
||||||
}
|
}
|
||||||
|
|
||||||
return distributionSetTypeRepository.save(type);
|
return distributionSetTypeRepository.save(type);
|
||||||
@@ -96,8 +103,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetType assignMandatorySoftwareModuleTypes(final Long dsTypeId,
|
public DistributionSetType assignMandatorySoftwareModuleTypes(final Long dsTypeId,
|
||||||
final Collection<Long> softwareModulesTypeIds) {
|
final Collection<Long> softwareModulesTypeIds) {
|
||||||
final Collection<JpaSoftwareModuleType> modules = softwareModuleTypeRepository
|
final Collection<JpaSoftwareModuleType> modules = softwareModuleTypeRepository.findAll(softwareModulesTypeIds);
|
||||||
.findByIdIn(softwareModulesTypeIds);
|
|
||||||
|
|
||||||
if (modules.size() < softwareModulesTypeIds.size()) {
|
if (modules.size() < softwareModulesTypeIds.size()) {
|
||||||
throw new EntityNotFoundException(SoftwareModuleType.class, softwareModulesTypeIds,
|
throw new EntityNotFoundException(SoftwareModuleType.class, softwareModulesTypeIds,
|
||||||
@@ -119,8 +125,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
public DistributionSetType assignOptionalSoftwareModuleTypes(final Long dsTypeId,
|
public DistributionSetType assignOptionalSoftwareModuleTypes(final Long dsTypeId,
|
||||||
final Collection<Long> softwareModulesTypeIds) {
|
final Collection<Long> softwareModulesTypeIds) {
|
||||||
|
|
||||||
final Collection<JpaSoftwareModuleType> modules = softwareModuleTypeRepository
|
final Collection<JpaSoftwareModuleType> modules = softwareModuleTypeRepository.findAll(softwareModulesTypeIds);
|
||||||
.findByIdIn(softwareModulesTypeIds);
|
|
||||||
|
|
||||||
if (modules.size() < softwareModulesTypeIds.size()) {
|
if (modules.size() < softwareModulesTypeIds.size()) {
|
||||||
throw new EntityNotFoundException(SoftwareModuleType.class, softwareModulesTypeIds,
|
throw new EntityNotFoundException(SoftwareModuleType.class, softwareModulesTypeIds,
|
||||||
@@ -149,37 +154,32 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSetType> findDistributionSetTypesAll(final String rsqlParam, final Pageable pageable) {
|
public Page<DistributionSetType> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||||
final Specification<JpaDistributionSetType> spec = RSQLUtility.parse(rsqlParam, DistributionSetTypeFields.class,
|
return convertPage(findByCriteriaAPI(pageable,
|
||||||
virtualPropertyReplacer);
|
Arrays.asList(RSQLUtility.parse(rsqlParam, DistributionSetTypeFields.class, virtualPropertyReplacer),
|
||||||
|
DistributionSetTypeSpecification.isDeleted(false))),
|
||||||
return convertDsTPage(distributionSetTypeRepository.findAll(spec, pageable));
|
pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSetType> findDistributionSetTypesAll(final Pageable pageable) {
|
public Slice<DistributionSetType> findAll(final Pageable pageable) {
|
||||||
return convertDsTPage(distributionSetTypeRepository.findByDeleted(pageable, false));
|
return convertPage(criteriaNoCountDao.findAll(DistributionSetTypeSpecification.isDeleted(false), pageable,
|
||||||
|
JpaDistributionSetType.class), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countDistributionSetTypesAll() {
|
public long count() {
|
||||||
return distributionSetTypeRepository.countByDeleted(false);
|
return distributionSetTypeRepository.countByDeleted(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSetType> findDistributionSetTypeByName(final String name) {
|
public Optional<DistributionSetType> getByName(final String name) {
|
||||||
return Optional
|
return Optional
|
||||||
.ofNullable(distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byName(name)));
|
.ofNullable(distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byName(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<DistributionSetType> findDistributionSetTypeById(final Long typeId) {
|
public Optional<DistributionSetType> getByKey(final String key) {
|
||||||
return Optional
|
|
||||||
.ofNullable(distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byId(typeId)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<DistributionSetType> findDistributionSetTypeByKey(final String key) {
|
|
||||||
return Optional.ofNullable(distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byKey(key)));
|
return Optional.ofNullable(distributionSetTypeRepository.findOne(DistributionSetTypeSpecification.byKey(key)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public DistributionSetType createDistributionSetType(final DistributionSetTypeCreate c) {
|
public DistributionSetType create(final DistributionSetTypeCreate c) {
|
||||||
final JpaDistributionSetTypeCreate create = (JpaDistributionSetTypeCreate) c;
|
final JpaDistributionSetTypeCreate create = (JpaDistributionSetTypeCreate) c;
|
||||||
|
|
||||||
return distributionSetTypeRepository.save(create.build());
|
return distributionSetTypeRepository.save(create.build());
|
||||||
@@ -197,7 +197,7 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteDistributionSetType(final Long typeId) {
|
public void delete(final Long typeId) {
|
||||||
|
|
||||||
final JpaDistributionSetType toDelete = distributionSetTypeRepository.findById(typeId)
|
final JpaDistributionSetType toDelete = distributionSetTypeRepository.findById(typeId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, typeId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, typeId));
|
||||||
@@ -214,21 +214,12 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<DistributionSetType> createDistributionSetTypes(final Collection<DistributionSetTypeCreate> types) {
|
public List<DistributionSetType> create(final Collection<DistributionSetTypeCreate> types) {
|
||||||
return types.stream().map(this::createDistributionSetType).collect(Collectors.toList());
|
return types.stream().map(this::create).collect(Collectors.toList());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long countDistributionSetsByType(final Long typeId) {
|
|
||||||
if (!distributionSetTypeRepository.exists(typeId)) {
|
|
||||||
throw new EntityNotFoundException(DistributionSetType.class, typeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return distributionSetRepository.countByTypeId(typeId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JpaDistributionSetType findDistributionSetTypeAndThrowExceptionIfNotFound(final Long setId) {
|
private JpaDistributionSetType findDistributionSetTypeAndThrowExceptionIfNotFound(final Long setId) {
|
||||||
return (JpaDistributionSetType) findDistributionSetTypeById(setId)
|
return (JpaDistributionSetType) get(setId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, setId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, setId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,8 +234,54 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Page<DistributionSetType> convertDsTPage(final Page<JpaDistributionSetType> findAll) {
|
private static Page<DistributionSetType> convertPage(final Page<JpaDistributionSetType> findAll,
|
||||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()));
|
final Pageable pageable) {
|
||||||
|
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Slice<DistributionSetType> convertPage(final Slice<JpaDistributionSetType> findAll,
|
||||||
|
final Pageable pageable) {
|
||||||
|
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Page<JpaDistributionSetType> findByCriteriaAPI(final Pageable pageable,
|
||||||
|
final List<Specification<JpaDistributionSetType>> specList) {
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(specList)) {
|
||||||
|
return distributionSetTypeRepository.findAll(pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
return distributionSetTypeRepository.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(include = {
|
||||||
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public void delete(final Collection<Long> ids) {
|
||||||
|
final List<JpaDistributionSetType> setsFound = distributionSetTypeRepository.findAll(ids);
|
||||||
|
|
||||||
|
if (setsFound.size() < ids.size()) {
|
||||||
|
throw new EntityNotFoundException(DistributionSetType.class, ids,
|
||||||
|
setsFound.stream().map(DistributionSetType::getId).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
distributionSetTypeRepository.delete(setsFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DistributionSetType> get(final Collection<Long> ids) {
|
||||||
|
return Collections.unmodifiableList(distributionSetTypeRepository.findAll(ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<DistributionSetType> get(final Long id) {
|
||||||
|
return Optional.ofNullable(distributionSetTypeRepository.findOne(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean exists(final Long id) {
|
||||||
|
return distributionSetTypeRepository.exists(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,12 +85,12 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
private RolloutStatusCache rolloutStatusCache;
|
private RolloutStatusCache rolloutStatusCache;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<RolloutGroup> findRolloutGroupById(final Long rolloutGroupId) {
|
public Optional<RolloutGroup> get(final Long rolloutGroupId) {
|
||||||
return Optional.ofNullable(rolloutGroupRepository.findOne(rolloutGroupId));
|
return Optional.ofNullable(rolloutGroupRepository.findOne(rolloutGroupId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<RolloutGroup> findRolloutGroupsByRolloutId(final Long rolloutId, final Pageable pageable) {
|
public Page<RolloutGroup> findByRollout(final Pageable pageable, final Long rolloutId) {
|
||||||
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
||||||
|
|
||||||
return convertPage(rolloutGroupRepository.findByRolloutId(rolloutId, pageable), pageable);
|
return convertPage(rolloutGroupRepository.findByRolloutId(rolloutId, pageable), pageable);
|
||||||
@@ -105,8 +105,8 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<RolloutGroup> findRolloutGroupsAll(final Long rolloutId, final String rsqlParam,
|
public Page<RolloutGroup> findByRolloutAndRsql(final Pageable pageable, final Long rolloutId,
|
||||||
final Pageable pageable) {
|
final String rsqlParam) {
|
||||||
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
||||||
|
|
||||||
final Specification<JpaRolloutGroup> specification = RSQLUtility.parse(rsqlParam, RolloutGroupFields.class,
|
final Specification<JpaRolloutGroup> specification = RSQLUtility.parse(rsqlParam, RolloutGroupFields.class,
|
||||||
@@ -130,7 +130,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<RolloutGroup> findAllRolloutGroupsWithDetailedStatus(final Long rolloutId, final Pageable pageable) {
|
public Page<RolloutGroup> findByRolloutWithDetailedStatus(final Pageable pageable, final Long rolloutId) {
|
||||||
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
||||||
|
|
||||||
final Page<JpaRolloutGroup> rolloutGroups = rolloutGroupRepository.findByRolloutId(rolloutId, pageable);
|
final Page<JpaRolloutGroup> rolloutGroups = rolloutGroupRepository.findByRolloutId(rolloutId, pageable);
|
||||||
@@ -155,8 +155,8 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<RolloutGroup> findRolloutGroupWithDetailedStatus(final Long rolloutGroupId) {
|
public Optional<RolloutGroup> getWithDetailedStatus(final Long rolloutGroupId) {
|
||||||
final Optional<RolloutGroup> rolloutGroup = findRolloutGroupById(rolloutGroupId);
|
final Optional<RolloutGroup> rolloutGroup = get(rolloutGroupId);
|
||||||
|
|
||||||
if (!rolloutGroup.isPresent()) {
|
if (!rolloutGroup.isPresent()) {
|
||||||
return rolloutGroup;
|
return rolloutGroup;
|
||||||
@@ -201,8 +201,8 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findRolloutGroupTargets(final Long rolloutGroupId, final String rsqlParam,
|
public Page<Target> findTargetsOfRolloutGroupByRsql(final Pageable pageable, final Long rolloutGroupId,
|
||||||
final Pageable pageable) {
|
final String rsqlParam) {
|
||||||
|
|
||||||
throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);
|
throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findRolloutGroupTargets(final Long rolloutGroupId, final Pageable page) {
|
public Page<Target> findTargetsOfRolloutGroup(final Pageable page, final Long rolloutGroupId) {
|
||||||
final JpaRolloutGroup rolloutGroup = rolloutGroupRepository.findById(rolloutGroupId)
|
final JpaRolloutGroup rolloutGroup = rolloutGroupRepository.findById(rolloutGroupId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(RolloutGroup.class, rolloutGroupId));
|
.orElseThrow(() -> new EntityNotFoundException(RolloutGroup.class, rolloutGroupId));
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<TargetWithActionStatus> findAllTargetsWithActionStatus(final Pageable pageRequest,
|
public Page<TargetWithActionStatus> findAllTargetsOfRolloutGroupWithActionStatus(final Pageable pageRequest,
|
||||||
final Long rolloutGroupId) {
|
final Long rolloutGroupId) {
|
||||||
throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);
|
throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);
|
||||||
|
|
||||||
@@ -269,7 +269,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countTargetsOfRolloutsGroup(@NotNull final Long rolloutGroupId) {
|
public long countTargetsOfRolloutsGroup(@NotNull final Long rolloutGroupId) {
|
||||||
throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);
|
throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);
|
||||||
|
|
||||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||||
@@ -287,7 +287,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long countRolloutGroupsByRolloutId(final Long rolloutId) {
|
public long countByRollout(final Long rolloutId) {
|
||||||
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
|
||||||
|
|
||||||
return rolloutGroupRepository.countByRolloutId(rolloutId);
|
return rolloutGroupRepository.countByRolloutId(rolloutId);
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Rollout> findAllByPredicate(final String rsqlParam, final Pageable pageable, final boolean deleted) {
|
public Page<Rollout> findByRsql(final Pageable pageable, final String rsqlParam, final boolean deleted) {
|
||||||
final List<Specification<JpaRollout>> specList = Lists.newArrayListWithExpectedSize(2);
|
final List<Specification<JpaRollout>> specList = Lists.newArrayListWithExpectedSize(2);
|
||||||
specList.add(RSQLUtility.parse(rsqlParam, RolloutFields.class, virtualPropertyReplacer));
|
specList.add(RSQLUtility.parse(rsqlParam, RolloutFields.class, virtualPropertyReplacer));
|
||||||
specList.add(RolloutSpecification.isDeletedWithDistributionSet(deleted));
|
specList.add(RolloutSpecification.isDeletedWithDistributionSet(deleted));
|
||||||
@@ -186,7 +186,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Rollout> findRolloutById(final Long rolloutId) {
|
public Optional<Rollout> get(final Long rolloutId) {
|
||||||
return Optional.ofNullable(rolloutRepository.findOne(rolloutId));
|
return Optional.ofNullable(rolloutRepository.findOne(rolloutId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,8 +194,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Rollout createRollout(final RolloutCreate rollout, final int amountGroup,
|
public Rollout create(final RolloutCreate rollout, final int amountGroup, final RolloutGroupConditions conditions) {
|
||||||
final RolloutGroupConditions conditions) {
|
|
||||||
RolloutHelper.verifyRolloutGroupParameter(amountGroup, quotaManagement);
|
RolloutHelper.verifyRolloutGroupParameter(amountGroup, quotaManagement);
|
||||||
final JpaRollout savedRollout = createRollout((JpaRollout) rollout.build());
|
final JpaRollout savedRollout = createRollout((JpaRollout) rollout.build());
|
||||||
return createRolloutGroups(amountGroup, conditions, savedRollout);
|
return createRolloutGroups(amountGroup, conditions, savedRollout);
|
||||||
@@ -205,7 +204,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Rollout createRollout(final RolloutCreate rollout, final List<RolloutGroupCreate> groups,
|
public Rollout create(final RolloutCreate rollout, final List<RolloutGroupCreate> groups,
|
||||||
final RolloutGroupConditions conditions) {
|
final RolloutGroupConditions conditions) {
|
||||||
RolloutHelper.verifyRolloutGroupParameter(groups.size(), quotaManagement);
|
RolloutHelper.verifyRolloutGroupParameter(groups.size(), quotaManagement);
|
||||||
final JpaRollout savedRollout = createRollout((JpaRollout) rollout.build());
|
final JpaRollout savedRollout = createRollout((JpaRollout) rollout.build());
|
||||||
@@ -214,7 +213,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
|
|
||||||
private JpaRollout createRollout(final JpaRollout rollout) {
|
private JpaRollout createRollout(final JpaRollout rollout) {
|
||||||
|
|
||||||
final Long totalTargets = targetManagement.countTargetByTargetFilterQuery(rollout.getTargetFilterQuery());
|
final Long totalTargets = targetManagement.countByRsql(rollout.getTargetFilterQuery());
|
||||||
if (totalTargets == 0) {
|
if (totalTargets == 0) {
|
||||||
throw new ValidationException("Rollout does not match any existing targets");
|
throw new ValidationException("Rollout does not match any existing targets");
|
||||||
}
|
}
|
||||||
@@ -320,9 +319,9 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
private void handleCreateRollout(final JpaRollout rollout) {
|
private void handleCreateRollout(final JpaRollout rollout) {
|
||||||
LOGGER.debug("handleCreateRollout called for rollout {}", rollout.getId());
|
LOGGER.debug("handleCreateRollout called for rollout {}", rollout.getId());
|
||||||
|
|
||||||
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement.findRolloutGroupsByRolloutId(rollout.getId(),
|
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement.findByRollout(
|
||||||
new PageRequest(0, quotaManagement.getMaxRolloutGroupsPerRollout(), new Sort(Direction.ASC, "id")))
|
new PageRequest(0, quotaManagement.getMaxRolloutGroupsPerRollout(), new Sort(Direction.ASC, "id")),
|
||||||
.getContent();
|
rollout.getId()).getContent();
|
||||||
|
|
||||||
int readyGroups = 0;
|
int readyGroups = 0;
|
||||||
int totalTargets = 0;
|
int totalTargets = 0;
|
||||||
@@ -368,7 +367,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
RolloutGroupStatus.READY, group);
|
RolloutGroupStatus.READY, group);
|
||||||
|
|
||||||
final long targetsInGroupFilter = runInNewTransaction("countAllTargetsByTargetFilterQueryAndNotInRolloutGroups",
|
final long targetsInGroupFilter = runInNewTransaction("countAllTargetsByTargetFilterQueryAndNotInRolloutGroups",
|
||||||
count -> targetManagement.countAllTargetsByTargetFilterQueryAndNotInRolloutGroups(readyGroups,
|
count -> targetManagement.countByRsqlAndNotInRolloutGroups(readyGroups,
|
||||||
groupTargetFilter));
|
groupTargetFilter));
|
||||||
final long expectedInGroup = Math.round(group.getTargetPercentage() / 100 * (double) targetsInGroupFilter);
|
final long expectedInGroup = Math.round(group.getTargetPercentage() / 100 * (double) targetsInGroupFilter);
|
||||||
final long currentlyInGroup = runInNewTransaction("countRolloutTargetGroupByRolloutGroup",
|
final long currentlyInGroup = runInNewTransaction("countRolloutTargetGroupByRolloutGroup",
|
||||||
@@ -410,7 +409,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
final List<Long> readyGroups = RolloutHelper.getGroupsByStatusIncludingGroup(rollout.getRolloutGroups(),
|
final List<Long> readyGroups = RolloutHelper.getGroupsByStatusIncludingGroup(rollout.getRolloutGroups(),
|
||||||
RolloutGroupStatus.READY, group);
|
RolloutGroupStatus.READY, group);
|
||||||
final Page<Target> targets = targetManagement
|
final Page<Target> targets = targetManagement
|
||||||
.findAllTargetsByTargetFilterQueryAndNotInRolloutGroups(pageRequest, readyGroups, targetFilter);
|
.findByTargetFilterQueryAndNotInRolloutGroups(pageRequest, readyGroups, targetFilter);
|
||||||
|
|
||||||
createAssignmentOfTargetsToGroup(targets, group);
|
createAssignmentOfTargetsToGroup(targets, group);
|
||||||
|
|
||||||
@@ -428,7 +427,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
final String targetFilter, final Long createdAt) {
|
final String targetFilter, final Long createdAt) {
|
||||||
|
|
||||||
final String baseFilter = RolloutHelper.getTargetFilterQuery(targetFilter, createdAt);
|
final String baseFilter = RolloutHelper.getTargetFilterQuery(targetFilter, createdAt);
|
||||||
final long totalTargets = targetManagement.countTargetByTargetFilterQuery(baseFilter);
|
final long totalTargets = targetManagement.countByRsql(baseFilter);
|
||||||
if (totalTargets == 0) {
|
if (totalTargets == 0) {
|
||||||
throw new ConstraintDeclarationException("Rollout target filter does not match any targets");
|
throw new ConstraintDeclarationException("Rollout target filter does not match any targets");
|
||||||
}
|
}
|
||||||
@@ -441,7 +440,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Rollout startRollout(final Long rolloutId) {
|
public Rollout start(final Long rolloutId) {
|
||||||
LOGGER.debug("startRollout called for rollout {}", rolloutId);
|
LOGGER.debug("startRollout called for rollout {}", rolloutId);
|
||||||
|
|
||||||
final JpaRollout rollout = getRolloutAndThrowExceptionIfNotFound(rolloutId);
|
final JpaRollout rollout = getRolloutAndThrowExceptionIfNotFound(rolloutId);
|
||||||
@@ -531,7 +530,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
final ActionType actionType = rollout.getActionType();
|
final ActionType actionType = rollout.getActionType();
|
||||||
final long forceTime = rollout.getForcedTime();
|
final long forceTime = rollout.getForcedTime();
|
||||||
|
|
||||||
final Page<Target> targets = targetManagement.findAllTargetsInRolloutGroupWithoutAction(pageRequest,
|
final Page<Target> targets = targetManagement.findByInRolloutGroupWithoutAction(pageRequest,
|
||||||
groupId);
|
groupId);
|
||||||
if (targets.getTotalElements() > 0) {
|
if (targets.getTotalElements() > 0) {
|
||||||
createScheduledAction(targets.getContent(), distributionSet, actionType, forceTime, rollout, group);
|
createScheduledAction(targets.getContent(), distributionSet, actionType, forceTime, rollout, group);
|
||||||
@@ -812,7 +811,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
LOGGER.debug(
|
LOGGER.debug(
|
||||||
"handleReadyRollout called for rollout {} with autostart beyond define time. Switch to STARTING",
|
"handleReadyRollout called for rollout {} with autostart beyond define time. Switch to STARTING",
|
||||||
rollout.getId());
|
rollout.getId());
|
||||||
startRollout(rollout.getId());
|
start(rollout.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -820,7 +819,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteRollout(final long rolloutId) {
|
public void delete(final Long rolloutId) {
|
||||||
final JpaRollout jpaRollout = rolloutRepository.findOne(rolloutId);
|
final JpaRollout jpaRollout = rolloutRepository.findOne(rolloutId);
|
||||||
|
|
||||||
if (jpaRollout == null) {
|
if (jpaRollout == null) {
|
||||||
@@ -915,17 +914,17 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countRolloutsAll() {
|
public long count() {
|
||||||
return rolloutRepository.count(RolloutSpecification.isDeletedWithDistributionSet(false));
|
return rolloutRepository.count(RolloutSpecification.isDeletedWithDistributionSet(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countRolloutsAllByFilters(final String searchText) {
|
public long countByFilters(final String searchText) {
|
||||||
return rolloutRepository.count(JpaRolloutHelper.likeNameOrDescription(searchText, false));
|
return rolloutRepository.count(JpaRolloutHelper.likeNameOrDescription(searchText, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Slice<Rollout> findRolloutWithDetailedStatusByFilters(final Pageable pageable, final String searchText,
|
public Slice<Rollout> findByFiltersWithDetailedStatus(final Pageable pageable, final String searchText,
|
||||||
final boolean deleted) {
|
final boolean deleted) {
|
||||||
final Slice<JpaRollout> findAll = findByCriteriaAPI(pageable,
|
final Slice<JpaRollout> findAll = findByCriteriaAPI(pageable,
|
||||||
Arrays.asList(JpaRolloutHelper.likeNameOrDescription(searchText, deleted)));
|
Arrays.asList(JpaRolloutHelper.likeNameOrDescription(searchText, deleted)));
|
||||||
@@ -934,7 +933,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Rollout> findRolloutByName(final String rolloutName) {
|
public Optional<Rollout> getByName(final String rolloutName) {
|
||||||
return rolloutRepository.findByName(rolloutName);
|
return rolloutRepository.findByName(rolloutName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -942,7 +941,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Rollout updateRollout(final RolloutUpdate u) {
|
public Rollout update(final RolloutUpdate u) {
|
||||||
final GenericRolloutUpdate update = (GenericRolloutUpdate) u;
|
final GenericRolloutUpdate update = (GenericRolloutUpdate) u;
|
||||||
final JpaRollout rollout = getRolloutAndThrowExceptionIfNotFound(update.getId());
|
final JpaRollout rollout = getRolloutAndThrowExceptionIfNotFound(update.getId());
|
||||||
|
|
||||||
@@ -954,7 +953,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
update.getForcedTime().ifPresent(rollout::setForcedTime);
|
update.getForcedTime().ifPresent(rollout::setForcedTime);
|
||||||
update.getStartAt().ifPresent(rollout::setStartAt);
|
update.getStartAt().ifPresent(rollout::setStartAt);
|
||||||
update.getSet().ifPresent(setId -> {
|
update.getSet().ifPresent(setId -> {
|
||||||
final DistributionSet set = distributionSetManagement.findDistributionSetById(setId)
|
final DistributionSet set = distributionSetManagement.get(setId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
||||||
|
|
||||||
rollout.setDistributionSet(set);
|
rollout.setDistributionSet(set);
|
||||||
@@ -975,7 +974,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Rollout> findAllRolloutsWithDetailedStatus(final Pageable pageable, final boolean deleted) {
|
public Page<Rollout> findAllWithDetailedStatus(final Pageable pageable, final boolean deleted) {
|
||||||
Page<JpaRollout> rollouts;
|
Page<JpaRollout> rollouts;
|
||||||
final Specification<JpaRollout> spec = RolloutSpecification.isDeletedWithDistributionSet(deleted);
|
final Specification<JpaRollout> spec = RolloutSpecification.isDeletedWithDistributionSet(deleted);
|
||||||
rollouts = rolloutRepository.findAll(spec, pageable);
|
rollouts = rolloutRepository.findAll(spec, pageable);
|
||||||
@@ -984,8 +983,8 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Rollout> findRolloutWithDetailedStatus(final Long rolloutId) {
|
public Optional<Rollout> getWithDetailedStatus(final Long rolloutId) {
|
||||||
final Optional<Rollout> rollout = findRolloutById(rolloutId);
|
final Optional<Rollout> rollout = get(rolloutId);
|
||||||
|
|
||||||
if (!rollout.isPresent()) {
|
if (!rollout.isPresent()) {
|
||||||
return rollout;
|
return rollout;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public SoftwareModule updateSoftwareModule(final SoftwareModuleUpdate u) {
|
public SoftwareModule update(final SoftwareModuleUpdate u) {
|
||||||
final GenericSoftwareModuleUpdate update = (GenericSoftwareModuleUpdate) u;
|
final GenericSoftwareModuleUpdate update = (GenericSoftwareModuleUpdate) u;
|
||||||
|
|
||||||
final JpaSoftwareModule module = softwareModuleRepository.findById(update.getId())
|
final JpaSoftwareModule module = softwareModuleRepository.findById(update.getId())
|
||||||
@@ -129,7 +129,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public SoftwareModule createSoftwareModule(final SoftwareModuleCreate c) {
|
public SoftwareModule create(final SoftwareModuleCreate c) {
|
||||||
final JpaSoftwareModuleCreate create = (JpaSoftwareModuleCreate) c;
|
final JpaSoftwareModuleCreate create = (JpaSoftwareModuleCreate) c;
|
||||||
|
|
||||||
return softwareModuleRepository.save(create.build());
|
return softwareModuleRepository.save(create.build());
|
||||||
@@ -139,12 +139,12 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<SoftwareModule> createSoftwareModule(final Collection<SoftwareModuleCreate> swModules) {
|
public List<SoftwareModule> create(final Collection<SoftwareModuleCreate> swModules) {
|
||||||
return swModules.stream().map(this::createSoftwareModule).collect(Collectors.toList());
|
return swModules.stream().map(this::create).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Slice<SoftwareModule> findSoftwareModulesByType(final Pageable pageable, final Long typeId) {
|
public Slice<SoftwareModule> findByType(final Pageable pageable, final Long typeId) {
|
||||||
throwExceptionIfSoftwareModuleTypeDoesNotExist(typeId);
|
throwExceptionIfSoftwareModuleTypeDoesNotExist(typeId);
|
||||||
|
|
||||||
final List<Specification<JpaSoftwareModule>> specList = Lists.newArrayListWithExpectedSize(2);
|
final List<Specification<JpaSoftwareModule>> specList = Lists.newArrayListWithExpectedSize(2);
|
||||||
@@ -152,7 +152,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
specList.add(SoftwareModuleSpecification.equalType(typeId));
|
specList.add(SoftwareModuleSpecification.equalType(typeId));
|
||||||
specList.add(SoftwareModuleSpecification.isDeletedFalse());
|
specList.add(SoftwareModuleSpecification.isDeletedFalse());
|
||||||
|
|
||||||
return convertSmPage(findSwModuleByCriteriaAPI(pageable, specList), pageable);
|
return convertSmPage(findByCriteriaAPI(pageable, specList), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void throwExceptionIfSoftwareModuleTypeDoesNotExist(final Long typeId) {
|
private void throwExceptionIfSoftwareModuleTypeDoesNotExist(final Long typeId) {
|
||||||
@@ -176,12 +176,12 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SoftwareModule> findSoftwareModuleById(final Long id) {
|
public Optional<SoftwareModule> get(final Long id) {
|
||||||
return Optional.ofNullable(softwareModuleRepository.findOne(id));
|
return Optional.ofNullable(softwareModuleRepository.findOne(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SoftwareModule> findSoftwareModuleByNameAndVersion(final String name, final String version,
|
public Optional<SoftwareModule> getByNameAndVersionAndType(final String name, final String version,
|
||||||
final Long typeId) {
|
final Long typeId) {
|
||||||
|
|
||||||
throwExceptionIfSoftwareModuleTypeDoesNotExist(typeId);
|
throwExceptionIfSoftwareModuleTypeDoesNotExist(typeId);
|
||||||
@@ -193,7 +193,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
return distributionSetRepository.countByModulesId(moduleId) <= 0;
|
return distributionSetRepository.countByModulesId(moduleId) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Slice<JpaSoftwareModule> findSwModuleByCriteriaAPI(final Pageable pageable,
|
private Slice<JpaSoftwareModule> findByCriteriaAPI(final Pageable pageable,
|
||||||
final List<Specification<JpaSoftwareModule>> specList) {
|
final List<Specification<JpaSoftwareModule>> specList) {
|
||||||
return criteriaNoCountDao.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable,
|
return criteriaNoCountDao.findAll(SpecificationsBuilder.combineWithAnd(specList), pageable,
|
||||||
JpaSoftwareModule.class);
|
JpaSoftwareModule.class);
|
||||||
@@ -213,7 +213,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteSoftwareModules(final Collection<Long> ids) {
|
public void delete(final Collection<Long> ids) {
|
||||||
final List<JpaSoftwareModule> swModulesToDelete = softwareModuleRepository.findByIdIn(ids);
|
final List<JpaSoftwareModule> swModulesToDelete = softwareModuleRepository.findByIdIn(ids);
|
||||||
|
|
||||||
if (swModulesToDelete.size() < ids.size()) {
|
if (swModulesToDelete.size() < ids.size()) {
|
||||||
@@ -245,7 +245,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Slice<SoftwareModule> findSoftwareModulesAll(final Pageable pageable) {
|
public Slice<SoftwareModule> findAll(final Pageable pageable) {
|
||||||
|
|
||||||
final List<Specification<JpaSoftwareModule>> specList = new ArrayList<>(2);
|
final List<Specification<JpaSoftwareModule>> specList = new ArrayList<>(2);
|
||||||
|
|
||||||
@@ -261,18 +261,18 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
|
|
||||||
specList.add(spec);
|
specList.add(spec);
|
||||||
|
|
||||||
return convertSmPage(findSwModuleByCriteriaAPI(pageable, specList), pageable);
|
return convertSmPage(findByCriteriaAPI(pageable, specList), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countSoftwareModulesAll() {
|
public long count() {
|
||||||
final Specification<JpaSoftwareModule> spec = SoftwareModuleSpecification.isDeletedFalse();
|
final Specification<JpaSoftwareModule> spec = SoftwareModuleSpecification.isDeletedFalse();
|
||||||
|
|
||||||
return countSwModuleByCriteriaAPI(Arrays.asList(spec));
|
return countSwModuleByCriteriaAPI(Arrays.asList(spec));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<SoftwareModule> findSoftwareModulesByPredicate(final String rsqlParam, final Pageable pageable) {
|
public Page<SoftwareModule> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||||
final Specification<JpaSoftwareModule> spec = RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class,
|
final Specification<JpaSoftwareModule> spec = RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class,
|
||||||
virtualPropertyReplacer);
|
virtualPropertyReplacer);
|
||||||
|
|
||||||
@@ -281,12 +281,12 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||||
public List<SoftwareModule> findSoftwareModulesById(final Collection<Long> ids) {
|
public List<SoftwareModule> get(final Collection<Long> ids) {
|
||||||
return Collections.unmodifiableList(softwareModuleRepository.findByIdIn(ids));
|
return Collections.unmodifiableList(softwareModuleRepository.findByIdIn(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Slice<SoftwareModule> findSoftwareModuleByFilters(final Pageable pageable, final String searchText,
|
public Slice<SoftwareModule> findByTextAndType(final Pageable pageable, final String searchText,
|
||||||
final Long typeId) {
|
final Long typeId) {
|
||||||
|
|
||||||
final List<Specification<JpaSoftwareModule>> specList = new ArrayList<>(4);
|
final List<Specification<JpaSoftwareModule>> specList = new ArrayList<>(4);
|
||||||
@@ -315,11 +315,11 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
|
|
||||||
specList.add(spec);
|
specList.add(spec);
|
||||||
|
|
||||||
return convertSmPage(findSwModuleByCriteriaAPI(pageable, specList), pageable);
|
return convertSmPage(findByCriteriaAPI(pageable, specList), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Slice<AssignedSoftwareModule> findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
public Slice<AssignedSoftwareModule> findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
||||||
final Pageable pageable, final Long orderByDistributionId, final String searchText, final Long typeId) {
|
final Pageable pageable, final Long orderByDistributionId, final String searchText, final Long typeId) {
|
||||||
|
|
||||||
final List<AssignedSoftwareModule> resultList = new ArrayList<>();
|
final List<AssignedSoftwareModule> resultList = new ArrayList<>();
|
||||||
@@ -408,7 +408,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countSoftwareModuleByFilters(final String searchText, final Long typeId) {
|
public long countByTextAndType(final String searchText, final Long typeId) {
|
||||||
|
|
||||||
final List<Specification<JpaSoftwareModule>> specList = new ArrayList<>(3);
|
final List<Specification<JpaSoftwareModule>> specList = new ArrayList<>(3);
|
||||||
|
|
||||||
@@ -431,7 +431,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<SoftwareModule> findSoftwareModuleByAssignedTo(final Pageable pageable, final Long setId) {
|
public Page<SoftwareModule> findByAssignedTo(final Pageable pageable, final Long setId) {
|
||||||
if (!distributionSetRepository.exists(setId)) {
|
if (!distributionSetRepository.exists(setId)) {
|
||||||
throw new EntityNotFoundException(DistributionSet.class, setId);
|
throw new EntityNotFoundException(DistributionSet.class, setId);
|
||||||
}
|
}
|
||||||
@@ -443,7 +443,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public SoftwareModuleMetadata createSoftwareModuleMetadata(final Long moduleId, final MetaData md) {
|
public SoftwareModuleMetadata createMetaData(final Long moduleId, final MetaData md) {
|
||||||
|
|
||||||
checkAndThrowAlreadyIfSoftwareModuleMetadataExists(moduleId, md);
|
checkAndThrowAlreadyIfSoftwareModuleMetadataExists(moduleId, md);
|
||||||
|
|
||||||
@@ -461,8 +461,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<SoftwareModuleMetadata> createSoftwareModuleMetadata(final Long moduleId,
|
public List<SoftwareModuleMetadata> createMetaData(final Long moduleId, final Collection<MetaData> md) {
|
||||||
final Collection<MetaData> md) {
|
|
||||||
md.forEach(meta -> checkAndThrowAlreadyIfSoftwareModuleMetadataExists(moduleId, meta));
|
md.forEach(meta -> checkAndThrowAlreadyIfSoftwareModuleMetadataExists(moduleId, meta));
|
||||||
|
|
||||||
final JpaSoftwareModule module = touch(moduleId);
|
final JpaSoftwareModule module = touch(moduleId);
|
||||||
@@ -477,10 +476,10 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public SoftwareModuleMetadata updateSoftwareModuleMetadata(final Long moduleId, final MetaData md) {
|
public SoftwareModuleMetadata updateMetaData(final Long moduleId, final MetaData md) {
|
||||||
|
|
||||||
// check if exists otherwise throw entity not found exception
|
// check if exists otherwise throw entity not found exception
|
||||||
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) findSoftwareModuleMetadata(moduleId,
|
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) getMetaDataBySoftwareModuleId(moduleId,
|
||||||
md.getKey()).orElseThrow(
|
md.getKey()).orElseThrow(
|
||||||
() -> new EntityNotFoundException(SoftwareModuleMetadata.class, moduleId, md.getKey()));
|
() -> new EntityNotFoundException(SoftwareModuleMetadata.class, moduleId, md.getKey()));
|
||||||
metadata.setValue(md.getValue());
|
metadata.setValue(md.getValue());
|
||||||
@@ -515,30 +514,21 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
* of the module to touch
|
* of the module to touch
|
||||||
*/
|
*/
|
||||||
private JpaSoftwareModule touch(final Long moduleId) {
|
private JpaSoftwareModule touch(final Long moduleId) {
|
||||||
return touch(findSoftwareModuleById(moduleId)
|
return touch(get(moduleId).orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, moduleId)));
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, moduleId)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteSoftwareModuleMetadata(final Long moduleId, final String key) {
|
public void deleteMetaData(final Long moduleId, final String key) {
|
||||||
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) findSoftwareModuleMetadata(moduleId, key)
|
final JpaSoftwareModuleMetadata metadata = (JpaSoftwareModuleMetadata) getMetaDataBySoftwareModuleId(moduleId,
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, moduleId, key));
|
key).orElseThrow(() -> new EntityNotFoundException(SoftwareModuleMetadata.class, moduleId, key));
|
||||||
|
|
||||||
touch(metadata.getSoftwareModule());
|
touch(metadata.getSoftwareModule());
|
||||||
softwareModuleMetadataRepository.delete(metadata.getId());
|
softwareModuleMetadataRepository.delete(metadata.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(final Long swId,
|
|
||||||
final Pageable pageable) {
|
|
||||||
throwExceptionIfSoftwareModuleDoesNotExist(swId);
|
|
||||||
|
|
||||||
return softwareModuleMetadataRepository.findBySoftwareModuleId(swId, pageable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void throwExceptionIfSoftwareModuleDoesNotExist(final Long swId) {
|
private void throwExceptionIfSoftwareModuleDoesNotExist(final Long swId) {
|
||||||
if (!softwareModuleRepository.exists(swId)) {
|
if (!softwareModuleRepository.exists(swId)) {
|
||||||
throw new EntityNotFoundException(SoftwareModule.class, swId);
|
throw new EntityNotFoundException(SoftwareModule.class, swId);
|
||||||
@@ -546,8 +536,8 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(final Long softwareModuleId,
|
public Page<SoftwareModuleMetadata> findMetaDataByRsql(final Pageable pageable, final Long softwareModuleId,
|
||||||
final String rsqlParam, final Pageable pageable) {
|
final String rsqlParam) {
|
||||||
|
|
||||||
throwExceptionIfSoftwareModuleDoesNotExist(softwareModuleId);
|
throwExceptionIfSoftwareModuleDoesNotExist(softwareModuleId);
|
||||||
|
|
||||||
@@ -564,18 +554,23 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
pageable);
|
pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private static Page<SoftwareModuleMetadata> convertMdPage(final Page<JpaSoftwareModuleMetadata> findAll,
|
||||||
public Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(final Pageable pageable,
|
final Pageable pageable) {
|
||||||
final Long softwareModuleId) {
|
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||||
throwExceptionIfSoftwareModuleDoesNotExist(softwareModuleId);
|
}
|
||||||
|
|
||||||
return convertSmMdPage(softwareModuleMetadataRepository.findAll((root, query, cb) -> cb.equal(
|
@Override
|
||||||
root.get(JpaSoftwareModuleMetadata_.softwareModule).get(JpaSoftwareModule_.id), softwareModuleId),
|
public Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleId(final Pageable pageable, final Long swId) {
|
||||||
|
throwExceptionIfSoftwareModuleDoesNotExist(swId);
|
||||||
|
|
||||||
|
return convertMdPage(softwareModuleMetadataRepository.findAll(
|
||||||
|
(Specification<JpaSoftwareModuleMetadata>) (root, query, cb) -> cb
|
||||||
|
.equal(root.get(JpaSoftwareModuleMetadata_.softwareModule).get(JpaSoftwareModule_.id), swId),
|
||||||
pageable), pageable);
|
pageable), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SoftwareModuleMetadata> findSoftwareModuleMetadata(final Long moduleId, final String key) {
|
public Optional<SoftwareModuleMetadata> getMetaDataBySoftwareModuleId(final Long moduleId, final String key) {
|
||||||
throwExceptionIfSoftwareModuleDoesNotExist(moduleId);
|
throwExceptionIfSoftwareModuleDoesNotExist(moduleId);
|
||||||
|
|
||||||
return Optional.ofNullable(softwareModuleMetadataRepository.findOne(new SwMetadataCompositeKey(moduleId, key)));
|
return Optional.ofNullable(softwareModuleMetadataRepository.findOne(new SwMetadataCompositeKey(moduleId, key)));
|
||||||
@@ -589,13 +584,13 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteSoftwareModule(final Long moduleId) {
|
public void delete(final Long moduleId) {
|
||||||
deleteSoftwareModules(Arrays.asList(moduleId));
|
delete(Arrays.asList(moduleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SoftwareModuleType> findSoftwareModuleTypesById(final Collection<Long> ids) {
|
public boolean exists(final Long id) {
|
||||||
return Collections.unmodifiableList(softwareModuleTypeRepository.findByIdIn(ids));
|
return softwareModuleRepository.exists(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.builder.JpaSoftwareModuleTypeCreate;
|
import org.eclipse.hawkbit.repository.jpa.builder.JpaSoftwareModuleTypeCreate;
|
||||||
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType_;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
@@ -30,6 +31,7 @@ import org.springframework.dao.ConcurrencyFailureException;
|
|||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageImpl;
|
import org.springframework.data.domain.PageImpl;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.retry.annotation.Backoff;
|
import org.springframework.retry.annotation.Backoff;
|
||||||
import org.springframework.retry.annotation.Retryable;
|
import org.springframework.retry.annotation.Retryable;
|
||||||
@@ -52,24 +54,27 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
|
|
||||||
private final SoftwareModuleRepository softwareModuleRepository;
|
private final SoftwareModuleRepository softwareModuleRepository;
|
||||||
|
|
||||||
|
private final NoCountPagingRepository criteriaNoCountDao;
|
||||||
|
|
||||||
JpaSoftwareModuleTypeManagement(final DistributionSetTypeRepository distributionSetTypeRepository,
|
JpaSoftwareModuleTypeManagement(final DistributionSetTypeRepository distributionSetTypeRepository,
|
||||||
final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
||||||
final VirtualPropertyReplacer virtualPropertyReplacer,
|
final VirtualPropertyReplacer virtualPropertyReplacer,
|
||||||
final SoftwareModuleRepository softwareModuleRepository) {
|
final SoftwareModuleRepository softwareModuleRepository, final NoCountPagingRepository criteriaNoCountDao) {
|
||||||
this.distributionSetTypeRepository = distributionSetTypeRepository;
|
this.distributionSetTypeRepository = distributionSetTypeRepository;
|
||||||
this.softwareModuleTypeRepository = softwareModuleTypeRepository;
|
this.softwareModuleTypeRepository = softwareModuleTypeRepository;
|
||||||
this.virtualPropertyReplacer = virtualPropertyReplacer;
|
this.virtualPropertyReplacer = virtualPropertyReplacer;
|
||||||
this.softwareModuleRepository = softwareModuleRepository;
|
this.softwareModuleRepository = softwareModuleRepository;
|
||||||
|
this.criteriaNoCountDao = criteriaNoCountDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public SoftwareModuleType updateSoftwareModuleType(final SoftwareModuleTypeUpdate u) {
|
public SoftwareModuleType update(final SoftwareModuleTypeUpdate u) {
|
||||||
final GenericSoftwareModuleTypeUpdate update = (GenericSoftwareModuleTypeUpdate) u;
|
final GenericSoftwareModuleTypeUpdate update = (GenericSoftwareModuleTypeUpdate) u;
|
||||||
|
|
||||||
final JpaSoftwareModuleType type = (JpaSoftwareModuleType) findSoftwareModuleTypeById(update.getId())
|
final JpaSoftwareModuleType type = (JpaSoftwareModuleType) get(update.getId())
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, update.getId()));
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, update.getId()));
|
||||||
|
|
||||||
update.getDescription().ifPresent(type::setDescription);
|
update.getDescription().ifPresent(type::setDescription);
|
||||||
@@ -79,36 +84,33 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<SoftwareModuleType> findSoftwareModuleTypesAll(final String rsqlParam, final Pageable pageable) {
|
public Page<SoftwareModuleType> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||||
|
|
||||||
final Specification<JpaSoftwareModuleType> spec = RSQLUtility.parse(rsqlParam, SoftwareModuleTypeFields.class,
|
final Specification<JpaSoftwareModuleType> spec = RSQLUtility.parse(rsqlParam, SoftwareModuleTypeFields.class,
|
||||||
virtualPropertyReplacer);
|
virtualPropertyReplacer);
|
||||||
|
|
||||||
return convertSmTPage(softwareModuleTypeRepository.findAll(spec, pageable), pageable);
|
return convertPage(softwareModuleTypeRepository.findAll(spec, pageable), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<SoftwareModuleType> findSoftwareModuleTypesAll(final Pageable pageable) {
|
public Slice<SoftwareModuleType> findAll(final Pageable pageable) {
|
||||||
return softwareModuleTypeRepository.findByDeleted(pageable, false);
|
return convertPage(criteriaNoCountDao.findAll(
|
||||||
|
(targetRoot, query, cb) -> cb.equal(targetRoot.<Boolean> get(JpaSoftwareModuleType_.deleted), false),
|
||||||
|
pageable, JpaSoftwareModuleType.class), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countSoftwareModuleTypesAll() {
|
public long count() {
|
||||||
return softwareModuleTypeRepository.countByDeleted(false);
|
return softwareModuleTypeRepository.countByDeleted(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SoftwareModuleType> findSoftwareModuleTypeByKey(final String key) {
|
public Optional<SoftwareModuleType> getByKey(final String key) {
|
||||||
return softwareModuleTypeRepository.findByKey(key);
|
return softwareModuleTypeRepository.findByKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SoftwareModuleType> findSoftwareModuleTypeById(final Long smTypeId) {
|
public Optional<SoftwareModuleType> getByName(final String name) {
|
||||||
return Optional.ofNullable(softwareModuleTypeRepository.findOne(smTypeId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<SoftwareModuleType> findSoftwareModuleTypeByName(final String name) {
|
|
||||||
return softwareModuleTypeRepository.findByName(name);
|
return softwareModuleTypeRepository.findByName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +118,7 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public SoftwareModuleType createSoftwareModuleType(final SoftwareModuleTypeCreate c) {
|
public SoftwareModuleType create(final SoftwareModuleTypeCreate c) {
|
||||||
final JpaSoftwareModuleTypeCreate create = (JpaSoftwareModuleTypeCreate) c;
|
final JpaSoftwareModuleTypeCreate create = (JpaSoftwareModuleTypeCreate) c;
|
||||||
|
|
||||||
return softwareModuleTypeRepository.save(create.build());
|
return softwareModuleTypeRepository.save(create.build());
|
||||||
@@ -126,7 +128,7 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteSoftwareModuleType(final Long typeId) {
|
public void delete(final Long typeId) {
|
||||||
final JpaSoftwareModuleType toDelete = softwareModuleTypeRepository.findById(typeId)
|
final JpaSoftwareModuleType toDelete = softwareModuleTypeRepository.findById(typeId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, typeId));
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, typeId));
|
||||||
|
|
||||||
@@ -143,13 +145,48 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<SoftwareModuleType> createSoftwareModuleType(final Collection<SoftwareModuleTypeCreate> creates) {
|
public List<SoftwareModuleType> create(final Collection<SoftwareModuleTypeCreate> creates) {
|
||||||
return creates.stream().map(this::createSoftwareModuleType).collect(Collectors.toList());
|
return creates.stream().map(this::create).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Page<SoftwareModuleType> convertSmTPage(final Page<JpaSoftwareModuleType> findAll,
|
private static Page<SoftwareModuleType> convertPage(final Page<JpaSoftwareModuleType> findAll,
|
||||||
final Pageable pageable) {
|
final Pageable pageable) {
|
||||||
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Slice<SoftwareModuleType> convertPage(final Slice<JpaSoftwareModuleType> findAll,
|
||||||
|
final Pageable pageable) {
|
||||||
|
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(include = {
|
||||||
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public void delete(final Collection<Long> ids) {
|
||||||
|
final List<JpaSoftwareModuleType> setsFound = softwareModuleTypeRepository.findAll(ids);
|
||||||
|
|
||||||
|
if (setsFound.size() < ids.size()) {
|
||||||
|
throw new EntityNotFoundException(SoftwareModuleType.class, ids,
|
||||||
|
setsFound.stream().map(SoftwareModuleType::getId).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
softwareModuleTypeRepository.delete(setsFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SoftwareModuleType> get(final Collection<Long> ids) {
|
||||||
|
return Collections.unmodifiableList(softwareModuleTypeRepository.findAll(ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<SoftwareModuleType> get(final Long id) {
|
||||||
|
return Optional.ofNullable(softwareModuleTypeRepository.findOne(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean exists(final Long id) {
|
||||||
|
return softwareModuleTypeRepository.exists(id);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public TargetFilterQuery createTargetFilterQuery(final TargetFilterQueryCreate c) {
|
public TargetFilterQuery create(final TargetFilterQueryCreate c) {
|
||||||
final JpaTargetFilterQueryCreate create = (JpaTargetFilterQueryCreate) c;
|
final JpaTargetFilterQueryCreate create = (JpaTargetFilterQueryCreate) c;
|
||||||
|
|
||||||
return targetFilterQueryRepository.save(create.build());
|
return targetFilterQueryRepository.save(create.build());
|
||||||
@@ -84,20 +84,20 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteTargetFilterQuery(final Long targetFilterQueryId) {
|
public void delete(final Long targetFilterQueryId) {
|
||||||
findTargetFilterQueryById(targetFilterQueryId)
|
get(targetFilterQueryId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
|
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
|
||||||
|
|
||||||
targetFilterQueryRepository.delete(targetFilterQueryId);
|
targetFilterQueryRepository.delete(targetFilterQueryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<TargetFilterQuery> findAllTargetFilterQuery(final Pageable pageable) {
|
public Page<TargetFilterQuery> findAll(final Pageable pageable) {
|
||||||
return convertPage(targetFilterQueryRepository.findAll(pageable), pageable);
|
return convertPage(targetFilterQueryRepository.findAll(pageable), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countAllTargetFilterQuery() {
|
public long count() {
|
||||||
return targetFilterQueryRepository.count();
|
return targetFilterQueryRepository.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<TargetFilterQuery> findTargetFilterQueryByName(final Pageable pageable, final String name) {
|
public Page<TargetFilterQuery> findByName(final Pageable pageable, final String name) {
|
||||||
List<Specification<JpaTargetFilterQuery>> specList = Collections.emptyList();
|
List<Specification<JpaTargetFilterQuery>> specList = Collections.emptyList();
|
||||||
if (!StringUtils.isEmpty(name)) {
|
if (!StringUtils.isEmpty(name)) {
|
||||||
specList = Collections.singletonList(TargetFilterQuerySpecification.likeName(name));
|
specList = Collections.singletonList(TargetFilterQuerySpecification.likeName(name));
|
||||||
@@ -116,7 +116,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<TargetFilterQuery> findTargetFilterQueryByFilter(final Pageable pageable, final String rsqlFilter) {
|
public Page<TargetFilterQuery> findByRsql(final Pageable pageable, final String rsqlFilter) {
|
||||||
List<Specification<JpaTargetFilterQuery>> specList = Collections.emptyList();
|
List<Specification<JpaTargetFilterQuery>> specList = Collections.emptyList();
|
||||||
if (!StringUtils.isEmpty(rsqlFilter)) {
|
if (!StringUtils.isEmpty(rsqlFilter)) {
|
||||||
specList = Collections.singletonList(
|
specList = Collections.singletonList(
|
||||||
@@ -126,7 +126,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<TargetFilterQuery> findTargetFilterQueryByQuery(final Pageable pageable, final String query) {
|
public Page<TargetFilterQuery> findByQuery(final Pageable pageable, final String query) {
|
||||||
List<Specification<JpaTargetFilterQuery>> specList = Collections.emptyList();
|
List<Specification<JpaTargetFilterQuery>> specList = Collections.emptyList();
|
||||||
if (!StringUtils.isEmpty(query)) {
|
if (!StringUtils.isEmpty(query)) {
|
||||||
specList = Collections.singletonList(TargetFilterQuerySpecification.equalsQuery(query));
|
specList = Collections.singletonList(TargetFilterQuerySpecification.equalsQuery(query));
|
||||||
@@ -135,7 +135,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(final Pageable pageable, final Long setId,
|
public Page<TargetFilterQuery> findByAutoAssignDSAndRsql(final Pageable pageable, final Long setId,
|
||||||
final String rsqlFilter) {
|
final String rsqlFilter) {
|
||||||
final List<Specification<JpaTargetFilterQuery>> specList = Lists.newArrayListWithExpectedSize(2);
|
final List<Specification<JpaTargetFilterQuery>> specList = Lists.newArrayListWithExpectedSize(2);
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<TargetFilterQuery> findTargetFilterQueryWithAutoAssignDS(final Pageable pageable) {
|
public Page<TargetFilterQuery> findWithAutoAssignDS(final Pageable pageable) {
|
||||||
final List<Specification<JpaTargetFilterQuery>> specList = Collections
|
final List<Specification<JpaTargetFilterQuery>> specList = Collections
|
||||||
.singletonList(TargetFilterQuerySpecification.withAutoAssignDS());
|
.singletonList(TargetFilterQuerySpecification.withAutoAssignDS());
|
||||||
return convertPage(findTargetFilterQueryByCriteriaAPI(pageable, specList), pageable);
|
return convertPage(findTargetFilterQueryByCriteriaAPI(pageable, specList), pageable);
|
||||||
@@ -167,18 +167,18 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<TargetFilterQuery> findTargetFilterQueryByName(final String targetFilterQueryName) {
|
public Optional<TargetFilterQuery> getByName(final String targetFilterQueryName) {
|
||||||
return targetFilterQueryRepository.findByName(targetFilterQueryName);
|
return targetFilterQueryRepository.findByName(targetFilterQueryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<TargetFilterQuery> findTargetFilterQueryById(final Long targetFilterQueryId) {
|
public Optional<TargetFilterQuery> get(final Long targetFilterQueryId) {
|
||||||
return Optional.ofNullable(targetFilterQueryRepository.findOne(targetFilterQueryId));
|
return Optional.ofNullable(targetFilterQueryRepository.findOne(targetFilterQueryId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public TargetFilterQuery updateTargetFilterQuery(final TargetFilterQueryUpdate u) {
|
public TargetFilterQuery update(final TargetFilterQueryUpdate u) {
|
||||||
final GenericTargetFilterQueryUpdate update = (GenericTargetFilterQueryUpdate) u;
|
final GenericTargetFilterQueryUpdate update = (GenericTargetFilterQueryUpdate) u;
|
||||||
|
|
||||||
final JpaTargetFilterQuery targetFilterQuery = findTargetFilterQueryOrThrowExceptionIfNotFound(update.getId());
|
final JpaTargetFilterQuery targetFilterQuery = findTargetFilterQueryOrThrowExceptionIfNotFound(update.getId());
|
||||||
@@ -191,7 +191,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public TargetFilterQuery updateTargetFilterQueryAutoAssignDS(final Long queryId, final Long dsId) {
|
public TargetFilterQuery updateAutoAssignDS(final Long queryId, final Long dsId) {
|
||||||
final JpaTargetFilterQuery targetFilterQuery = findTargetFilterQueryOrThrowExceptionIfNotFound(queryId);
|
final JpaTargetFilterQuery targetFilterQuery = findTargetFilterQueryOrThrowExceptionIfNotFound(queryId);
|
||||||
|
|
||||||
targetFilterQuery.setAutoAssignDistributionSet(
|
targetFilterQuery.setAutoAssignDistributionSet(
|
||||||
@@ -201,7 +201,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private JpaDistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
private JpaDistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
||||||
return (JpaDistributionSet) distributionSetManagement.findDistributionSetByIdWithDetails(setId)
|
return (JpaDistributionSet) distributionSetManagement.getWithDetails(setId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,28 +116,28 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
private VirtualPropertyReplacer virtualPropertyReplacer;
|
private VirtualPropertyReplacer virtualPropertyReplacer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Target> findTargetByControllerID(final String controllerId) {
|
public Optional<Target> getByControllerID(final String controllerId) {
|
||||||
return targetRepository.findByControllerId(controllerId);
|
return targetRepository.findByControllerId(controllerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Target> findTargetsByControllerID(final Collection<String> controllerIDs) {
|
public List<Target> getByControllerID(final Collection<String> controllerIDs) {
|
||||||
return Collections.unmodifiableList(
|
return Collections.unmodifiableList(
|
||||||
targetRepository.findAll(TargetSpecifications.byControllerIdWithAssignedDsInJoin(controllerIDs)));
|
targetRepository.findAll(TargetSpecifications.byControllerIdWithAssignedDsInJoin(controllerIDs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countTargetsAll() {
|
public long count() {
|
||||||
return targetRepository.count();
|
return targetRepository.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Slice<Target> findTargetsAll(final Pageable pageable) {
|
public Slice<Target> findAll(final Pageable pageable) {
|
||||||
return convertPage(criteriaNoCountDao.findAll(pageable, JpaTarget.class), pageable);
|
return convertPage(criteriaNoCountDao.findAll(pageable, JpaTarget.class), pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Slice<Target> findTargetsByTargetFilterQuery(final Long targetFilterQueryId, final Pageable pageable) {
|
public Slice<Target> findByTargetFilterQuery(final Pageable pageable, final Long targetFilterQueryId) {
|
||||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryRepository.findById(targetFilterQueryId)
|
final TargetFilterQuery targetFilterQuery = targetFilterQueryRepository.findById(targetFilterQueryId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
|
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findTargetsAll(final String targetFilterQuery, final Pageable pageable) {
|
public Page<Target> findByRsql(final Pageable pageable, final String targetFilterQuery) {
|
||||||
return findTargetsBySpec(RSQLUtility.parse(targetFilterQuery, TargetFields.class, virtualPropertyReplacer),
|
return findTargetsBySpec(RSQLUtility.parse(targetFilterQuery, TargetFields.class, virtualPropertyReplacer),
|
||||||
pageable);
|
pageable);
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Target updateTarget(final TargetUpdate u) {
|
public Target update(final TargetUpdate u) {
|
||||||
final JpaTargetUpdate update = (JpaTargetUpdate) u;
|
final JpaTargetUpdate update = (JpaTargetUpdate) u;
|
||||||
|
|
||||||
final JpaTarget target = (JpaTarget) targetRepository.findByControllerId(update.getControllerId())
|
final JpaTarget target = (JpaTarget) targetRepository.findByControllerId(update.getControllerId())
|
||||||
@@ -177,7 +177,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteTargets(final Collection<Long> targetIDs) {
|
public void delete(final Collection<Long> targetIDs) {
|
||||||
final List<JpaTarget> targets = targetRepository.findAll(targetIDs);
|
final List<JpaTarget> targets = targetRepository.findAll(targetIDs);
|
||||||
|
|
||||||
if (targets.size() < targetIDs.size()) {
|
if (targets.size() < targetIDs.size()) {
|
||||||
@@ -197,7 +197,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public void deleteTarget(final String controllerID) {
|
public void deleteByControllerID(final String controllerID) {
|
||||||
final Target target = targetRepository.findByControllerId(controllerID)
|
final Target target = targetRepository.findByControllerId(controllerID)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerID));
|
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerID));
|
||||||
|
|
||||||
@@ -205,15 +205,15 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findTargetByAssignedDistributionSet(final Long distributionSetID, final Pageable pageReq) {
|
public Page<Target> findByAssignedDistributionSet(final Pageable pageReq, final Long distributionSetID) {
|
||||||
throwEntityNotFoundIfDsDoesNotExist(distributionSetID);
|
throwEntityNotFoundIfDsDoesNotExist(distributionSetID);
|
||||||
|
|
||||||
return targetRepository.findByAssignedDistributionSetId(pageReq, distributionSetID);
|
return targetRepository.findByAssignedDistributionSetId(pageReq, distributionSetID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findTargetByAssignedDistributionSet(final Long distributionSetID, final String rsqlParam,
|
public Page<Target> findByAssignedDistributionSetAndRsql(final Pageable pageReq, final Long distributionSetID,
|
||||||
final Pageable pageReq) {
|
final String rsqlParam) {
|
||||||
throwEntityNotFoundIfDsDoesNotExist(distributionSetID);
|
throwEntityNotFoundIfDsDoesNotExist(distributionSetID);
|
||||||
|
|
||||||
final Specification<JpaTarget> spec = RSQLUtility.parse(rsqlParam, TargetFields.class, virtualPropertyReplacer);
|
final Specification<JpaTarget> spec = RSQLUtility.parse(rsqlParam, TargetFields.class, virtualPropertyReplacer);
|
||||||
@@ -242,14 +242,14 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findTargetByInstalledDistributionSet(final Long distributionSetID, final Pageable pageReq) {
|
public Page<Target> findByInstalledDistributionSet(final Pageable pageReq, final Long distributionSetID) {
|
||||||
throwEntityNotFoundIfDsDoesNotExist(distributionSetID);
|
throwEntityNotFoundIfDsDoesNotExist(distributionSetID);
|
||||||
return targetRepository.findByInstalledDistributionSetId(pageReq, distributionSetID);
|
return targetRepository.findByInstalledDistributionSetId(pageReq, distributionSetID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findTargetByInstalledDistributionSet(final Long distributionSetId, final String rsqlParam,
|
public Page<Target> findByInstalledDistributionSetAndRsql(final Pageable pageable, final Long distributionSetId,
|
||||||
final Pageable pageable) {
|
final String rsqlParam) {
|
||||||
throwEntityNotFoundIfDsDoesNotExist(distributionSetId);
|
throwEntityNotFoundIfDsDoesNotExist(distributionSetId);
|
||||||
|
|
||||||
final Specification<JpaTarget> spec = RSQLUtility.parse(rsqlParam, TargetFields.class, virtualPropertyReplacer);
|
final Specification<JpaTarget> spec = RSQLUtility.parse(rsqlParam, TargetFields.class, virtualPropertyReplacer);
|
||||||
@@ -264,27 +264,22 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findTargetByUpdateStatus(final Pageable pageable, final TargetUpdateStatus status) {
|
public Page<Target> findByUpdateStatus(final Pageable pageable, final TargetUpdateStatus status) {
|
||||||
return targetRepository.findByUpdateStatus(pageable, status);
|
return targetRepository.findByUpdateStatus(pageable, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Slice<Target> findTargetByFilters(final Pageable pageable, final Collection<TargetUpdateStatus> status,
|
public Slice<Target> findByFilters(final Pageable pageable, final FilterParams filterParams) {
|
||||||
final Boolean overdueState, final String searchText, final Long installedOrAssignedDistributionSetId,
|
final List<Specification<JpaTarget>> specList = buildSpecificationList(filterParams);
|
||||||
final Boolean selectTargetWithNoTag, final String... tagNames) {
|
|
||||||
final List<Specification<JpaTarget>> specList = buildSpecificationList(
|
|
||||||
new FilterParams(installedOrAssignedDistributionSetId, status, overdueState, searchText,
|
|
||||||
selectTargetWithNoTag, tagNames));
|
|
||||||
return findByCriteriaAPI(pageable, specList);
|
return findByCriteriaAPI(pageable, specList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countTargetByFilters(final Collection<TargetUpdateStatus> status, final Boolean overdueState,
|
public long countByFilters(final Collection<TargetUpdateStatus> status, final Boolean overdueState,
|
||||||
final String searchText, final Long installedOrAssignedDistributionSetId,
|
final String searchText, final Long installedOrAssignedDistributionSetId,
|
||||||
final Boolean selectTargetWithNoTag, final String... tagNames) {
|
final Boolean selectTargetWithNoTag, final String... tagNames) {
|
||||||
final List<Specification<JpaTarget>> specList = buildSpecificationList(
|
final List<Specification<JpaTarget>> specList = buildSpecificationList(new FilterParams(status, overdueState,
|
||||||
new FilterParams(installedOrAssignedDistributionSetId, status, overdueState, searchText,
|
searchText, installedOrAssignedDistributionSetId, selectTargetWithNoTag, tagNames));
|
||||||
selectTargetWithNoTag, tagNames));
|
|
||||||
return countByCriteriaAPI(specList);
|
return countByCriteriaAPI(specList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,7 +416,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Slice<Target> findTargetsAllOrderByLinkedDistributionSet(final Pageable pageable,
|
public Slice<Target> findByFilterOrderByLinkedDistributionSet(final Pageable pageable,
|
||||||
final Long orderByDistributionId, final FilterParams filterParams) {
|
final Long orderByDistributionId, final FilterParams filterParams) {
|
||||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||||
final CriteriaQuery<JpaTarget> query = cb.createQuery(JpaTarget.class);
|
final CriteriaQuery<JpaTarget> query = cb.createQuery(JpaTarget.class);
|
||||||
@@ -475,22 +470,22 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countTargetByAssignedDistributionSet(final Long distId) {
|
public long countByAssignedDistributionSet(final Long distId) {
|
||||||
throwEntityNotFoundIfDsDoesNotExist(distId);
|
throwEntityNotFoundIfDsDoesNotExist(distId);
|
||||||
|
|
||||||
return targetRepository.countByAssignedDistributionSetId(distId);
|
return targetRepository.countByAssignedDistributionSetId(distId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countTargetByInstalledDistributionSet(final Long distId) {
|
public long countByInstalledDistributionSet(final Long distId) {
|
||||||
throwEntityNotFoundIfDsDoesNotExist(distId);
|
throwEntityNotFoundIfDsDoesNotExist(distId);
|
||||||
|
|
||||||
return targetRepository.countByInstalledDistributionSetId(distId);
|
return targetRepository.countByInstalledDistributionSetId(distId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findAllTargetsByTargetFilterQueryAndNonDS(final Pageable pageRequest,
|
public Page<Target> findByTargetFilterQueryAndNonDS(final Pageable pageRequest, final Long distributionSetId,
|
||||||
final Long distributionSetId, final String targetFilterQuery) {
|
final String targetFilterQuery) {
|
||||||
throwEntityNotFoundIfDsDoesNotExist(distributionSetId);
|
throwEntityNotFoundIfDsDoesNotExist(distributionSetId);
|
||||||
|
|
||||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||||
@@ -505,7 +500,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findAllTargetsByTargetFilterQueryAndNotInRolloutGroups(final Pageable pageRequest,
|
public Page<Target> findByTargetFilterQueryAndNotInRolloutGroups(final Pageable pageRequest,
|
||||||
final Collection<Long> groups, final String targetFilterQuery) {
|
final Collection<Long> groups, final String targetFilterQuery) {
|
||||||
|
|
||||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||||
@@ -517,7 +512,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findAllTargetsInRolloutGroupWithoutAction(@NotNull final Pageable pageRequest,
|
public Page<Target> findByInRolloutGroupWithoutAction(@NotNull final Pageable pageRequest,
|
||||||
@NotNull final Long group) {
|
@NotNull final Long group) {
|
||||||
if (!rolloutGroupRepository.exists(group)) {
|
if (!rolloutGroupRepository.exists(group)) {
|
||||||
throw new EntityNotFoundException(RolloutGroup.class, group);
|
throw new EntityNotFoundException(RolloutGroup.class, group);
|
||||||
@@ -529,8 +524,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countAllTargetsByTargetFilterQueryAndNotInRolloutGroups(final Collection<Long> groups,
|
public long countByRsqlAndNotInRolloutGroups(final Collection<Long> groups, final String targetFilterQuery) {
|
||||||
final String targetFilterQuery) {
|
|
||||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||||
virtualPropertyReplacer);
|
virtualPropertyReplacer);
|
||||||
final List<Specification<JpaTarget>> specList = Arrays.asList(spec,
|
final List<Specification<JpaTarget>> specList = Arrays.asList(spec,
|
||||||
@@ -540,7 +534,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countTargetsByTargetFilterQueryAndNonDS(final Long distributionSetId, final String targetFilterQuery) {
|
public long countByRsqlAndNonDS(final Long distributionSetId, final String targetFilterQuery) {
|
||||||
throwEntityNotFoundIfDsDoesNotExist(distributionSetId);
|
throwEntityNotFoundIfDsDoesNotExist(distributionSetId);
|
||||||
|
|
||||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||||
@@ -556,7 +550,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public Target createTarget(final TargetCreate c) {
|
public Target create(final TargetCreate c) {
|
||||||
final JpaTargetCreate create = (JpaTargetCreate) c;
|
final JpaTargetCreate create = (JpaTargetCreate) c;
|
||||||
return targetRepository.save(create.build());
|
return targetRepository.save(create.build());
|
||||||
}
|
}
|
||||||
@@ -565,12 +559,12 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Retryable(include = {
|
@Retryable(include = {
|
||||||
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
public List<Target> createTargets(final Collection<TargetCreate> targets) {
|
public List<Target> create(final Collection<TargetCreate> targets) {
|
||||||
return targets.stream().map(this::createTarget).collect(Collectors.toList());
|
return targets.stream().map(this::create).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findTargetsByTag(final Pageable pageable, final Long tagId) {
|
public Page<Target> findByTag(final Pageable pageable, final Long tagId) {
|
||||||
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
|
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
|
||||||
|
|
||||||
return convertPage(targetRepository.findByTag(pageable, tagId), pageable);
|
return convertPage(targetRepository.findByTag(pageable, tagId), pageable);
|
||||||
@@ -583,7 +577,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findTargetsByTag(final Pageable pageable, final String rsqlParam, final Long tagId) {
|
public Page<Target> findByRsqlAndTag(final Pageable pageable, final String rsqlParam, final Long tagId) {
|
||||||
|
|
||||||
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
|
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
|
||||||
|
|
||||||
@@ -595,7 +589,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countTargetByTargetFilterQuery(final Long targetFilterQueryId) {
|
public long countByTargetFilterQuery(final Long targetFilterQueryId) {
|
||||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryRepository.findById(targetFilterQueryId)
|
final TargetFilterQuery targetFilterQuery = targetFilterQueryRepository.findById(targetFilterQueryId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
|
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
|
||||||
|
|
||||||
@@ -605,7 +599,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long countTargetByTargetFilterQuery(final String targetFilterQuery) {
|
public long countByRsql(final String targetFilterQuery) {
|
||||||
final Specification<JpaTarget> specs = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
final Specification<JpaTarget> specs = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||||
virtualPropertyReplacer);
|
virtualPropertyReplacer);
|
||||||
return targetRepository.count((root, query, cb) -> {
|
return targetRepository.count((root, query, cb) -> {
|
||||||
@@ -615,18 +609,18 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Target> findTargetById(final Long id) {
|
public Optional<Target> get(final Long id) {
|
||||||
return Optional.ofNullable(targetRepository.findOne(id));
|
return Optional.ofNullable(targetRepository.findOne(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Target> findTargetsById(final Collection<Long> ids) {
|
public List<Target> get(final Collection<Long> ids) {
|
||||||
return Collections.unmodifiableList(targetRepository.findAll(ids));
|
return Collections.unmodifiableList(targetRepository.findAll(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getControllerAttributes(final String controllerId) {
|
public Map<String, String> getControllerAttributes(final String controllerId) {
|
||||||
final JpaTarget target = (JpaTarget) findTargetByControllerID(controllerId)
|
final JpaTarget target = (JpaTarget) getByControllerID(controllerId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||||
|
|
||||||
return target.getControllerAttributes();
|
return target.getControllerAttributes();
|
||||||
|
|||||||
@@ -0,0 +1,153 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
|
*
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*/
|
||||||
|
package org.eclipse.hawkbit.repository.jpa;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.repository.TagFields;
|
||||||
|
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||||
|
import org.eclipse.hawkbit.repository.builder.GenericTagUpdate;
|
||||||
|
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||||
|
import org.eclipse.hawkbit.repository.builder.TagUpdate;
|
||||||
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.builder.JpaTagCreate;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.specifications.TagSpecification;
|
||||||
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
|
import org.springframework.dao.ConcurrencyFailureException;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
import org.springframework.retry.annotation.Backoff;
|
||||||
|
import org.springframework.retry.annotation.Retryable;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JPA implementation of {@link TargetTagManagement}.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
@Validated
|
||||||
|
public class JpaTargetTagManagement implements TargetTagManagement {
|
||||||
|
|
||||||
|
private final TargetTagRepository targetTagRepository;
|
||||||
|
|
||||||
|
private final TargetRepository targetRepository;
|
||||||
|
|
||||||
|
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
||||||
|
|
||||||
|
JpaTargetTagManagement(final TargetTagRepository targetTagRepository, final TargetRepository targetRepository,
|
||||||
|
final VirtualPropertyReplacer virtualPropertyReplacer) {
|
||||||
|
this.targetTagRepository = targetTagRepository;
|
||||||
|
this.targetRepository = targetRepository;
|
||||||
|
this.virtualPropertyReplacer = virtualPropertyReplacer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<TargetTag> getByName(final String name) {
|
||||||
|
return targetTagRepository.findByNameEquals(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(include = {
|
||||||
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public TargetTag create(final TagCreate c) {
|
||||||
|
final JpaTagCreate create = (JpaTagCreate) c;
|
||||||
|
|
||||||
|
return targetTagRepository.save(create.buildTargetTag());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(include = {
|
||||||
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public List<TargetTag> create(final Collection<TagCreate> tt) {
|
||||||
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
|
final Collection<JpaTagCreate> targetTags = (Collection) tt;
|
||||||
|
|
||||||
|
return Collections.unmodifiableList(targetTags.stream()
|
||||||
|
.map(ttc -> targetTagRepository.save(ttc.buildTargetTag())).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(include = {
|
||||||
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public void delete(final String targetTagName) {
|
||||||
|
if (!targetTagRepository.existsByName(targetTagName)) {
|
||||||
|
throw new EntityNotFoundException(TargetTag.class, targetTagName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// finally delete the tag itself
|
||||||
|
targetTagRepository.deleteByName(targetTagName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<TargetTag> findByRsql(final Pageable pageable, final String rsqlParam) {
|
||||||
|
|
||||||
|
final Specification<JpaTargetTag> spec = RSQLUtility.parse(rsqlParam, TagFields.class, virtualPropertyReplacer);
|
||||||
|
return convertTPage(targetTagRepository.findAll(spec, pageable), pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Page<TargetTag> convertTPage(final Page<JpaTargetTag> findAll, final Pageable pageable) {
|
||||||
|
return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, findAll.getTotalElements());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long count() {
|
||||||
|
return targetTagRepository.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@Retryable(include = {
|
||||||
|
ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY))
|
||||||
|
public TargetTag update(final TagUpdate u) {
|
||||||
|
final GenericTagUpdate update = (GenericTagUpdate) u;
|
||||||
|
|
||||||
|
final JpaTargetTag tag = targetTagRepository.findById(update.getId())
|
||||||
|
.orElseThrow(() -> new EntityNotFoundException(TargetTag.class, update.getId()));
|
||||||
|
|
||||||
|
update.getName().ifPresent(tag::setName);
|
||||||
|
update.getDescription().ifPresent(tag::setDescription);
|
||||||
|
update.getColour().ifPresent(tag::setColour);
|
||||||
|
|
||||||
|
return targetTagRepository.save(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<TargetTag> get(final Long id) {
|
||||||
|
return Optional.ofNullable(targetTagRepository.findOne(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<TargetTag> findAll(final Pageable pageable) {
|
||||||
|
return convertTPage(targetTagRepository.findAll(pageable), pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<TargetTag> findByTarget(final Pageable pageable, final String controllerId) {
|
||||||
|
if (!targetRepository.existsByControllerId(controllerId)) {
|
||||||
|
throw new EntityNotFoundException(Target.class, controllerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return convertTPage(targetTagRepository.findAll(TagSpecification.ofTarget(controllerId), pageable), pageable);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ import org.eclipse.hawkbit.repository.ArtifactManagement;
|
|||||||
import org.eclipse.hawkbit.repository.ControllerManagement;
|
import org.eclipse.hawkbit.repository.ControllerManagement;
|
||||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||||
|
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
|
||||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||||
import org.eclipse.hawkbit.repository.PropertiesQuotaManagement;
|
import org.eclipse.hawkbit.repository.PropertiesQuotaManagement;
|
||||||
@@ -28,9 +29,9 @@ import org.eclipse.hawkbit.repository.RolloutStatusCache;
|
|||||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||||
import org.eclipse.hawkbit.repository.TagManagement;
|
|
||||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||||
|
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||||
import org.eclipse.hawkbit.repository.TenantStatsManagement;
|
import org.eclipse.hawkbit.repository.TenantStatsManagement;
|
||||||
import org.eclipse.hawkbit.repository.builder.DistributionSetBuilder;
|
import org.eclipse.hawkbit.repository.builder.DistributionSetBuilder;
|
||||||
@@ -165,8 +166,9 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
|||||||
* @return DistributionSetTypeBuilder bean
|
* @return DistributionSetTypeBuilder bean
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
DistributionSetTypeBuilder distributionSetTypeBuilder(final SoftwareModuleManagement softwareManagement) {
|
DistributionSetTypeBuilder distributionSetTypeBuilder(
|
||||||
return new JpaDistributionSetTypeBuilder(softwareManagement);
|
final SoftwareModuleTypeManagement softwareModuleTypeManagement) {
|
||||||
|
return new JpaDistributionSetTypeBuilder(softwareModuleTypeManagement);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -369,9 +371,9 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
|||||||
final DistributionSetTypeRepository distributionSetTypeRepository,
|
final DistributionSetTypeRepository distributionSetTypeRepository,
|
||||||
final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
||||||
final DistributionSetRepository distributionSetRepository,
|
final DistributionSetRepository distributionSetRepository,
|
||||||
final VirtualPropertyReplacer virtualPropertyReplacer) {
|
final VirtualPropertyReplacer virtualPropertyReplacer, final NoCountPagingRepository criteriaNoCountDao) {
|
||||||
return new JpaDistributionSetTypeManagement(distributionSetTypeRepository, softwareModuleTypeRepository,
|
return new JpaDistributionSetTypeManagement(distributionSetTypeRepository, softwareModuleTypeRepository,
|
||||||
distributionSetRepository, virtualPropertyReplacer);
|
distributionSetRepository, virtualPropertyReplacer, criteriaNoCountDao);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -430,14 +432,30 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link JpaTagManagement} bean.
|
* {@link JpaTargetTagManagement} bean.
|
||||||
*
|
*
|
||||||
* @return a new {@link TagManagement}
|
* @return a new {@link TargetTagManagement}
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
TagManagement tagManagement() {
|
TargetTagManagement targetTagManagement(final TargetTagRepository targetTagRepository,
|
||||||
return new JpaTagManagement();
|
final TargetRepository targetRepository, final VirtualPropertyReplacer virtualPropertyReplacer) {
|
||||||
|
return new JpaTargetTagManagement(targetTagRepository, targetRepository, virtualPropertyReplacer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link JpaDistributionSetTagManagement} bean.
|
||||||
|
*
|
||||||
|
* @return a new {@link JpaDistributionSetTagManagement}
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
DistributionSetTagManagement distributionSetTagManagement(
|
||||||
|
final DistributionSetTagRepository distributionSetTagRepository,
|
||||||
|
final DistributionSetRepository distributionSetRepository,
|
||||||
|
final VirtualPropertyReplacer virtualPropertyReplacer, final NoCountPagingRepository criteriaNoCountDao) {
|
||||||
|
return new JpaDistributionSetTagManagement(distributionSetTagRepository, distributionSetRepository,
|
||||||
|
virtualPropertyReplacer, criteriaNoCountDao);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -462,9 +480,9 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
|||||||
final DistributionSetTypeRepository distributionSetTypeRepository,
|
final DistributionSetTypeRepository distributionSetTypeRepository,
|
||||||
final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
final SoftwareModuleTypeRepository softwareModuleTypeRepository,
|
||||||
final VirtualPropertyReplacer virtualPropertyReplacer,
|
final VirtualPropertyReplacer virtualPropertyReplacer,
|
||||||
final SoftwareModuleRepository softwareModuleRepository) {
|
final SoftwareModuleRepository softwareModuleRepository, final NoCountPagingRepository criteriaNoCountDao) {
|
||||||
return new JpaSoftwareModuleTypeManagement(distributionSetTypeRepository, softwareModuleTypeRepository,
|
return new JpaSoftwareModuleTypeManagement(distributionSetTypeRepository, softwareModuleTypeRepository,
|
||||||
virtualPropertyReplacer, softwareModuleRepository);
|
virtualPropertyReplacer, softwareModuleRepository, criteriaNoCountDao);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@@ -537,7 +555,7 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public EntityFactory entityFactory() {
|
EntityFactory entityFactory() {
|
||||||
return new JpaEntityFactory();
|
return new JpaEntityFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ package org.eclipse.hawkbit.repository.jpa;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleMetadata;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleMetadata;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.SwMetadataCompositeKey;
|
import org.eclipse.hawkbit.repository.jpa.model.SwMetadataCompositeKey;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -26,15 +24,4 @@ public interface SoftwareModuleMetadataRepository
|
|||||||
extends PagingAndSortingRepository<JpaSoftwareModuleMetadata, SwMetadataCompositeKey>,
|
extends PagingAndSortingRepository<JpaSoftwareModuleMetadata, SwMetadataCompositeKey>,
|
||||||
JpaSpecificationExecutor<JpaSoftwareModuleMetadata> {
|
JpaSpecificationExecutor<JpaSoftwareModuleMetadata> {
|
||||||
|
|
||||||
/**
|
|
||||||
* finds all software module meta data of the given software module id.
|
|
||||||
*
|
|
||||||
* @param swId
|
|
||||||
* the ID of the software module to retrieve the meta data
|
|
||||||
* @param pageable
|
|
||||||
* the page request to page the result set
|
|
||||||
* @return the paged result of all meta data of an given software module id
|
|
||||||
*/
|
|
||||||
Page<SoftwareModuleMetadata> findBySoftwareModuleId(final Long swId, Pageable pageable);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import java.util.Optional;
|
|||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -68,18 +67,6 @@ public interface SoftwareModuleTypeRepository
|
|||||||
*/
|
*/
|
||||||
Optional<SoftwareModuleType> findByName(String name);
|
Optional<SoftwareModuleType> findByName(String name);
|
||||||
|
|
||||||
/**
|
|
||||||
* retrieves all software module types with a given
|
|
||||||
* {@link SoftwareModuleType#getId()}.
|
|
||||||
*
|
|
||||||
* @param ids
|
|
||||||
* to search for
|
|
||||||
* @return {@link List} of found {@link SoftwareModule}s
|
|
||||||
*/
|
|
||||||
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
|
|
||||||
@Query("SELECT sm FROM JpaSoftwareModuleType sm WHERE sm.id IN ?1")
|
|
||||||
List<JpaSoftwareModuleType> findByIdIn(Iterable<Long> ids);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all {@link TenantAwareBaseEntity} of a given tenant. For safety
|
* Deletes all {@link TenantAwareBaseEntity} of a given tenant. For safety
|
||||||
* reasons (this is a "delete everything" query after all) we add the tenant
|
* reasons (this is a "delete everything" query after all) we add the tenant
|
||||||
@@ -93,4 +80,9 @@ public interface SoftwareModuleTypeRepository
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Query("DELETE FROM JpaSoftwareModuleType t WHERE t.tenant = :tenant")
|
@Query("DELETE FROM JpaSoftwareModuleType t WHERE t.tenant = :tenant")
|
||||||
void deleteByTenant(@Param("tenant") String tenant);
|
void deleteByTenant(@Param("tenant") String tenant);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
// Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477
|
||||||
|
@Query("SELECT d FROM JpaSoftwareModuleType d WHERE d.id IN ?1")
|
||||||
|
List<JpaSoftwareModuleType> findAll(Iterable<Long> ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public class AutoAssignChecker {
|
|||||||
final PageRequest pageRequest = new PageRequest(0, PAGE_SIZE);
|
final PageRequest pageRequest = new PageRequest(0, PAGE_SIZE);
|
||||||
|
|
||||||
final Page<TargetFilterQuery> filterQueries = targetFilterQueryManagement
|
final Page<TargetFilterQuery> filterQueries = targetFilterQueryManagement
|
||||||
.findTargetFilterQueryWithAutoAssignDS(pageRequest);
|
.findWithAutoAssignDS(pageRequest);
|
||||||
|
|
||||||
for (final TargetFilterQuery filterQuery : filterQueries) {
|
for (final TargetFilterQuery filterQuery : filterQueries) {
|
||||||
checkByTargetFilterQueryAndAssignDS(filterQuery);
|
checkByTargetFilterQueryAndAssignDS(filterQuery);
|
||||||
@@ -176,7 +176,7 @@ public class AutoAssignChecker {
|
|||||||
private List<TargetWithActionType> getTargetsWithActionType(final String targetFilterQuery, final Long dsId,
|
private List<TargetWithActionType> getTargetsWithActionType(final String targetFilterQuery, final Long dsId,
|
||||||
final int count) {
|
final int count) {
|
||||||
final Page<Target> targets = targetManagement
|
final Page<Target> targets = targetManagement
|
||||||
.findAllTargetsByTargetFilterQueryAndNonDS(new PageRequest(0, count), dsId, targetFilterQuery);
|
.findByTargetFilterQueryAndNonDS(new PageRequest(0, count), dsId, targetFilterQuery);
|
||||||
|
|
||||||
return targets.getContent().stream().map(t -> new TargetWithActionType(t.getControllerId(),
|
return targets.getContent().stream().map(t -> new TargetWithActionType(t.getControllerId(),
|
||||||
Action.ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME)).collect(Collectors.toList());
|
Action.ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME)).collect(Collectors.toList());
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreat
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final String distributionSetTypekey) {
|
private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final String distributionSetTypekey) {
|
||||||
return distributionSetTypeManagement.findDistributionSetTypeByKey(distributionSetTypekey)
|
return distributionSetTypeManagement.getByKey(distributionSetTypekey)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypekey));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSetType.class, distributionSetTypekey));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ public class JpaDistributionSetCreate extends AbstractDistributionSetUpdateCreat
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Collection<SoftwareModule> module = softwareModuleManagement.findSoftwareModulesById(softwareModuleId);
|
final Collection<SoftwareModule> module = softwareModuleManagement.get(softwareModuleId);
|
||||||
if (module.size() < softwareModuleId.size()) {
|
if (module.size() < softwareModuleId.size()) {
|
||||||
throw new EntityNotFoundException(SoftwareModule.class, softwareModuleId);
|
throw new EntityNotFoundException(SoftwareModule.class, softwareModuleId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.builder;
|
package org.eclipse.hawkbit.repository.jpa.builder;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeBuilder;
|
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeBuilder;
|
||||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate;
|
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate;
|
||||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeUpdate;
|
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeUpdate;
|
||||||
@@ -21,10 +21,10 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
|||||||
*/
|
*/
|
||||||
public class JpaDistributionSetTypeBuilder implements DistributionSetTypeBuilder {
|
public class JpaDistributionSetTypeBuilder implements DistributionSetTypeBuilder {
|
||||||
|
|
||||||
private final SoftwareModuleManagement softwareModuleManagement;
|
private final SoftwareModuleTypeManagement softwareModuleTypeManagement;
|
||||||
|
|
||||||
public JpaDistributionSetTypeBuilder(final SoftwareModuleManagement softwareManagement) {
|
public JpaDistributionSetTypeBuilder(final SoftwareModuleTypeManagement softwareModuleTypeManagement) {
|
||||||
this.softwareModuleManagement = softwareManagement;
|
this.softwareModuleTypeManagement = softwareModuleTypeManagement;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -34,7 +34,7 @@ public class JpaDistributionSetTypeBuilder implements DistributionSetTypeBuilder
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DistributionSetTypeCreate create() {
|
public DistributionSetTypeCreate create() {
|
||||||
return new JpaDistributionSetTypeCreate(softwareModuleManagement);
|
return new JpaDistributionSetTypeCreate(softwareModuleTypeManagement);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.repository.jpa.builder;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
import org.eclipse.hawkbit.repository.SoftwareModuleTypeManagement;
|
||||||
import org.eclipse.hawkbit.repository.builder.AbstractDistributionSetTypeUpdateCreate;
|
import org.eclipse.hawkbit.repository.builder.AbstractDistributionSetTypeUpdateCreate;
|
||||||
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate;
|
import org.eclipse.hawkbit.repository.builder.DistributionSetTypeCreate;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
@@ -26,10 +26,10 @@ import org.springframework.util.CollectionUtils;
|
|||||||
public class JpaDistributionSetTypeCreate extends AbstractDistributionSetTypeUpdateCreate<DistributionSetTypeCreate>
|
public class JpaDistributionSetTypeCreate extends AbstractDistributionSetTypeUpdateCreate<DistributionSetTypeCreate>
|
||||||
implements DistributionSetTypeCreate {
|
implements DistributionSetTypeCreate {
|
||||||
|
|
||||||
private final SoftwareModuleManagement softwareModuleManagement;
|
private final SoftwareModuleTypeManagement softwareModuleTypeManagement;
|
||||||
|
|
||||||
JpaDistributionSetTypeCreate(final SoftwareModuleManagement softwareManagement) {
|
JpaDistributionSetTypeCreate(final SoftwareModuleTypeManagement softwareModuleTypeManagement) {
|
||||||
this.softwareModuleManagement = softwareManagement;
|
this.softwareModuleTypeManagement = softwareModuleTypeManagement;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -48,8 +48,7 @@ public class JpaDistributionSetTypeCreate extends AbstractDistributionSetTypeUpd
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Collection<SoftwareModuleType> module = softwareModuleManagement
|
final Collection<SoftwareModuleType> module = softwareModuleTypeManagement.get(softwareModuleTypeId);
|
||||||
.findSoftwareModuleTypesById(softwareModuleTypeId);
|
|
||||||
if (module.size() < softwareModuleTypeId.size()) {
|
if (module.size() < softwareModuleTypeId.size()) {
|
||||||
throw new EntityNotFoundException(SoftwareModuleType.class, softwareModuleTypeId);
|
throw new EntityNotFoundException(SoftwareModuleType.class, softwareModuleTypeId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class JpaRolloutCreate extends AbstractRolloutUpdateCreate<RolloutCreate>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
private DistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
||||||
return distributionSetManagement.findDistributionSetById(setId)
|
return distributionSetManagement.get(setId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class JpaSoftwareModuleCreate extends AbstractSoftwareModuleUpdateCreate<
|
|||||||
throw new ValidationException("type cannot be null");
|
throw new ValidationException("type cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
return softwareModuleTypeManagement.findSoftwareModuleTypeByKey(type.trim())
|
return softwareModuleTypeManagement.getByKey(type.trim())
|
||||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, type.trim()));
|
.orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, type.trim()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class JpaTargetFilterQueryCreate extends AbstractTargetFilterQueryUpdateC
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
private DistributionSet findDistributionSetAndThrowExceptionIfNotFound(final Long setId) {
|
||||||
return distributionSetManagement.findDistributionSetById(setId)
|
return distributionSetManagement.get(setId)
|
||||||
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
.orElseThrow(() -> new EntityNotFoundException(DistributionSet.class, setId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import com.google.common.base.Splitter;
|
|||||||
/**
|
/**
|
||||||
* Entity to store the status for a specific action.
|
* Entity to store the status for a specific action.
|
||||||
*/
|
*/
|
||||||
@Table(name = "sp_action_status", indexes = { @Index(name = "sp_idx_action_status_01", columnList = "tenant,action"),
|
@Table(name = "sp_action_status", indexes = {
|
||||||
@Index(name = "sp_idx_action_status_02", columnList = "tenant,action,status"),
|
@Index(name = "sp_idx_action_status_02", columnList = "tenant,action,status"),
|
||||||
@Index(name = "sp_idx_action_status_prim", columnList = "tenant,id") })
|
@Index(name = "sp_idx_action_status_prim", columnList = "tenant,id") })
|
||||||
@NamedEntityGraph(name = "ActionStatus.withMessages", attributeNodes = { @NamedAttributeNode("messages") })
|
@NamedEntityGraph(name = "ActionStatus.withMessages", attributeNodes = { @NamedAttributeNode("messages") })
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ import org.springframework.context.ApplicationEvent;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_distribution_set", uniqueConstraints = {
|
@Table(name = "sp_distribution_set", uniqueConstraints = {
|
||||||
@UniqueConstraint(columnNames = { "name", "version", "tenant" }, name = "uk_distrib_set") }, indexes = {
|
@UniqueConstraint(columnNames = { "name", "version", "tenant" }, name = "uk_distrib_set") }, indexes = {
|
||||||
@Index(name = "sp_idx_distribution_set_01", columnList = "tenant,deleted,name,complete"),
|
@Index(name = "sp_idx_distribution_set_01", columnList = "tenant,deleted,complete"),
|
||||||
@Index(name = "sp_idx_distribution_set_02", columnList = "tenant,required_migration_step"),
|
|
||||||
@Index(name = "sp_idx_distribution_set_prim", columnList = "tenant,id") })
|
@Index(name = "sp_idx_distribution_set_prim", columnList = "tenant,id") })
|
||||||
@NamedEntityGraph(name = "DistributionSet.detail", attributeNodes = { @NamedAttributeNode("modules"),
|
@NamedEntityGraph(name = "DistributionSet.detail", attributeNodes = { @NamedAttributeNode("modules"),
|
||||||
@NamedAttributeNode("tags"), @NamedAttributeNode("type") })
|
@NamedAttributeNode("tags"), @NamedAttributeNode("type") })
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import javax.persistence.EnumType;
|
|||||||
import javax.persistence.Enumerated;
|
import javax.persistence.Enumerated;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.ForeignKey;
|
import javax.persistence.ForeignKey;
|
||||||
import javax.persistence.Index;
|
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -52,9 +51,8 @@ import org.hibernate.validator.constraints.NotEmpty;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_rollout", indexes = {
|
@Table(name = "sp_rollout", uniqueConstraints = @UniqueConstraint(columnNames = { "name",
|
||||||
@Index(name = "sp_idx_rollout_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
"tenant" }, name = "uk_rollout"))
|
||||||
"name", "tenant" }, name = "uk_rollout"))
|
|
||||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||||
// sub entities
|
// sub entities
|
||||||
@SuppressWarnings("squid:S2160")
|
@SuppressWarnings("squid:S2160")
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import javax.persistence.ConstraintMode;
|
|||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.ForeignKey;
|
import javax.persistence.ForeignKey;
|
||||||
import javax.persistence.Index;
|
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -44,9 +43,8 @@ import org.eclipse.persistence.descriptors.DescriptorEvent;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_rolloutgroup", indexes = {
|
@Table(name = "sp_rolloutgroup", uniqueConstraints = @UniqueConstraint(columnNames = { "name", "rollout",
|
||||||
@Index(name = "sp_idx_rolloutgroup_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
"tenant" }, name = "uk_rolloutgroup"))
|
||||||
"name", "rollout", "tenant" }, name = "uk_rolloutgroup"))
|
|
||||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||||
// sub entities
|
// sub entities
|
||||||
@SuppressWarnings("squid:S2160")
|
@SuppressWarnings("squid:S2160")
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ public class JpaSoftwareModuleMetadata extends JpaMetaData implements SoftwareMo
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@ManyToOne(optional = false, targetEntity = JpaSoftwareModule.class, fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||||
@JoinColumn(name = "sw_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_sw"))
|
@JoinColumn(name = "sw_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_metadata_sw"))
|
||||||
private SoftwareModule softwareModule;
|
private JpaSoftwareModule softwareModule;
|
||||||
|
|
||||||
public JpaSoftwareModuleMetadata() {
|
public JpaSoftwareModuleMetadata() {
|
||||||
// default public constructor for JPA
|
// default public constructor for JPA
|
||||||
@@ -42,7 +42,7 @@ public class JpaSoftwareModuleMetadata extends JpaMetaData implements SoftwareMo
|
|||||||
|
|
||||||
public JpaSoftwareModuleMetadata(final String key, final SoftwareModule softwareModule, final String value) {
|
public JpaSoftwareModuleMetadata(final String key, final SoftwareModule softwareModule, final String value) {
|
||||||
super(key, value);
|
super(key, value);
|
||||||
this.softwareModule = softwareModule;
|
this.softwareModule = (JpaSoftwareModule) softwareModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SwMetadataCompositeKey getId() {
|
public SwMetadataCompositeKey getId() {
|
||||||
@@ -54,7 +54,7 @@ public class JpaSoftwareModuleMetadata extends JpaMetaData implements SoftwareMo
|
|||||||
return softwareModule;
|
return softwareModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSoftwareModule(final SoftwareModule softwareModule) {
|
public void setSoftwareModule(final JpaSoftwareModule softwareModule) {
|
||||||
this.softwareModule = softwareModule;
|
this.softwareModule = softwareModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_target", indexes = {
|
@Table(name = "sp_target", indexes = {
|
||||||
@Index(name = "sp_idx_target_01", columnList = "tenant,name,assigned_distribution_set"),
|
@Index(name = "sp_idx_target_01", columnList = "tenant,name,assigned_distribution_set"),
|
||||||
@Index(name = "sp_idx_target_02", columnList = "tenant,name"),
|
|
||||||
@Index(name = "sp_idx_target_03", columnList = "tenant,controller_id,assigned_distribution_set"),
|
@Index(name = "sp_idx_target_03", columnList = "tenant,controller_id,assigned_distribution_set"),
|
||||||
@Index(name = "sp_idx_target_04", columnList = "tenant,created_at"),
|
@Index(name = "sp_idx_target_04", columnList = "tenant,created_at"),
|
||||||
@Index(name = "sp_idx_target_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
@Index(name = "sp_idx_target_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import javax.persistence.ConstraintMode;
|
|||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.ForeignKey;
|
import javax.persistence.ForeignKey;
|
||||||
import javax.persistence.Index;
|
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
@@ -30,9 +29,8 @@ import org.hibernate.validator.constraints.NotEmpty;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_target_filter_query", indexes = {
|
@Table(name = "sp_target_filter_query", uniqueConstraints = @UniqueConstraint(columnNames = { "name",
|
||||||
@Index(name = "sp_idx_target_filter_query_01", columnList = "tenant,name") }, uniqueConstraints = @UniqueConstraint(columnNames = {
|
"tenant" }, name = "uk_tenant_custom_filter_name"))
|
||||||
"name", "tenant" }, name = "uk_tenant_custom_filter_name"))
|
|
||||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||||
// sub entities
|
// sub entities
|
||||||
@SuppressWarnings("squid:S2160")
|
@SuppressWarnings("squid:S2160")
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
|||||||
context.setSyntaxErrorContext(errorContext);
|
context.setSyntaxErrorContext(errorContext);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
targetManagement.findTargetsAll(rsqlQuery, new PageRequest(0, 1));
|
targetManagement.findByRsql(new PageRequest(0, 1), rsqlQuery);
|
||||||
context.setSyntaxError(false);
|
context.setSyntaxError(false);
|
||||||
suggestionContext.getSuggestions().addAll(getLogicalOperatorSuggestion(rsqlQuery));
|
suggestionContext.getSuggestions().addAll(getLogicalOperatorSuggestion(rsqlQuery));
|
||||||
} catch (final RSQLParameterSyntaxException | RSQLParserException ex) {
|
} catch (final RSQLParameterSyntaxException | RSQLParserException ex) {
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
ALTER TABLE sp_action_status DROP INDEX sp_idx_action_status_01;
|
||||||
|
ALTER TABLE sp_rollout DROP INDEX sp_idx_rollout_01;
|
||||||
|
ALTER TABLE sp_rolloutgroup DROP INDEX sp_idx_rolloutgroup_01;
|
||||||
|
ALTER TABLE sp_target DROP INDEX sp_idx_target_02;
|
||||||
|
ALTER TABLE sp_target_filter_query DROP INDEX sp_idx_target_filter_query_01;
|
||||||
|
ALTER TABLE sp_distribution_set DROP INDEX sp_idx_distribution_set_01;
|
||||||
|
ALTER TABLE sp_distribution_set DROP INDEX sp_idx_distribution_set_02;
|
||||||
|
CREATE INDEX sp_idx_distribution_set_01 ON sp_distribution_set (tenant, deleted, complete);
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
ALTER TABLE sp_action_status DROP INDEX sp_idx_action_status_01;
|
||||||
|
ALTER TABLE sp_rollout DROP INDEX sp_idx_rollout_01;
|
||||||
|
ALTER TABLE sp_rolloutgroup DROP INDEX sp_idx_rolloutgroup_01;
|
||||||
|
ALTER TABLE sp_target DROP INDEX sp_idx_target_02;
|
||||||
|
ALTER TABLE sp_target_filter_query DROP INDEX sp_idx_target_filter_query_01;
|
||||||
|
ALTER TABLE sp_distribution_set DROP INDEX sp_idx_distribution_set_01;
|
||||||
|
ALTER TABLE sp_distribution_set DROP INDEX sp_idx_distribution_set_02;
|
||||||
|
CREATE INDEX sp_idx_distribution_set_01 ON sp_distribution_set (tenant, deleted, complete);
|
||||||
@@ -30,7 +30,7 @@ public class DistributionSetCreatedEventTest extends AbstractRemoteEntityEventTe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DistributionSet createEntity() {
|
protected DistributionSet createEntity() {
|
||||||
return distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create()
|
return distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||||
.name("incomplete").version("2").description("incomplete").type("os"));
|
.name("incomplete").version("2").description("incomplete").type("os"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class DistributionSetTagEventTest extends AbstractRemoteEntityEventTest<D
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DistributionSetTag createEntity() {
|
protected DistributionSetTag createEntity() {
|
||||||
return tagManagement.createDistributionSetTag(entityFactory.tag().create().name("tag1"));
|
return distributionSetTagManagement.create(entityFactory.tag().create().name("tag1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class DistributionSetUpdatedEventTest extends AbstractRemoteEntityEventTe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DistributionSet createEntity() {
|
protected DistributionSet createEntity() {
|
||||||
return distributionSetManagement.createDistributionSet(entityFactory.distributionSet().create()
|
return distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||||
.name("incomplete").version("2").description("incomplete").type("os"));
|
.name("incomplete").version("2").description("incomplete").type("os"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ public class RolloutEventTest extends AbstractRemoteEntityEventTest<Rollout> {
|
|||||||
@Override
|
@Override
|
||||||
protected Rollout createEntity() {
|
protected Rollout createEntity() {
|
||||||
testdataFactory.createTarget("12345");
|
testdataFactory.createTarget("12345");
|
||||||
final DistributionSet ds = distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
final DistributionSet ds = distributionSetManagement.create(entityFactory.distributionSet()
|
||||||
.create().name("incomplete").version("2").description("incomplete").type("os"));
|
.create().name("incomplete").version("2").description("incomplete").type("os"));
|
||||||
|
|
||||||
return rolloutManagement.createRollout(
|
return rolloutManagement.create(
|
||||||
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").set(ds),
|
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").set(ds),
|
||||||
10, new RolloutGroupConditionBuilder().withDefaults()
|
10, new RolloutGroupConditionBuilder().withDefaults()
|
||||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
||||||
|
|||||||
@@ -91,15 +91,15 @@ public class RolloutGroupEventTest extends AbstractRemoteEntityEventTest<Rollout
|
|||||||
protected RolloutGroup createEntity() {
|
protected RolloutGroup createEntity() {
|
||||||
testdataFactory.createTarget(UUID.randomUUID().toString());
|
testdataFactory.createTarget(UUID.randomUUID().toString());
|
||||||
|
|
||||||
final DistributionSet ds = distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
final DistributionSet ds = distributionSetManagement.create(entityFactory.distributionSet()
|
||||||
.create().name("incomplete").version("2").description("incomplete").type("os"));
|
.create().name("incomplete").version("2").description("incomplete").type("os"));
|
||||||
|
|
||||||
final Rollout entity = rolloutManagement.createRollout(
|
final Rollout entity = rolloutManagement.create(
|
||||||
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").set(ds),
|
entityFactory.rollout().create().name("exampleRollout").targetFilterQuery("controllerId==*").set(ds),
|
||||||
10, new RolloutGroupConditionBuilder().withDefaults()
|
10, new RolloutGroupConditionBuilder().withDefaults()
|
||||||
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "10").build());
|
||||||
|
|
||||||
return rolloutGroupManagement.findRolloutGroupsByRolloutId(entity.getId(), PAGE).getContent().get(0);
|
return rolloutGroupManagement.findByRollout(PAGE, entity.getId()).getContent().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class TargetTagEventTest extends AbstractRemoteEntityEventTest<TargetTag>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TargetTag createEntity() {
|
protected TargetTag createEntity() {
|
||||||
return tagManagement.createTargetTag(entityFactory.tag().create().name("tag1"));
|
return targetTagManagement.create(entityFactory.tag().create().name("tag1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,11 +53,11 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||||
final SoftwareModule module = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule module = testdataFactory.createSoftwareModuleOs();
|
||||||
|
|
||||||
assertThat(artifactManagement.findArtifact(NOT_EXIST_IDL)).isNotPresent();
|
assertThat(artifactManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||||
assertThat(artifactManagement.findByFilenameAndSoftwareModule(NOT_EXIST_ID, module.getId()).isPresent())
|
assertThat(artifactManagement.getByFilenameAndSoftwareModule(NOT_EXIST_ID, module.getId()).isPresent())
|
||||||
.isFalse();
|
.isFalse();
|
||||||
|
|
||||||
assertThat(artifactManagement.findFirstArtifactBySHA1(NOT_EXIST_ID)).isNotPresent();
|
assertThat(artifactManagement.findFirstBySHA1(NOT_EXIST_ID)).isNotPresent();
|
||||||
assertThat(artifactManagement.loadArtifactBinary(NOT_EXIST_ID)).isNotPresent();
|
assertThat(artifactManagement.loadArtifactBinary(NOT_EXIST_ID)).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,20 +67,20 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@ExpectEvents({ @Expect(type = SoftwareModuleDeletedEvent.class, count = 0) })
|
@ExpectEvents({ @Expect(type = SoftwareModuleDeletedEvent.class, count = 0) })
|
||||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() throws URISyntaxException {
|
public void entityQueriesReferringToNotExistingEntitiesThrowsException() throws URISyntaxException {
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> artifactManagement.createArtifact(IOUtils.toInputStream("test", "UTF-8"),
|
verifyThrownExceptionBy(() -> artifactManagement.create(IOUtils.toInputStream("test", "UTF-8"),
|
||||||
NOT_EXIST_IDL, "xxx", null, null, false, null), "SoftwareModule");
|
NOT_EXIST_IDL, "xxx", null, null, false, null), "SoftwareModule");
|
||||||
|
|
||||||
verifyThrownExceptionBy(
|
verifyThrownExceptionBy(
|
||||||
() -> artifactManagement.createArtifact(IOUtils.toInputStream("test", "UTF-8"), 1234L, "xxx", false),
|
() -> artifactManagement.create(IOUtils.toInputStream("test", "UTF-8"), 1234L, "xxx", false),
|
||||||
"SoftwareModule");
|
"SoftwareModule");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> artifactManagement.deleteArtifact(NOT_EXIST_IDL), "Artifact");
|
verifyThrownExceptionBy(() -> artifactManagement.delete(NOT_EXIST_IDL), "Artifact");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> artifactManagement.findArtifactBySoftwareModule(PAGE, NOT_EXIST_IDL),
|
verifyThrownExceptionBy(() -> artifactManagement.findBySoftwareModule(PAGE, NOT_EXIST_IDL),
|
||||||
"SoftwareModule");
|
"SoftwareModule");
|
||||||
assertThat(artifactManagement.findArtifactByFilename(NOT_EXIST_ID).isPresent()).isFalse();
|
assertThat(artifactManagement.getByFilename(NOT_EXIST_ID).isPresent()).isFalse();
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> artifactManagement.findByFilenameAndSoftwareModule("xxx", NOT_EXIST_IDL),
|
verifyThrownExceptionBy(() -> artifactManagement.getByFilenameAndSoftwareModule("xxx", NOT_EXIST_IDL),
|
||||||
"SoftwareModule");
|
"SoftwareModule");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,11 +102,11 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||||
|
|
||||||
final Artifact result = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1",
|
final Artifact result = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1",
|
||||||
false);
|
false);
|
||||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file11", false);
|
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file11", false);
|
||||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file12", false);
|
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file12", false);
|
||||||
final Artifact result2 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm2.getId(),
|
final Artifact result2 = artifactManagement.create(new ByteArrayInputStream(random), sm2.getId(),
|
||||||
"file2", false);
|
"file2", false);
|
||||||
|
|
||||||
assertThat(result).isInstanceOf(Artifact.class);
|
assertThat(result).isInstanceOf(Artifact.class);
|
||||||
@@ -117,15 +117,15 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertThat(result).isNotEqualTo(result2);
|
assertThat(result).isNotEqualTo(result2);
|
||||||
assertThat(((JpaArtifact) result).getSha1Hash()).isEqualTo(((JpaArtifact) result2).getSha1Hash());
|
assertThat(((JpaArtifact) result).getSha1Hash()).isEqualTo(((JpaArtifact) result2).getSha1Hash());
|
||||||
|
|
||||||
assertThat(artifactManagement.findArtifactByFilename("file1").get().getSha1Hash())
|
assertThat(artifactManagement.getByFilename("file1").get().getSha1Hash())
|
||||||
.isEqualTo(HashGeneratorUtils.generateSHA1(random));
|
.isEqualTo(HashGeneratorUtils.generateSHA1(random));
|
||||||
assertThat(artifactManagement.findArtifactByFilename("file1").get().getMd5Hash())
|
assertThat(artifactManagement.getByFilename("file1").get().getMd5Hash())
|
||||||
.isEqualTo(HashGeneratorUtils.generateMD5(random));
|
.isEqualTo(HashGeneratorUtils.generateMD5(random));
|
||||||
|
|
||||||
assertThat(artifactRepository.findAll()).hasSize(4);
|
assertThat(artifactRepository.findAll()).hasSize(4);
|
||||||
assertThat(softwareModuleRepository.findAll()).hasSize(3);
|
assertThat(softwareModuleRepository.findAll()).hasSize(3);
|
||||||
|
|
||||||
assertThat(softwareModuleManagement.findSoftwareModuleById(sm.getId()).get().getArtifacts()).hasSize(3);
|
assertThat(softwareModuleManagement.get(sm.getId()).get().getArtifacts()).hasSize(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -136,7 +136,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||||
|
|
||||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1", false);
|
||||||
assertThat(artifactRepository.findAll()).hasSize(1);
|
assertThat(artifactRepository.findAll()).hasSize(1);
|
||||||
|
|
||||||
softwareModuleRepository.deleteAll();
|
softwareModuleRepository.deleteAll();
|
||||||
@@ -145,7 +145,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for
|
* Test method for
|
||||||
* {@link org.eclipse.hawkbit.repository.ArtifactManagement#deleteArtifact(java.lang.Long)}
|
* {@link org.eclipse.hawkbit.repository.ArtifactManagement#delete(java.lang.Long)}
|
||||||
* .
|
* .
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
@@ -162,9 +162,9 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
assertThat(artifactRepository.findAll()).isEmpty();
|
assertThat(artifactRepository.findAll()).isEmpty();
|
||||||
|
|
||||||
final Artifact result = artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(),
|
final Artifact result = artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), sm.getId(),
|
||||||
"file1", false);
|
"file1", false);
|
||||||
final Artifact result2 = artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024),
|
final Artifact result2 = artifactManagement.create(new RandomGeneratedInputStream(5 * 1024),
|
||||||
sm2.getId(), "file2", false);
|
sm2.getId(), "file2", false);
|
||||||
|
|
||||||
assertThat(artifactRepository.findAll()).hasSize(2);
|
assertThat(artifactRepository.findAll()).hasSize(2);
|
||||||
@@ -178,14 +178,14 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result2.getSha1Hash()))
|
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result2.getSha1Hash()))
|
||||||
.isNotNull();
|
.isNotNull();
|
||||||
|
|
||||||
artifactManagement.deleteArtifact(result.getId());
|
artifactManagement.delete(result.getId());
|
||||||
|
|
||||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
||||||
.isNull();
|
.isNull();
|
||||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result2.getSha1Hash()))
|
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result2.getSha1Hash()))
|
||||||
.isNotNull();
|
.isNotNull();
|
||||||
|
|
||||||
artifactManagement.deleteArtifact(result2.getId());
|
artifactManagement.delete(result2.getId());
|
||||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result2.getSha1Hash()))
|
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result2.getSha1Hash()))
|
||||||
.isNull();
|
.isNull();
|
||||||
|
|
||||||
@@ -204,9 +204,9 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||||
|
|
||||||
final Artifact result = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1",
|
final Artifact result = artifactManagement.create(new ByteArrayInputStream(random), sm.getId(), "file1",
|
||||||
false);
|
false);
|
||||||
final Artifact result2 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm2.getId(),
|
final Artifact result2 = artifactManagement.create(new ByteArrayInputStream(random), sm2.getId(),
|
||||||
"file2", false);
|
"file2", false);
|
||||||
|
|
||||||
assertThat(artifactRepository.findAll()).hasSize(2);
|
assertThat(artifactRepository.findAll()).hasSize(2);
|
||||||
@@ -216,11 +216,11 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
||||||
.isNotNull();
|
.isNotNull();
|
||||||
artifactManagement.deleteArtifact(result.getId());
|
artifactManagement.delete(result.getId());
|
||||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
||||||
.isNotNull();
|
.isNotNull();
|
||||||
|
|
||||||
artifactManagement.deleteArtifact(result2.getId());
|
artifactManagement.delete(result2.getId());
|
||||||
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
assertThat(binaryArtifactRepository.getArtifactBySha1(tenantAware.getCurrentTenant(), result.getSha1Hash()))
|
||||||
.isNull();
|
.isNull();
|
||||||
}
|
}
|
||||||
@@ -228,10 +228,10 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
@Description("Loads an local artifact based on given ID.")
|
@Description("Loads an local artifact based on given ID.")
|
||||||
public void findArtifact() throws NoSuchAlgorithmException, IOException {
|
public void findArtifact() throws NoSuchAlgorithmException, IOException {
|
||||||
final Artifact result = artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024),
|
final Artifact result = artifactManagement.create(new RandomGeneratedInputStream(5 * 1024),
|
||||||
testdataFactory.createSoftwareModuleOs().getId(), "file1", false);
|
testdataFactory.createSoftwareModuleOs().getId(), "file1", false);
|
||||||
|
|
||||||
assertThat(artifactManagement.findArtifact(result.getId()).get()).isEqualTo(result);
|
assertThat(artifactManagement.get(result.getId()).get()).isEqualTo(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -239,7 +239,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
public void loadStreamOfArtifact() throws NoSuchAlgorithmException, IOException {
|
public void loadStreamOfArtifact() throws NoSuchAlgorithmException, IOException {
|
||||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||||
|
|
||||||
final Artifact result = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
final Artifact result = artifactManagement.create(new ByteArrayInputStream(random),
|
||||||
testdataFactory.createSoftwareModuleOs().getId(), "file1", false);
|
testdataFactory.createSoftwareModuleOs().getId(), "file1", false);
|
||||||
|
|
||||||
try (InputStream fileInputStream = artifactManagement.loadArtifactBinary(result.getSha1Hash()).get()
|
try (InputStream fileInputStream = artifactManagement.loadArtifactBinary(result.getSha1Hash()).get()
|
||||||
@@ -266,11 +266,11 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
public void findArtifactBySoftwareModule() {
|
public void findArtifactBySoftwareModule() {
|
||||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||||
|
|
||||||
assertThat(artifactManagement.findArtifactBySoftwareModule(PAGE, sm.getId())).isEmpty();
|
assertThat(artifactManagement.findBySoftwareModule(PAGE, sm.getId())).isEmpty();
|
||||||
|
|
||||||
artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file1", false);
|
artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file1", false);
|
||||||
|
|
||||||
assertThat(artifactManagement.findArtifactBySoftwareModule(PAGE, sm.getId())).hasSize(1);
|
assertThat(artifactManagement.findBySoftwareModule(PAGE, sm.getId())).hasSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -278,12 +278,12 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
public void findByFilenameAndSoftwareModule() {
|
public void findByFilenameAndSoftwareModule() {
|
||||||
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
|
||||||
|
|
||||||
assertThat(artifactManagement.findByFilenameAndSoftwareModule("file1", sm.getId())).isNotPresent();
|
assertThat(artifactManagement.getByFilenameAndSoftwareModule("file1", sm.getId())).isNotPresent();
|
||||||
|
|
||||||
artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file1", false);
|
artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file1", false);
|
||||||
artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file2", false);
|
artifactManagement.create(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file2", false);
|
||||||
|
|
||||||
assertThat(artifactManagement.findByFilenameAndSoftwareModule("file1", sm.getId())).isPresent();
|
assertThat(artifactManagement.getByFilenameAndSoftwareModule("file1", sm.getId())).isPresent();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final SoftwareModule module = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule module = testdataFactory.createSoftwareModuleOs();
|
||||||
|
|
||||||
assertThat(controllerManagement.findActionWithDetails(NOT_EXIST_IDL)).isNotPresent();
|
assertThat(controllerManagement.findActionWithDetails(NOT_EXIST_IDL)).isNotPresent();
|
||||||
assertThat(controllerManagement.findByControllerId(NOT_EXIST_ID)).isNotPresent();
|
assertThat(controllerManagement.getByControllerId(NOT_EXIST_ID)).isNotPresent();
|
||||||
assertThat(controllerManagement.findByTargetId(NOT_EXIST_IDL)).isNotPresent();
|
assertThat(controllerManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||||
assertThat(controllerManagement.getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(),
|
assertThat(controllerManagement.getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(),
|
||||||
module.getId())).isNotPresent();
|
module.getId())).isNotPresent();
|
||||||
|
|
||||||
@@ -308,8 +308,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final Long dsId = testdataFactory.createDistributionSet().getId();
|
final Long dsId = testdataFactory.createDistributionSet().getId();
|
||||||
testdataFactory.createTarget();
|
testdataFactory.createTarget();
|
||||||
assignDistributionSet(dsId, TestdataFactory.DEFAULT_CONTROLLER_ID);
|
assignDistributionSet(dsId, TestdataFactory.DEFAULT_CONTROLLER_ID);
|
||||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getUpdateStatus())
|
||||||
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
|
|
||||||
return deploymentManagement.findActiveActionsByTarget(PAGE, TestdataFactory.DEFAULT_CONTROLLER_ID).getContent()
|
return deploymentManagement.findActiveActionsByTarget(PAGE, TestdataFactory.DEFAULT_CONTROLLER_ID).getContent()
|
||||||
.get(0).getId();
|
.get(0).getId();
|
||||||
@@ -364,7 +364,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
private void assertActionStatus(final Long actionId, final String controllerId,
|
private void assertActionStatus(final Long actionId, final String controllerId,
|
||||||
final TargetUpdateStatus expectedTargetUpdateStatus, final Action.Status expectedActionActionStatus,
|
final TargetUpdateStatus expectedTargetUpdateStatus, final Action.Status expectedActionActionStatus,
|
||||||
final Action.Status expectedActionStatus, final boolean actionActive) {
|
final Action.Status expectedActionStatus, final boolean actionActive) {
|
||||||
final TargetUpdateStatus targetStatus = targetManagement.findTargetByControllerID(controllerId).get()
|
final TargetUpdateStatus targetStatus = targetManagement.getByControllerID(controllerId).get()
|
||||||
.getUpdateStatus();
|
.getUpdateStatus();
|
||||||
assertThat(targetStatus).isEqualTo(expectedTargetUpdateStatus);
|
assertThat(targetStatus).isEqualTo(expectedTargetUpdateStatus);
|
||||||
final Action action = deploymentManagement.findAction(actionId).get();
|
final Action action = deploymentManagement.findAction(actionId).get();
|
||||||
@@ -396,9 +396,9 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
Target savedTarget = testdataFactory.createTarget();
|
Target savedTarget = testdataFactory.createTarget();
|
||||||
|
|
||||||
// create two artifacts with identical SHA1 hash
|
// create two artifacts with identical SHA1 hash
|
||||||
final Artifact artifact = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
final Artifact artifact = artifactManagement.create(new ByteArrayInputStream(random),
|
||||||
ds.findFirstModuleByType(osType).get().getId(), "file1", false);
|
ds.findFirstModuleByType(osType).get().getId(), "file1", false);
|
||||||
final Artifact artifact2 = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
final Artifact artifact2 = artifactManagement.create(new ByteArrayInputStream(random),
|
||||||
ds2.findFirstModuleByType(osType).get().getId(), "file1", false);
|
ds2.findFirstModuleByType(osType).get().getId(), "file1", false);
|
||||||
assertThat(artifact.getSha1Hash()).isEqualTo(artifact2.getSha1Hash());
|
assertThat(artifact.getSha1Hash()).isEqualTo(artifact2.getSha1Hash());
|
||||||
|
|
||||||
@@ -531,8 +531,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
entityFactory.actionStatus().create(action.getId()).status(Action.Status.RUNNING));
|
entityFactory.actionStatus().create(action.getId()).status(Action.Status.RUNNING));
|
||||||
|
|
||||||
// nothing changed as "feedback after close" is disabled
|
// nothing changed as "feedback after close" is disabled
|
||||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getUpdateStatus())
|
||||||
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
|
|
||||||
assertThat(actionStatusRepository.count()).isEqualTo(3);
|
assertThat(actionStatusRepository.count()).isEqualTo(3);
|
||||||
assertThat(controllerManagement.findActionStatusByAction(PAGE, action.getId()).getNumberOfElements())
|
assertThat(controllerManagement.findActionStatusByAction(PAGE, action.getId()).getNumberOfElements())
|
||||||
@@ -556,8 +556,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
entityFactory.actionStatus().create(action.getId()).status(Action.Status.RUNNING));
|
entityFactory.actionStatus().create(action.getId()).status(Action.Status.RUNNING));
|
||||||
|
|
||||||
// nothing changed as "feedback after close" is disabled
|
// nothing changed as "feedback after close" is disabled
|
||||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
|
assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getUpdateStatus())
|
||||||
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
|
|
||||||
// however, additional action status has been stored
|
// however, additional action status has been stored
|
||||||
assertThat(actionStatusRepository.findAll(PAGE).getNumberOfElements()).isEqualTo(4);
|
assertThat(actionStatusRepository.findAll(PAGE).getNumberOfElements()).isEqualTo(4);
|
||||||
@@ -581,7 +581,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// verify that audit information has not changed
|
// verify that audit information has not changed
|
||||||
final Target targetVerify = targetManagement.findTargetByControllerID(controllerId).get();
|
final Target targetVerify = targetManagement.getByControllerID(controllerId).get();
|
||||||
assertThat(targetVerify.getCreatedBy()).isEqualTo(target.getCreatedBy());
|
assertThat(targetVerify.getCreatedBy()).isEqualTo(target.getCreatedBy());
|
||||||
assertThat(targetVerify.getCreatedAt()).isEqualTo(target.getCreatedAt());
|
assertThat(targetVerify.getCreatedAt()).isEqualTo(target.getCreatedAt());
|
||||||
assertThat(targetVerify.getLastModifiedBy()).isEqualTo(target.getLastModifiedBy());
|
assertThat(targetVerify.getLastModifiedBy()).isEqualTo(target.getLastModifiedBy());
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetSpecification;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.specifications.SpecificationsBuilder;
|
||||||
import org.eclipse.hawkbit.repository.model.Action;
|
import org.eclipse.hawkbit.repository.model.Action;
|
||||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||||
@@ -223,8 +225,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
// not exists
|
// not exists
|
||||||
assignDS.add(100L);
|
assignDS.add(100L);
|
||||||
|
|
||||||
final DistributionSetTag tag = tagManagement
|
final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name("Tag1"));
|
||||||
.createDistributionSetTag(entityFactory.tag().create().name("Tag1"));
|
|
||||||
|
|
||||||
assertThatExceptionOfType(EntityNotFoundException.class)
|
assertThatExceptionOfType(EntityNotFoundException.class)
|
||||||
.isThrownBy(() -> distributionSetManagement.assignTag(assignDS, tag.getId()))
|
.isThrownBy(() -> distributionSetManagement.assignTag(assignDS, tag.getId()))
|
||||||
@@ -271,8 +272,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final DistributionSet dsInstalled = action.getDistributionSet();
|
final DistributionSet dsInstalled = action.getDistributionSet();
|
||||||
|
|
||||||
// check initial status
|
// check initial status
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("target has update status")
|
||||||
.as("target has update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
|
|
||||||
// assign the two sets in a row
|
// assign the two sets in a row
|
||||||
JpaAction firstAction = assignSet(target, dsFirst);
|
JpaAction firstAction = assignSet(target, dsFirst);
|
||||||
@@ -289,7 +290,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
entityFactory.actionStatus().create(secondAction.getId()).status(Status.CANCELED));
|
entityFactory.actionStatus().create(secondAction.getId()).status(Status.CANCELED));
|
||||||
assertThat(actionStatusRepository.findAll()).as("wrong size of actions status").hasSize(7);
|
assertThat(actionStatusRepository.findAll()).as("wrong size of actions status").hasSize(7);
|
||||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong ds").isEqualTo(dsFirst);
|
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong ds").isEqualTo(dsFirst);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
|
|
||||||
// we cancel first -> back to installed
|
// we cancel first -> back to installed
|
||||||
@@ -301,7 +302,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(9);
|
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(9);
|
||||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong assigned ds")
|
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong assigned ds")
|
||||||
.isEqualTo(dsInstalled);
|
.isEqualTo(dsInstalled);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,7 +318,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final DistributionSet dsInstalled = action.getDistributionSet();
|
final DistributionSet dsInstalled = action.getDistributionSet();
|
||||||
|
|
||||||
// check initial status
|
// check initial status
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
|
|
||||||
// assign the two sets in a row
|
// assign the two sets in a row
|
||||||
@@ -336,8 +337,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(7);
|
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(7);
|
||||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong assigned ds")
|
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong assigned ds")
|
||||||
.isEqualTo(dsSecond);
|
.isEqualTo(dsSecond);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong target update status")
|
||||||
.as("wrong target update status").isEqualTo(TargetUpdateStatus.PENDING);
|
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
|
|
||||||
// we cancel second -> remain assigned until finished cancellation
|
// we cancel second -> remain assigned until finished cancellation
|
||||||
deploymentManagement.cancelAction(secondAction.getId());
|
deploymentManagement.cancelAction(secondAction.getId());
|
||||||
@@ -351,7 +352,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
// cancelled success -> back to dsInstalled
|
// cancelled success -> back to dsInstalled
|
||||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong installed ds")
|
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong installed ds")
|
||||||
.isEqualTo(dsInstalled);
|
.isEqualTo(dsInstalled);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus())
|
||||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +366,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final DistributionSet ds = testdataFactory.createDistributionSet("newDS", true);
|
final DistributionSet ds = testdataFactory.createDistributionSet("newDS", true);
|
||||||
|
|
||||||
// verify initial status
|
// verify initial status
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus())
|
||||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
|
|
||||||
Action assigningAction = assignSet(target, ds);
|
Action assigningAction = assignSet(target, ds);
|
||||||
@@ -386,8 +387,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertThat(assigningAction.getStatus()).as("wrong size of status").isEqualTo(Status.CANCELED);
|
assertThat(assigningAction.getStatus()).as("wrong size of status").isEqualTo(Status.CANCELED);
|
||||||
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong assigned ds")
|
assertThat(deploymentManagement.getAssignedDistributionSet("4712").get()).as("wrong assigned ds")
|
||||||
.isEqualTo(dsInstalled);
|
.isEqualTo(dsInstalled);
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong target update status")
|
||||||
.as("wrong target update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -399,7 +400,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final DistributionSet ds = testdataFactory.createDistributionSet("newDS", true);
|
final DistributionSet ds = testdataFactory.createDistributionSet("newDS", true);
|
||||||
|
|
||||||
// verify initial status
|
// verify initial status
|
||||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status")
|
||||||
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
.isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
|
|
||||||
final Action assigningAction = assignSet(target, ds);
|
final Action assigningAction = assignSet(target, ds);
|
||||||
@@ -418,7 +419,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
private JpaAction assignSet(final Target target, final DistributionSet ds) {
|
private JpaAction assignSet(final Target target, final DistributionSet ds) {
|
||||||
assignDistributionSet(ds.getId(), target.getControllerId());
|
assignDistributionSet(ds.getId(), target.getControllerId());
|
||||||
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID(target.getControllerId()).get().getUpdateStatus())
|
||||||
.as("wrong update status").isEqualTo(TargetUpdateStatus.PENDING);
|
.as("wrong update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get())
|
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get())
|
||||||
.as("wrong assigned ds").isEqualTo(ds);
|
.as("wrong assigned ds").isEqualTo(ds);
|
||||||
@@ -450,9 +451,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
.getAssignedEntity();
|
.getAssignedEntity();
|
||||||
assertThat(actionRepository.count()).isEqualTo(20);
|
assertThat(actionRepository.count()).isEqualTo(20);
|
||||||
|
|
||||||
assertThat(targetManagement.findTargetByInstalledDistributionSet(ds.getId(), PAGE).getContent())
|
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, ds.getId()).getContent()).containsAll(targets)
|
||||||
.containsAll(targets).hasSize(10)
|
.hasSize(10).containsAll(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId()))
|
||||||
.containsAll(targetManagement.findTargetByAssignedDistributionSet(ds.getId(), PAGE))
|
|
||||||
.as("InstallationDate set").allMatch(target -> target.getInstallationDate() >= current)
|
.as("InstallationDate set").allMatch(target -> target.getInstallationDate() >= current)
|
||||||
.as("TargetUpdateStatus IN_SYNC")
|
.as("TargetUpdateStatus IN_SYNC")
|
||||||
.allMatch(target -> TargetUpdateStatus.IN_SYNC.equals(target.getUpdateStatus()))
|
.allMatch(target -> TargetUpdateStatus.IN_SYNC.equals(target.getUpdateStatus()))
|
||||||
@@ -486,10 +486,10 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
// verify that one Action for each assignDistributionSet
|
// verify that one Action for each assignDistributionSet
|
||||||
assertThat(actionRepository.findAll(PAGE).getNumberOfElements()).as("wrong size of actions").isEqualTo(20);
|
assertThat(actionRepository.findAll(PAGE).getNumberOfElements()).as("wrong size of actions").isEqualTo(20);
|
||||||
|
|
||||||
final Iterable<Target> allFoundTargets = targetManagement.findTargetsAll(PAGE).getContent();
|
final Iterable<Target> allFoundTargets = targetManagement.findAll(PAGE).getContent();
|
||||||
|
|
||||||
// get final updated version of targets
|
// get final updated version of targets
|
||||||
savedDeployedTargets = targetManagement.findTargetsByControllerID(
|
savedDeployedTargets = targetManagement.getByControllerID(
|
||||||
savedDeployedTargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()));
|
savedDeployedTargets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()));
|
||||||
|
|
||||||
assertThat(allFoundTargets).as("founded targets are wrong").containsAll(savedDeployedTargets)
|
assertThat(allFoundTargets).as("founded targets are wrong").containsAll(savedDeployedTargets)
|
||||||
@@ -500,13 +500,13 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
.doesNotContain(Iterables.toArray(savedDeployedTargets, Target.class));
|
.doesNotContain(Iterables.toArray(savedDeployedTargets, Target.class));
|
||||||
|
|
||||||
for (final Target myt : savedNakedTargets) {
|
for (final Target myt : savedNakedTargets) {
|
||||||
final Target t = targetManagement.findTargetByControllerID(myt.getControllerId()).get();
|
final Target t = targetManagement.getByControllerID(myt.getControllerId()).get();
|
||||||
assertThat(deploymentManagement.countActionsByTarget(t.getControllerId())).as("action should be empty")
|
assertThat(deploymentManagement.countActionsByTarget(t.getControllerId())).as("action should be empty")
|
||||||
.isEqualTo(0L);
|
.isEqualTo(0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Target myt : savedDeployedTargets) {
|
for (final Target myt : savedDeployedTargets) {
|
||||||
final Target t = targetManagement.findTargetByControllerID(myt.getControllerId()).get();
|
final Target t = targetManagement.getByControllerID(myt.getControllerId()).get();
|
||||||
final List<Action> activeActionsByTarget = deploymentManagement
|
final List<Action> activeActionsByTarget = deploymentManagement
|
||||||
.findActiveActionsByTarget(PAGE, t.getControllerId()).getContent();
|
.findActiveActionsByTarget(PAGE, t.getControllerId()).getContent();
|
||||||
assertThat(activeActionsByTarget).as("action should not be empty").isNotEmpty();
|
assertThat(activeActionsByTarget).as("action should not be empty").isNotEmpty();
|
||||||
@@ -531,9 +531,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||||
final SoftwareModule os = testdataFactory.createSoftwareModuleOs();
|
final SoftwareModule os = testdataFactory.createSoftwareModuleOs();
|
||||||
|
|
||||||
final DistributionSet incomplete = distributionSetManagement
|
final DistributionSet incomplete = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||||
.createDistributionSet(entityFactory.distributionSet().create().name("incomplete").version("v1")
|
.name("incomplete").version("v1").type(standardDsType).modules(Arrays.asList(ah.getId())));
|
||||||
.type(standardDsType).modules(Arrays.asList(ah.getId())));
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assignDistributionSet(incomplete, targets);
|
assignDistributionSet(incomplete, targets);
|
||||||
@@ -664,7 +663,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
.isEqualTo(dsC.getId());
|
.isEqualTo(dsC.getId());
|
||||||
assertThat(deploymentManagement.getInstalledDistributionSet(t.getControllerId()))
|
assertThat(deploymentManagement.getInstalledDistributionSet(t.getControllerId()))
|
||||||
.as("installed ds should not be null").isNotPresent();
|
.as("installed ds should not be null").isNotPresent();
|
||||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.PENDING);
|
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -675,12 +674,12 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
// verify, that dsA is deployed correctly
|
// verify, that dsA is deployed correctly
|
||||||
for (final Target t_ : updatedTsDsA) {
|
for (final Target t_ : updatedTsDsA) {
|
||||||
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId()).get();
|
final Target t = targetManagement.getByControllerID(t_.getControllerId()).get();
|
||||||
assertThat(deploymentManagement.getAssignedDistributionSet(t.getControllerId()).get())
|
assertThat(deploymentManagement.getAssignedDistributionSet(t.getControllerId()).get())
|
||||||
.as("assigned ds is wrong").isEqualTo(dsA);
|
.as("assigned ds is wrong").isEqualTo(dsA);
|
||||||
assertThat(deploymentManagement.getInstalledDistributionSet(t.getControllerId()).get())
|
assertThat(deploymentManagement.getInstalledDistributionSet(t.getControllerId()).get())
|
||||||
.as("installed ds is wrong").isEqualTo(dsA);
|
.as("installed ds is wrong").isEqualTo(dsA);
|
||||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, t.getControllerId()))
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, t.getControllerId()))
|
||||||
.as("no actions should be active").hasSize(0);
|
.as("no actions should be active").hasSize(0);
|
||||||
@@ -695,19 +694,19 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
actionRepository.findByDistributionSetId(pageRequest, dsA.getId()).getContent().get(1);
|
actionRepository.findByDistributionSetId(pageRequest, dsA.getId()).getContent().get(1);
|
||||||
|
|
||||||
// get final updated version of targets
|
// get final updated version of targets
|
||||||
final List<Target> deployResWithDsBTargets = targetManagement.findTargetsByControllerID(deployResWithDsB
|
final List<Target> deployResWithDsBTargets = targetManagement.getByControllerID(deployResWithDsB
|
||||||
.getDeployedTargets().stream().map(Target::getControllerId).collect(Collectors.toList()));
|
.getDeployedTargets().stream().map(Target::getControllerId).collect(Collectors.toList()));
|
||||||
|
|
||||||
assertThat(deployed2DS).as("deployed ds is wrong").containsAll(deployResWithDsBTargets);
|
assertThat(deployed2DS).as("deployed ds is wrong").containsAll(deployResWithDsBTargets);
|
||||||
assertThat(deployed2DS).as("deployed ds is wrong").hasSameSizeAs(deployResWithDsBTargets);
|
assertThat(deployed2DS).as("deployed ds is wrong").hasSameSizeAs(deployResWithDsBTargets);
|
||||||
|
|
||||||
for (final Target t_ : deployed2DS) {
|
for (final Target t_ : deployed2DS) {
|
||||||
final Target t = targetManagement.findTargetByControllerID(t_.getControllerId()).get();
|
final Target t = targetManagement.getByControllerID(t_.getControllerId()).get();
|
||||||
assertThat(deploymentManagement.getAssignedDistributionSet(t.getControllerId()).get())
|
assertThat(deploymentManagement.getAssignedDistributionSet(t.getControllerId()).get())
|
||||||
.as("assigned ds is wrong").isEqualTo(dsA);
|
.as("assigned ds is wrong").isEqualTo(dsA);
|
||||||
assertThat(deploymentManagement.getInstalledDistributionSet(t.getControllerId()))
|
assertThat(deploymentManagement.getInstalledDistributionSet(t.getControllerId()))
|
||||||
.as("installed ds should be null").isNotPresent();
|
.as("installed ds should be null").isNotPresent();
|
||||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).get().getUpdateStatus())
|
assertThat(targetManagement.getByControllerID(t.getControllerId()).get().getUpdateStatus())
|
||||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.PENDING);
|
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -739,42 +738,41 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
final DistributionSet dsA = testdataFactory.createDistributionSet("");
|
||||||
|
|
||||||
distributionSetManagement.deleteDistributionSet(dsA.getId());
|
distributionSetManagement.delete(dsA.getId());
|
||||||
|
|
||||||
assertThat(distributionSetManagement.findDistributionSetById(dsA.getId())).isNotPresent();
|
assertThat(distributionSetManagement.get(dsA.getId())).isNotPresent();
|
||||||
|
|
||||||
// // verify that the ds is not physically deleted
|
// // verify that the ds is not physically deleted
|
||||||
for (final DistributionSet ds : deploymentResult.getDistributionSets()) {
|
for (final DistributionSet ds : deploymentResult.getDistributionSets()) {
|
||||||
distributionSetManagement.deleteDistributionSet(ds.getId());
|
distributionSetManagement.delete(ds.getId());
|
||||||
final DistributionSet foundDS = distributionSetManagement.findDistributionSetById(ds.getId()).get();
|
final DistributionSet foundDS = distributionSetManagement.get(ds.getId()).get();
|
||||||
assertThat(foundDS).as("founded should not be null").isNotNull();
|
assertThat(foundDS).as("founded should not be null").isNotNull();
|
||||||
assertThat(foundDS.isDeleted()).as("found ds should be deleted").isTrue();
|
assertThat(foundDS.isDeleted()).as("found ds should be deleted").isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify that deleted attribute is used correctly
|
// verify that deleted attribute is used correctly
|
||||||
List<DistributionSet> allFoundDS = distributionSetManagement
|
List<DistributionSet> allFoundDS = distributionSetManagement.findByCompleted(PAGE, true).getContent();
|
||||||
.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true).getContent();
|
|
||||||
assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0);
|
assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0);
|
||||||
allFoundDS = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageRequest, true, true)
|
|
||||||
.getContent();
|
assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays
|
||||||
assertThat(allFoundDS).as("wrong size of founded ds").hasSize(noOfDistributionSets);
|
.asList(DistributionSetSpecification.isDeleted(true), DistributionSetSpecification.isCompleted(true))),
|
||||||
|
PAGE).getContent()).as("wrong size of founded ds").hasSize(noOfDistributionSets);
|
||||||
|
|
||||||
for (final DistributionSet ds : deploymentResult.getDistributionSets()) {
|
for (final DistributionSet ds : deploymentResult.getDistributionSets()) {
|
||||||
testdataFactory.sendUpdateActionStatusToTargets(deploymentResult.getDeployedTargets(), Status.FINISHED,
|
testdataFactory.sendUpdateActionStatusToTargets(deploymentResult.getDeployedTargets(), Status.FINISHED,
|
||||||
Collections.singletonList("blabla alles gut"));
|
Collections.singletonList("blabla alles gut"));
|
||||||
}
|
}
|
||||||
// try to delete again
|
// try to delete again
|
||||||
distributionSetManagement.deleteDistributionSet(deploymentResult.getDistributionSetIDs());
|
distributionSetManagement.delete(deploymentResult.getDistributionSetIDs());
|
||||||
// verify that the result is the same, even though distributionSet dsA
|
// verify that the result is the same, even though distributionSet dsA
|
||||||
// has been installed
|
// has been installed
|
||||||
// successfully and no activeAction is referring to created distribution
|
// successfully and no activeAction is referring to created distribution
|
||||||
// sets
|
// sets
|
||||||
allFoundDS = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageRequest, false, true)
|
allFoundDS = distributionSetManagement.findByCompleted(pageRequest, true).getContent();
|
||||||
.getContent();
|
|
||||||
assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0);
|
assertThat(allFoundDS.size()).as("no ds should be founded").isEqualTo(0);
|
||||||
allFoundDS = distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageRequest, true, true)
|
assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays
|
||||||
.getContent();
|
.asList(DistributionSetSpecification.isDeleted(true), DistributionSetSpecification.isCompleted(true))),
|
||||||
assertThat(allFoundDS).as("size of founded ds is wrong").hasSize(noOfDistributionSets);
|
PAGE).getContent()).as("wrong size of founded ds").hasSize(noOfDistributionSets);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -798,13 +796,13 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
Collections.singletonList("blabla alles gut"));
|
Collections.singletonList("blabla alles gut"));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(targetManagement.countTargetsAll()).as("size of targets is wrong").isNotZero();
|
assertThat(targetManagement.count()).as("size of targets is wrong").isNotZero();
|
||||||
assertThat(actionStatusRepository.count()).as("size of action status is wrong").isNotZero();
|
assertThat(actionStatusRepository.count()).as("size of action status is wrong").isNotZero();
|
||||||
|
|
||||||
targetManagement.deleteTargets(deploymentResult.getUndeployedTargetIDs());
|
targetManagement.delete(deploymentResult.getUndeployedTargetIDs());
|
||||||
targetManagement.deleteTargets(deploymentResult.getDeployedTargetIDs());
|
targetManagement.delete(deploymentResult.getDeployedTargetIDs());
|
||||||
|
|
||||||
assertThat(targetManagement.countTargetsAll()).as("size of targets should be zero").isZero();
|
assertThat(targetManagement.count()).as("size of targets should be zero").isZero();
|
||||||
assertThat(actionStatusRepository.count()).as("size of action status is wrong").isZero();
|
assertThat(actionStatusRepository.count()).as("size of action status is wrong").isZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -818,13 +816,13 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
// doing the assignment
|
// doing the assignment
|
||||||
targs = assignDistributionSet(dsA, targs).getAssignedEntity();
|
targs = assignDistributionSet(dsA, targs).getAssignedEntity();
|
||||||
Target targ = targetManagement.findTargetByControllerID(targs.iterator().next().getControllerId()).get();
|
Target targ = targetManagement.getByControllerID(targs.iterator().next().getControllerId()).get();
|
||||||
|
|
||||||
// checking the revisions of the created entities
|
// checking the revisions of the created entities
|
||||||
// verifying that the revision of the object and the revision within the
|
// verifying that the revision of the object and the revision within the
|
||||||
// DB has not changed
|
// DB has not changed
|
||||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo(
|
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong")
|
||||||
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).get().getOptLockRevision());
|
.isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||||
|
|
||||||
// verifying that the assignment is correct
|
// verifying that the assignment is correct
|
||||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements())
|
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements())
|
||||||
@@ -843,7 +841,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
controllerManagement.addUpdateActionStatus(
|
controllerManagement.addUpdateActionStatus(
|
||||||
entityFactory.actionStatus().create(updAct.getContent().get(0).getId()).status(Status.FINISHED));
|
entityFactory.actionStatus().create(updAct.getContent().get(0).getId()).status(Status.FINISHED));
|
||||||
|
|
||||||
targ = targetManagement.findTargetByControllerID(targ.getControllerId()).get();
|
targ = targetManagement.getByControllerID(targ.getControllerId()).get();
|
||||||
|
|
||||||
assertEquals("active target actions are wrong", 0,
|
assertEquals("active target actions are wrong", 0,
|
||||||
deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
|
deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
|
||||||
@@ -863,7 +861,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertEquals("active actions are wrong", 1,
|
assertEquals("active actions are wrong", 1,
|
||||||
deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
|
deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
|
||||||
assertEquals("target status is wrong", TargetUpdateStatus.PENDING,
|
assertEquals("target status is wrong", TargetUpdateStatus.PENDING,
|
||||||
targetManagement.findTargetByControllerID(targ.getControllerId()).get().getUpdateStatus());
|
targetManagement.getByControllerID(targ.getControllerId()).get().getUpdateStatus());
|
||||||
assertEquals("wrong assigned ds", dsB,
|
assertEquals("wrong assigned ds", dsB,
|
||||||
deploymentManagement.getAssignedDistributionSet(targ.getControllerId()).get());
|
deploymentManagement.getAssignedDistributionSet(targ.getControllerId()).get());
|
||||||
assertEquals("Installed ds is wrong", dsA.getId(),
|
assertEquals("Installed ds is wrong", dsA.getId(),
|
||||||
@@ -881,13 +879,13 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
testdataFactory.createDistributionSet("b");
|
testdataFactory.createDistributionSet("b");
|
||||||
final Target targ = testdataFactory.createTarget("target-id-A");
|
final Target targ = testdataFactory.createTarget("target-id-A");
|
||||||
|
|
||||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo(
|
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong")
|
||||||
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).get().getOptLockRevision());
|
.isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||||
|
|
||||||
assignDistributionSet(dsA, Arrays.asList(targ));
|
assignDistributionSet(dsA, Arrays.asList(targ));
|
||||||
|
|
||||||
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong").isEqualTo(
|
assertThat(dsA.getOptLockRevision()).as("lock revision is wrong")
|
||||||
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).get().getOptLockRevision());
|
.isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1004,9 +1002,9 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertThat(event.getActionId()).as("Action id in database and event do not match")
|
assertThat(event.getActionId()).as("Action id in database and event do not match")
|
||||||
.isEqualTo(activeActionsByTarget.get(0).getId());
|
.isEqualTo(activeActionsByTarget.get(0).getId());
|
||||||
|
|
||||||
assertThat(distributionSetManagement.findDistributionSetById(event.getDistributionSetId()).get()
|
assertThat(distributionSetManagement.get(event.getDistributionSetId()).get().getModules())
|
||||||
.getModules()).as("softwaremodule size is not correct")
|
.as("softwaremodule size is not correct")
|
||||||
.containsOnly(ds.getModules().toArray(new SoftwareModule[ds.getModules().size()]));
|
.containsOnly(ds.getModules().toArray(new SoftwareModule[ds.getModules().size()]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertThat(found).as("No event found for controller " + myt.getControllerId()).isTrue();
|
assertThat(found).as("No event found for controller " + myt.getControllerId()).isTrue();
|
||||||
|
|||||||
@@ -73,11 +73,10 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3) })
|
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3) })
|
||||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||||
final DistributionSet set = testdataFactory.createDistributionSet();
|
final DistributionSet set = testdataFactory.createDistributionSet();
|
||||||
assertThat(distributionSetManagement.findDistributionSetById(NOT_EXIST_IDL)).isNotPresent();
|
assertThat(distributionSetManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||||
assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(NOT_EXIST_IDL)).isNotPresent();
|
assertThat(distributionSetManagement.getWithDetails(NOT_EXIST_IDL)).isNotPresent();
|
||||||
assertThat(distributionSetManagement.findDistributionSetByNameAndVersion(NOT_EXIST_ID, NOT_EXIST_ID))
|
assertThat(distributionSetManagement.getByNameAndVersion(NOT_EXIST_ID, NOT_EXIST_ID)).isNotPresent();
|
||||||
.isNotPresent();
|
assertThat(distributionSetManagement.getMetaDataByDistributionSetId(set.getId(), NOT_EXIST_ID)).isNotPresent();
|
||||||
assertThat(distributionSetManagement.findDistributionSetMetadata(set.getId(), NOT_EXIST_ID)).isNotPresent();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +98,8 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
() -> distributionSetManagement.assignSoftwareModules(set.getId(), Arrays.asList(NOT_EXIST_IDL)),
|
() -> distributionSetManagement.assignSoftwareModules(set.getId(), Arrays.asList(NOT_EXIST_IDL)),
|
||||||
"SoftwareModule");
|
"SoftwareModule");
|
||||||
|
|
||||||
|
verifyThrownExceptionBy(() -> distributionSetManagement.countByTypeId(NOT_EXIST_IDL), "DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.unassignSoftwareModule(NOT_EXIST_IDL, module.getId()),
|
verifyThrownExceptionBy(() -> distributionSetManagement.unassignSoftwareModule(NOT_EXIST_IDL, module.getId()),
|
||||||
"DistributionSet");
|
"DistributionSet");
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.unassignSoftwareModule(set.getId(), NOT_EXIST_IDL),
|
verifyThrownExceptionBy(() -> distributionSetManagement.unassignSoftwareModule(set.getId(), NOT_EXIST_IDL),
|
||||||
@@ -110,10 +111,8 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
verifyThrownExceptionBy(() -> distributionSetManagement.assignTag(Arrays.asList(NOT_EXIST_IDL), dsTag.getId()),
|
verifyThrownExceptionBy(() -> distributionSetManagement.assignTag(Arrays.asList(NOT_EXIST_IDL), dsTag.getId()),
|
||||||
"DistributionSet");
|
"DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.findDistributionSetsByTag(PAGE, NOT_EXIST_IDL),
|
verifyThrownExceptionBy(() -> distributionSetManagement.findByTag(PAGE, NOT_EXIST_IDL), "DistributionSetTag");
|
||||||
"DistributionSetTag");
|
verifyThrownExceptionBy(() -> distributionSetManagement.findByRsqlAndTag(PAGE, "name==*", NOT_EXIST_IDL),
|
||||||
verifyThrownExceptionBy(
|
|
||||||
() -> distributionSetManagement.findDistributionSetsByTag(PAGE, "name==*", NOT_EXIST_IDL),
|
|
||||||
"DistributionSetTag");
|
"DistributionSetTag");
|
||||||
|
|
||||||
verifyThrownExceptionBy(
|
verifyThrownExceptionBy(
|
||||||
@@ -131,47 +130,44 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
verifyThrownExceptionBy(
|
verifyThrownExceptionBy(
|
||||||
() -> distributionSetManagement
|
() -> distributionSetManagement
|
||||||
.createDistributionSet(entityFactory.distributionSet().create().name("xxx").type(NOT_EXIST_ID)),
|
.create(entityFactory.distributionSet().create().name("xxx").type(NOT_EXIST_ID)),
|
||||||
"DistributionSetType");
|
"DistributionSetType");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.createDistributionSetMetadata(NOT_EXIST_IDL,
|
verifyThrownExceptionBy(() -> distributionSetManagement.createMetaData(NOT_EXIST_IDL,
|
||||||
Arrays.asList(entityFactory.generateMetadata("123", "123"))), "DistributionSet");
|
Arrays.asList(entityFactory.generateMetadata("123", "123"))), "DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteDistributionSet(Arrays.asList(NOT_EXIST_IDL)),
|
verifyThrownExceptionBy(() -> distributionSetManagement.delete(Arrays.asList(NOT_EXIST_IDL)),
|
||||||
"DistributionSet");
|
"DistributionSet");
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteDistributionSet(NOT_EXIST_IDL),
|
verifyThrownExceptionBy(() -> distributionSetManagement.delete(NOT_EXIST_IDL), "DistributionSet");
|
||||||
|
verifyThrownExceptionBy(() -> distributionSetManagement.deleteMetaData(NOT_EXIST_IDL, "xxx"),
|
||||||
"DistributionSet");
|
"DistributionSet");
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.deleteDistributionSetMetadata(NOT_EXIST_IDL, "xxx"),
|
verifyThrownExceptionBy(() -> distributionSetManagement.deleteMetaData(set.getId(), NOT_EXIST_ID),
|
||||||
"DistributionSet");
|
|
||||||
verifyThrownExceptionBy(
|
|
||||||
() -> distributionSetManagement.deleteDistributionSetMetadata(set.getId(), NOT_EXIST_ID),
|
|
||||||
"DistributionSetMetadata");
|
"DistributionSetMetadata");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.findDistributionSetByAction(NOT_EXIST_IDL), "Action");
|
verifyThrownExceptionBy(() -> distributionSetManagement.getByAction(NOT_EXIST_IDL), "Action");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.findDistributionSetMetadata(NOT_EXIST_IDL, "xxx"),
|
verifyThrownExceptionBy(() -> distributionSetManagement.getMetaDataByDistributionSetId(NOT_EXIST_IDL, "xxx"),
|
||||||
|
"DistributionSet");
|
||||||
|
|
||||||
|
verifyThrownExceptionBy(() -> distributionSetManagement.findMetaDataByDistributionSetId(PAGE, NOT_EXIST_IDL),
|
||||||
"DistributionSet");
|
"DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(
|
verifyThrownExceptionBy(
|
||||||
() -> distributionSetManagement.findDistributionSetMetadataByDistributionSetId(NOT_EXIST_IDL, PAGE),
|
() -> distributionSetManagement.findMetaDataByDistributionSetIdAndRsql(PAGE, NOT_EXIST_IDL, "name==*"),
|
||||||
"DistributionSet");
|
"DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement
|
assertThatThrownBy(() -> distributionSetManagement.isInUse(NOT_EXIST_IDL))
|
||||||
.findDistributionSetMetadataByDistributionSetId(NOT_EXIST_IDL, "name==*", PAGE), "DistributionSet");
|
|
||||||
|
|
||||||
assertThatThrownBy(() -> distributionSetManagement.isDistributionSetInUse(NOT_EXIST_IDL))
|
|
||||||
.isInstanceOf(EntityNotFoundException.class).hasMessageContaining(NOT_EXIST_ID)
|
.isInstanceOf(EntityNotFoundException.class).hasMessageContaining(NOT_EXIST_ID)
|
||||||
.hasMessageContaining("DistributionSet");
|
.hasMessageContaining("DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(
|
verifyThrownExceptionBy(
|
||||||
() -> distributionSetManagement
|
() -> distributionSetManagement.update(entityFactory.distributionSet().update(NOT_EXIST_IDL)),
|
||||||
.updateDistributionSet(entityFactory.distributionSet().update(NOT_EXIST_IDL)),
|
|
||||||
"DistributionSet");
|
"DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateDistributionSetMetadata(NOT_EXIST_IDL,
|
verifyThrownExceptionBy(() -> distributionSetManagement.updateMetaData(NOT_EXIST_IDL,
|
||||||
entityFactory.generateMetadata("xxx", "xxx")), "DistributionSet");
|
entityFactory.generateMetadata("xxx", "xxx")), "DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> distributionSetManagement.updateDistributionSetMetadata(set.getId(),
|
verifyThrownExceptionBy(() -> distributionSetManagement.updateMetaData(set.getId(),
|
||||||
entityFactory.generateMetadata(NOT_EXIST_ID, "xxx")), "DistributionSetMetadata");
|
entityFactory.generateMetadata(NOT_EXIST_ID, "xxx")), "DistributionSetMetadata");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,13 +188,13 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
private void createAndUpdateDistributionSetWithInvalidDescription(final DistributionSet set) {
|
private void createAndUpdateDistributionSetWithInvalidDescription(final DistributionSet set) {
|
||||||
|
|
||||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a")
|
||||||
.create().name("a").version("a").description(RandomStringUtils.randomAlphanumeric(513))))
|
.version("a").description(RandomStringUtils.randomAlphanumeric(513))))
|
||||||
.as("entity with too long description should not be created");
|
.as("entity with too long description should not be created");
|
||||||
|
|
||||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||||
.update(set.getId()).description(RandomStringUtils.randomAlphanumeric(513))))
|
.description(RandomStringUtils.randomAlphanumeric(513))))
|
||||||
.as("entity with too long description should not be updated");
|
.as("entity with too long description should not be updated");
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -207,23 +203,21 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
private void createAndUpdateDistributionSetWithInvalidName(final DistributionSet set) {
|
private void createAndUpdateDistributionSetWithInvalidName(final DistributionSet set) {
|
||||||
|
|
||||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().version("a")
|
||||||
.create().version("a").name(RandomStringUtils.randomAlphanumeric(65))))
|
.name(RandomStringUtils.randomAlphanumeric(65))))
|
||||||
|
.as("entity with too long name should not be created");
|
||||||
|
|
||||||
|
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||||
|
() -> distributionSetManagement.create(entityFactory.distributionSet().create().version("a").name("")))
|
||||||
.as("entity with too long name should not be created");
|
.as("entity with too long name should not be created");
|
||||||
|
|
||||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||||
.isThrownBy(() -> distributionSetManagement
|
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||||
.createDistributionSet(entityFactory.distributionSet().create().version("a").name("")))
|
.name(RandomStringUtils.randomAlphanumeric(65))))
|
||||||
.as("entity with too long name should not be created");
|
|
||||||
|
|
||||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
|
||||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
|
||||||
.update(set.getId()).name(RandomStringUtils.randomAlphanumeric(65))))
|
|
||||||
.as("entity with too long name should not be updated");
|
.as("entity with too long name should not be updated");
|
||||||
|
|
||||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||||
.isThrownBy(() -> distributionSetManagement
|
() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId()).name("")))
|
||||||
.updateDistributionSet(entityFactory.distributionSet().update(set.getId()).name("")))
|
|
||||||
.as("entity with too short name should not be updated");
|
.as("entity with too short name should not be updated");
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -232,23 +226,21 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
private void createAndUpdateDistributionSetWithInvalidVersion(final DistributionSet set) {
|
private void createAndUpdateDistributionSetWithInvalidVersion(final DistributionSet set) {
|
||||||
|
|
||||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||||
.isThrownBy(() -> distributionSetManagement.createDistributionSet(entityFactory.distributionSet()
|
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a")
|
||||||
.create().name("a").version(RandomStringUtils.randomAlphanumeric(65))))
|
.version(RandomStringUtils.randomAlphanumeric(65))))
|
||||||
|
.as("entity with too long name should not be created");
|
||||||
|
|
||||||
|
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||||
|
() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a").version("")))
|
||||||
.as("entity with too long name should not be created");
|
.as("entity with too long name should not be created");
|
||||||
|
|
||||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||||
.isThrownBy(() -> distributionSetManagement
|
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||||
.createDistributionSet(entityFactory.distributionSet().create().name("a").version("")))
|
.version(RandomStringUtils.randomAlphanumeric(65))))
|
||||||
.as("entity with too long name should not be created");
|
|
||||||
|
|
||||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
|
||||||
.isThrownBy(() -> distributionSetManagement.updateDistributionSet(entityFactory.distributionSet()
|
|
||||||
.update(set.getId()).version(RandomStringUtils.randomAlphanumeric(65))))
|
|
||||||
.as("entity with too long name should not be updated");
|
.as("entity with too long name should not be updated");
|
||||||
|
|
||||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(
|
||||||
.isThrownBy(() -> distributionSetManagement
|
() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId()).version("")))
|
||||||
.updateDistributionSet(entityFactory.distributionSet().update(set.getId()).version("")))
|
|
||||||
.as("entity with too short name should not be updated");
|
.as("entity with too short name should not be updated");
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -266,7 +258,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@Description("Verifies that a DS is of default type if not specified explicitly at creation time.")
|
@Description("Verifies that a DS is of default type if not specified explicitly at creation time.")
|
||||||
public void createDistributionSetWithImplicitType() {
|
public void createDistributionSetWithImplicitType() {
|
||||||
final DistributionSet set = distributionSetManagement
|
final DistributionSet set = distributionSetManagement
|
||||||
.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
.create(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
||||||
|
|
||||||
assertThat(set.getType()).as("Type should be equal to default type of tenant")
|
assertThat(set.getType()).as("Type should be equal to default type of tenant")
|
||||||
.isEqualTo(systemManagement.getTenantMetadata().getDefaultDsType());
|
.isEqualTo(systemManagement.getTenantMetadata().getDefaultDsType());
|
||||||
@@ -276,11 +268,10 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
@Description("Verifies that a DS cannot be created if another DS with same name and version exists.")
|
@Description("Verifies that a DS cannot be created if another DS with same name and version exists.")
|
||||||
public void createDistributionSetWithDuplicateNameAndVersionFails() {
|
public void createDistributionSetWithDuplicateNameAndVersionFails() {
|
||||||
distributionSetManagement
|
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
||||||
.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft").version("1"));
|
|
||||||
|
|
||||||
assertThatExceptionOfType(EntityAlreadyExistsException.class).isThrownBy(() -> distributionSetManagement
|
assertThatExceptionOfType(EntityAlreadyExistsException.class).isThrownBy(() -> distributionSetManagement
|
||||||
.createDistributionSet(entityFactory.distributionSet().create().name("newtypesoft").version("1")));
|
.create(entityFactory.distributionSet().create().name("newtypesoft").version("1")));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,7 +284,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
creates.add(entityFactory.distributionSet().create().name("newtypesoft" + i).version("1" + i));
|
creates.add(entityFactory.distributionSet().create().name("newtypesoft" + i).version("1" + i));
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<DistributionSet> sets = distributionSetManagement.createDistributionSets(creates);
|
final List<DistributionSet> sets = distributionSetManagement.create(creates);
|
||||||
|
|
||||||
assertThat(sets).as("Type should be equal to default type of tenant").are(new Condition<DistributionSet>() {
|
assertThat(sets).as("Type should be equal to default type of tenant").are(new Condition<DistributionSet>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -330,33 +321,30 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId());
|
assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
final DistributionSetTag tag = tagManagement
|
final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name("Tag1"));
|
||||||
.createDistributionSetTag(entityFactory.tag().create().name("Tag1"));
|
|
||||||
|
|
||||||
final List<DistributionSet> assignedDS = distributionSetManagement.assignTag(assignDS, tag.getId());
|
final List<DistributionSet> assignedDS = distributionSetManagement.assignTag(assignDS, tag.getId());
|
||||||
assertThat(assignedDS.size()).as("assigned ds has wrong size").isEqualTo(4);
|
assertThat(assignedDS.size()).as("assigned ds has wrong size").isEqualTo(4);
|
||||||
assignedDS.stream().map(c -> (JpaDistributionSet) c)
|
assignedDS.stream().map(c -> (JpaDistributionSet) c)
|
||||||
.forEach(ds -> assertThat(ds.getTags().size()).as("ds has wrong tag size").isEqualTo(1));
|
.forEach(ds -> assertThat(ds.getTags().size()).as("ds has wrong tag size").isEqualTo(1));
|
||||||
|
|
||||||
DistributionSetTag findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1").get();
|
DistributionSetTag findDistributionSetTag = distributionSetTagManagement.getByName("Tag1").get();
|
||||||
|
|
||||||
assertThat(assignedDS.size()).as("assigned ds has wrong size").isEqualTo(
|
assertThat(assignedDS.size()).as("assigned ds has wrong size")
|
||||||
distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId()).getNumberOfElements());
|
.isEqualTo(distributionSetManagement.findByTag(PAGE, tag.getId()).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").isEqualTo(0);
|
assertThat(unAssignDS.getTags().size()).as("unassigned ds has wrong tag size").isEqualTo(0);
|
||||||
findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1").get();
|
findDistributionSetTag = distributionSetTagManagement.getByName("Tag1").get();
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByTag(PAGE, tag.getId()).getNumberOfElements())
|
assertThat(distributionSetManagement.findByTag(PAGE, tag.getId()).getNumberOfElements())
|
||||||
.as("ds tag ds has wrong ds size").isEqualTo(3);
|
.as("ds tag ds has wrong ds size").isEqualTo(3);
|
||||||
|
|
||||||
assertThat(distributionSetManagement
|
assertThat(distributionSetManagement.findByRsqlAndTag(PAGE, "name==" + unAssignDS.getName(), tag.getId())
|
||||||
.findDistributionSetsByTag(PAGE, "name==" + unAssignDS.getName(), tag.getId()).getNumberOfElements())
|
.getNumberOfElements()).as("ds tag ds has wrong ds size").isEqualTo(0);
|
||||||
.as("ds tag ds has wrong ds size").isEqualTo(0);
|
assertThat(distributionSetManagement.findByRsqlAndTag(PAGE, "name!=" + unAssignDS.getName(), tag.getId())
|
||||||
assertThat(distributionSetManagement
|
.getNumberOfElements()).as("ds tag ds has wrong ds size").isEqualTo(3);
|
||||||
.findDistributionSetsByTag(PAGE, "name!=" + unAssignDS.getName(), tag.getId()).getNumberOfElements())
|
|
||||||
.as("ds tag ds has wrong ds size").isEqualTo(3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -375,7 +363,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
// assign target
|
// assign target
|
||||||
assignDistributionSet(ds.getId(), target.getControllerId());
|
assignDistributionSet(ds.getId(), target.getControllerId());
|
||||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
ds = distributionSetManagement.getWithDetails(ds.getId()).get();
|
||||||
|
|
||||||
final Long dsId = ds.getId();
|
final Long dsId = ds.getId();
|
||||||
// not allowed as it is assigned now
|
// not allowed as it is assigned now
|
||||||
@@ -392,14 +380,13 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@Description("Ensures that it is not possible to add a software module that is not defined of the DS's type.")
|
@Description("Ensures that it is not possible to add a software module that is not defined of the DS's type.")
|
||||||
public void updateDistributionSetUnsupportedModuleFails() {
|
public void updateDistributionSetUnsupportedModuleFails() {
|
||||||
final DistributionSet set = distributionSetManagement
|
final DistributionSet set = distributionSetManagement
|
||||||
.createDistributionSet(
|
.create(entityFactory.distributionSet().create().name("agent-hub2")
|
||||||
entityFactory.distributionSet().create().name("agent-hub2").version("1.0.5")
|
.version(
|
||||||
.type(distributionSetTypeManagement
|
"1.0.5")
|
||||||
.createDistributionSetType(entityFactory.distributionSetType().create()
|
.type(distributionSetTypeManagement.create(entityFactory.distributionSetType().create()
|
||||||
.key("test").name("test").mandatory(Arrays.asList(osType.getId())))
|
.key("test").name("test").mandatory(Arrays.asList(osType.getId()))).getKey()));
|
||||||
.getKey()));
|
|
||||||
|
|
||||||
final SoftwareModule module = softwareModuleManagement.createSoftwareModule(
|
final SoftwareModule module = softwareModuleManagement.create(
|
||||||
entityFactory.softwareModule().create().name("agent-hub2").version("1.0.5").type(appType.getKey()));
|
entityFactory.softwareModule().create().name("agent-hub2").version("1.0.5").type(appType.getKey()));
|
||||||
|
|
||||||
// update data
|
// update data
|
||||||
@@ -418,19 +405,18 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
// update data
|
// update data
|
||||||
// legal update of module addition
|
// legal update of module addition
|
||||||
distributionSetManagement.assignSoftwareModules(ds.getId(), Sets.newHashSet(os.getId()));
|
distributionSetManagement.assignSoftwareModules(ds.getId(), Sets.newHashSet(os.getId()));
|
||||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
ds = distributionSetManagement.getWithDetails(ds.getId()).get();
|
||||||
assertThat(ds.findFirstModuleByType(osType).get()).isEqualTo(os);
|
assertThat(ds.findFirstModuleByType(osType).get()).isEqualTo(os);
|
||||||
|
|
||||||
// legal update of module removal
|
// legal update of module removal
|
||||||
distributionSetManagement.unassignSoftwareModule(ds.getId(), ds.findFirstModuleByType(appType).get().getId());
|
distributionSetManagement.unassignSoftwareModule(ds.getId(), ds.findFirstModuleByType(appType).get().getId());
|
||||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
ds = distributionSetManagement.getWithDetails(ds.getId()).get();
|
||||||
assertThat(ds.findFirstModuleByType(appType).isPresent()).isFalse();
|
assertThat(ds.findFirstModuleByType(appType).isPresent()).isFalse();
|
||||||
|
|
||||||
// Update description
|
// Update description
|
||||||
distributionSetManagement
|
distributionSetManagement.update(entityFactory.distributionSet().update(ds.getId()).name("a new name")
|
||||||
.updateDistributionSet(entityFactory.distributionSet().update(ds.getId()).name("a new name")
|
.description("a new description").version("a new version").requiredMigrationStep(true));
|
||||||
.description("a new description").version("a new version").requiredMigrationStep(true));
|
ds = distributionSetManagement.getWithDetails(ds.getId()).get();
|
||||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
|
||||||
assertThat(ds.getDescription()).isEqualTo("a new description");
|
assertThat(ds.getDescription()).isEqualTo("a new description");
|
||||||
assertThat(ds.getName()).isEqualTo("a new name");
|
assertThat(ds.getName()).isEqualTo("a new name");
|
||||||
assertThat(ds.getVersion()).isEqualTo("a new version");
|
assertThat(ds.getVersion()).isEqualTo("a new version");
|
||||||
@@ -453,18 +439,18 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
// create an DS meta data entry
|
// create an DS meta data entry
|
||||||
createDistributionSetMetadata(ds.getId(), new JpaDistributionSetMetadata(knownKey, ds, knownValue));
|
createDistributionSetMetadata(ds.getId(), new JpaDistributionSetMetadata(knownKey, ds, knownValue));
|
||||||
|
|
||||||
DistributionSet changedLockRevisionDS = distributionSetManagement.findDistributionSetById(ds.getId()).get();
|
DistributionSet changedLockRevisionDS = distributionSetManagement.get(ds.getId()).get();
|
||||||
assertThat(changedLockRevisionDS.getOptLockRevision()).isEqualTo(2);
|
assertThat(changedLockRevisionDS.getOptLockRevision()).isEqualTo(2);
|
||||||
|
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
|
||||||
// update the DS metadata
|
// update the DS metadata
|
||||||
final JpaDistributionSetMetadata updated = (JpaDistributionSetMetadata) distributionSetManagement
|
final JpaDistributionSetMetadata updated = (JpaDistributionSetMetadata) distributionSetManagement
|
||||||
.updateDistributionSetMetadata(ds.getId(), entityFactory.generateMetadata(knownKey, knownUpdateValue));
|
.updateMetaData(ds.getId(), entityFactory.generateMetadata(knownKey, knownUpdateValue));
|
||||||
// we are updating the sw meta data so also modifying the base software
|
// we are updating the sw meta data so also modifying the base software
|
||||||
// module so opt lock
|
// module so opt lock
|
||||||
// revision must be three
|
// revision must be three
|
||||||
changedLockRevisionDS = distributionSetManagement.findDistributionSetById(ds.getId()).get();
|
changedLockRevisionDS = distributionSetManagement.get(ds.getId()).get();
|
||||||
assertThat(changedLockRevisionDS.getOptLockRevision()).isEqualTo(3);
|
assertThat(changedLockRevisionDS.getOptLockRevision()).isEqualTo(3);
|
||||||
assertThat(changedLockRevisionDS.getLastModifiedAt()).isGreaterThan(0L);
|
assertThat(changedLockRevisionDS.getLastModifiedAt()).isGreaterThan(0L);
|
||||||
|
|
||||||
@@ -505,15 +491,19 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
.setIsDeleted(false).setIsComplete(true).setSelectDSWithNoTag(Boolean.FALSE);
|
.setIsDeleted(false).setIsComplete(true).setSelectDSWithNoTag(Boolean.FALSE);
|
||||||
|
|
||||||
// target first only has an assigned DS-three so check order correct
|
// target first only has an assigned DS-three so check order correct
|
||||||
final List<DistributionSet> tFirstPin = distributionSetManagement.findDistributionSetsAllOrderedByLinkTarget(
|
final List<DistributionSet> tFirstPin = distributionSetManagement
|
||||||
PAGE, distributionSetFilterBuilder, tFirst.getControllerId()).getContent();
|
.findByFilterAndAssignedInstalledDsOrderedByLinkTarget(PAGE, distributionSetFilterBuilder,
|
||||||
|
tFirst.getControllerId())
|
||||||
|
.getContent();
|
||||||
assertThat(tFirstPin.get(0)).isEqualTo(dsThree);
|
assertThat(tFirstPin.get(0)).isEqualTo(dsThree);
|
||||||
assertThat(tFirstPin).hasSize(10);
|
assertThat(tFirstPin).hasSize(10);
|
||||||
|
|
||||||
// target second has installed DS-2 and assigned DS-4 so check order
|
// target second has installed DS-2 and assigned DS-4 so check order
|
||||||
// correct
|
// correct
|
||||||
final List<DistributionSet> tSecondPin = distributionSetManagement.findDistributionSetsAllOrderedByLinkTarget(
|
final List<DistributionSet> tSecondPin = distributionSetManagement
|
||||||
PAGE, distributionSetFilterBuilder, tSecond.getControllerId()).getContent();
|
.findByFilterAndAssignedInstalledDsOrderedByLinkTarget(PAGE, distributionSetFilterBuilder,
|
||||||
|
tSecond.getControllerId())
|
||||||
|
.getContent();
|
||||||
assertThat(tSecondPin.get(0)).isEqualTo(dsSecond);
|
assertThat(tSecondPin.get(0)).isEqualTo(dsSecond);
|
||||||
assertThat(tSecondPin.get(1)).isEqualTo(dsFour);
|
assertThat(tSecondPin.get(1)).isEqualTo(dsFour);
|
||||||
assertThat(tFirstPin).hasSize(10);
|
assertThat(tFirstPin).hasSize(10);
|
||||||
@@ -522,35 +512,35 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
@Description("searches for distribution sets based on the various filter options, e.g. name, version, desc., tags.")
|
@Description("searches for distribution sets based on the various filter options, e.g. name, version, desc., tags.")
|
||||||
public void searchDistributionSetsOnFilters() {
|
public void searchDistributionSetsOnFilters() {
|
||||||
DistributionSetTag dsTagA = tagManagement
|
DistributionSetTag dsTagA = distributionSetTagManagement
|
||||||
.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-A"));
|
.create(entityFactory.tag().create().name("DistributionSetTag-A"));
|
||||||
final DistributionSetTag dsTagB = tagManagement
|
final DistributionSetTag dsTagB = distributionSetTagManagement
|
||||||
.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-B"));
|
.create(entityFactory.tag().create().name("DistributionSetTag-B"));
|
||||||
final DistributionSetTag dsTagC = tagManagement
|
final DistributionSetTag dsTagC = distributionSetTagManagement
|
||||||
.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-C"));
|
.create(entityFactory.tag().create().name("DistributionSetTag-C"));
|
||||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("DistributionSetTag-D"));
|
distributionSetTagManagement.create(entityFactory.tag().create().name("DistributionSetTag-D"));
|
||||||
|
|
||||||
List<DistributionSet> ds5Group1 = testdataFactory.createDistributionSets("", 5);
|
List<DistributionSet> ds5Group1 = testdataFactory.createDistributionSets("", 5);
|
||||||
List<DistributionSet> dsGroup2 = testdataFactory.createDistributionSets("test2", 5);
|
List<DistributionSet> dsGroup2 = testdataFactory.createDistributionSets("test2", 5);
|
||||||
DistributionSet dsDeleted = testdataFactory.createDistributionSet("deleted");
|
DistributionSet dsDeleted = testdataFactory.createDistributionSet("deleted");
|
||||||
final DistributionSet dsInComplete = distributionSetManagement.createDistributionSet(entityFactory
|
final DistributionSet dsInComplete = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||||
.distributionSet().create().name("notcomplete").version("1").type(standardDsType.getKey()));
|
.name("notcomplete").version("1").type(standardDsType.getKey()));
|
||||||
|
|
||||||
DistributionSetType newType = distributionSetTypeManagement.createDistributionSetType(
|
DistributionSetType newType = distributionSetTypeManagement
|
||||||
entityFactory.distributionSetType().create().key("foo").name("bar").description("test"));
|
.create(entityFactory.distributionSetType().create().key("foo").name("bar").description("test"));
|
||||||
|
|
||||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(newType.getId(),
|
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(newType.getId(),
|
||||||
Arrays.asList(osType.getId()));
|
Arrays.asList(osType.getId()));
|
||||||
newType = distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(newType.getId(),
|
newType = distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(newType.getId(),
|
||||||
Arrays.asList(appType.getId(), runtimeType.getId()));
|
Arrays.asList(appType.getId(), runtimeType.getId()));
|
||||||
|
|
||||||
final DistributionSet dsNewType = distributionSetManagement.createDistributionSet(
|
final DistributionSet dsNewType = distributionSetManagement.create(
|
||||||
entityFactory.distributionSet().create().name("newtype").version("1").type(newType.getKey()).modules(
|
entityFactory.distributionSet().create().name("newtype").version("1").type(newType.getKey()).modules(
|
||||||
dsDeleted.getModules().stream().map(SoftwareModule::getId).collect(Collectors.toList())));
|
dsDeleted.getModules().stream().map(SoftwareModule::getId).collect(Collectors.toList())));
|
||||||
|
|
||||||
assignDistributionSet(dsDeleted, testdataFactory.createTargets(5));
|
assignDistributionSet(dsDeleted, testdataFactory.createTargets(5));
|
||||||
distributionSetManagement.deleteDistributionSet(dsDeleted.getId());
|
distributionSetManagement.delete(dsDeleted.getId());
|
||||||
dsDeleted = distributionSetManagement.findDistributionSetById(dsDeleted.getId()).get();
|
dsDeleted = distributionSetManagement.get(dsDeleted.getId()).get();
|
||||||
|
|
||||||
ds5Group1 = toggleTagAssignment(ds5Group1, dsTagA).getAssignedEntity();
|
ds5Group1 = toggleTagAssignment(ds5Group1, dsTagA).getAssignedEntity();
|
||||||
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName()).get();
|
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName()).get();
|
||||||
@@ -571,18 +561,18 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
expected.add(dsNewType);
|
expected.add(dsNewType);
|
||||||
|
|
||||||
assertThat(distributionSetManagement
|
assertThat(distributionSetManagement
|
||||||
.findDistributionSetsByFilters(PAGE, getDistributionSetFilterBuilder().build()).getContent())
|
.findByDistributionSetFilter(PAGE, getDistributionSetFilterBuilder().build()).getContent()).hasSize(13)
|
||||||
.hasSize(13).containsOnly(expected.toArray(new DistributionSet[0]));
|
.containsOnly(expected.toArray(new DistributionSet[0]));
|
||||||
|
|
||||||
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
||||||
|
|
||||||
// search for not deleted
|
// search for not deleted
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE);
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(1);
|
.getContent()).hasSize(1);
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(false);
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(false);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(12);
|
.getContent()).hasSize(12);
|
||||||
|
|
||||||
// search for completed
|
// search for completed
|
||||||
@@ -593,50 +583,50 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
expected.add(dsNewType);
|
expected.add(dsNewType);
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true);
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(12).containsOnly(expected.toArray(new DistributionSet[0]));
|
.getContent()).hasSize(12).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
|
||||||
expected = new ArrayList<>();
|
expected = new ArrayList<>();
|
||||||
expected.add(dsInComplete);
|
expected.add(dsInComplete);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||||
|
|
||||||
// search for type
|
// search for type
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(newType);
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(newType);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(1);
|
.getContent()).hasSize(1);
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType);
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(12);
|
.getContent()).hasSize(12);
|
||||||
|
|
||||||
// search for text
|
// search for text
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setSearchText("%test2");
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setSearchText("%test2");
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(5);
|
.getContent()).hasSize(5);
|
||||||
|
|
||||||
// search for tags
|
// search for tags
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagA.getName()));
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagA.getName()));
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(10);
|
.getContent()).hasSize(10);
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagB.getName()));
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagB.getName()));
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(5);
|
.getContent()).hasSize(5);
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
||||||
.setTagNames(Arrays.asList(dsTagA.getName(), dsTagB.getName()));
|
.setTagNames(Arrays.asList(dsTagA.getName(), dsTagB.getName()));
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(10);
|
.getContent()).hasSize(10);
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder()
|
||||||
.setTagNames(Arrays.asList(dsTagC.getName(), dsTagB.getName()));
|
.setTagNames(Arrays.asList(dsTagC.getName(), dsTagB.getName()));
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(5);
|
.getContent()).hasSize(5);
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagC.getName()));
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setTagNames(Arrays.asList(dsTagC.getName()));
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(0);
|
.getContent()).hasSize(0);
|
||||||
|
|
||||||
// combine deleted and complete
|
// combine deleted and complete
|
||||||
@@ -647,23 +637,23 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||||
.setIsDeleted(Boolean.FALSE);
|
.setIsDeleted(Boolean.FALSE);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(11).containsOnly(expected.toArray(new DistributionSet[0]));
|
.getContent()).hasSize(11).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||||
|
|
||||||
expected = Arrays.asList(dsInComplete);
|
expected = Arrays.asList(dsInComplete);
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.FALSE);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||||
|
|
||||||
expected = Arrays.asList(dsDeleted);
|
expected = Arrays.asList(dsDeleted);
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||||
.setIsDeleted(Boolean.TRUE);
|
.setIsDeleted(Boolean.TRUE);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE)
|
||||||
.setIsComplete(Boolean.FALSE);
|
.setIsComplete(Boolean.FALSE);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(0);
|
.getContent()).hasSize(0);
|
||||||
|
|
||||||
// combine deleted and complete and type
|
// combine deleted and complete and type
|
||||||
@@ -672,57 +662,57 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
expected.addAll(dsGroup2);
|
expected.addAll(dsGroup2);
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.FALSE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.FALSE)
|
||||||
.setIsComplete(Boolean.TRUE).setType(standardDsType);
|
.setIsComplete(Boolean.TRUE).setType(standardDsType);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(10).containsOnly(expected.toArray(new DistributionSet[0]));
|
.getContent()).hasSize(10).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||||
|
|
||||||
expected = Arrays.asList(dsDeleted);
|
expected = Arrays.asList(dsDeleted);
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||||
.setType(standardDsType).setIsDeleted(Boolean.TRUE);
|
.setType(standardDsType).setIsDeleted(Boolean.TRUE);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsDeleted(Boolean.TRUE)
|
||||||
.setIsComplete(Boolean.FALSE).setType(standardDsType);
|
.setIsComplete(Boolean.FALSE).setType(standardDsType);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(0);
|
.getContent()).hasSize(0);
|
||||||
|
|
||||||
expected = Arrays.asList(dsNewType);
|
expected = Arrays.asList(dsNewType);
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setType(newType);
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setType(newType);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
.getContent()).hasSize(1).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||||
|
|
||||||
// combine deleted and complete and type and text
|
// combine deleted and complete and type and text
|
||||||
expected = dsGroup2;
|
expected = dsGroup2;
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||||
.setType(standardDsType).setSearchText("%test2");
|
.setType(standardDsType).setSearchText("%test2");
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(5).containsOnly(expected.toArray(new DistributionSet[0]));
|
.getContent()).hasSize(5).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||||
.setIsDeleted(Boolean.TRUE).setType(standardDsType).setSearchText("%test2");
|
.setIsDeleted(Boolean.TRUE).setType(standardDsType).setSearchText("%test2");
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(0);
|
.getContent()).hasSize(0);
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType).setSearchText("%test2")
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType).setSearchText("%test2")
|
||||||
.setIsComplete(false).setIsDeleted(false);
|
.setIsComplete(false).setIsDeleted(false);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(0);
|
.getContent()).hasSize(0);
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(newType).setSearchText("%test2")
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(newType).setSearchText("%test2")
|
||||||
.setIsComplete(Boolean.TRUE).setIsDeleted(false);
|
.setIsComplete(Boolean.TRUE).setIsDeleted(false);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(0);
|
.getContent()).hasSize(0);
|
||||||
|
|
||||||
// combine deleted and complete and type and text and tag
|
// combine deleted and complete and type and text and tag
|
||||||
expected = dsGroup2;
|
expected = dsGroup2;
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setType(standardDsType)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setType(standardDsType)
|
||||||
.setSearchText("%test2").setTagNames(Arrays.asList(dsTagA.getName()));
|
.setSearchText("%test2").setTagNames(Arrays.asList(dsTagA.getName()));
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(5).containsOnly(expected.toArray(new DistributionSet[0]));
|
.getContent()).hasSize(5).containsOnly(expected.toArray(new DistributionSet[0]));
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType).setSearchText("%test2")
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setType(standardDsType).setSearchText("%test2")
|
||||||
.setTagNames(Arrays.asList(dsTagA.getName())).setIsComplete(Boolean.FALSE).setIsDeleted(Boolean.FALSE);
|
.setTagNames(Arrays.asList(dsTagA.getName())).setIsComplete(Boolean.FALSE).setIsDeleted(Boolean.FALSE);
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
assertThat(distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getContent()).hasSize(0);
|
.getContent()).hasSize(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -736,8 +726,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
public void findDistributionSetsWithoutLazy() {
|
public void findDistributionSetsWithoutLazy() {
|
||||||
testdataFactory.createDistributionSets(20);
|
testdataFactory.createDistributionSets(20);
|
||||||
|
|
||||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(PAGE, false, true))
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(20);
|
||||||
.hasSize(20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -748,12 +737,10 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
// delete a ds
|
// delete a ds
|
||||||
assertThat(distributionSetRepository.findAll()).hasSize(2);
|
assertThat(distributionSetRepository.findAll()).hasSize(2);
|
||||||
distributionSetManagement.deleteDistributionSet(ds1.getId());
|
distributionSetManagement.delete(ds1.getId());
|
||||||
// not assigned so not marked as deleted but fully deleted
|
// not assigned so not marked as deleted but fully deleted
|
||||||
assertThat(distributionSetRepository.findAll()).hasSize(1);
|
assertThat(distributionSetRepository.findAll()).hasSize(1);
|
||||||
assertThat(distributionSetManagement
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true).getTotalElements()).isEqualTo(1);
|
||||||
.findDistributionSetsByDeletedAndOrCompleted(PAGE, Boolean.FALSE, Boolean.TRUE).getTotalElements())
|
|
||||||
.isEqualTo(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -776,10 +763,10 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Page<DistributionSetMetadata> metadataOfDs1 = distributionSetManagement
|
final Page<DistributionSetMetadata> metadataOfDs1 = distributionSetManagement
|
||||||
.findDistributionSetMetadataByDistributionSetId(ds1.getId(), new PageRequest(0, 100));
|
.findMetaDataByDistributionSetId(new PageRequest(0, 100), ds1.getId());
|
||||||
|
|
||||||
final Page<DistributionSetMetadata> metadataOfDs2 = distributionSetManagement
|
final Page<DistributionSetMetadata> metadataOfDs2 = distributionSetManagement
|
||||||
.findDistributionSetMetadataByDistributionSetId(ds2.getId(), new PageRequest(0, 100));
|
.findMetaDataByDistributionSetId(new PageRequest(0, 100), ds2.getId());
|
||||||
|
|
||||||
assertThat(metadataOfDs1.getNumberOfElements()).isEqualTo(10);
|
assertThat(metadataOfDs1.getNumberOfElements()).isEqualTo(10);
|
||||||
assertThat(metadataOfDs1.getTotalElements()).isEqualTo(10);
|
assertThat(metadataOfDs1.getTotalElements()).isEqualTo(10);
|
||||||
@@ -806,14 +793,11 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
// delete assigned ds
|
// delete assigned ds
|
||||||
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
||||||
distributionSetManagement
|
distributionSetManagement.delete(Arrays.asList(dsToTargetAssigned.getId(), dsToRolloutAssigned.getId()));
|
||||||
.deleteDistributionSet(Arrays.asList(dsToTargetAssigned.getId(), dsToRolloutAssigned.getId()));
|
|
||||||
|
|
||||||
// not assigned so not marked as deleted
|
// not assigned so not marked as deleted
|
||||||
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
||||||
assertThat(distributionSetManagement
|
assertThat(distributionSetManagement.findByCompleted(PAGE, true).getTotalElements()).isEqualTo(2);
|
||||||
.findDistributionSetsByDeletedAndOrCompleted(PAGE, Boolean.FALSE, Boolean.TRUE).getTotalElements())
|
|
||||||
.isEqualTo(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -846,7 +830,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
testdataFactory.createDistributionSet("test" + i);
|
testdataFactory.createDistributionSet("test" + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<DistributionSet> foundDs = distributionSetManagement.findDistributionSetsById(searchIds);
|
final List<DistributionSet> foundDs = distributionSetManagement.get(searchIds);
|
||||||
|
|
||||||
assertThat(foundDs).hasSize(3);
|
assertThat(foundDs).hasSize(3);
|
||||||
|
|
||||||
|
|||||||
@@ -18,20 +18,16 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.TagManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent;
|
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent;
|
||||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
|
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
|
||||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdatedEvent;
|
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdatedEvent;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||||
import org.eclipse.hawkbit.repository.model.Tag;
|
import org.eclipse.hawkbit.repository.model.Tag;
|
||||||
import org.eclipse.hawkbit.repository.model.Target;
|
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
|
||||||
import org.eclipse.hawkbit.repository.test.matcher.Expect;
|
import org.eclipse.hawkbit.repository.test.matcher.Expect;
|
||||||
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
|
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -41,22 +37,20 @@ import ru.yandex.qatools.allure.annotations.Features;
|
|||||||
import ru.yandex.qatools.allure.annotations.Stories;
|
import ru.yandex.qatools.allure.annotations.Stories;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for {@link TagManagement}.
|
* {@link DistributionSetTagManagement} tests.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Features("Component Tests - Repository")
|
@Features("Component Tests - Repository")
|
||||||
@Stories("Tag Management")
|
@Stories("DistributionSet Tag Management")
|
||||||
public class TagManagementTest extends AbstractJpaIntegrationTest {
|
public class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verifies that management get access reacts as specfied on calls for non existing entities by means "
|
@Description("Verifies that management get access reacts as specfied on calls for non existing entities by means "
|
||||||
+ "of Optional not present.")
|
+ "of Optional not present.")
|
||||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
|
||||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||||
assertThat(tagManagement.findDistributionSetTag(NOT_EXIST_ID)).isNotPresent();
|
assertThat(distributionSetTagManagement.getByName(NOT_EXIST_ID)).isNotPresent();
|
||||||
assertThat(tagManagement.findDistributionSetTagById(NOT_EXIST_IDL)).isNotPresent();
|
assertThat(distributionSetTagManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||||
assertThat(tagManagement.findTargetTag(NOT_EXIST_ID)).isNotPresent();
|
|
||||||
assertThat(tagManagement.findTargetTagById(NOT_EXIST_IDL)).isNotPresent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -65,18 +59,16 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@ExpectEvents({ @Expect(type = DistributionSetTagUpdatedEvent.class, count = 0),
|
@ExpectEvents({ @Expect(type = DistributionSetTagUpdatedEvent.class, count = 0),
|
||||||
@Expect(type = TargetTagUpdatedEvent.class, count = 0) })
|
@Expect(type = TargetTagUpdatedEvent.class, count = 0) })
|
||||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||||
verifyThrownExceptionBy(() -> tagManagement.deleteDistributionSetTag(NOT_EXIST_ID), "DistributionSetTag");
|
verifyThrownExceptionBy(() -> distributionSetTagManagement.delete(NOT_EXIST_ID),
|
||||||
verifyThrownExceptionBy(() -> tagManagement.deleteTargetTag(NOT_EXIST_ID), "TargetTag");
|
"DistributionSetTag");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> tagManagement.findDistributionSetTagsByDistributionSet(PAGE, NOT_EXIST_IDL),
|
verifyThrownExceptionBy(
|
||||||
|
() -> distributionSetTagManagement.findByDistributionSet(PAGE, NOT_EXIST_IDL),
|
||||||
"DistributionSet");
|
"DistributionSet");
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> tagManagement.updateDistributionSetTag(entityFactory.tag().update(NOT_EXIST_IDL)),
|
verifyThrownExceptionBy(
|
||||||
|
() -> distributionSetTagManagement.update(entityFactory.tag().update(NOT_EXIST_IDL)),
|
||||||
"DistributionSetTag");
|
"DistributionSetTag");
|
||||||
verifyThrownExceptionBy(() -> tagManagement.updateTargetTag(entityFactory.tag().update(NOT_EXIST_IDL)),
|
|
||||||
"TargetTag");
|
|
||||||
|
|
||||||
verifyThrownExceptionBy(() -> tagManagement.findAllTargetTags(PAGE, NOT_EXIST_ID), "Target");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -90,28 +82,33 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final Collection<DistributionSet> dsBCs = testdataFactory.createDistributionSets("DS-BC", 13);
|
final Collection<DistributionSet> dsBCs = testdataFactory.createDistributionSets("DS-BC", 13);
|
||||||
final Collection<DistributionSet> dsABCs = testdataFactory.createDistributionSets("DS-ABC", 9);
|
final Collection<DistributionSet> dsABCs = testdataFactory.createDistributionSets("DS-ABC", 9);
|
||||||
|
|
||||||
final DistributionSetTag tagA = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("A"));
|
final DistributionSetTag tagA = distributionSetTagManagement
|
||||||
final DistributionSetTag tagB = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("B"));
|
.create(entityFactory.tag().create().name("A"));
|
||||||
final DistributionSetTag tagC = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("C"));
|
final DistributionSetTag tagB = distributionSetTagManagement
|
||||||
final DistributionSetTag tagX = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("X"));
|
.create(entityFactory.tag().create().name("B"));
|
||||||
final DistributionSetTag tagY = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("Y"));
|
final DistributionSetTag tagC = distributionSetTagManagement
|
||||||
|
.create(entityFactory.tag().create().name("C"));
|
||||||
|
final DistributionSetTag tagX = distributionSetTagManagement
|
||||||
|
.create(entityFactory.tag().create().name("X"));
|
||||||
|
final DistributionSetTag tagY = distributionSetTagManagement
|
||||||
|
.create(entityFactory.tag().create().name("Y"));
|
||||||
|
|
||||||
toggleTagAssignment(dsAs, tagA);
|
toggleTagAssignment(dsAs, tagA);
|
||||||
toggleTagAssignment(dsBs, tagB);
|
toggleTagAssignment(dsBs, tagB);
|
||||||
toggleTagAssignment(dsCs, tagC);
|
toggleTagAssignment(dsCs, tagC);
|
||||||
|
|
||||||
toggleTagAssignment(dsABs, tagManagement.findDistributionSetTag(tagA.getName()).get());
|
toggleTagAssignment(dsABs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
||||||
toggleTagAssignment(dsABs, tagManagement.findDistributionSetTag(tagB.getName()).get());
|
toggleTagAssignment(dsABs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
||||||
|
|
||||||
toggleTagAssignment(dsACs, tagManagement.findDistributionSetTag(tagA.getName()).get());
|
toggleTagAssignment(dsACs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
||||||
toggleTagAssignment(dsACs, tagManagement.findDistributionSetTag(tagC.getName()).get());
|
toggleTagAssignment(dsACs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
||||||
|
|
||||||
toggleTagAssignment(dsBCs, tagManagement.findDistributionSetTag(tagB.getName()).get());
|
toggleTagAssignment(dsBCs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
||||||
toggleTagAssignment(dsBCs, tagManagement.findDistributionSetTag(tagC.getName()).get());
|
toggleTagAssignment(dsBCs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
||||||
|
|
||||||
toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagA.getName()).get());
|
toggleTagAssignment(dsABCs, distributionSetTagManagement.getByName(tagA.getName()).get());
|
||||||
toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagB.getName()).get());
|
toggleTagAssignment(dsABCs, distributionSetTagManagement.getByName(tagB.getName()).get());
|
||||||
toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagC.getName()).get());
|
toggleTagAssignment(dsABCs, distributionSetTagManagement.getByName(tagC.getName()).get());
|
||||||
|
|
||||||
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
||||||
|
|
||||||
@@ -121,7 +118,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertEquals("filter works not correct",
|
assertEquals("filter works not correct",
|
||||||
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||||
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getTotalElements());
|
.getTotalElements());
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||||
@@ -129,7 +126,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertEquals("filter works not correct",
|
assertEquals("filter works not correct",
|
||||||
dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||||
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getTotalElements());
|
.getTotalElements());
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||||
@@ -137,22 +134,22 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertEquals("filter works not correct",
|
assertEquals("filter works not correct",
|
||||||
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||||
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getTotalElements());
|
.getTotalElements());
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||||
.setTagNames(Arrays.asList(tagX.getName()));
|
.setTagNames(Arrays.asList(tagX.getName()));
|
||||||
assertEquals("filter works not correct", 0, distributionSetManagement
|
assertEquals("filter works not correct", 0, distributionSetManagement
|
||||||
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
||||||
|
|
||||||
assertEquals("wrong tag size", 5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
assertEquals("wrong tag size", 5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||||
|
|
||||||
tagManagement.deleteDistributionSetTag(tagY.getName());
|
distributionSetTagManagement.delete(tagY.getName());
|
||||||
assertEquals("wrong tag size", 4, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
assertEquals("wrong tag size", 4, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||||
tagManagement.deleteDistributionSetTag(tagX.getName());
|
distributionSetTagManagement.delete(tagX.getName());
|
||||||
assertEquals("wrong tag size", 3, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
assertEquals("wrong tag size", 3, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||||
|
|
||||||
tagManagement.deleteDistributionSetTag(tagB.getName());
|
distributionSetTagManagement.delete(tagB.getName());
|
||||||
assertEquals("wrong tag size", 2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
assertEquals("wrong tag size", 2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||||
@@ -160,27 +157,23 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertEquals("filter works not correct",
|
assertEquals("filter works not correct",
|
||||||
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||||
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getTotalElements());
|
.getTotalElements());
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||||
.setTagNames(Arrays.asList(tagB.getName()));
|
.setTagNames(Arrays.asList(tagB.getName()));
|
||||||
assertEquals("filter works not correct", 0, distributionSetManagement
|
assertEquals("filter works not correct", 0, distributionSetManagement
|
||||||
.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
||||||
|
|
||||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||||
.setTagNames(Arrays.asList(tagC.getName()));
|
.setTagNames(Arrays.asList(tagC.getName()));
|
||||||
assertEquals("filter works not correct",
|
assertEquals("filter works not correct",
|
||||||
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||||
distributionSetManagement.findDistributionSetsByFilters(PAGE, distributionSetFilterBuilder.build())
|
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||||
.getTotalElements());
|
.getTotalElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSetFilterBuilder getDistributionSetFilterBuilder() {
|
|
||||||
return new DistributionSetFilterBuilder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Verifies the toogle mechanism by means on assigning tag if at least on DS in the list does not have"
|
@Description("Verifies the toogle mechanism by means on assigning tag if at least on DS in the list does not have"
|
||||||
+ "the tag yet. Unassign if all of them have the tag already.")
|
+ "the tag yet. Unassign if all of them have the tag already.")
|
||||||
@@ -188,15 +181,15 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final Collection<DistributionSet> groupA = testdataFactory.createDistributionSets(20);
|
final Collection<DistributionSet> groupA = testdataFactory.createDistributionSets(20);
|
||||||
final Collection<DistributionSet> groupB = testdataFactory.createDistributionSets("unassigned", 20);
|
final Collection<DistributionSet> groupB = testdataFactory.createDistributionSets("unassigned", 20);
|
||||||
|
|
||||||
final DistributionSetTag tag = tagManagement
|
final DistributionSetTag tag = distributionSetTagManagement
|
||||||
.createDistributionSetTag(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
.create(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||||
|
|
||||||
// toggle A only -> A is now assigned
|
// toggle A only -> A is now assigned
|
||||||
DistributionSetTagAssignmentResult result = toggleTagAssignment(groupA, tag);
|
DistributionSetTagAssignmentResult result = toggleTagAssignment(groupA, tag);
|
||||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||||
assertThat(result.getAssigned()).isEqualTo(20);
|
assertThat(result.getAssigned()).isEqualTo(20);
|
||||||
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement
|
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement
|
||||||
.findDistributionSetsById(groupA.stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
.get(groupA.stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
||||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||||
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||||
@@ -206,7 +199,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
|
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
|
||||||
assertThat(result.getAssigned()).isEqualTo(20);
|
assertThat(result.getAssigned()).isEqualTo(20);
|
||||||
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement
|
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement
|
||||||
.findDistributionSetsById(groupB.stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
.get(groupB.stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
||||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
assertThat(result.getUnassigned()).isEqualTo(0);
|
||||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
assertThat(result.getUnassignedEntity()).isEmpty();
|
||||||
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||||
@@ -217,147 +210,24 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
assertThat(result.getAssigned()).isEqualTo(0);
|
assertThat(result.getAssigned()).isEqualTo(0);
|
||||||
assertThat(result.getAssignedEntity()).isEmpty();
|
assertThat(result.getAssignedEntity()).isEmpty();
|
||||||
assertThat(result.getUnassigned()).isEqualTo(40);
|
assertThat(result.getUnassigned()).isEqualTo(40);
|
||||||
assertThat(result.getUnassignedEntity()).containsAll(distributionSetManagement.findDistributionSetsById(
|
assertThat(result.getUnassignedEntity()).containsAll(distributionSetManagement.get(
|
||||||
concat(groupB, groupA).stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
concat(groupB, groupA).stream().map(DistributionSet::getId).collect(Collectors.toList())));
|
||||||
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Description("Verifies the toogle mechanism by means on assigning tag if at least on target in the list does not have"
|
|
||||||
+ "the tag yet. Unassign if all of them have the tag already.")
|
|
||||||
public void assignAndUnassignTargetTags() {
|
|
||||||
final List<Target> groupA = testdataFactory.createTargets(20);
|
|
||||||
final List<Target> groupB = testdataFactory.createTargets(20, "groupb", "groupb");
|
|
||||||
|
|
||||||
final TargetTag tag = tagManagement
|
|
||||||
.createTargetTag(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
|
||||||
|
|
||||||
// toggle A only -> A is now assigned
|
|
||||||
TargetTagAssignmentResult result = toggleTagAssignment(groupA, tag);
|
|
||||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
|
||||||
assertThat(result.getAssigned()).isEqualTo(20);
|
|
||||||
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetsByControllerID(
|
|
||||||
groupA.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
|
||||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
|
||||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
|
||||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
|
||||||
|
|
||||||
// toggle A+B -> A is still assigned and B is assigned as well
|
|
||||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
|
||||||
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
|
|
||||||
assertThat(result.getAssigned()).isEqualTo(20);
|
|
||||||
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetsByControllerID(
|
|
||||||
groupB.stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
|
||||||
assertThat(result.getUnassigned()).isEqualTo(0);
|
|
||||||
assertThat(result.getUnassignedEntity()).isEmpty();
|
|
||||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
|
||||||
|
|
||||||
// toggle A+B -> both unassigned
|
|
||||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
|
||||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
|
||||||
assertThat(result.getAssigned()).isEqualTo(0);
|
|
||||||
assertThat(result.getAssignedEntity()).isEmpty();
|
|
||||||
assertThat(result.getUnassigned()).isEqualTo(40);
|
|
||||||
assertThat(result.getUnassignedEntity()).containsAll(targetManagement.findTargetsByControllerID(
|
|
||||||
concat(groupB, groupA).stream().map(target -> target.getControllerId()).collect(Collectors.toList())));
|
|
||||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@SafeVarargs
|
|
||||||
private final <T> Collection<T> concat(final Collection<T>... targets) {
|
|
||||||
final List<T> result = new ArrayList<>();
|
|
||||||
Arrays.asList(targets).forEach(result::addAll);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Description("Ensures that all tags are retrieved through repository.")
|
|
||||||
public void findAllTargetTags() {
|
|
||||||
final List<JpaTargetTag> tags = createTargetsWithTags();
|
|
||||||
|
|
||||||
assertThat(targetTagRepository.findAll()).isEqualTo(targetTagRepository.findAll()).isEqualTo(tags)
|
|
||||||
.as("Wrong tag size").hasSize(20);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Description("Ensures that a created tag is persisted in the repository as defined.")
|
|
||||||
public void createTargetTag() {
|
|
||||||
final Tag tag = tagManagement
|
|
||||||
.createTargetTag(entityFactory.tag().create().name("kai1").description("kai2").colour("colour"));
|
|
||||||
|
|
||||||
assertThat(targetTagRepository.findByNameEquals("kai1").get().getDescription()).as("wrong tag ed")
|
|
||||||
.isEqualTo("kai2");
|
|
||||||
assertThat(tagManagement.findTargetTag("kai1").get().getColour()).as("wrong tag found").isEqualTo("colour");
|
|
||||||
assertThat(tagManagement.findTargetTagById(tag.getId()).get().getColour()).as("wrong tag found")
|
|
||||||
.isEqualTo("colour");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Description("Ensures that a deleted tag is removed from the repository as defined.")
|
|
||||||
public void deleteTargetTags() {
|
|
||||||
|
|
||||||
// create test data
|
|
||||||
final Iterable<JpaTargetTag> tags = createTargetsWithTags();
|
|
||||||
final TargetTag toDelete = tags.iterator().next();
|
|
||||||
|
|
||||||
for (final Target target : targetRepository.findAll()) {
|
|
||||||
assertThat(tagManagement.findAllTargetTags(PAGE, target.getControllerId()).getContent())
|
|
||||||
.contains(toDelete);
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete
|
|
||||||
tagManagement.deleteTargetTag(toDelete.getName());
|
|
||||||
|
|
||||||
// check
|
|
||||||
for (final Target target : targetRepository.findAll()) {
|
|
||||||
assertThat(tagManagement.findAllTargetTags(PAGE, target.getControllerId()).getContent())
|
|
||||||
.doesNotContain(toDelete);
|
|
||||||
}
|
|
||||||
assertThat(targetTagRepository.findOne(toDelete.getId())).as("No tag should be found").isNull();
|
|
||||||
assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(19);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Description("Tests the name update of a target tag.")
|
|
||||||
public void updateTargetTag() {
|
|
||||||
final List<JpaTargetTag> tags = createTargetsWithTags();
|
|
||||||
|
|
||||||
// change data
|
|
||||||
final TargetTag savedAssigned = tags.iterator().next();
|
|
||||||
|
|
||||||
// persist
|
|
||||||
tagManagement.updateTargetTag(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
|
|
||||||
|
|
||||||
// check data
|
|
||||||
assertThat(targetTagRepository.findAll()).as("Wrong target tag size").hasSize(tags.size());
|
|
||||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getName()).as("wrong target tag is saved")
|
|
||||||
.isEqualTo("test123");
|
|
||||||
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getOptLockRevision())
|
|
||||||
.as("wrong target tag is saved").isEqualTo(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Ensures that a created tag is persisted in the repository as defined.")
|
@Description("Ensures that a created tag is persisted in the repository as defined.")
|
||||||
public void createDistributionSetTag() {
|
public void createDistributionSetTag() {
|
||||||
final Tag tag = tagManagement.createDistributionSetTag(
|
final Tag tag = distributionSetTagManagement.create(
|
||||||
entityFactory.tag().create().name("kai1").description("kai2").colour("colour"));
|
entityFactory.tag().create().name("kai1").description("kai2").colour("colour"));
|
||||||
|
|
||||||
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(tagManagement.findDistributionSetTag("kai1").get().getColour()).as("wrong tag found")
|
assertThat(distributionSetTagManagement.getByName("kai1").get().getColour()).as("wrong tag found")
|
||||||
.isEqualTo("colour");
|
.isEqualTo("colour");
|
||||||
assertThat(tagManagement.findDistributionSetTagById(tag.getId()).get().getColour()).as("wrong tag found")
|
assertThat(distributionSetTagManagement.get(tag.getId()).get().getColour())
|
||||||
.isEqualTo("colour");
|
.as("wrong tag found").isEqualTo("colour");
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Description("Ensures that a created tags are persisted in the repository as defined.")
|
|
||||||
public void createDistributionSetTags() {
|
|
||||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
|
||||||
|
|
||||||
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags created").hasSize(tags.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -373,11 +243,11 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
tagManagement.deleteDistributionSetTag(tags.iterator().next().getName());
|
distributionSetTagManagement.delete(tags.iterator().next().getName());
|
||||||
|
|
||||||
// check
|
// check
|
||||||
assertThat(distributionSetTagRepository.findOne(toDelete.getId())).as("Deleted tag should be null").isNull();
|
assertThat(distributionSetTagRepository.findOne(toDelete.getId())).as("Deleted tag should be null").isNull();
|
||||||
assertThat(tagManagement.findAllDistributionSetTags(PAGE).getContent())
|
assertThat(distributionSetTagManagement.findAll(PAGE).getContent())
|
||||||
.as("Wrong size of tags after deletion").hasSize(19);
|
.as("Wrong size of tags after deletion").hasSize(19);
|
||||||
|
|
||||||
for (final DistributionSet set : distributionSetRepository.findAll()) {
|
for (final DistributionSet set : distributionSetRepository.findAll()) {
|
||||||
@@ -386,39 +256,12 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
|
||||||
public void failedDuplicateTargetTagNameException() {
|
|
||||||
tagManagement.createTargetTag(entityFactory.tag().create().name("A"));
|
|
||||||
|
|
||||||
try {
|
|
||||||
tagManagement.createTargetTag(entityFactory.tag().create().name("A"));
|
|
||||||
fail("should not have worked as tag already exists");
|
|
||||||
} catch (final EntityAlreadyExistsException e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
|
|
||||||
public void failedDuplicateTargetTagNameExceptionAfterUpdate() {
|
|
||||||
tagManagement.createTargetTag(entityFactory.tag().create().name("A"));
|
|
||||||
final TargetTag tag = tagManagement.createTargetTag(entityFactory.tag().create().name("B"));
|
|
||||||
|
|
||||||
try {
|
|
||||||
tagManagement.updateTargetTag(entityFactory.tag().update(tag.getId()).name("A"));
|
|
||||||
fail("should not have worked as tag already exists");
|
|
||||||
} catch (final EntityAlreadyExistsException e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
||||||
public void failedDuplicateDsTagNameException() {
|
public void failedDuplicateDsTagNameException() {
|
||||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("A"));
|
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||||
try {
|
try {
|
||||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("A"));
|
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||||
fail("should not have worked as tag already exists");
|
fail("should not have worked as tag already exists");
|
||||||
} catch (final EntityAlreadyExistsException e) {
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
@@ -428,11 +271,12 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
|
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
|
||||||
public void failedDuplicateDsTagNameExceptionAfterUpdate() {
|
public void failedDuplicateDsTagNameExceptionAfterUpdate() {
|
||||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("A"));
|
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||||
final DistributionSetTag tag = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("B"));
|
final DistributionSetTag tag = distributionSetTagManagement
|
||||||
|
.create(entityFactory.tag().create().name("B"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tagManagement.updateDistributionSetTag(entityFactory.tag().update(tag.getId()).name("A"));
|
distributionSetTagManagement.update(entityFactory.tag().update(tag.getId()).name("A"));
|
||||||
fail("should not have worked as tag already exists");
|
fail("should not have worked as tag already exists");
|
||||||
} catch (final EntityAlreadyExistsException e) {
|
} catch (final EntityAlreadyExistsException e) {
|
||||||
|
|
||||||
@@ -450,11 +294,12 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final DistributionSetTag savedAssigned = tags.iterator().next();
|
final DistributionSetTag savedAssigned = tags.iterator().next();
|
||||||
|
|
||||||
// persist
|
// persist
|
||||||
tagManagement.updateDistributionSetTag(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
|
distributionSetTagManagement
|
||||||
|
.update(entityFactory.tag().update(savedAssigned.getId()).name("test123"));
|
||||||
|
|
||||||
// check data
|
// check data
|
||||||
assertThat(tagManagement.findAllDistributionSetTags(PAGE).getContent()).as("Wrong size of ds tags")
|
assertThat(distributionSetTagManagement.findAll(PAGE).getContent())
|
||||||
.hasSize(tags.size());
|
.as("Wrong size of ds tags").hasSize(tags.size());
|
||||||
assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).as("Wrong ds tag found")
|
assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).as("Wrong ds tag found")
|
||||||
.isEqualTo("test123");
|
.isEqualTo("test123");
|
||||||
}
|
}
|
||||||
@@ -465,18 +310,17 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||||
|
|
||||||
// test
|
// test
|
||||||
assertThat(tagManagement.findAllDistributionSetTags(PAGE).getContent()).as("Wrong size of tags")
|
assertThat(distributionSetTagManagement.findAll(PAGE).getContent()).as("Wrong size of tags")
|
||||||
.hasSize(tags.size());
|
.hasSize(tags.size());
|
||||||
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags").hasSize(20);
|
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags").hasSize(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<JpaTargetTag> createTargetsWithTags() {
|
@Test
|
||||||
final List<Target> targets = testdataFactory.createTargets(20);
|
@Description("Ensures that a created tags are persisted in the repository as defined.")
|
||||||
final Iterable<TargetTag> tags = testdataFactory.createTargetTags(20, "");
|
public void createDistributionSetTags() {
|
||||||
|
final List<DistributionSetTag> tags = createDsSetsWithTags();
|
||||||
|
|
||||||
tags.forEach(tag -> toggleTagAssignment(targets, tag));
|
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags created").hasSize(tags.size());
|
||||||
|
|
||||||
return targetTagRepository.findAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DistributionSetTag> createDsSetsWithTags() {
|
private List<DistributionSetTag> createDsSetsWithTags() {
|
||||||
@@ -486,6 +330,18 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
tags.forEach(tag -> toggleTagAssignment(sets, tag));
|
tags.forEach(tag -> toggleTagAssignment(sets, tag));
|
||||||
|
|
||||||
return tagManagement.findAllDistributionSetTags(PAGE).getContent();
|
return distributionSetTagManagement.findAll(PAGE).getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DistributionSetFilterBuilder getDistributionSetFilterBuilder() {
|
||||||
|
return new DistributionSetFilterBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SafeVarargs
|
||||||
|
private final <T> Collection<T> concat(final Collection<T>... targets) {
|
||||||
|
final List<T> result = new ArrayList<>();
|
||||||
|
Arrays.asList(targets).forEach(result::addAll);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user