Repository API query signatures Entity free (#403)
* Migrated target management queries to IDs inetsead of full entities Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Added missing comment. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * refactored target,DS,cont,deploy,rg mangement. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Adde versioning documentation. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Rollout, Dist and Software mgmt refactored Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Readded line that was remove by incident. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fixed broken tests. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Query management refactored Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix bug of auto assign DS delete Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Switch to collection Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fixed compile error Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Small glitches Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fixed test after merge Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -27,6 +27,12 @@ https://hawkbit.eu-gb.mybluemix.net/UI/
|
||||
|
||||
We are not providing an off the shelf installation ready hawkBit update server. However, we recommend to check out the [Example Application](examples/hawkbit-example-app) for a runtime ready Spring Boot based update server that is empowered by hawkBit. In addition we have [guide](https://github.com/eclipse/hawkbit/wiki/Run-hawkBit) for setting up a complete landscape.
|
||||
|
||||
# API stability
|
||||
|
||||
hawkBit is currently in '0.X' semantic version. That is due to the need that there is still content in hawkBit that is in need for refactoring. That includes the maven module structure, Spring Boot Properties, Spring Boot auto configuration as well as internal Java APIs (e.g. the [repository API](https://github.com/eclipse/hawkbit/issues/197) ).
|
||||
|
||||
However, the external APIs (i.e. [Management API](https://github.com/eclipse/hawkbit/tree/master/hawkbit-mgmt-api), [DDI API](https://github.com/eclipse/hawkbit/tree/master/hawkbit-ddi-api), [DDI Artifact Download API](https://github.com/eclipse/hawkbit/tree/master/hawkbit-ddi-dl-api) and [DMF API](https://github.com/eclipse/hawkbit/tree/master/hawkbit-dmf-api) are on major version 'v1' and will be kept stable.
|
||||
|
||||
# hawkBit (Spring boot) starters
|
||||
|
||||
Next to the [Example Application](examples/hawkbit-example-app) we are also providing a set of [Spring Boot Starters](hawkbit-starters) to quick start your own [Spring Boot](https://projects.spring.io/spring-boot/) based application.
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
# Eclipse.IoT hawkBit - DDI API
|
||||
# Eclipse.IoT hawkBit - Direct Device Integration API - Model and Resources
|
||||
|
||||
The Direct Device Integration (DDI) API is used by devices for communicating with the HawkBit Update Server through HTTP.
|
||||
|
||||
# Version 1
|
||||
|
||||
The model follows [semantic versioning](http://semver.org) with MAJOR version, i.e. breaking changes will result in a new MAJOR version.
|
||||
|
||||
# Compile
|
||||
|
||||
#### Build hawkbit-ddi-api
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
# Eclipse.IoT hawkBit - DDI Download API
|
||||
# Eclipse.IoT hawkBit - DDI Artifact Download API - Resources
|
||||
|
||||
This module is part of the Direct Device Integration (DDI) API and is used by devices/targets for downloading artifacts through HTTP.
|
||||
|
||||
# Version 1
|
||||
|
||||
The model follows [semantic versioning](http://semver.org) with MAJOR version, i.e. breaking changes will result in a new MAJOR version.
|
||||
|
||||
# Compile
|
||||
|
||||
#### Build hawkbit-ddi-dl-api
|
||||
|
||||
@@ -89,7 +89,7 @@ public class DdiArtifactStoreController implements DdiDlArtifactStoreControllerR
|
||||
if (ifMatch != null && !RestResourceConversionHelper.matchesHttpHeader(ifMatch, artifact.getSha1Hash())) {
|
||||
result = new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED);
|
||||
} else {
|
||||
final DbArtifact file = artifactManagement.loadArtifactBinary(artifact);
|
||||
final DbArtifact file = artifactManagement.loadArtifactBinary(artifact.getId());
|
||||
|
||||
// we set a download status only if we are aware of the
|
||||
// targetid, i.e. authenticated and not anonymous
|
||||
|
||||
@@ -131,10 +131,9 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
|
||||
final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(controllerId, IpUtil
|
||||
.getClientIpFromRequest(requestResponseContextHolder.getHttpServletRequest(), securityProperties));
|
||||
return new ResponseEntity<>(
|
||||
DataConversionHelper.fromTarget(target, controllerManagement.findOldestActiveActionByTarget(target),
|
||||
controllerManagement.getPollingTime(), tenantAware),
|
||||
HttpStatus.OK);
|
||||
return new ResponseEntity<>(DataConversionHelper.fromTarget(target,
|
||||
controllerManagement.findOldestActiveActionByTarget(controllerId),
|
||||
controllerManagement.getPollingTime(), tenantAware), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,7 +157,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
@SuppressWarnings("squid:S3655")
|
||||
final Artifact artifact = module.getArtifactByFilename(fileName).get();
|
||||
|
||||
final DbArtifact file = artifactManagement.loadArtifactBinary(artifact);
|
||||
final DbArtifact file = artifactManagement.loadArtifactBinary(artifact.getId());
|
||||
|
||||
final String ifMatch = requestResponseContextHolder.getHttpServletRequest().getHeader("If-Match");
|
||||
if (ifMatch != null && !RestResourceConversionHelper.matchesHttpHeader(ifMatch, artifact.getSha1Hash())) {
|
||||
@@ -254,7 +253,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
|
||||
LOG.debug("Found an active UpdateAction for target {}. returning deyploment: {}", controllerId, base);
|
||||
|
||||
controllerManagement.registerRetrieved(action, RepositoryConstants.SERVER_MESSAGE_PREFIX
|
||||
controllerManagement.registerRetrieved(action.getId(), RepositoryConstants.SERVER_MESSAGE_PREFIX
|
||||
+ "Target retrieved update action and should start now the download.");
|
||||
|
||||
return new ResponseEntity<>(base, HttpStatus.OK);
|
||||
@@ -388,7 +387,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
|
||||
LOG.debug("Found an active CancelAction for target {}. returning cancel: {}", controllerId, cancel);
|
||||
|
||||
controllerManagement.registerRetrieved(action, RepositoryConstants.SERVER_MESSAGE_PREFIX
|
||||
controllerManagement.registerRetrieved(action.getId(), RepositoryConstants.SERVER_MESSAGE_PREFIX
|
||||
+ "Target retrieved cancel action and should start now the cancelation.");
|
||||
|
||||
return new ResponseEntity<>(cancel, HttpStatus.OK);
|
||||
|
||||
@@ -379,13 +379,15 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
||||
Arrays.equals(result.getResponse().getContentAsByteArray(), random));
|
||||
|
||||
// one (update) action
|
||||
assertThat(deploymentManagement.findActionsByTarget(target)).hasSize(1);
|
||||
final Action action = deploymentManagement.findActionsByTarget(target).get(0);
|
||||
assertThat(deploymentManagement.countActionsByTarget(target.getControllerId())).isEqualTo(1);
|
||||
final Action action = deploymentManagement.findActionsByTarget(target.getControllerId(), pageReq).getContent()
|
||||
.get(0);
|
||||
|
||||
// one status - download
|
||||
assertThat(action.getActionStatus()).hasSize(2);
|
||||
assertThat(deploymentManagement.findActionStatusByAction(new PageRequest(0, 400, Direction.DESC, "id"), action)
|
||||
.getContent().get(0).getStatus()).isEqualTo(Status.DOWNLOAD);
|
||||
assertThat(deploymentManagement
|
||||
.findActionStatusByAction(new PageRequest(0, 400, Direction.DESC, "id"), action.getId()).getContent()
|
||||
.get(0).getStatus()).isEqualTo(Status.DOWNLOAD);
|
||||
|
||||
// download complete
|
||||
assertThat(downLoadProgress).isEqualTo(10);
|
||||
|
||||
@@ -54,8 +54,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
final Action updateAction = deploymentManagement.findActionWithDetails(
|
||||
assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getActions().get(0));
|
||||
|
||||
final Action cancelAction = deploymentManagement.cancelAction(updateAction,
|
||||
targetManagement.findTargetByControllerID(savedTarget.getControllerId()));
|
||||
final Action cancelAction = deploymentManagement.cancelAction(updateAction.getId());
|
||||
|
||||
// controller rejects cancelation
|
||||
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
|
||||
@@ -125,14 +124,14 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
// Retrieved is reported
|
||||
|
||||
List<Action> activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(savedTarget);
|
||||
List<Action> activeActionsByTarget = deploymentManagement
|
||||
.findActiveActionsByTarget(savedTarget.getControllerId());
|
||||
|
||||
assertThat(activeActionsByTarget).hasSize(1);
|
||||
assertThat(activeActionsByTarget.get(0).getStatus()).isEqualTo(Status.RUNNING);
|
||||
final Action cancelAction = deploymentManagement.cancelAction(updateAction,
|
||||
targetManagement.findTargetByControllerID(savedTarget.getControllerId()));
|
||||
final Action cancelAction = deploymentManagement.cancelAction(updateAction.getId());
|
||||
|
||||
activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(savedTarget);
|
||||
activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId());
|
||||
|
||||
// the canceled action should still be active!
|
||||
assertThat(cancelAction.isActive()).isTrue();
|
||||
@@ -176,7 +175,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
|
||||
activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(savedTarget);
|
||||
activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId());
|
||||
assertThat(activeActionsByTarget).hasSize(0);
|
||||
final Action canceledAction = deploymentManagement.findAction(cancelAction.getId());
|
||||
assertThat(canceledAction.isActive()).isFalse();
|
||||
@@ -223,8 +222,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
final Action updateAction = deploymentManagement
|
||||
.findActionWithDetails(assignDistributionSet(ds, toAssign).getActions().get(0));
|
||||
|
||||
return deploymentManagement.cancelAction(updateAction,
|
||||
targetManagement.findTargetByControllerID(savedTarget.getControllerId()));
|
||||
return deploymentManagement.cancelAction(updateAction.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -239,11 +237,10 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActions().get(0));
|
||||
|
||||
// cancel action manually
|
||||
final Action cancelAction = deploymentManagement.cancelAction(updateAction,
|
||||
targetManagement.findTargetByControllerID(savedTarget.getControllerId()));
|
||||
final Action cancelAction = deploymentManagement.cancelAction(updateAction.getId());
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2);
|
||||
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
|
||||
long current = System.currentTimeMillis();
|
||||
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
|
||||
+ cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant())
|
||||
@@ -253,7 +250,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).getTargetInfo()
|
||||
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
||||
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(3);
|
||||
|
||||
current = System.currentTimeMillis();
|
||||
@@ -264,7 +261,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).getTargetInfo()
|
||||
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(4);
|
||||
|
||||
current = System.currentTimeMillis();
|
||||
@@ -276,10 +273,10 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).getTargetInfo()
|
||||
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(5);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
|
||||
|
||||
// cancelation canceled -> should remove the action from active
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
|
||||
current = System.currentTimeMillis();
|
||||
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
|
||||
+ cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant())
|
||||
@@ -289,12 +286,12 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).getTargetInfo()
|
||||
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(6);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
|
||||
|
||||
// cancelation rejected -> action still active until controller close it
|
||||
// with finished or
|
||||
// error
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
|
||||
current = System.currentTimeMillis();
|
||||
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
|
||||
+ cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant())
|
||||
@@ -304,7 +301,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).getTargetInfo()
|
||||
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(7);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
|
||||
|
||||
// cancelaction closed -> should remove the action from active
|
||||
current = System.currentTimeMillis();
|
||||
@@ -316,7 +313,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).getTargetInfo()
|
||||
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(8);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(0);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -338,15 +335,13 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(3);
|
||||
|
||||
// 3 update actions, 0 cancel actions
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(3);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(3);
|
||||
final Action cancelAction = deploymentManagement.cancelAction(updateAction,
|
||||
targetManagement.findTargetByControllerID(savedTarget.getControllerId()));
|
||||
final Action cancelAction2 = deploymentManagement.cancelAction(updateAction2,
|
||||
targetManagement.findTargetByControllerID(savedTarget.getControllerId()));
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(3);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(3);
|
||||
final Action cancelAction = deploymentManagement.cancelAction(updateAction.getId());
|
||||
final Action cancelAction2 = deploymentManagement.cancelAction(updateAction2.getId());
|
||||
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(3);
|
||||
assertThat(deploymentManagement.findActionsByTarget(savedTarget)).hasSize(3);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(3);
|
||||
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
|
||||
mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
|
||||
+ cancelAction.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -372,8 +367,8 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(7);
|
||||
|
||||
// 1 update actions, 1 cancel actions
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(2);
|
||||
assertThat(deploymentManagement.findActionsByTarget(savedTarget)).hasSize(3);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(2);
|
||||
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
|
||||
mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
|
||||
+ cancelAction2.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -406,15 +401,13 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(10);
|
||||
|
||||
// 1 update actions, 0 cancel actions
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
|
||||
|
||||
final Action cancelAction3 = deploymentManagement.cancelAction(
|
||||
deploymentManagement.findAction(updateAction3.getId()),
|
||||
targetManagement.findTargetByControllerID(savedTarget.getControllerId()));
|
||||
final Action cancelAction3 = deploymentManagement.cancelAction(updateAction3.getId());
|
||||
|
||||
// action is in cancelling state
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActionsByTarget(savedTarget)).hasSize(3);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
|
||||
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID)
|
||||
.getAssignedDistributionSet()).isEqualTo(ds3);
|
||||
|
||||
@@ -435,8 +428,8 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(13);
|
||||
|
||||
// final status
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(0);
|
||||
assertThat(deploymentManagement.findActionsByTarget(savedTarget)).hasSize(3);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(0);
|
||||
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -448,8 +441,7 @@ public class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
|
||||
final Action action = deploymentManagement.findActionWithDetails(
|
||||
assignDistributionSet(ds.getId(), TestdataFactory.DEFAULT_CONTROLLER_ID).getActions().get(0));
|
||||
|
||||
final Action cancelAction = deploymentManagement.cancelAction(action,
|
||||
targetManagement.findTargetByControllerID(target.getControllerId()));
|
||||
final Action cancelAction = deploymentManagement.cancelAction(action.getId());
|
||||
|
||||
final String feedback = JsonBuilder.cancelActionFeedback(cancelAction.getId().toString(), "proceeding");
|
||||
// assignDistributionSet creates an ActionStatus and cancel action
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.apache.commons.lang3.RandomUtils;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
@@ -118,24 +119,24 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
final Target savedTarget = testdataFactory.createTarget("4712");
|
||||
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).isEmpty();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).isEmpty();
|
||||
assertThat(deploymentManagement.countActionsAll()).isEqualTo(0);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(0);
|
||||
|
||||
List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.FORCED,
|
||||
RepositoryModelConstants.NO_FORCE_TIME, Lists.newArrayList(savedTarget.getControllerId()))
|
||||
.getAssignedEntity();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
|
||||
|
||||
final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
|
||||
final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId()).get(0);
|
||||
assertThat(deploymentManagement.countActionsAll()).isEqualTo(1);
|
||||
saved = assignDistributionSet(ds2, saved).getAssignedEntity();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(2);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(2);
|
||||
assertThat(deploymentManagement.countActionsAll()).isEqualTo(2);
|
||||
|
||||
final Action uaction = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
|
||||
final Action uaction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId()).get(0);
|
||||
assertThat(uaction.getDistributionSet()).isEqualTo(ds);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(2);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(2);
|
||||
|
||||
// Run test
|
||||
long current = System.currentTimeMillis();
|
||||
@@ -154,7 +155,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
current = System.currentTimeMillis();
|
||||
|
||||
final DistributionSet findDistributionSetByAction = distributionSetManagement
|
||||
.findDistributionSetByAction(action);
|
||||
.findDistributionSetByAction(action.getId());
|
||||
|
||||
mvc.perform(
|
||||
get("/{tenant}/controller/v1/4712/deploymentBase/" + uaction.getId(), tenantAware.getCurrentTenant())
|
||||
@@ -221,7 +222,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
// Retrieved is reported
|
||||
final Iterable<ActionStatus> actionStatusMessages = deploymentManagement
|
||||
.findActionStatusByAction(new PageRequest(0, 100, Direction.DESC, "id"), uaction);
|
||||
.findActionStatusByAction(new PageRequest(0, 100, Direction.DESC, "id"), uaction.getId());
|
||||
assertThat(actionStatusMessages).hasSize(2);
|
||||
final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
|
||||
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
|
||||
@@ -238,7 +239,8 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
ActionType.TIMEFORCED, System.currentTimeMillis() + 1_000,
|
||||
Lists.newArrayList(target.getControllerId()));
|
||||
|
||||
final Action action = deploymentManagement.findActiveActionsByTarget(result.getAssignedEntity().get(0)).get(0);
|
||||
final Action action = deploymentManagement
|
||||
.findActiveActionsByTarget(result.getAssignedEntity().get(0).getControllerId()).get(0);
|
||||
|
||||
MvcResult mvcResult = mvc.perform(get("/{tenant}/controller/v1/4712", tenantAware.getCurrentTenant()))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -282,24 +284,24 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
final Target savedTarget = testdataFactory.createTarget("4712");
|
||||
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).isEmpty();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).isEmpty();
|
||||
assertThat(deploymentManagement.countActionsAll()).isEqualTo(0);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(0);
|
||||
|
||||
List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.SOFT,
|
||||
RepositoryModelConstants.NO_FORCE_TIME, Lists.newArrayList(savedTarget.getControllerId()))
|
||||
.getAssignedEntity();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
|
||||
|
||||
final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
|
||||
final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId()).get(0);
|
||||
assertThat(deploymentManagement.countActionsAll()).isEqualTo(1);
|
||||
saved = assignDistributionSet(ds2, saved).getAssignedEntity();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(2);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(2);
|
||||
assertThat(deploymentManagement.countActionsAll()).isEqualTo(2);
|
||||
|
||||
final Action uaction = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
|
||||
final Action uaction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId()).get(0);
|
||||
assertThat(uaction.getDistributionSet()).isEqualTo(ds);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(2);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(2);
|
||||
|
||||
// Run test
|
||||
|
||||
@@ -319,7 +321,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
current = System.currentTimeMillis();
|
||||
|
||||
final DistributionSet findDistributionSetByAction = distributionSetManagement
|
||||
.findDistributionSetByAction(action);
|
||||
.findDistributionSetByAction(action.getId());
|
||||
|
||||
mvc.perform(
|
||||
get("/{tenant}/controller/v1/4712/deploymentBase/" + uaction.getId(), tenantAware.getCurrentTenant())
|
||||
@@ -378,7 +380,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
// Retrieved is reported
|
||||
final List<ActionStatus> actionStatusMessages = deploymentManagement
|
||||
.findActionStatusByAction(new PageRequest(0, 100, Direction.DESC, "id"), uaction).getContent();
|
||||
.findActionStatusByAction(new PageRequest(0, 100, Direction.DESC, "id"), uaction.getId()).getContent();
|
||||
assertThat(actionStatusMessages).hasSize(2);
|
||||
final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
|
||||
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
|
||||
@@ -399,23 +401,23 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
final Target savedTarget = testdataFactory.createTarget("4712");
|
||||
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).isEmpty();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).isEmpty();
|
||||
assertThat(deploymentManagement.countActionsAll()).isEqualTo(0);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(0);
|
||||
|
||||
List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.TIMEFORCED,
|
||||
System.currentTimeMillis(), Lists.newArrayList(savedTarget.getControllerId())).getAssignedEntity();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
|
||||
|
||||
final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
|
||||
final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId()).get(0);
|
||||
assertThat(deploymentManagement.countActionsAll()).isEqualTo(1);
|
||||
saved = assignDistributionSet(ds2, saved).getAssignedEntity();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(2);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(2);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(2);
|
||||
|
||||
final Action uaction = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
|
||||
final Action uaction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId()).get(0);
|
||||
assertThat(uaction.getDistributionSet()).isEqualTo(ds);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget)).hasSize(2);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(2);
|
||||
|
||||
// Run test
|
||||
|
||||
@@ -435,7 +437,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
current = System.currentTimeMillis();
|
||||
|
||||
final DistributionSet findDistributionSetByAction = distributionSetManagement
|
||||
.findDistributionSetByAction(action);
|
||||
.findDistributionSetByAction(action.getId());
|
||||
|
||||
mvc.perform(get("/{tenant}/controller/v1/4712/deploymentBase/{actionId}", tenantAware.getCurrentTenant(),
|
||||
uaction.getId()).accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
@@ -501,7 +503,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
// Retrieved is reported
|
||||
final Iterable<ActionStatus> actionStatusMessages = deploymentManagement
|
||||
.findActionStatusByAction(new PageRequest(0, 100, Direction.DESC, "id"), uaction).getContent();
|
||||
.findActionStatusByAction(new PageRequest(0, 100, Direction.DESC, "id"), uaction.getId()).getContent();
|
||||
assertThat(actionStatusMessages).hasSize(2);
|
||||
final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
|
||||
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
|
||||
@@ -554,7 +556,8 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
||||
|
||||
assignDistributionSet(ds.getId(), "4712");
|
||||
final Action action = deploymentManagement.findActionsByTarget(target).get(0);
|
||||
final Action action = deploymentManagement.findActionsByTarget(target.getControllerId(), pageReq).getContent()
|
||||
.get(0);
|
||||
|
||||
final String feedback = JsonBuilder.deploymentActionFeedback(action.getId().toString(), "proceeding");
|
||||
// assign distribution set creates an action status, so only 99 left
|
||||
@@ -594,7 +597,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
Target myT = targetManagement.findTargetByControllerID("4712");
|
||||
assertThat(myT.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(3);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT.getControllerId())).hasSize(3);
|
||||
assertThat(myT.getAssignedDistributionSet()).isEqualTo(ds3);
|
||||
assertThat(myT.getTargetInfo().getInstalledDistributionSet()).isNull();
|
||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.UNKNOWN))
|
||||
@@ -612,7 +615,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(myT.getTargetInfo().getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
|
||||
assertThat(myT.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
||||
assertThat(myT.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(2);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT.getControllerId())).hasSize(2);
|
||||
assertThat(myT.getTargetInfo().getInstalledDistributionSet().getId()).isEqualTo(ds1.getId());
|
||||
assertThat(myT.getAssignedDistributionSet()).isEqualTo(ds3);
|
||||
|
||||
@@ -633,7 +636,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(myT.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
||||
|
||||
assertThat(myT.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT.getControllerId())).hasSize(1);
|
||||
assertThat(myT.getTargetInfo().getInstalledDistributionSet().getId()).isEqualTo(ds2.getId());
|
||||
assertThat(myT.getAssignedDistributionSet()).isEqualTo(ds3);
|
||||
actionStatusMessages = deploymentManagement.findActionStatusAll(new PageRequest(0, 100, Direction.DESC, "id"))
|
||||
@@ -652,7 +655,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(myT.getTargetInfo().getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
|
||||
assertThat(myT.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
||||
assertThat(myT.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(0);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT.getControllerId())).hasSize(0);
|
||||
assertThat(myT.getTargetInfo().getInstalledDistributionSet()).isEqualTo(ds3);
|
||||
assertThat(myT.getAssignedDistributionSet()).isEqualTo(ds3);
|
||||
actionStatusMessages = deploymentManagement.findActionStatusAll(new PageRequest(0, 100, Direction.DESC, "id"))
|
||||
@@ -674,7 +677,8 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||
assignDistributionSet(ds, toAssign);
|
||||
final Action action = deploymentManagement.findActionsByDistributionSet(pageReq, ds).getContent().get(0);
|
||||
final Action action = deploymentManagement.findActionsByDistributionSet(pageReq, ds.getId()).getContent()
|
||||
.get(0);
|
||||
|
||||
long current = System.currentTimeMillis();
|
||||
mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action.getId() + "/feedback",
|
||||
@@ -694,8 +698,8 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
.hasSize(1);
|
||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC))
|
||||
.hasSize(0);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(0);
|
||||
assertThat(deploymentManagement.findActionsByTarget(myT)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT.getControllerId())).hasSize(0);
|
||||
assertThat(deploymentManagement.countActionsByTarget(myT.getControllerId())).isEqualTo(1);
|
||||
final Iterable<ActionStatus> actionStatusMessages = deploymentManagement
|
||||
.findActionStatusAll(new PageRequest(0, 100, Direction.DESC, "id")).getContent();
|
||||
assertThat(actionStatusMessages).hasSize(2);
|
||||
@@ -706,7 +710,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
toAssign.add(targetManagement.findTargetByControllerID("4712"));
|
||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId());
|
||||
assignDistributionSet(ds, toAssign);
|
||||
final Action action2 = deploymentManagement.findActiveActionsByTarget(myT).get(0);
|
||||
final Action action2 = deploymentManagement.findActiveActionsByTarget(myT.getControllerId()).get(0);
|
||||
current = System.currentTimeMillis();
|
||||
|
||||
mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action2.getId() + "/feedback",
|
||||
@@ -725,12 +729,12 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
.hasSize(0);
|
||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC))
|
||||
.hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(0);
|
||||
assertThat(deploymentManagement.findInActiveActionsByTarget(myT)).hasSize(2);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT.getControllerId())).hasSize(0);
|
||||
assertThat(deploymentManagement.findInActiveActionsByTarget(myT.getControllerId())).hasSize(2);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(4);
|
||||
assertThat(deploymentManagement.findActionStatusByAction(pageReq, action).getContent()).haveAtLeast(1,
|
||||
assertThat(deploymentManagement.findActionStatusByAction(pageReq, action.getId()).getContent()).haveAtLeast(1,
|
||||
new ActionStatusCondition(Status.ERROR));
|
||||
assertThat(deploymentManagement.findActionStatusByAction(pageReq, action2).getContent()).haveAtLeast(1,
|
||||
assertThat(deploymentManagement.findActionStatusByAction(pageReq, action2.getId()).getContent()).haveAtLeast(1,
|
||||
new ActionStatusCondition(Status.FINISHED));
|
||||
|
||||
}
|
||||
@@ -747,7 +751,8 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
Target myT = targetManagement.findTargetByControllerID("4712");
|
||||
assertThat(myT.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||
assignDistributionSet(ds, toAssign);
|
||||
final Action action = deploymentManagement.findActionsByDistributionSet(pageReq, ds).getContent().get(0);
|
||||
final Action action = deploymentManagement.findActionsByDistributionSet(pageReq, ds.getId()).getContent()
|
||||
.get(0);
|
||||
|
||||
myT = targetManagement.findTargetByControllerID("4712");
|
||||
assertThat(myT.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||
@@ -775,7 +780,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
.hasSize(0);
|
||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC))
|
||||
.hasSize(0);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT.getControllerId())).hasSize(1);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(5);
|
||||
assertThat(deploymentManagement.findActionStatusAll(pageReq).getContent()).haveAtLeast(5,
|
||||
new ActionStatusCondition(Status.RUNNING));
|
||||
@@ -795,7 +800,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
.hasSize(0);
|
||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC))
|
||||
.hasSize(0);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT.getControllerId())).hasSize(1);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(6);
|
||||
assertThat(deploymentManagement.findActionStatusAll(pageReq).getContent()).haveAtLeast(5,
|
||||
new ActionStatusCondition(Status.RUNNING));
|
||||
@@ -815,7 +820,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
.hasSize(0);
|
||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC))
|
||||
.hasSize(0);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT.getControllerId())).hasSize(1);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(7);
|
||||
assertThat(deploymentManagement.findActionStatusAll(pageReq).getContent()).haveAtLeast(6,
|
||||
new ActionStatusCondition(Status.RUNNING));
|
||||
@@ -829,7 +834,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
myT = targetManagement.findTargetByControllerID("4712");
|
||||
assertThat(myT.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
||||
assertThat(myT.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT.getControllerId())).hasSize(1);
|
||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.PENDING))
|
||||
.hasSize(1);
|
||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR))
|
||||
@@ -852,7 +857,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
myT = targetManagement.findTargetByControllerID("4712");
|
||||
assertThat(myT.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
||||
assertThat(myT.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT.getControllerId())).hasSize(1);
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(9);
|
||||
assertThat(deploymentManagement.findActionStatusAll(pageReq).getContent()).haveAtLeast(6,
|
||||
new ActionStatusCondition(Status.RUNNING));
|
||||
@@ -870,7 +875,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
myT = targetManagement.findTargetByControllerID("4712");
|
||||
assertThat(myT.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
|
||||
assertThat(myT.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(0);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT.getControllerId())).hasSize(0);
|
||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.ERROR))
|
||||
.hasSize(0);
|
||||
assertThat(targetManagement.findTargetByUpdateStatus(new PageRequest(0, 10), TargetUpdateStatus.IN_SYNC))
|
||||
@@ -917,7 +922,8 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
savedTarget = assignDistributionSet(savedSet, toAssign).getAssignedEntity().iterator().next();
|
||||
assignDistributionSet(savedSet2, toAssign2);
|
||||
|
||||
final Action updateAction = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
|
||||
final Action updateAction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())
|
||||
.get(0);
|
||||
|
||||
// action exists but is not assigned to this target
|
||||
mvc.perform(post("/{tenant}/controller/v1/4713/deploymentBase/" + updateAction.getId() + "/feedback",
|
||||
@@ -942,6 +948,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
@Description("Ensures that an invalid id in feedback body returns a bad request.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1) })
|
||||
public void invalidIdInFeedbackReturnsBadRequest() throws Exception {
|
||||
@@ -949,7 +956,8 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
||||
|
||||
assignDistributionSet(ds.getId(), "1080");
|
||||
final Action action = deploymentManagement.findActionsByTarget(target).get(0);
|
||||
final Action action = deploymentManagement.findActionsByTarget(target.getControllerId(), pageReq).getContent()
|
||||
.get(0);
|
||||
|
||||
mvc.perform(post("/{tenant}/controller/v1/1080/deploymentBase/" + action.getId() + "/feedback",
|
||||
tenantAware.getCurrentTenant()).content(JsonBuilder.deploymentActionInProgressFeedback("AAAA"))
|
||||
@@ -961,6 +969,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
@Description("Ensures that a missing feedback result in feedback body returns a bad request.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1) })
|
||||
public void missingResultAttributeInFeedbackReturnsBadRequest() throws Exception {
|
||||
@@ -969,7 +978,8 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
||||
|
||||
assignDistributionSet(ds.getId(), "1080");
|
||||
final Action action = deploymentManagement.findActionsByTarget(target).get(0);
|
||||
final Action action = deploymentManagement.findActionsByTarget(target.getControllerId(), pageReq).getContent()
|
||||
.get(0);
|
||||
final String missingResultInFeedback = JsonBuilder.missingResultInFeedback(action.getId().toString(), "closed",
|
||||
"test");
|
||||
mvc.perform(post("/{tenant}/controller/v1/1080/deploymentBase/" + action.getId() + "/feedback",
|
||||
@@ -983,6 +993,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
@Description("Ensures that a missing finished result in feedback body returns a bad request.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
|
||||
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1) })
|
||||
public void missingFinishedAttributeInFeedbackReturnsBadRequest() throws Exception {
|
||||
@@ -991,7 +1002,8 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
||||
assignDistributionSet(ds.getId(), "1080");
|
||||
|
||||
final Action action = deploymentManagement.findActionsByTarget(target).get(0);
|
||||
final Action action = deploymentManagement.findActionsByTarget(target.getControllerId(), pageReq).getContent()
|
||||
.get(0);
|
||||
final String missingFinishedResultInFeedback = JsonBuilder
|
||||
.missingFinishedResultInFeedback(action.getId().toString(), "closed", "test");
|
||||
mvc.perform(post("/{tenant}/controller/v1/1080/deploymentBase/" + action.getId() + "/feedback",
|
||||
@@ -1003,9 +1015,6 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
private class ActionStatusCondition extends Condition<ActionStatus> {
|
||||
private final Status status;
|
||||
|
||||
/**
|
||||
* @param status
|
||||
*/
|
||||
public ActionStatusCondition(final Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
assignDistributionSet(ds.getId(), "4711");
|
||||
|
||||
final Action updateAction = deploymentManagement.findActiveActionsByTarget(target).get(0);
|
||||
final Action updateAction = deploymentManagement.findActiveActionsByTarget(target.getControllerId()).get(0);
|
||||
final String etagWithFirstUpdate = mvc
|
||||
.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())
|
||||
.header("If-None-Match", etag).accept(MediaType.APPLICATION_JSON))
|
||||
@@ -232,7 +232,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
assignDistributionSet(ds2.getId(), "4711");
|
||||
|
||||
final Action updateAction2 = deploymentManagement.findActiveActionsByTarget(target).get(0);
|
||||
final Action updateAction2 = deploymentManagement.findActiveActionsByTarget(target.getControllerId()).get(0);
|
||||
|
||||
mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())
|
||||
.header("If-None-Match", etagWithFirstUpdate).accept(MediaType.APPLICATION_JSON))
|
||||
@@ -319,7 +319,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
||||
Target savedTarget = testdataFactory.createTarget("911");
|
||||
savedTarget = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getAssignedEntity().iterator()
|
||||
.next();
|
||||
final Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
|
||||
final Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId()).get(0);
|
||||
mvc.perform(post("/{tenant}/controller/v1/911/deploymentBase/" + savedAction.getId() + "/feedback",
|
||||
tenantAware.getCurrentTenant())
|
||||
.content(JsonBuilder.deploymentActionFeedback(savedAction.getId().toString(), "proceeding"))
|
||||
|
||||
@@ -150,9 +150,9 @@ public class DosFilterTest extends AbstractDDiApiIntegrationTest {
|
||||
final List<Target> toAssign = Lists.newArrayList(target);
|
||||
|
||||
final Iterable<Target> saved = assignDistributionSet(ds, toAssign).getAssignedEntity();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(target)).hasSize(1);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(target.getControllerId())).hasSize(1);
|
||||
|
||||
final Action uaction = deploymentManagement.findActiveActionsByTarget(target).get(0);
|
||||
final Action uaction = deploymentManagement.findActiveActionsByTarget(target.getControllerId()).get(0);
|
||||
|
||||
return uaction.getId();
|
||||
}
|
||||
|
||||
@@ -116,46 +116,43 @@ public class AmqpAuthenticationMessageHandler extends BaseAmqpService {
|
||||
*
|
||||
* @param secruityToken
|
||||
* the security token which holds the target ID to check on
|
||||
* @param artifact
|
||||
* @param artifactId
|
||||
* the artifact to verify if the given target is allowed to
|
||||
* download it
|
||||
*/
|
||||
private void checkIfArtifactIsAssignedToTarget(final TenantSecurityToken secruityToken,
|
||||
final org.eclipse.hawkbit.repository.model.Artifact artifact) {
|
||||
private void checkIfArtifactIsAssignedToTarget(final TenantSecurityToken secruityToken, final Long artifactId) {
|
||||
|
||||
if (secruityToken.getControllerId() != null) {
|
||||
checkByControllerId(artifact, secruityToken.getControllerId());
|
||||
checkByControllerId(artifactId, secruityToken.getControllerId());
|
||||
} else if (secruityToken.getTargetId() != null) {
|
||||
checkByTargetId(artifact, secruityToken.getTargetId());
|
||||
checkByTargetId(artifactId, secruityToken.getTargetId());
|
||||
} else {
|
||||
LOG.info("anonymous download no authentication check for artifact {}", artifact);
|
||||
LOG.info("anonymous download no authentication check for artifact {}", artifactId);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void checkByTargetId(final org.eclipse.hawkbit.repository.model.Artifact localArtifact,
|
||||
final Long targetId) {
|
||||
private void checkByTargetId(final Long artifactId, final Long targetId) {
|
||||
LOG.debug("no anonymous download request, doing authentication check for target {} and artifact {}", targetId,
|
||||
localArtifact);
|
||||
if (!controllerManagement.hasTargetArtifactAssigned(targetId, localArtifact)) {
|
||||
artifactId);
|
||||
if (!controllerManagement.hasTargetArtifactAssigned(targetId, artifactId)) {
|
||||
LOG.info("target {} tried to download artifact {} which is not assigned to the target", targetId,
|
||||
localArtifact);
|
||||
artifactId);
|
||||
throw new EntityNotFoundException();
|
||||
}
|
||||
LOG.info("download security check for target {} and artifact {} granted", targetId, localArtifact);
|
||||
LOG.info("download security check for target {} and artifact {} granted", targetId, artifactId);
|
||||
}
|
||||
|
||||
private void checkByControllerId(final org.eclipse.hawkbit.repository.model.Artifact localArtifact,
|
||||
final String controllerId) {
|
||||
private void checkByControllerId(final Long artifactId, final String controllerId) {
|
||||
LOG.debug("no anonymous download request, doing authentication check for target {} and artifact {}",
|
||||
controllerId, localArtifact);
|
||||
if (!controllerManagement.hasTargetArtifactAssigned(controllerId, localArtifact)) {
|
||||
controllerId, artifactId);
|
||||
if (!controllerManagement.hasTargetArtifactAssigned(controllerId, artifactId)) {
|
||||
LOG.info("target {} tried to download artifact {} which is not assigned to the target", controllerId,
|
||||
localArtifact);
|
||||
artifactId);
|
||||
throw new EntityNotFoundException();
|
||||
}
|
||||
LOG.info("download security check for target {} and artifact {} granted", controllerId, localArtifact);
|
||||
LOG.info("download security check for target {} and artifact {} granted", controllerId, artifactId);
|
||||
}
|
||||
|
||||
private org.eclipse.hawkbit.repository.model.Artifact findArtifactByFileResource(final FileResource fileResource) {
|
||||
@@ -201,9 +198,9 @@ public class AmqpAuthenticationMessageHandler extends BaseAmqpService {
|
||||
throw new EntityNotFoundException();
|
||||
}
|
||||
|
||||
checkIfArtifactIsAssignedToTarget(secruityToken, localArtifact);
|
||||
checkIfArtifactIsAssignedToTarget(secruityToken, localArtifact.getId());
|
||||
|
||||
final Artifact artifact = convertDbArtifact(artifactManagement.loadArtifactBinary(localArtifact));
|
||||
final Artifact artifact = convertDbArtifact(artifactManagement.loadArtifactBinary(localArtifact.getId()));
|
||||
if (artifact == null) {
|
||||
throw new EntityNotFoundException();
|
||||
}
|
||||
|
||||
@@ -180,7 +180,8 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
||||
}
|
||||
|
||||
private void lookIfUpdateAvailable(final Target target) {
|
||||
final Optional<Action> actionOptional = controllerManagement.findOldestActiveActionByTarget(target);
|
||||
final Optional<Action> actionOptional = controllerManagement
|
||||
.findOldestActiveActionByTarget(target.getControllerId());
|
||||
if (!actionOptional.isPresent()) {
|
||||
return;
|
||||
}
|
||||
@@ -286,7 +287,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
||||
}
|
||||
|
||||
private void updateLastPollTime(final Target target) {
|
||||
controllerManagement.updateTargetStatus(target.getTargetInfo(), null, System.currentTimeMillis(), null);
|
||||
controllerManagement.updateLastTargetQuery(target.getControllerId(), null);
|
||||
}
|
||||
|
||||
private static String convertCorrelationId(final Message message) {
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.eclipse.hawkbit.repository.jpa.JpaEntityFactory;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaArtifact;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
|
||||
import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
||||
@@ -153,8 +152,9 @@ public class AmqpControllerAuthenticationTest {
|
||||
|
||||
authenticationManager.postConstruct();
|
||||
|
||||
final Artifact testArtifact = new JpaArtifact("afilename", "afilename", new JpaSoftwareModule(
|
||||
final JpaArtifact testArtifact = new JpaArtifact("afilename", "afilename", new JpaSoftwareModule(
|
||||
new JpaSoftwareModuleType("a key", "a name", null, 1), "a name", null, null, null));
|
||||
testArtifact.setId(1L);
|
||||
|
||||
when(artifactManagementMock.findArtifact(ARTIFACT_ID)).thenReturn(testArtifact);
|
||||
when(artifactManagementMock.findFirstArtifactBySHA1(SHA1)).thenReturn(testArtifact);
|
||||
@@ -162,7 +162,7 @@ public class AmqpControllerAuthenticationTest {
|
||||
final DbArtifact artifact = new DbArtifact();
|
||||
artifact.setSize(ARTIFACT_SIZE);
|
||||
artifact.setHashes(new DbArtifactHash("sha1 test", "md5 test"));
|
||||
when(artifactManagementMock.loadArtifactBinary(testArtifact)).thenReturn(artifact);
|
||||
when(artifactManagementMock.loadArtifactBinary(1L)).thenReturn(artifact);
|
||||
|
||||
amqpMessageHandlerService = new AmqpMessageHandlerService(rabbitTemplate,
|
||||
mock(AmqpMessageDispatcherService.class), controllerManagementMock, new JpaEntityFactory());
|
||||
@@ -173,8 +173,8 @@ public class AmqpControllerAuthenticationTest {
|
||||
|
||||
when(hostnameResolverMock.resolveHostname()).thenReturn(new URL("http://localhost"));
|
||||
|
||||
when(controllerManagementMock.hasTargetArtifactAssigned(TARGET_ID, testArtifact)).thenReturn(true);
|
||||
when(controllerManagementMock.hasTargetArtifactAssigned(CONTROLLER_ID, testArtifact)).thenReturn(true);
|
||||
when(controllerManagementMock.hasTargetArtifactAssigned(TARGET_ID, 1L)).thenReturn(true);
|
||||
when(controllerManagementMock.hasTargetArtifactAssigned(CONTROLLER_ID, 1L)).thenReturn(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.amqp;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -49,9 +50,7 @@ import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -149,10 +148,12 @@ public class AmqpMessageHandlerServiceTest {
|
||||
messageProperties.setHeader(MessageHeaderKey.THING_ID, "1");
|
||||
final Message message = messageConverter.toMessage(new byte[0], messageProperties);
|
||||
|
||||
final Target targetMock = mock(Target.class);
|
||||
|
||||
final ArgumentCaptor<String> targetIdCaptor = ArgumentCaptor.forClass(String.class);
|
||||
final ArgumentCaptor<URI> uriCaptor = ArgumentCaptor.forClass(URI.class);
|
||||
when(controllerManagementMock.findOrRegisterTargetIfItDoesNotexist(targetIdCaptor.capture(),
|
||||
uriCaptor.capture())).thenReturn(null);
|
||||
uriCaptor.capture())).thenReturn(targetMock);
|
||||
when(controllerManagementMock.findOldestActiveActionByTarget(Matchers.any())).thenReturn(Optional.empty());
|
||||
|
||||
amqpMessageHandlerService.onMessage(message, MessageType.THING_CREATED.name(), TENANT, "vHost");
|
||||
@@ -326,11 +327,14 @@ public class AmqpMessageHandlerServiceTest {
|
||||
|
||||
// mock
|
||||
final Artifact localArtifactMock = mock(Artifact.class);
|
||||
final Long mockedArtifactId = 1L;
|
||||
when(localArtifactMock.getId()).thenReturn(mockedArtifactId);
|
||||
|
||||
final DbArtifact dbArtifactMock = mock(DbArtifact.class);
|
||||
when(artifactManagementMock.findFirstArtifactBySHA1(anyString())).thenReturn(localArtifactMock);
|
||||
when(controllerManagementMock.hasTargetArtifactAssigned(securityToken.getControllerId(), localArtifactMock))
|
||||
when(controllerManagementMock.hasTargetArtifactAssigned(securityToken.getControllerId(), mockedArtifactId))
|
||||
.thenReturn(true);
|
||||
when(artifactManagementMock.loadArtifactBinary(localArtifactMock)).thenReturn(dbArtifactMock);
|
||||
when(artifactManagementMock.loadArtifactBinary(anyLong())).thenReturn(dbArtifactMock);
|
||||
when(dbArtifactMock.getArtifactId()).thenReturn("artifactId");
|
||||
when(dbArtifactMock.getSize()).thenReturn(1L);
|
||||
when(dbArtifactMock.getHashes()).thenReturn(new DbArtifactHash("sha1", "md5"));
|
||||
@@ -377,8 +381,7 @@ public class AmqpMessageHandlerServiceTest {
|
||||
amqpMessageHandlerService.onMessage(message, MessageType.EVENT.name(), TENANT, "vHost");
|
||||
|
||||
// verify
|
||||
verify(controllerManagementMock).updateTargetStatus(Matchers.any(TargetInfo.class),
|
||||
Matchers.isNull(TargetUpdateStatus.class), Matchers.isNotNull(Long.class), Matchers.isNull(URI.class));
|
||||
verify(controllerManagementMock).updateLastTargetQuery(Matchers.any(String.class), Matchers.isNull(URI.class));
|
||||
|
||||
final ArgumentCaptor<String> tenantCaptor = ArgumentCaptor.forClass(String.class);
|
||||
final ArgumentCaptor<Target> targetCaptor = ArgumentCaptor.forClass(Target.class);
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
# HawkBit Software Provisioning device management federation API
|
||||
# hawkBit device management federation API - model definition
|
||||
|
||||
This API is used for communicating with the HawkBit Software Provisioning server through AMQP.
|
||||
It is used to integrate other device management system through a high performance protocol.
|
||||
This API is used for communicating with the hawkBit Update Server through AMQP.
|
||||
It is used to integrate other device management system through a high throughput protocol optimized for service to service communication.
|
||||
|
||||
# Version 1
|
||||
|
||||
The model follows [semantic versioning](http://semver.org) with MAJOR version, i.e. breaking changes will result in a new MAJOR version.
|
||||
@@ -1,7 +1,10 @@
|
||||
# Eclipse.IoT hawkBit - Mgmt API
|
||||
# Eclipse.IoT hawkBit - Management API - Model and Resources
|
||||
|
||||
This Management (Mgmt) API is used to manage and monitor the HawkBit Update Server via HTTP. This API allows Create/Read/Update/Delete operations for provisioning targets (i.e. devices) and repository content (i.e. software).
|
||||
|
||||
# Version 1
|
||||
|
||||
The model follows [semantic versioning](http://semver.org) with MAJOR version, i.e. breaking changes will result in a new MAJOR version.
|
||||
|
||||
# Compile
|
||||
|
||||
|
||||
@@ -137,10 +137,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> deleteDistributionSet(@PathVariable("distributionSetId") final Long distributionSetId) {
|
||||
final DistributionSet set = findDistributionSetWithExceptionIfNotFound(distributionSetId);
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(set);
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(distributionSetId);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -222,21 +219,13 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam,
|
||||
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
|
||||
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) {
|
||||
final DistributionSet distributionSet = findDistributionSetWithExceptionIfNotFound(distributionSetId);
|
||||
|
||||
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
|
||||
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
|
||||
final Sort sorting = PagingUtility.sanitizeTargetFilterQuerySortParam(sortParam);
|
||||
|
||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||
final Page<TargetFilterQuery> targetFilterQueries;
|
||||
if (rsqlParam != null) {
|
||||
targetFilterQueries = targetFilterQueryManagement.findTargetFilterQueryByAutoAssignDS(pageable,
|
||||
distributionSet, rsqlParam);
|
||||
} else {
|
||||
targetFilterQueries = targetFilterQueryManagement.findTargetFilterQueryByAutoAssignDS(pageable,
|
||||
distributionSet);
|
||||
}
|
||||
final Page<TargetFilterQuery> targetFilterQueries = targetFilterQueryManagement
|
||||
.findTargetFilterQueryByAutoAssignDS(pageable, distributionSetId, rsqlParam);
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new PagedList<>(MgmtTargetFilterQueryMapper.toResponse(targetFilterQueries.getContent()),
|
||||
@@ -340,7 +329,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
@RequestBody final List<MgmtSoftwareModuleAssigment> softwareModuleIDs) {
|
||||
|
||||
distributionSetManagement.assignSoftwareModules(distributionSetId,
|
||||
softwareModuleIDs.stream().map(module -> module.getId()).collect(Collectors.toList()));
|
||||
softwareModuleIDs.stream().map(MgmtSoftwareModuleAssigment::getId).collect(Collectors.toList()));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -360,13 +349,13 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam) {
|
||||
// check if distribution set exists otherwise throw exception
|
||||
// immediately
|
||||
final DistributionSet foundDs = findDistributionSetWithExceptionIfNotFound(distributionSetId);
|
||||
findDistributionSetWithExceptionIfNotFound(distributionSetId);
|
||||
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
|
||||
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
|
||||
final Sort sorting = PagingUtility.sanitizeSoftwareModuleSortParam(sortParam);
|
||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||
final Page<SoftwareModule> softwaremodules = softwareManagement.findSoftwareModuleByAssignedTo(pageable,
|
||||
foundDs);
|
||||
distributionSetId);
|
||||
return new ResponseEntity<>(new PagedList<>(MgmtSoftwareModuleMapper.toResponse(softwaremodules.getContent()),
|
||||
softwaremodules.getTotalElements()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -167,10 +167,8 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
||||
@PathVariable("distributionsetTagId") final Long distributionsetTagId,
|
||||
@RequestBody final List<MgmtAssignedDistributionSetRequestBody> assignedDSRequestBodies) {
|
||||
LOG.debug("Assign DistributionSet {} for ds tag {}", assignedDSRequestBodies.size(), distributionsetTagId);
|
||||
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
|
||||
|
||||
final List<DistributionSet> assignedDs = this.distributionSetManagement
|
||||
.assignTag(findDistributionSetIds(assignedDSRequestBodies), tag);
|
||||
.assignTag(findDistributionSetIds(assignedDSRequestBodies), distributionsetTagId);
|
||||
LOG.debug("Assignd DistributionSet {}", assignedDs.size());
|
||||
return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDistributionSets(assignedDs), HttpStatus.OK);
|
||||
}
|
||||
@@ -179,14 +177,9 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
||||
public ResponseEntity<Void> unassignDistributionSets(
|
||||
@PathVariable("distributionsetTagId") final Long distributionsetTagId) {
|
||||
LOG.debug("Unassign all DS for ds tag {}", distributionsetTagId);
|
||||
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
|
||||
if (tag.getAssignedToDistributionSet() == null) {
|
||||
LOG.debug("No assigned ds founded");
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
final List<DistributionSet> distributionSets = this.distributionSetManagement
|
||||
.unAssignAllDistributionSetsByTag(tag);
|
||||
.unAssignAllDistributionSetsByTag(distributionsetTagId);
|
||||
LOG.debug("Unassigned ds {}", distributionSets.size());
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
@@ -196,8 +189,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
||||
@PathVariable("distributionsetTagId") final Long distributionsetTagId,
|
||||
@PathVariable("distributionsetId") final Long distributionsetId) {
|
||||
LOG.debug("Unassign ds {} for ds tag {}", distributionsetId, distributionsetTagId);
|
||||
final DistributionSetTag tag = findDistributionTagById(distributionsetTagId);
|
||||
this.distributionSetManagement.unAssignTag(distributionsetId, tag);
|
||||
this.distributionSetManagement.unAssignTag(distributionsetId, distributionsetTagId);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,8 +101,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
|
||||
public ResponseEntity<Void> deleteDistributionSetType(
|
||||
@PathVariable("distributionSetTypeId") final Long distributionSetTypeId) {
|
||||
|
||||
final DistributionSetType module = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId);
|
||||
distributionSetManagement.deleteDistributionSetType(module);
|
||||
distributionSetManagement.deleteDistributionSetType(distributionSetTypeId);
|
||||
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class MgmtDownloadArtifactResource implements MgmtDownloadArtifactRestApi
|
||||
}
|
||||
|
||||
final Artifact artifact = module.getArtifact(artifactId).get();
|
||||
final DbArtifact file = artifactManagement.loadArtifactBinary(artifact);
|
||||
final DbArtifact file = artifactManagement.loadArtifactBinary(artifact.getId());
|
||||
final HttpServletRequest request = requestResponseContextHolder.getHttpServletRequest();
|
||||
final String ifMatch = request.getHeader("If-Match");
|
||||
if (ifMatch != null && !RestResourceConversionHelper.matchesHttpHeader(ifMatch, artifact.getSha1Hash())) {
|
||||
|
||||
@@ -188,8 +188,6 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
||||
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
|
||||
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) {
|
||||
findRolloutOrThrowException(rolloutId);
|
||||
final RolloutGroup rolloutGroup = findRolloutGroupOrThrowException(groupId);
|
||||
|
||||
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
|
||||
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
|
||||
final Sort sorting = PagingUtility.sanitizeTargetSortParam(sortParam);
|
||||
@@ -198,11 +196,9 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
||||
|
||||
final Page<Target> rolloutGroupTargets;
|
||||
if (rsqlParam != null) {
|
||||
rolloutGroupTargets = this.rolloutGroupManagement.findRolloutGroupTargets(rolloutGroup, rsqlParam,
|
||||
pageable);
|
||||
rolloutGroupTargets = this.rolloutGroupManagement.findRolloutGroupTargets(groupId, rsqlParam, pageable);
|
||||
} else {
|
||||
final Page<Target> pageTargets = this.rolloutGroupManagement.findRolloutGroupTargets(rolloutGroup,
|
||||
pageable);
|
||||
final Page<Target> pageTargets = this.rolloutGroupManagement.findRolloutGroupTargets(groupId, pageable);
|
||||
rolloutGroupTargets = pageTargets;
|
||||
}
|
||||
final List<MgmtTarget> rest = MgmtTargetMapper.toResponse(rolloutGroupTargets.getContent());
|
||||
|
||||
@@ -87,10 +87,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
|
||||
@Override
|
||||
public ResponseEntity<Void> deleteSoftwareModuleType(
|
||||
@PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) {
|
||||
final SoftwareModuleType module = findSoftwareModuleTypeWithExceptionIfNotFound(softwareModuleTypeId);
|
||||
|
||||
softwareManagement.deleteSoftwareModuleType(module);
|
||||
|
||||
softwareManagement.deleteSoftwareModuleType(softwareModuleTypeId);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -130,8 +130,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> deleteTarget(@PathVariable("controllerId") final String controllerId) {
|
||||
final Target target = findTargetWithExceptionIfNotFound(controllerId);
|
||||
this.targetManagement.deleteTargets(target.getId());
|
||||
this.targetManagement.deleteTarget(controllerId);
|
||||
LOG.debug("{} target deleted, return status {}", controllerId, HttpStatus.OK);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
@@ -158,7 +157,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam,
|
||||
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) {
|
||||
|
||||
final Target foundTarget = findTargetWithExceptionIfNotFound(controllerId);
|
||||
findTargetWithExceptionIfNotFound(controllerId);
|
||||
|
||||
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
|
||||
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
|
||||
@@ -168,11 +167,11 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
final Slice<Action> activeActions;
|
||||
final Long totalActionCount;
|
||||
if (rsqlParam != null) {
|
||||
activeActions = this.deploymentManagement.findActionsByTarget(rsqlParam, foundTarget, pageable);
|
||||
totalActionCount = this.deploymentManagement.countActionsByTarget(rsqlParam, foundTarget);
|
||||
activeActions = this.deploymentManagement.findActionsByTarget(rsqlParam, controllerId, pageable);
|
||||
totalActionCount = this.deploymentManagement.countActionsByTarget(rsqlParam, controllerId);
|
||||
} else {
|
||||
activeActions = this.deploymentManagement.findActionsByTarget(foundTarget, pageable);
|
||||
totalActionCount = this.deploymentManagement.countActionsByTarget(foundTarget);
|
||||
activeActions = this.deploymentManagement.findActionsByTarget(controllerId, pageable);
|
||||
totalActionCount = this.deploymentManagement.countActionsByTarget(controllerId);
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(
|
||||
@@ -184,11 +183,10 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
@Override
|
||||
public ResponseEntity<MgmtAction> getAction(@PathVariable("controllerId") final String controllerId,
|
||||
@PathVariable("actionId") final Long actionId) {
|
||||
final Target target = findTargetWithExceptionIfNotFound(controllerId);
|
||||
|
||||
final Action action = findActionWithExceptionIfNotFound(actionId);
|
||||
if (!action.getTarget().getId().equals(target.getId())) {
|
||||
LOG.warn("given action ({}) is not assigned to given target ({}).", action.getId(), target.getId());
|
||||
if (!action.getTarget().getControllerId().equals(controllerId)) {
|
||||
LOG.warn("given action ({}) is not assigned to given target ({}).", action.getId(), controllerId);
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -215,13 +213,17 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
public ResponseEntity<Void> cancelAction(@PathVariable("controllerId") final String controllerId,
|
||||
@PathVariable("actionId") final Long actionId,
|
||||
@RequestParam(value = "force", required = false, defaultValue = "false") final boolean force) {
|
||||
final Target target = findTargetWithExceptionIfNotFound(controllerId);
|
||||
final Action action = findActionWithExceptionIfNotFound(actionId);
|
||||
|
||||
if (!action.getTarget().getControllerId().equals(controllerId)) {
|
||||
LOG.warn("given action ({}) is not assigned to given target ({}).", actionId, controllerId);
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
if (force) {
|
||||
this.deploymentManagement.forceQuitAction(action);
|
||||
this.deploymentManagement.forceQuitAction(actionId);
|
||||
} else {
|
||||
this.deploymentManagement.cancelAction(action, target);
|
||||
this.deploymentManagement.cancelAction(actionId);
|
||||
}
|
||||
// both functions will throw an exception, when action is in wrong
|
||||
// state, which is mapped by MgmtResponseExceptionHandler.
|
||||
@@ -249,7 +251,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
final Sort sorting = PagingUtility.sanitizeActionStatusSortParam(sortParam);
|
||||
|
||||
final Page<ActionStatus> statusList = this.deploymentManagement.findActionStatusByActionWithMessages(
|
||||
new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action);
|
||||
new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action.getId());
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new PagedList<>(MgmtTargetMapper.toActionStatusRestResponse(statusList.getContent()),
|
||||
|
||||
@@ -152,21 +152,16 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
||||
public ResponseEntity<List<MgmtTarget>> assignTargets(@PathVariable("targetTagId") final Long targetTagId,
|
||||
@RequestBody final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies) {
|
||||
LOG.debug("Assign Targets {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId);
|
||||
final TargetTag targetTag = findTargetTagById(targetTagId);
|
||||
final List<Target> assignedTarget = this.targetManagement
|
||||
.assignTag(findTargetControllerIds(assignedTargetRequestBodies), targetTag);
|
||||
.assignTag(findTargetControllerIds(assignedTargetRequestBodies), targetTagId);
|
||||
return new ResponseEntity<>(MgmtTargetMapper.toResponseWithLinksAndPollStatus(assignedTarget), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Void> unassignTargets(@PathVariable("targetTagId") final Long targetTagId) {
|
||||
LOG.debug("Unassign all Targets for target tag {}", targetTagId);
|
||||
final TargetTag targetTag = findTargetTagById(targetTagId);
|
||||
if (targetTag.getAssignedToTargets() == null) {
|
||||
LOG.debug("No assigned targets found");
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
this.targetManagement.unAssignAllTargetsByTag(targetTag);
|
||||
|
||||
this.targetManagement.unAssignAllTargetsByTag(targetTagId);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -174,8 +169,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
||||
public ResponseEntity<Void> unassignTarget(@PathVariable("targetTagId") final Long targetTagId,
|
||||
@PathVariable("controllerId") final String controllerId) {
|
||||
LOG.debug("Unassign target {} for target tag {}", controllerId, targetTagId);
|
||||
final TargetTag targetTag = findTargetTagById(targetTagId);
|
||||
this.targetManagement.unAssignTag(controllerId, targetTag);
|
||||
this.targetManagement.unAssignTag(controllerId, targetTagId);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -189,7 +183,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
||||
|
||||
private List<String> findTargetControllerIds(
|
||||
final List<MgmtAssignedTargetRequestBody> assignedTargetRequestBodies) {
|
||||
return assignedTargetRequestBodies.stream().map(request -> request.getControllerId())
|
||||
return assignedTargetRequestBodies.stream().map(MgmtAssignedTargetRequestBody::getControllerId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
||||
|
||||
// binary
|
||||
try (InputStream fileInputStream = artifactManagement
|
||||
.loadArtifactBinary(softwareManagement.findSoftwareModuleById(sm.getId()).getArtifacts().get(0))
|
||||
.loadArtifactBinary(softwareManagement.findSoftwareModuleById(sm.getId()).getArtifacts().get(0).getId())
|
||||
.getFileInputStream()) {
|
||||
assertTrue("Wrong artifact content",
|
||||
IOUtils.contentEquals(new ByteArrayInputStream(random), fileInputStream));
|
||||
@@ -689,9 +689,9 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
||||
.andExpect(jsonPath("[1].createdAt", not(equalTo(0)))).andReturn();
|
||||
|
||||
final SoftwareModule osCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name1", "version1",
|
||||
osType);
|
||||
osType.getId());
|
||||
final SoftwareModule appCreated = softwareManagement.findSoftwareModuleByNameAndVersion("name3", "version3",
|
||||
appType);
|
||||
appType.getId());
|
||||
|
||||
assertThat(
|
||||
JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString())
|
||||
|
||||
@@ -110,8 +110,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
entityFactory.actionStatus().create(actions.get(0).getId()).status(Status.FINISHED).message("test"));
|
||||
|
||||
final PageRequest pageRequest = new PageRequest(0, 1000, Direction.ASC, ActionFields.ID.getFieldName());
|
||||
final ActionStatus status = deploymentManagement
|
||||
.findActionsByTarget(pageRequest, targetManagement.findTargetByControllerID(knownTargetId)).getContent()
|
||||
final ActionStatus status = deploymentManagement.findActionsByTarget(knownTargetId, pageRequest).getContent()
|
||||
.get(0).getActionStatus().stream().sorted((e1, e2) -> Long.compare(e2.getId(), e1.getId()))
|
||||
.collect(Collectors.toList()).get(0);
|
||||
|
||||
@@ -247,10 +246,10 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
final Target tA = createTargetAndStartAction();
|
||||
|
||||
// cancel the active action
|
||||
deploymentManagement.cancelAction(tA.getActions().get(0), tA);
|
||||
deploymentManagement.cancelAction(tA.getActions().get(0).getId());
|
||||
|
||||
// find the current active action
|
||||
final List<Action> cancelActions = deploymentManagement.findActionsByTarget(new PageRequest(0, 100), tA)
|
||||
final List<Action> cancelActions = deploymentManagement.findActionsByTarget(tA.getControllerId(), pageReq)
|
||||
.getContent().stream().filter(action -> action.isCancelingOrCanceled()).collect(Collectors.toList());
|
||||
assertThat(cancelActions).hasSize(1);
|
||||
|
||||
@@ -267,11 +266,11 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
final Target tA = createTargetAndStartAction();
|
||||
|
||||
// cancel the active action
|
||||
deploymentManagement.cancelAction(tA.getActions().get(0), tA);
|
||||
deploymentManagement.cancelAction(tA.getActions().get(0).getId());
|
||||
|
||||
// find the current active action
|
||||
final List<Action> cancelActions = deploymentManagement.findActionsByTarget(pageReq, tA).getContent().stream()
|
||||
.filter(Action::isCancelingOrCanceled).collect(Collectors.toList());
|
||||
final List<Action> cancelActions = deploymentManagement.findActionsByTarget(tA.getControllerId(), pageReq)
|
||||
.getContent().stream().filter(Action::isCancelingOrCanceled).collect(Collectors.toList());
|
||||
assertThat(cancelActions).hasSize(1);
|
||||
assertThat(cancelActions.get(0).isCancelingOrCanceled()).isTrue();
|
||||
|
||||
@@ -1045,7 +1044,8 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
assignDistributionSet(two, updatedTargets);
|
||||
|
||||
// two updates, one cancellation
|
||||
final List<Action> actions = deploymentManagement.findActionsByTarget(target);
|
||||
final List<Action> actions = deploymentManagement.findActionsByTarget(target.getControllerId(), pageReq)
|
||||
.getContent();
|
||||
|
||||
assertThat(actions).hasSize(2);
|
||||
return actions;
|
||||
@@ -1096,7 +1096,8 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk());
|
||||
|
||||
final List<Action> findActiveActionsByTarget = deploymentManagement.findActiveActionsByTarget(target);
|
||||
final List<Action> findActiveActionsByTarget = deploymentManagement
|
||||
.findActiveActionsByTarget(target.getControllerId());
|
||||
assertThat(findActiveActionsByTarget).hasSize(1);
|
||||
assertThat(findActiveActionsByTarget.get(0).getActionType()).isEqualTo(ActionType.TIMEFORCED);
|
||||
assertThat(findActiveActionsByTarget.get(0).getForcedTime()).isEqualTo(forceTime);
|
||||
@@ -1276,7 +1277,7 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
|
||||
// assign a distribution set so we get an active update action
|
||||
assignDistributionSet(dsA, Lists.newArrayList(tA));
|
||||
// verify active action
|
||||
final Slice<Action> actionsByTarget = deploymentManagement.findActionsByTarget(new PageRequest(0, 100), tA);
|
||||
final Slice<Action> actionsByTarget = deploymentManagement.findActionsByTarget(tA.getControllerId(), pageReq);
|
||||
assertThat(actionsByTarget.getContent()).hasSize(1);
|
||||
return targetManagement.findTargetByControllerID(tA.getControllerId());
|
||||
}
|
||||
|
||||
@@ -104,13 +104,13 @@ public interface ArtifactManagement {
|
||||
* Garbage collects local artifact binary file if only referenced by given
|
||||
* {@link Artifact} metadata object.
|
||||
*
|
||||
* @param onlyByThisReferenced
|
||||
* @param artifactId
|
||||
* the related local artifact
|
||||
*
|
||||
* @return <code>true</code> if an binary was actually garbage collected
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
boolean clearArtifactBinary(@NotNull Artifact onlyByThisReferenced);
|
||||
boolean clearArtifactBinary(@NotNull Long artifactId);
|
||||
|
||||
/**
|
||||
* Deletes {@link Artifact} based on given id.
|
||||
@@ -186,15 +186,18 @@ public interface ArtifactManagement {
|
||||
/**
|
||||
* Loads {@link DbArtifact} from store for given {@link Artifact}.
|
||||
*
|
||||
* @param artifact
|
||||
* @param artifactId
|
||||
* to search for
|
||||
* @return loaded {@link DbArtifact}
|
||||
*
|
||||
* @throws GridFSDBFileNotFoundException
|
||||
* if file could not be found in store
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* is artifact with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DOWNLOAD_ARTIFACT + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.HAS_CONTROLLER_DOWNLOAD)
|
||||
DbArtifact loadArtifactBinary(@NotNull Artifact artifact);
|
||||
DbArtifact loadArtifactBinary(@NotNull Long artifactId);
|
||||
|
||||
}
|
||||
|
||||
@@ -24,10 +24,8 @@ import org.eclipse.hawkbit.repository.exception.TooManyStatusEntriesException;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
@@ -116,12 +114,15 @@ public interface ControllerManagement {
|
||||
* Retrieves oldest {@link Action} that is active and assigned to a
|
||||
* {@link Target}.
|
||||
*
|
||||
* @param target
|
||||
* the target to retrieve the actions from
|
||||
* @param controllerId
|
||||
* identifies the target to retrieve the actions from
|
||||
* @return a list of actions assigned to given target which are active
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Optional<Action> findOldestActiveActionByTarget(@NotNull Target target);
|
||||
Optional<Action> findOldestActiveActionByTarget(@NotNull String controllerId);
|
||||
|
||||
/**
|
||||
* Get the {@link Action} entity for given actionId with all lazy
|
||||
@@ -177,7 +178,7 @@ public interface ControllerManagement {
|
||||
*
|
||||
* @param controllerId
|
||||
* the ID of the target to check
|
||||
* @param localArtifact
|
||||
* @param artifactId
|
||||
* the artifact to verify if the given target had even been
|
||||
* assigned to
|
||||
* @return {@code true} if the given target has currently or had ever a
|
||||
@@ -185,7 +186,7 @@ public interface ControllerManagement {
|
||||
* otherwise {@code false}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
boolean hasTargetArtifactAssigned(@NotNull String controllerId, @NotNull Artifact localArtifact);
|
||||
boolean hasTargetArtifactAssigned(@NotNull String controllerId, @NotNull Long artifactId);
|
||||
|
||||
/**
|
||||
* Checks if a given target has currently or has even been assigned to the
|
||||
@@ -196,7 +197,7 @@ public interface ControllerManagement {
|
||||
*
|
||||
* @param targetId
|
||||
* the ID of the target to check
|
||||
* @param localArtifact
|
||||
* @param artifactId
|
||||
* the artifact to verify if the given target had even been
|
||||
* assigned to
|
||||
* @return {@code true} if the given target has currently or had ever a
|
||||
@@ -204,21 +205,24 @@ public interface ControllerManagement {
|
||||
* otherwise {@code false}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
boolean hasTargetArtifactAssigned(@NotNull Long targetId, @NotNull Artifact localArtifact);
|
||||
boolean hasTargetArtifactAssigned(@NotNull Long targetId, @NotNull Long artifactId);
|
||||
|
||||
/**
|
||||
* Registers retrieved status for given {@link Target} and {@link Action} if
|
||||
* it does not exist yet.
|
||||
*
|
||||
* @param action
|
||||
* @param actionId
|
||||
* to the handle status for
|
||||
* @param message
|
||||
* for the status
|
||||
* @return the update action in case the status has been changed to
|
||||
* {@link Status#RETRIEVED}
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if action with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Action registerRetrieved(@NotNull Action action, String message);
|
||||
Action registerRetrieved(@NotNull Long actionId, String message);
|
||||
|
||||
/**
|
||||
* Updates attributes of the controller.
|
||||
@@ -255,40 +259,6 @@ public interface ControllerManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Target updateLastTargetQuery(@NotEmpty String controllerId, URI address);
|
||||
|
||||
/**
|
||||
* Refreshes the time of the last time the controller has been connected to
|
||||
* the server.
|
||||
*
|
||||
* @param target
|
||||
* to update
|
||||
* @param address
|
||||
* the client address of the target, might be {@code null}
|
||||
* @return the updated target
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
TargetInfo updateLastTargetQuery(@NotNull TargetInfo target, @NotNull URI address);
|
||||
|
||||
/**
|
||||
* Update selective the target status of a given {@code target}.
|
||||
*
|
||||
* @param targetInfo
|
||||
* the target to update the target status
|
||||
* @param status
|
||||
* the status to be set of the target. Might be {@code null} if
|
||||
* the target status should not be updated
|
||||
* @param lastTargetQuery
|
||||
* the last target query to be set of the target. Might be
|
||||
* {@code null} if the target lastTargetQuery should not be
|
||||
* updated
|
||||
* @param address
|
||||
* the client address of the target, might be {@code null}
|
||||
* @return the updated TargetInfo
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
TargetInfo updateTargetStatus(@NotNull TargetInfo targetInfo, TargetUpdateStatus status, Long lastTargetQuery,
|
||||
URI address);
|
||||
|
||||
/**
|
||||
* Finds {@link Target} based on given controller ID returns found Target
|
||||
* without details, i.e. NO {@link Target#getTags()} and
|
||||
@@ -301,7 +271,7 @@ public interface ControllerManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
Target findByControllerId(@NotEmpty final String controllerId);
|
||||
Target findByControllerId(@NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* Finds {@link Target} based on given ID returns found Target without
|
||||
@@ -315,6 +285,6 @@ public interface ControllerManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
Target findByTargetId(final long targetId);
|
||||
Target findByTargetId(@NotNull Long targetId);
|
||||
|
||||
}
|
||||
|
||||
@@ -114,57 +114,33 @@ public interface DeploymentManagement {
|
||||
DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID,
|
||||
@NotEmpty Collection<TargetWithActionType> targets, String actionMessage);
|
||||
|
||||
/**
|
||||
* method assigns the {@link DistributionSet} to all {@link Target}s by
|
||||
* their IDs with a specific {@link ActionType} and {@code forcetime}.
|
||||
*
|
||||
* @param dsID
|
||||
* the ID of the distribution set to assign
|
||||
* @param targets
|
||||
* a list of all targets and their action type
|
||||
* @param rollout
|
||||
* the rollout for this assignment
|
||||
* @param rolloutGroup
|
||||
* the rollout group for this assignment
|
||||
* @return the assignment result
|
||||
*
|
||||
* @throw IncompleteDistributionSetException if mandatory
|
||||
* {@link SoftwareModuleType} are not assigned as define by the
|
||||
* {@link DistributionSetType}.
|
||||
*
|
||||
* @throw {@link EntityNotFoundException} if either provided
|
||||
* {@link DistributionSet} or {@link Target}s do not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
|
||||
DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID,
|
||||
@NotEmpty Collection<TargetWithActionType> targets, Rollout rollout, RolloutGroup rolloutGroup);
|
||||
|
||||
/**
|
||||
* Cancels given {@link Action} for given {@link Target}. The method will
|
||||
* immediately add a {@link Status#CANCELED} status to the action. However,
|
||||
* it might be possible that the controller will continue to work on the
|
||||
* cancellation.
|
||||
*
|
||||
* @param action
|
||||
* @param actionId
|
||||
* to be canceled
|
||||
* @param target
|
||||
* for which the action needs cancellation
|
||||
*
|
||||
* @return generated {@link Action} or <code>null</code> if not active on
|
||||
* given {@link Target}.
|
||||
* @throws CancelActionNotAllowedException
|
||||
* in case the given action is not active or is already a cancel
|
||||
* action
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if action with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
Action cancelAction(@NotNull Action action, @NotNull Target target);
|
||||
Action cancelAction(@NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* counts all actions associated to a specific target.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param target
|
||||
* @param controllerId
|
||||
* the target associated to the actions to count
|
||||
* @return the count value of found actions associated to the target
|
||||
*
|
||||
@@ -175,7 +151,7 @@ public interface DeploymentManagement {
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countActionsByTarget(@NotNull String rsqlParam, @NotNull Target target);
|
||||
Long countActionsByTarget(@NotNull String rsqlParam, @NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* @return the total amount of stored action status
|
||||
@@ -192,35 +168,12 @@ public interface DeploymentManagement {
|
||||
/**
|
||||
* counts all actions associated to a specific target.
|
||||
*
|
||||
* @param target
|
||||
* @param controllerId
|
||||
* the target associated to the actions to count
|
||||
* @return the count value of found actions associated to the target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countActionsByTarget(@NotNull Target target);
|
||||
|
||||
/**
|
||||
* Creates an action entry into the action repository. In case of existing
|
||||
* scheduled actions the scheduled actions gets canceled. A scheduled action
|
||||
* is created in-active.
|
||||
*
|
||||
* @param targets
|
||||
* the targets to create scheduled actions for
|
||||
* @param distributionSet
|
||||
* the distribution set for the actions
|
||||
* @param actionType
|
||||
* the action type for the action
|
||||
* @param forcedTime
|
||||
* the forcedTime of the action
|
||||
* @param rollout
|
||||
* the roll out for this action
|
||||
* @param rolloutGroup
|
||||
* the roll out group for this action
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
void createScheduledAction(@NotEmpty Collection<Target> targets, @NotNull DistributionSet distributionSet,
|
||||
@NotNull ActionType actionType, Long forcedTime, @NotNull Rollout rollout,
|
||||
@NotNull RolloutGroup rolloutGroup);
|
||||
Long countActionsByTarget(@NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* Get the {@link Action} entity for given actionId.
|
||||
@@ -232,30 +185,6 @@ public interface DeploymentManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Action findAction(@NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* Retrieves all actions for a specific rollout and in a specific status.
|
||||
*
|
||||
* @param rollout
|
||||
* the rollout the actions beglong to
|
||||
* @param actionStatus
|
||||
* the status of the actions
|
||||
* @return the actions referring a specific rollout an in a specific status
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Action> findActionsByRolloutAndStatus(@NotNull Rollout rollout, @NotNull Action.Status actionStatus);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s of a specific target.
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @param target
|
||||
* of which the actions have to be searched
|
||||
* @return a paged list of actions associated with the given target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Action> findActionsByTarget(@NotNull Pageable pageable, @NotNull Target target);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s from repository.
|
||||
*
|
||||
@@ -272,14 +201,14 @@ public interface DeploymentManagement {
|
||||
*
|
||||
* @param pageable
|
||||
* the page request parameter for paging and sorting the result
|
||||
* @param distributionSet
|
||||
* @param distributionSetId
|
||||
* the distribution set which should be assigned to the actions
|
||||
* in the result
|
||||
* @return a list of {@link Action} which are assigned to a specific
|
||||
* {@link DistributionSet}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Action> findActionsByDistributionSet(@NotNull Pageable pageable, @NotNull DistributionSet distributionSet);
|
||||
Slice<Action> findActionsByDistributionSet(@NotNull Pageable pageable, @NotNull Long distributionSetId);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s assigned to a specific {@link Target} and a
|
||||
@@ -287,7 +216,7 @@ public interface DeploymentManagement {
|
||||
*
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param target
|
||||
* @param controllerId
|
||||
* the target which must be assigned to the actions
|
||||
* @param pageable
|
||||
* the page request
|
||||
@@ -301,31 +230,21 @@ public interface DeploymentManagement {
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Action> findActionsByTarget(@NotNull String rsqlParam, @NotNull Target target, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s of a specific target ordered by action ID.
|
||||
*
|
||||
* @param target
|
||||
* the target associated with the actions
|
||||
* @return a list of actions associated with the given target ordered by
|
||||
* action ID
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Action> findActionsByTarget(@NotNull Target target);
|
||||
Slice<Action> findActionsByTarget(@NotNull String rsqlParam, @NotEmpty String controllerId,
|
||||
@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s which are referring the given
|
||||
* {@link Target}.
|
||||
*
|
||||
* @param foundTarget
|
||||
* @param controllerId
|
||||
* the target to find actions for
|
||||
* @param pageable
|
||||
* the pageable request to limit, sort the actions
|
||||
* @return a slice of actions found for a specific target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Action> findActionsByTarget(@NotNull Target foundTarget, @NotNull Pageable pageable);
|
||||
Slice<Action> findActionsByTarget(@NotEmpty String controllerId, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all the {@link ActionStatus} entries of the given
|
||||
@@ -333,12 +252,12 @@ public interface DeploymentManagement {
|
||||
*
|
||||
* @param pageReq
|
||||
* pagination parameter
|
||||
* @param action
|
||||
* @param actionId
|
||||
* to be filtered on
|
||||
* @return the corresponding {@link Page} of {@link ActionStatus}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<ActionStatus> findActionStatusByAction(@NotNull Pageable pageReq, @NotNull Action action);
|
||||
Page<ActionStatus> findActionStatusByAction(@NotNull Pageable pageReq, @NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link ActionStatus} inclusive their messages by a specific
|
||||
@@ -346,23 +265,23 @@ public interface DeploymentManagement {
|
||||
*
|
||||
* @param pageable
|
||||
* the page request parameter for paging and sorting the result
|
||||
* @param action
|
||||
* @param actionId
|
||||
* the {@link Action} to retrieve the {@link ActionStatus} from
|
||||
* @return a page of {@link ActionStatus} by a speciifc {@link Action}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<ActionStatus> findActionStatusByActionWithMessages(@NotNull Pageable pageable, @NotNull Action action);
|
||||
Page<ActionStatus> findActionStatusByActionWithMessages(@NotNull Pageable pageable, @NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s of a specific target ordered by action ID.
|
||||
*
|
||||
* @param target
|
||||
* @param controllerId
|
||||
* the target associated with the actions
|
||||
* @return a list of actions associated with the given target ordered by
|
||||
* action ID
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<ActionWithStatusCount> findActionsWithStatusCountByTargetOrderByIdDesc(@NotNull Target target);
|
||||
List<ActionWithStatusCount> findActionsWithStatusCountByTargetOrderByIdDesc(@NotNull String controllerId);
|
||||
|
||||
/**
|
||||
* Get the {@link Action} entity for given actionId with all lazy attributes
|
||||
@@ -379,23 +298,23 @@ public interface DeploymentManagement {
|
||||
* Retrieves all active {@link Action}s of a specific target ordered by
|
||||
* action ID.
|
||||
*
|
||||
* @param target
|
||||
* @param controllerId
|
||||
* the target associated with the actions
|
||||
* @return a list of actions associated with the given target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Action> findActiveActionsByTarget(@NotNull Target target);
|
||||
List<Action> findActiveActionsByTarget(@NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* Retrieves all inactive {@link Action}s of a specific target ordered by
|
||||
* action ID.
|
||||
*
|
||||
* @param target
|
||||
* @param controllerId
|
||||
* the target associated with the actions
|
||||
* @return a list of actions associated with the given target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Action> findInActiveActionsByTarget(@NotNull Target target);
|
||||
List<Action> findInActiveActionsByTarget(@NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* Force cancels given {@link Action} for given {@link Target}. Force
|
||||
@@ -403,16 +322,19 @@ public interface DeploymentManagement {
|
||||
* and a cancel request is sent to the target. But however it's not tracked,
|
||||
* if the targets handles the cancel request or not.
|
||||
*
|
||||
* @param action
|
||||
* @param actionId
|
||||
* to be canceled
|
||||
*
|
||||
* @return generated {@link Action} or <code>null</code> if not active on
|
||||
* {@link Target}.
|
||||
* @throws CancelActionNotAllowedException
|
||||
* in case the given action is not active
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if action with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
Action forceQuitAction(@NotNull Action action);
|
||||
Action forceQuitAction(@NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* Updates a {@link Action} and forces the {@link Action} if it's not
|
||||
@@ -425,17 +347,6 @@ public interface DeploymentManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
Action forceTargetAction(@NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* Starting an action which is scheduled, e.g. in case of roll out a
|
||||
* scheduled action must be started now.
|
||||
*
|
||||
* @param actionId
|
||||
* the the ID of the action to start now.
|
||||
* @return the action which has been started
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Action startScheduledAction(@NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* Starts all scheduled actions of an RolloutGroup parent.
|
||||
*
|
||||
|
||||
@@ -81,12 +81,15 @@ public interface DistributionSetManagement {
|
||||
*
|
||||
* @param dsIds
|
||||
* to assign for
|
||||
* @param tag
|
||||
* @param tagId
|
||||
* to assign
|
||||
* @return list of assigned ds
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if tag with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
List<DistributionSet> assignTag(@NotEmpty Collection<Long> dsIds, @NotNull DistributionSetTag tag);
|
||||
List<DistributionSet> assignTag(@NotEmpty Collection<Long> dsIds, @NotNull Long tagId);
|
||||
|
||||
/**
|
||||
* Count all {@link DistributionSet}s in the repository that are not marked
|
||||
@@ -101,13 +104,13 @@ public interface DistributionSetManagement {
|
||||
* Count all {@link DistributionSet}s in the repository that are not marked
|
||||
* as deleted.
|
||||
*
|
||||
* @param type
|
||||
* @param typeId
|
||||
* to look for
|
||||
*
|
||||
* @return number of {@link DistributionSet}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countDistributionSetsByType(@NotNull DistributionSetType type);
|
||||
Long countDistributionSetsByType(@NotNull Long typeId);
|
||||
|
||||
/**
|
||||
* @return number of {@link DistributionSetType}s in the repository.
|
||||
@@ -212,22 +215,22 @@ public interface DistributionSetManagement {
|
||||
* e.g. findByDeletedFalse())
|
||||
* </p>
|
||||
*
|
||||
* @param set
|
||||
* @param setId
|
||||
* to delete
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteDistributionSet(@NotNull DistributionSet set);
|
||||
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 distributionSetIDs
|
||||
* @param dsIds
|
||||
* to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteDistributionSet(@NotEmpty Long... distributionSetIDs);
|
||||
void deleteDistributionSet(@NotEmpty Collection<Long> dsIds);
|
||||
|
||||
/**
|
||||
* deletes a distribution set meta data entry.
|
||||
@@ -246,21 +249,24 @@ public interface DistributionSetManagement {
|
||||
/**
|
||||
* Deletes or mark as delete in case the type is in use.
|
||||
*
|
||||
* @param type
|
||||
* @param typeId
|
||||
* to delete
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if given set does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteDistributionSetType(@NotNull DistributionSetType type);
|
||||
void deleteDistributionSetType(@NotNull Long typeId);
|
||||
|
||||
/**
|
||||
* retrieves the distribution set for a given action.
|
||||
*
|
||||
* @param action
|
||||
* @param actionId
|
||||
* the action associated with the distribution set
|
||||
* @return the distribution set which is associated with the action
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
DistributionSet findDistributionSetByAction(@NotNull Action action);
|
||||
DistributionSet findDistributionSetByAction(@NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* Find {@link DistributionSet} based on given ID without details, e.g.
|
||||
@@ -510,28 +516,13 @@ public interface DistributionSetManagement {
|
||||
* Checks if a {@link DistributionSet} is currently in use by a target in
|
||||
* the repository.
|
||||
*
|
||||
* @param distributionSet
|
||||
* @param setId
|
||||
* to check
|
||||
*
|
||||
* @return <code>true</code> if in use
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
boolean isDistributionSetInUse(@NotNull DistributionSet distributionSet);
|
||||
|
||||
/**
|
||||
* entity based method call for
|
||||
* {@link #toggleTagAssignment(Collection, String)}.
|
||||
*
|
||||
* @param sets
|
||||
* to toggle for
|
||||
* @param tag
|
||||
* to toggle
|
||||
* @return {@link DistributionSetTagAssignmentResult} with all meta data of
|
||||
* the assignment outcome.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<DistributionSet> sets,
|
||||
@NotNull DistributionSetTag tag);
|
||||
boolean isDistributionSetInUse(@NotNull Long setId);
|
||||
|
||||
/**
|
||||
* Toggles {@link DistributionSetTag} assignment to given
|
||||
@@ -553,12 +544,15 @@ public interface DistributionSetManagement {
|
||||
* Unassign all {@link DistributionSet} from a given
|
||||
* {@link DistributionSetTag} .
|
||||
*
|
||||
* @param tag
|
||||
* @param tagId
|
||||
* to unassign all ds
|
||||
* @return list of unassigned ds
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if tag with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
List<DistributionSet> unAssignAllDistributionSetsByTag(@NotNull DistributionSetTag tag);
|
||||
List<DistributionSet> unAssignAllDistributionSetsByTag(@NotNull Long tagId);
|
||||
|
||||
/**
|
||||
* Unassigns a {@link SoftwareModule} form an existing
|
||||
@@ -571,7 +565,7 @@ public interface DistributionSetManagement {
|
||||
* @return the updated {@link DistributionSet}.
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if given module does not exist
|
||||
* if given module or DS does not exist
|
||||
*
|
||||
* @throws EntityReadOnlyException
|
||||
* if use tries to change the {@link DistributionSet} s while
|
||||
@@ -586,12 +580,15 @@ public interface DistributionSetManagement {
|
||||
*
|
||||
* @param dsId
|
||||
* to unassign for
|
||||
* @param distributionSetTag
|
||||
* @param tagId
|
||||
* to unassign
|
||||
* @return the unassigned ds or <null> if no ds is unassigned
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if set or tag with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSet unAssignTag(@NotNull Long dsId, @NotNull DistributionSetTag distributionSetTag);
|
||||
DistributionSet unAssignTag(@NotNull Long dsId, @NotNull Long tagId);
|
||||
|
||||
/**
|
||||
* Updates existing {@link DistributionSet}.
|
||||
|
||||
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository;
|
||||
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.RSQLParameterSyntaxException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
@@ -51,13 +52,13 @@ public interface RolloutGroupManagement {
|
||||
*
|
||||
* @param pageRequest
|
||||
* the page request to sort and limit the result
|
||||
* @param rolloutGroup
|
||||
* @param rolloutGroupId
|
||||
* rollout group
|
||||
* @return {@link TargetWithActionStatus} target with action status
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||
Page<TargetWithActionStatus> findAllTargetsWithActionStatus(@NotNull PageRequest pageRequest,
|
||||
@NotNull RolloutGroup rolloutGroup);
|
||||
@NotNull Long rolloutGroupId);
|
||||
|
||||
/**
|
||||
* Retrieves a single {@link RolloutGroup} by its ID.
|
||||
@@ -109,20 +110,23 @@ public interface RolloutGroupManagement {
|
||||
/**
|
||||
* Get targets of specified rollout group.
|
||||
*
|
||||
* @param rolloutGroup
|
||||
* @param rolloutGroupId
|
||||
* rollout group
|
||||
* @param page
|
||||
* the page request to sort and limit the result
|
||||
*
|
||||
* @return Page<Target> list of targets of a rollout group
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if group with ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||
Page<Target> findRolloutGroupTargets(@NotNull RolloutGroup rolloutGroup, @NotNull Pageable page);
|
||||
Page<Target> findRolloutGroupTargets(@NotNull Long rolloutGroupId, @NotNull Pageable page);
|
||||
|
||||
/**
|
||||
* Get targets of specified rollout group.
|
||||
*
|
||||
* @param rolloutGroup
|
||||
* @param rolloutGroupId
|
||||
* rollout group
|
||||
* @param rsqlParam
|
||||
* the specification for filtering the targets of a rollout group
|
||||
@@ -138,7 +142,7 @@ public interface RolloutGroupManagement {
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||
Page<Target> findRolloutGroupTargets(@NotNull RolloutGroup rolloutGroup, @NotNull String rsqlParam,
|
||||
Page<Target> findRolloutGroupTargets(@NotNull Long rolloutGroupId, @NotNull String rsqlParam,
|
||||
@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
|
||||
@@ -290,12 +290,12 @@ public interface RolloutManagement {
|
||||
*
|
||||
* @param rolloutId
|
||||
* the ID of the {@link Rollout}
|
||||
* @param rolloutGroup
|
||||
* @param rolloutGroupId
|
||||
* the ID of the {@link RolloutGroup}
|
||||
* @return percentage finished
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
float getFinishedPercentForRunningGroup(@NotNull Long rolloutId, @NotNull RolloutGroup rolloutGroup);
|
||||
float getFinishedPercentForRunningGroup(@NotNull Long rolloutId, @NotNull Long rolloutGroupId);
|
||||
|
||||
/**
|
||||
* Pauses a rollout which is currently running. The Rollout switches
|
||||
@@ -313,10 +313,11 @@ public interface RolloutManagement {
|
||||
* the rollout to be paused.
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if rollout with given ID does not exist
|
||||
* if rollout or group with given ID does not exist
|
||||
* @throws RolloutIllegalStateException
|
||||
* if given rollout is not in {@link RolloutStatus#RUNNING}.
|
||||
* Only running rollouts can be paused.
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
void pauseRollout(@NotNull Long rollout);
|
||||
|
||||
@@ -175,22 +175,25 @@ public interface SoftwareManagement {
|
||||
/**
|
||||
* Deletes or marks as delete in case the type is in use.
|
||||
*
|
||||
* @param type
|
||||
* @param typeId
|
||||
* to delete
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* not found is type with giben ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteSoftwareModuleType(@NotNull SoftwareModuleType type);
|
||||
void deleteSoftwareModuleType(@NotNull Long typeId);
|
||||
|
||||
/**
|
||||
* @param pageable
|
||||
* the page request to page the result set
|
||||
* @param set
|
||||
* @param setId
|
||||
* to search for
|
||||
* @return all {@link SoftwareModule}s that are assigned to given
|
||||
* {@link DistributionSet}.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<SoftwareModule> findSoftwareModuleByAssignedTo(@NotNull Pageable pageable, @NotNull DistributionSet set);
|
||||
Page<SoftwareModule> findSoftwareModuleByAssignedTo(@NotNull Pageable pageable, @NotNull Long setId);
|
||||
|
||||
/**
|
||||
* Filter {@link SoftwareModule}s with given
|
||||
@@ -238,13 +241,13 @@ public interface SoftwareManagement {
|
||||
* of the {@link SoftwareModule}
|
||||
* @param version
|
||||
* of the {@link SoftwareModule}
|
||||
* @param type
|
||||
* @param typeId
|
||||
* of the {@link SoftwareModule}
|
||||
* @return the found {@link SoftwareModule} or <code>null</code>
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
SoftwareModule findSoftwareModuleByNameAndVersion(@NotEmpty String name, @NotEmpty String version,
|
||||
@NotNull SoftwareModuleType type);
|
||||
@NotNull Long typeId);
|
||||
|
||||
/**
|
||||
* finds a single software module meta data by its id.
|
||||
@@ -433,12 +436,8 @@ public interface SoftwareManagement {
|
||||
* {@link SoftwareModule#getDescription()}
|
||||
* {@link SoftwareModule#getVendor()}.
|
||||
*
|
||||
* @param moduleId
|
||||
* to update
|
||||
* @param description
|
||||
* to update or <code>null</code>
|
||||
* @param vendor
|
||||
* to update or <code>null</code>
|
||||
* @param update
|
||||
* contains properties to update
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if given module does not exist
|
||||
|
||||
@@ -16,7 +16,6 @@ import org.eclipse.hawkbit.repository.builder.TargetFilterQueryUpdate;
|
||||
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.TargetFilterQuery;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -62,7 +61,7 @@ public interface TargetFilterQueryManagement {
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
boolean verifyTargetFilterQuerySyntax(String query);
|
||||
boolean verifyTargetFilterQuerySyntax(@NotNull String query);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -94,7 +93,7 @@ public interface TargetFilterQueryManagement {
|
||||
* @return the page with the found {@link TargetFilterQuery}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByName(@NotNull Pageable pageable, String name);
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByName(@NotNull Pageable pageable, @NotNull String name);
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||
@@ -107,7 +106,7 @@ public interface TargetFilterQueryManagement {
|
||||
* @return the page with the found {@link TargetFilterQuery}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByFilter(@NotNull Pageable pageable, String rsqlFilter);
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByFilter(@NotNull Pageable pageable, @NotNull String rsqlFilter);
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||
@@ -115,29 +114,18 @@ public interface TargetFilterQueryManagement {
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @param distributionSet
|
||||
* the auto assign distribution set
|
||||
* @return the page with the found {@link TargetFilterQuery}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(@NotNull Pageable pageable,
|
||||
DistributionSet distributionSet);
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||
*
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @param distributionSet
|
||||
* @param setId
|
||||
* the auto assign distribution set
|
||||
* @param rsqlParam
|
||||
* RSQL filter
|
||||
* @return the page with the found {@link TargetFilterQuery}
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if DS with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(@NotNull Pageable pageable,
|
||||
DistributionSet distributionSet, String rsqlParam);
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(@NotNull Pageable pageable, @NotNull Long setId,
|
||||
String rsqlParam);
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query with auto assign DS which
|
||||
@@ -185,7 +173,7 @@ public interface TargetFilterQueryManagement {
|
||||
* provided but not found
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetFilterQuery updateTargetFilterQuery(TargetFilterQueryUpdate update);
|
||||
TargetFilterQuery updateTargetFilterQuery(@NotNull TargetFilterQueryUpdate update);
|
||||
|
||||
/**
|
||||
* updates the {@link TargetFilterQuery#getAutoAssignDistributionSet()}.
|
||||
@@ -193,7 +181,7 @@ public interface TargetFilterQueryManagement {
|
||||
* @param queryId
|
||||
* to be updated
|
||||
* @param dsId
|
||||
* to be updated or <code>null</code>
|
||||
* to be updated or <code>null</code> in order to remove it
|
||||
* @return the updated {@link TargetFilterQuery}
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
@@ -201,6 +189,6 @@ public interface TargetFilterQueryManagement {
|
||||
* provided but not found
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetFilterQuery updateTargetFilterQueryAutoAssignDS(Long queryId, Long dsId);
|
||||
TargetFilterQuery updateTargetFilterQueryAutoAssignDS(@NotNull Long queryId, Long dsId);
|
||||
|
||||
}
|
||||
|
||||
@@ -45,14 +45,17 @@ public interface TargetManagement {
|
||||
/**
|
||||
* Assign a {@link TargetTag} assignment to given {@link Target}s.
|
||||
*
|
||||
* @param targetIds
|
||||
* @param controllerIds
|
||||
* to assign for
|
||||
* @param tag
|
||||
* @param tagId
|
||||
* to assign
|
||||
* @return list of assigned targets
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if given tagId does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
List<Target> assignTag(@NotEmpty Collection<String> targetIds, @NotNull TargetTag tag);
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
|
||||
List<Target> assignTag(@NotEmpty Collection<String> controllerIds, @NotNull Long tagId);
|
||||
|
||||
/**
|
||||
* Counts number of targets with given
|
||||
@@ -112,22 +115,25 @@ public interface TargetManagement {
|
||||
/**
|
||||
* Count {@link TargetFilterQuery}s for given target filter query.
|
||||
*
|
||||
* @param targetFilterQuery
|
||||
* {link TargetFilterQuery}
|
||||
* @return the found number {@link TargetFilterQuery}s
|
||||
* @param rsqlParam
|
||||
* filter definition in RSQL syntax
|
||||
* @return the found number {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetByTargetFilterQuery(@NotEmpty String targetFilterQuery);
|
||||
Long countTargetByTargetFilterQuery(@NotEmpty String rsqlParam);
|
||||
|
||||
/**
|
||||
* Count {@link TargetFilterQuery}s for given filter parameter.
|
||||
* Count {@link TargetFilterQuery}s for given target filter query.
|
||||
*
|
||||
* @param targetFilterQuery
|
||||
* {link TargetFilterQuery}
|
||||
* @return the found number {@link TargetFilterQuery}s
|
||||
* @param targetFilterQueryId
|
||||
* {@link TargetFilterQuery#getId()}
|
||||
* @return the found number {@link Target}s
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if {@link TargetFilterQuery} with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetByTargetFilterQuery(@NotNull TargetFilterQuery targetFilterQuery);
|
||||
Long countTargetByTargetFilterQuery(@NotNull Long targetFilterQueryId);
|
||||
|
||||
/**
|
||||
* Counts all {@link Target}s in the repository.
|
||||
@@ -169,28 +175,22 @@ public interface TargetManagement {
|
||||
* Deletes all targets with the given IDs.
|
||||
*
|
||||
* @param targetIDs
|
||||
* the technical IDs of the targets to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void deleteTargets(@NotEmpty Long... targetIDs);
|
||||
|
||||
/**
|
||||
* Deletes all targets with the given IDs.
|
||||
*
|
||||
* @param targetIDs
|
||||
* the technical IDs of the targets to be deleted
|
||||
* the IDs of the targets to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void deleteTargets(@NotEmpty Collection<Long> targetIDs);
|
||||
|
||||
/**
|
||||
* finds all {@link Target#getControllerId()} which are currently in the
|
||||
* database.
|
||||
* Deletes target with the given IDs.
|
||||
*
|
||||
* @return all IDs of all {@link Target} in the system
|
||||
* @param controllerID
|
||||
* the ID of the targets to be deleted
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<TargetIdName> findAllTargetIds();
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void deleteTarget(@NotEmpty String controllerID);
|
||||
|
||||
/**
|
||||
* Finds all targets for all the given parameters but returns not the full
|
||||
@@ -231,13 +231,12 @@ public interface TargetManagement {
|
||||
*
|
||||
* @param pageRequest
|
||||
* the pageRequest to enhance the query for paging and sorting
|
||||
* @param targetFilterQuery
|
||||
* {@link TargetFilterQuery}
|
||||
* @param rsqlParam
|
||||
* filter definition in RSQL syntax
|
||||
* @return the found {@link TargetIdName}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<TargetIdName> findAllTargetIdsByTargetFilterQuery(@NotNull Pageable pageRequest,
|
||||
@NotNull TargetFilterQuery targetFilterQuery);
|
||||
List<TargetIdName> findAllTargetIdsByTargetFilterQuery(@NotNull Pageable pageRequest, @NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
||||
@@ -248,13 +247,13 @@ public interface TargetManagement {
|
||||
* the pageRequest to enhance the query for paging and sorting
|
||||
* @param distributionSetId
|
||||
* id of the {@link DistributionSet}
|
||||
* @param targetFilterQuery
|
||||
* {@link TargetFilterQuery}
|
||||
* @param rsqlParam
|
||||
* filter definition in RSQL syntax
|
||||
* @return a page of the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findAllTargetsByTargetFilterQueryAndNonDS(@NotNull Pageable pageRequest, Long distributionSetId,
|
||||
@NotNull TargetFilterQuery targetFilterQuery);
|
||||
@NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Counts all targets for all the given parameter {@link TargetFilterQuery}
|
||||
@@ -263,12 +262,12 @@ public interface TargetManagement {
|
||||
*
|
||||
* @param distributionSetId
|
||||
* id of the {@link DistributionSet}
|
||||
* @param targetFilterQuery
|
||||
* {@link TargetFilterQuery}
|
||||
* @param rsqlParam
|
||||
* filter definition in RSQL syntax
|
||||
* @return the count of found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetsByTargetFilterQueryAndNonDS(Long distributionSetId, @NotNull TargetFilterQuery targetFilterQuery);
|
||||
Long countTargetsByTargetFilterQueryAndNonDS(@NotNull Long distributionSetId, @NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
||||
@@ -278,13 +277,13 @@ public interface TargetManagement {
|
||||
* the pageRequest to enhance the query for paging and sorting
|
||||
* @param groups
|
||||
* the list of {@link RolloutGroup}s
|
||||
* @param targetFilterQuery
|
||||
* RSQL filter
|
||||
* @param rsqlParam
|
||||
* filter definition in RSQL syntax
|
||||
* @return a page of the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findAllTargetsByTargetFilterQueryAndNotInRolloutGroups(@NotNull Pageable pageRequest,
|
||||
List<RolloutGroup> groups, @NotNull String targetFilterQuery);
|
||||
@NotEmpty Collection<Long> groups, @NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Counts all targets for all the given parameter {@link TargetFilterQuery}
|
||||
@@ -292,13 +291,13 @@ public interface TargetManagement {
|
||||
*
|
||||
* @param groups
|
||||
* the list of {@link RolloutGroup}s
|
||||
* @param targetFilterQuery
|
||||
* RSQL filter
|
||||
* @param rsqlParam
|
||||
* filter definition in RSQL syntax
|
||||
* @return count of the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countAllTargetsByTargetFilterQueryAndNotInRolloutGroups(List<RolloutGroup> groups,
|
||||
@NotNull String targetFilterQuery);
|
||||
Long countAllTargetsByTargetFilterQueryAndNotInRolloutGroups(@NotEmpty Collection<Long> groups,
|
||||
@NotNull String rsqlParam);
|
||||
|
||||
/**
|
||||
* Finds all targets of the provided {@link RolloutGroup} that have no
|
||||
@@ -311,7 +310,7 @@ public interface TargetManagement {
|
||||
* @return the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findAllTargetsInRolloutGroupWithoutAction(@NotNull Pageable pageRequest, @NotNull RolloutGroup group);
|
||||
Page<Target> findAllTargetsInRolloutGroupWithoutAction(@NotNull Pageable pageRequest, @NotNull Long group);
|
||||
|
||||
/**
|
||||
* retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
||||
@@ -490,13 +489,15 @@ public interface TargetManagement {
|
||||
* and {@link Target#getActions()} possible based on
|
||||
* {@link TargetFilterQuery#getQuery()}
|
||||
*
|
||||
* @param targetFilterQuery
|
||||
* in string notation
|
||||
* @param rsqlParam
|
||||
* in RSQL notation
|
||||
*
|
||||
* @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}
|
||||
@@ -504,20 +505,22 @@ public interface TargetManagement {
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findTargetsAll(@NotNull String targetFilterQuery, @NotNull Pageable pageable);
|
||||
Page<Target> findTargetsAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
|
||||
* and {@link Target#getActions()} possible based on
|
||||
* {@link TargetFilterQuery#getQuery()}
|
||||
*
|
||||
* @param targetFilterQuery
|
||||
* the specification for the query
|
||||
* @param targetFilterQueryId
|
||||
* {@link TargetFilterQuery#getId()}
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
*
|
||||
* @return the found {@link Target}s, never {@code null}
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if {@link TargetFilterQuery} with given ID does not exist.
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
* if a field in the RSQL string is used but not provided by the
|
||||
* given {@code fieldNameProvider}
|
||||
@@ -525,7 +528,7 @@ public interface TargetManagement {
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Target> findTargetsAll(@NotNull TargetFilterQuery targetFilterQuery, @NotNull Pageable pageable);
|
||||
Slice<Target> findTargetsByTargetFilterQuery(@NotNull Long targetFilterQueryId, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* method retrieves all {@link Target}s from the repo in the following
|
||||
@@ -594,40 +597,33 @@ public interface TargetManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<String> targetIds, @NotEmpty String tagName);
|
||||
|
||||
/**
|
||||
* {@link Target} based method call for
|
||||
* {@link #toggleTagAssignment(Collection, String)}.
|
||||
*
|
||||
* @param targets
|
||||
* to toggle for
|
||||
* @param tag
|
||||
* to toggle
|
||||
* @return TagAssigmentResult with all meta data of the assignment outcome.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<Target> targets, @NotNull TargetTag tag);
|
||||
|
||||
/**
|
||||
* Un-assign all {@link Target} from a given {@link TargetTag} .
|
||||
*
|
||||
* @param tag
|
||||
* @param targetTagId
|
||||
* to un-assign all targets
|
||||
* @return list of unassigned targets
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if TAG with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
List<Target> unAssignAllTargetsByTag(@NotNull TargetTag tag);
|
||||
List<Target> unAssignAllTargetsByTag(@NotNull Long targetTagId);
|
||||
|
||||
/**
|
||||
* Un-assign a {@link TargetTag} assignment to given {@link Target}.
|
||||
*
|
||||
* @param controllerID
|
||||
* to un-assign for
|
||||
* @param targetTag
|
||||
* @param targetTagId
|
||||
* to un-assign
|
||||
* @return the unassigned target or <null> if no target is unassigned
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if TAG with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
Target unAssignTag(@NotEmpty String controllerID, @NotNull TargetTag targetTag);
|
||||
Target unAssignTag(@NotEmpty String controllerID, @NotNull Long targetTagId);
|
||||
|
||||
/**
|
||||
* updates the {@link Target}.
|
||||
@@ -642,5 +638,5 @@ public interface TargetManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
Target updateTarget(TargetUpdate update);
|
||||
Target updateTarget(@NotNull TargetUpdate update);
|
||||
}
|
||||
|
||||
@@ -61,11 +61,11 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction, Long>,
|
||||
*
|
||||
* @param pageable
|
||||
* page parameters
|
||||
* @param ds
|
||||
* @param dsId
|
||||
* the {@link DistributionSet} on which will be filtered
|
||||
* @return the found {@link Action}s
|
||||
*/
|
||||
Page<Action> findByDistributionSet(final Pageable pageable, final JpaDistributionSet ds);
|
||||
Page<Action> findByDistributionSetId(final Pageable pageable, final Long dsId);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s which are referring the given
|
||||
@@ -73,11 +73,11 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction, Long>,
|
||||
*
|
||||
* @param pageable
|
||||
* page parameters
|
||||
* @param target
|
||||
* @param controllerId
|
||||
* the target to find assigned actions
|
||||
* @return the found {@link Action}s
|
||||
*/
|
||||
Slice<Action> findByTarget(Pageable pageable, JpaTarget target);
|
||||
Slice<Action> findByTargetControllerId(Pageable pageable, String controllerId);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s which are active and referring to the given
|
||||
@@ -97,7 +97,7 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction, Long>,
|
||||
*
|
||||
* @param sort
|
||||
* order
|
||||
* @param target
|
||||
* @param controllerId
|
||||
* the target to find assigned actions
|
||||
* @param active
|
||||
* the action active flag
|
||||
@@ -105,7 +105,7 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction, Long>,
|
||||
* @return the found {@link Action}
|
||||
*/
|
||||
@EntityGraph(value = "Action.ds", type = EntityGraphType.LOAD)
|
||||
Optional<Action> findFirstByTargetAndActive(final Sort sort, final JpaTarget target, boolean active);
|
||||
Optional<Action> findFirstByTargetControllerIdAndActive(final Sort sort, final String controllerId, boolean active);
|
||||
|
||||
/**
|
||||
* Retrieves latest {@link Action} for given target and
|
||||
@@ -162,8 +162,8 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction, Long>,
|
||||
* @return a list of actions ordered by action ID
|
||||
*/
|
||||
@EntityGraph(value = "Action.ds", type = EntityGraphType.LOAD)
|
||||
@Query("Select a from JpaAction a where a.target = :target and a.active= :active order by a.id")
|
||||
List<Action> findByActiveAndTarget(@Param("target") JpaTarget target, @Param("active") boolean active);
|
||||
@Query("Select a from JpaAction a where a.target.controllerId = :target and a.active= :active order by a.id")
|
||||
List<Action> findByActiveAndTarget(@Param("target") String target, @Param("active") boolean active);
|
||||
|
||||
/**
|
||||
* Switches the status of actions from one specific status into another,
|
||||
@@ -203,11 +203,11 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction, Long>,
|
||||
/**
|
||||
* Counts all {@link Action}s referring to the given target.
|
||||
*
|
||||
* @param target
|
||||
* @param controllerId
|
||||
* the target to count the {@link Action}s
|
||||
* @return the count of actions referring to the given target
|
||||
*/
|
||||
Long countByTarget(JpaTarget target);
|
||||
Long countByTargetControllerId(String controllerId);
|
||||
|
||||
/**
|
||||
* Counts all {@link Action}s referring to the given DistributionSet.
|
||||
@@ -216,7 +216,7 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction, Long>,
|
||||
* DistributionSet to count the {@link Action}s from
|
||||
* @return the count of actions referring to the given distributionSet
|
||||
*/
|
||||
Long countByDistributionSet(JpaDistributionSet distributionSet);
|
||||
Long countByDistributionSetId(Long distributionSet);
|
||||
|
||||
/**
|
||||
* Counts all actions referring to a given rollout and rolloutgroup which
|
||||
@@ -303,13 +303,13 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction, Long>,
|
||||
/**
|
||||
* Retrieves all actions for a specific rollout and in a specific status.
|
||||
*
|
||||
* @param rollout
|
||||
* @param rolloutId
|
||||
* the rollout the actions beglong to
|
||||
* @param actionStatus
|
||||
* the status of the actions
|
||||
* @return the actions referring a specific rollout an in a specific status
|
||||
*/
|
||||
List<Action> findByRolloutAndStatus(JpaRollout rollout, Status actionStatus);
|
||||
List<Action> findByRolloutIdAndStatus(Long rolloutId, Status actionStatus);
|
||||
|
||||
/**
|
||||
* Get list of objects which has details of status and count of targets in
|
||||
|
||||
@@ -44,11 +44,11 @@ public interface ActionStatusRepository
|
||||
*
|
||||
* @param pageReq
|
||||
* parameters
|
||||
* @param action
|
||||
* @param actionId
|
||||
* of the status entries
|
||||
* @return pages list of {@link ActionStatus} entries
|
||||
*/
|
||||
Page<ActionStatus> findByAction(Pageable pageReq, JpaAction action);
|
||||
Page<ActionStatus> findByActionId(Pageable pageReq, Long actionId);
|
||||
|
||||
/**
|
||||
* Finds all status updates for the defined action and target including
|
||||
@@ -58,11 +58,11 @@ public interface ActionStatusRepository
|
||||
* for page configuration
|
||||
* @param target
|
||||
* to look for
|
||||
* @param action
|
||||
* @param actionId
|
||||
* to look for
|
||||
* @return Page with found targets
|
||||
*/
|
||||
@EntityGraph(value = "ActionStatus.withMessages", type = EntityGraphType.LOAD)
|
||||
Page<ActionStatus> getByAction(Pageable pageReq, JpaAction action);
|
||||
Page<ActionStatus> getByActionId(Pageable pageReq, Long actionId);
|
||||
|
||||
}
|
||||
|
||||
@@ -11,10 +11,8 @@ package org.eclipse.hawkbit.repository.jpa;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
@@ -89,7 +87,7 @@ public interface DistributionSetRepository
|
||||
* @return list of {@link DistributionSet#getId()}
|
||||
*/
|
||||
@Query("select ac.distributionSet.id from JpaAction ac where ac.distributionSet.id in :ids")
|
||||
List<Long> findAssignedToTargetDistributionSetsById(@Param("ids") Long... ids);
|
||||
List<Long> findAssignedToTargetDistributionSetsById(@Param("ids") Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* Finds {@link DistributionSet}s based on given ID that are assigned yet to
|
||||
@@ -100,7 +98,7 @@ public interface DistributionSetRepository
|
||||
* @return list of {@link DistributionSet#getId()}
|
||||
*/
|
||||
@Query("select ra.distributionSet.id from JpaRollout ra where ra.distributionSet.id in :ids")
|
||||
List<Long> findAssignedToRolloutDistributionSetsById(@Param("ids") Long... ids);
|
||||
List<Long> findAssignedToRolloutDistributionSetsById(@Param("ids") Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* Finds the distribution set for a specific action.
|
||||
@@ -109,17 +107,17 @@ public interface DistributionSetRepository
|
||||
* the action associated with the distribution set to find
|
||||
* @return the distribution set associated with the given action
|
||||
*/
|
||||
@Query("select DISTINCT d from JpaDistributionSet d join fetch d.modules m join d.actions a where a = :action")
|
||||
JpaDistributionSet findByAction(@Param("action") JpaAction action);
|
||||
@Query("select DISTINCT d from JpaDistributionSet d join fetch d.modules m join d.actions a where a.id = :action")
|
||||
JpaDistributionSet findByActionId(@Param("action") Long action);
|
||||
|
||||
/**
|
||||
* Counts {@link DistributionSet} instances of given type in the repository.
|
||||
*
|
||||
* @param type
|
||||
* @param typeId
|
||||
* to search for
|
||||
* @return number of found {@link DistributionSet}s
|
||||
*/
|
||||
long countByType(JpaDistributionSetType type);
|
||||
long countByTypeId(Long typeId);
|
||||
|
||||
/**
|
||||
* Counts {@link DistributionSet} with given
|
||||
|
||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.hawkbit.artifact.repository.ArtifactRepository;
|
||||
import org.eclipse.hawkbit.artifact.repository.ArtifactStoreException;
|
||||
@@ -104,10 +105,14 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public boolean clearArtifactBinary(final Artifact existing) {
|
||||
public boolean clearArtifactBinary(final Long existing) {
|
||||
return clearArtifactBinary(Optional.ofNullable(localArtifactRepository.findOne(existing))
|
||||
.orElseThrow(() -> new EntityNotFoundException("Artifact with given ID" + existing + " not found.")));
|
||||
}
|
||||
|
||||
for (final Artifact lArtifact : localArtifactRepository
|
||||
.findByGridFsFileName(((JpaArtifact) existing).getGridFsFileName())) {
|
||||
private boolean clearArtifactBinary(final JpaArtifact existing) {
|
||||
|
||||
for (final Artifact lArtifact : localArtifactRepository.findByGridFsFileName(existing.getGridFsFileName())) {
|
||||
if (!lArtifact.getSoftwareModule().isDeleted()
|
||||
&& Long.compare(lArtifact.getSoftwareModule().getId(), existing.getSoftwareModule().getId()) != 0) {
|
||||
return false;
|
||||
@@ -115,8 +120,8 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
}
|
||||
|
||||
try {
|
||||
LOG.debug("deleting artifact from repository {}", ((JpaArtifact) existing).getGridFsFileName());
|
||||
artifactRepository.deleteBySha1(((JpaArtifact) existing).getGridFsFileName());
|
||||
LOG.debug("deleting artifact from repository {}", existing.getGridFsFileName());
|
||||
artifactRepository.deleteBySha1(existing.getGridFsFileName());
|
||||
return true;
|
||||
} catch (final ArtifactStoreException e) {
|
||||
throw new ArtifactDeleteFailedException(e);
|
||||
@@ -166,10 +171,13 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DbArtifact loadArtifactBinary(final Artifact artifact) {
|
||||
final DbArtifact result = artifactRepository.getArtifactBySha1(((JpaArtifact) artifact).getGridFsFileName());
|
||||
public DbArtifact loadArtifactBinary(final Long artifactId) {
|
||||
final JpaArtifact artifact = Optional.ofNullable(localArtifactRepository.findOne(artifactId))
|
||||
.orElseThrow(() -> new EntityNotFoundException("Artifact with given id " + artifactId + " not found."));
|
||||
|
||||
final DbArtifact result = artifactRepository.getArtifactBySha1(artifact.getGridFsFileName());
|
||||
if (result == null) {
|
||||
throw new GridFSDBFileNotFoundException(((JpaArtifact) artifact).getGridFsFileName());
|
||||
throw new GridFSDBFileNotFoundException(artifact.getGridFsFileName());
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.eclipse.hawkbit.repository.jpa.executor.AfterTransactionCommitExecuto
|
||||
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.JpaAction_;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
@@ -45,7 +46,6 @@ import org.eclipse.hawkbit.repository.jpa.specifications.ActionSpecifications;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||
@@ -135,12 +135,10 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public Target updateLastTargetQuery(final String controllerId, final URI address) {
|
||||
final Target target = targetRepository.findByControllerId(controllerId);
|
||||
if (target == null) {
|
||||
throw new EntityNotFoundException(controllerId);
|
||||
}
|
||||
final Target target = Optional.ofNullable(targetRepository.findByControllerId(controllerId))
|
||||
.orElseThrow(() -> new EntityNotFoundException("Target with given ID " + controllerId + " not found"));
|
||||
|
||||
return updateLastTargetQuery(target.getTargetInfo(), address).getTarget();
|
||||
return updateTargetStatus(target.getTargetInfo(), null, System.currentTimeMillis(), address).getTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,7 +156,7 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTargetArtifactAssigned(final String controllerId, final Artifact localArtifact) {
|
||||
public boolean hasTargetArtifactAssigned(final String controllerId, final Long localArtifact) {
|
||||
final Target target = targetRepository.findByControllerId(controllerId);
|
||||
if (target == null) {
|
||||
return false;
|
||||
@@ -167,7 +165,7 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTargetArtifactAssigned(final Long targetId, final Artifact localArtifact) {
|
||||
public boolean hasTargetArtifactAssigned(final Long targetId, final Long localArtifact) {
|
||||
final Target target = targetRepository.findOne(targetId);
|
||||
if (target == null) {
|
||||
return false;
|
||||
@@ -176,10 +174,11 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Action> findOldestActiveActionByTarget(final Target target) {
|
||||
public Optional<Action> findOldestActiveActionByTarget(final String controllerId) {
|
||||
// used in favorite to findFirstByTargetAndActiveOrderByIdAsc due to
|
||||
// DATAJPA-841 issue.
|
||||
return actionRepository.findFirstByTargetAndActive(new Sort(Direction.ASC, "id"), (JpaTarget) target, true);
|
||||
return actionRepository.findFirstByTargetControllerIdAndActive(new Sort(Direction.ASC, "id"), controllerId,
|
||||
true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,13 +207,10 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
return result;
|
||||
}
|
||||
|
||||
return updateLastTargetQuery(target.getTargetInfo(), address).getTarget();
|
||||
return updateTargetStatus(target.getTargetInfo(), null, System.currentTimeMillis(), address).getTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public TargetInfo updateTargetStatus(final TargetInfo targetInfo, final TargetUpdateStatus status,
|
||||
private TargetInfo updateTargetStatus(final TargetInfo targetInfo, final TargetUpdateStatus status,
|
||||
final Long lastTargetQuery, final URI address) {
|
||||
final JpaTargetInfo mtargetInfo = (JpaTargetInfo) entityManager.merge(targetInfo);
|
||||
if (status != null) {
|
||||
@@ -431,22 +427,24 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public Action registerRetrieved(final Action action, final String message) {
|
||||
return handleRegisterRetrieved((JpaAction) action, message);
|
||||
public Action registerRetrieved(final Long actionId, final String message) {
|
||||
return handleRegisterRetrieved(actionId, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers retrieved status for given {@link Target} and {@link Action} if
|
||||
* it does not exist yet.
|
||||
*
|
||||
* @param action
|
||||
* @param actionId
|
||||
* to the handle status for
|
||||
* @param message
|
||||
* for the status
|
||||
* @return the updated action in case the status has been changed to
|
||||
* {@link Status#RETRIEVED}
|
||||
*/
|
||||
private Action handleRegisterRetrieved(final JpaAction action, final String message) {
|
||||
private Action handleRegisterRetrieved(final Long actionId, final String message) {
|
||||
final JpaAction action = Optional.ofNullable(actionRepository.findById(actionId)).orElseThrow(
|
||||
() -> new EntityNotFoundException("Actionw ith given ID " + actionId + " doesn not exist."));
|
||||
// do a manual query with CriteriaBuilder to avoid unnecessary field
|
||||
// queries and an extra
|
||||
// count query made by spring-data when using pageable requests, we
|
||||
@@ -458,7 +456,7 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
final Root<JpaActionStatus> actionStatusRoot = queryActionStatus.from(JpaActionStatus.class);
|
||||
final CriteriaQuery<Object[]> query = queryActionStatus
|
||||
.multiselect(actionStatusRoot.get(JpaActionStatus_.id), actionStatusRoot.get(JpaActionStatus_.status))
|
||||
.where(cb.equal(actionStatusRoot.get(JpaActionStatus_.action), action))
|
||||
.where(cb.equal(actionStatusRoot.get(JpaActionStatus_.action).get(JpaAction_.id), actionId))
|
||||
.orderBy(cb.desc(actionStatusRoot.get(JpaActionStatus_.id)));
|
||||
final List<Object[]> resultList = entityManager.createQuery(query).setFirstResult(0).setMaxResults(1)
|
||||
.getResultList();
|
||||
@@ -480,9 +478,8 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
// we modify the action status and the controller won't get the
|
||||
// cancel job anymore.
|
||||
if (!action.isCancelingOrCanceled()) {
|
||||
final JpaAction actionMerge = entityManager.merge(action);
|
||||
actionMerge.setStatus(Status.RETRIEVED);
|
||||
return actionRepository.save(actionMerge);
|
||||
action.setStatus(Status.RETRIEVED);
|
||||
return actionRepository.save(action);
|
||||
}
|
||||
}
|
||||
return action;
|
||||
@@ -507,13 +504,6 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
.orElseThrow(() -> new EntityNotFoundException("Action with ID " + actionId + " not found!"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public TargetInfo updateLastTargetQuery(final TargetInfo target, final URI address) {
|
||||
return updateTargetStatus(target, null, System.currentTimeMillis(), address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadProgress(final Long statusId, final Long requestedBytes, final Long shippedBytesSinceLast,
|
||||
final Long shippedBytesOverall) {
|
||||
@@ -527,7 +517,7 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Target findByTargetId(final long targetId) {
|
||||
public Target findByTargetId(final Long targetId) {
|
||||
return targetRepository.findOne(targetId);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -51,6 +52,7 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaRollout_;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetInfo;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget_;
|
||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.TargetSpecifications;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
@@ -85,7 +87,6 @@ import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
@@ -180,20 +181,6 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
return assignDistributionSetToTargets(set, targets, null, null, actionMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
public DistributionSetAssignmentResult assignDistributionSet(final Long dsID,
|
||||
final Collection<TargetWithActionType> targets, final Rollout rollout, final RolloutGroup rolloutGroup) {
|
||||
final JpaDistributionSet set = distributoinSetRepository.findOne(dsID);
|
||||
if (set == null) {
|
||||
throw new EntityNotFoundException(
|
||||
String.format("no %s with id %d found", DistributionSet.class.getSimpleName(), dsID));
|
||||
}
|
||||
|
||||
return assignDistributionSetToTargets(set, targets, (JpaRollout) rollout, (JpaRolloutGroup) rolloutGroup, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* method assigns the {@link DistributionSet} to all {@link Target}s by
|
||||
* their IDs with a specific {@link ActionType} and {@code forcetime}.
|
||||
@@ -375,22 +362,25 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
public Action cancelAction(final Action action, final Target target) {
|
||||
LOG.debug("cancelAction({}, {})", action, target);
|
||||
public Action cancelAction(final Long actionId) {
|
||||
LOG.debug("cancelAction({})", actionId);
|
||||
|
||||
final JpaAction action = Optional.ofNullable(actionRepository.findOne(actionId))
|
||||
.orElseThrow(() -> new EntityNotFoundException("Action with given ID " + actionId + " not found"));
|
||||
|
||||
if (action.isCancelingOrCanceled()) {
|
||||
throw new CancelActionNotAllowedException("Actions in canceling or canceled state cannot be canceled");
|
||||
}
|
||||
final JpaAction myAction = (JpaAction) entityManager.merge(action);
|
||||
|
||||
if (myAction.isActive()) {
|
||||
if (action.isActive()) {
|
||||
LOG.debug("action ({}) was still active. Change to {}.", action, Status.CANCELING);
|
||||
myAction.setStatus(Status.CANCELING);
|
||||
action.setStatus(Status.CANCELING);
|
||||
|
||||
// document that the status has been retrieved
|
||||
actionStatusRepository.save(new JpaActionStatus(myAction, Status.CANCELING, System.currentTimeMillis(),
|
||||
actionStatusRepository.save(new JpaActionStatus(action, Status.CANCELING, System.currentTimeMillis(),
|
||||
"manual cancelation requested"));
|
||||
final Action saveAction = actionRepository.save(myAction);
|
||||
cancelAssignDistributionSetEvent(target, myAction.getId());
|
||||
final Action saveAction = actionRepository.save(action);
|
||||
cancelAssignDistributionSetEvent(action.getTarget(), action.getId());
|
||||
|
||||
return saveAction;
|
||||
} else {
|
||||
@@ -421,15 +411,16 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
public Action forceQuitAction(final Action action) {
|
||||
final JpaAction mergedAction = (JpaAction) entityManager.merge(action);
|
||||
public Action forceQuitAction(final Long actionId) {
|
||||
final JpaAction action = Optional.ofNullable(actionRepository.findOne(actionId))
|
||||
.orElseThrow(() -> new EntityNotFoundException("Action with given ID " + actionId + " not found"));
|
||||
|
||||
if (!mergedAction.isCancelingOrCanceled()) {
|
||||
if (!action.isCancelingOrCanceled()) {
|
||||
throw new ForceQuitActionNotAllowedException(
|
||||
"Action [id: " + action.getId() + "] is not canceled yet and cannot be force quit");
|
||||
}
|
||||
|
||||
if (!mergedAction.isActive()) {
|
||||
if (!action.isActive()) {
|
||||
throw new ForceQuitActionNotAllowedException(
|
||||
"Action [id: " + action.getId() + "] is not active and cannot be force quit");
|
||||
}
|
||||
@@ -437,39 +428,13 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
LOG.warn("action ({}) was still activ and has been force quite.", action);
|
||||
|
||||
// document that the status has been retrieved
|
||||
actionStatusRepository.save(new JpaActionStatus(mergedAction, Status.CANCELED, System.currentTimeMillis(),
|
||||
actionStatusRepository.save(new JpaActionStatus(action, Status.CANCELED, System.currentTimeMillis(),
|
||||
"A force quit has been performed."));
|
||||
|
||||
DeploymentHelper.successCancellation(mergedAction, actionRepository, targetRepository, targetInfoRepository,
|
||||
DeploymentHelper.successCancellation(action, actionRepository, targetRepository, targetInfoRepository,
|
||||
entityManager);
|
||||
|
||||
return actionRepository.save(mergedAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
public void createScheduledAction(final Collection<Target> targets, final DistributionSet distributionSet,
|
||||
final ActionType actionType, final Long forcedTime, final Rollout rollout,
|
||||
final RolloutGroup rolloutGroup) {
|
||||
// cancel all current scheduled actions for this target. E.g. an action
|
||||
// is already scheduled and a next action is created then cancel the
|
||||
// current scheduled action to cancel. E.g. a new scheduled action is
|
||||
// created.
|
||||
final List<Long> targetIds = targets.stream().map(t -> t.getId()).collect(Collectors.toList());
|
||||
actionRepository.switchStatus(Action.Status.CANCELED, targetIds, false, Action.Status.SCHEDULED);
|
||||
targets.forEach(target -> {
|
||||
final JpaAction action = new JpaAction();
|
||||
action.setTarget(target);
|
||||
action.setActive(false);
|
||||
action.setDistributionSet(distributionSet);
|
||||
action.setActionType(actionType);
|
||||
action.setForcedTime(forcedTime);
|
||||
action.setStatus(Status.SCHEDULED);
|
||||
action.setRollout(rollout);
|
||||
action.setRolloutGroup(rolloutGroup);
|
||||
actionRepository.save(action);
|
||||
});
|
||||
return actionRepository.save(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -517,14 +482,6 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
|
||||
public Action startScheduledAction(final Long actionId) {
|
||||
final JpaAction action = actionRepository.findById(actionId);
|
||||
return startScheduledAction(action);
|
||||
}
|
||||
|
||||
private Action startScheduledAction(final JpaAction action) {
|
||||
// check if we need to override running update actions
|
||||
final Set<Long> overrideObsoleteUpdateActions = overrideObsoleteUpdateActions(
|
||||
@@ -595,17 +552,12 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Action> findActionsByTarget(final Pageable pageable, final Target target) {
|
||||
return actionRepository.findByTarget(pageable, (JpaTarget) target);
|
||||
public Slice<Action> findActionsByTarget(final String controllerId, final Pageable pageable) {
|
||||
return actionRepository.findByTargetControllerId(pageable, controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Action> findActionsByTarget(final Target target) {
|
||||
return Collections.unmodifiableList(actionRepository.findByTarget(target));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActionWithStatusCount> findActionsWithStatusCountByTargetOrderByIdDesc(final Target target) {
|
||||
public List<ActionWithStatusCount> findActionsWithStatusCountByTargetOrderByIdDesc(final String controllerId) {
|
||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
final CriteriaQuery<JpaActionWithStatusCount> query = cb.createQuery(JpaActionWithStatusCount.class);
|
||||
final Root<JpaAction> actionRoot = query.from(JpaAction.class);
|
||||
@@ -621,24 +573,25 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
actionDsJoin.get(JpaDistributionSet_.id), actionDsJoin.get(JpaDistributionSet_.name),
|
||||
actionDsJoin.get(JpaDistributionSet_.version), cb.count(actionStatusJoin),
|
||||
actionRolloutJoin.get(JpaRollout_.name));
|
||||
multiselect.where(cb.equal(actionRoot.get(JpaAction_.target), target));
|
||||
multiselect.where(cb.equal(actionRoot.get(JpaAction_.target).get(JpaTarget_.controllerId), controllerId));
|
||||
multiselect.orderBy(cb.desc(actionRoot.get(JpaAction_.id)));
|
||||
multiselect.groupBy(actionRoot.get(JpaAction_.id));
|
||||
return Collections.unmodifiableList(entityManager.createQuery(multiselect).getResultList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Action> findActionsByTarget(final String rsqlParam, final Target target, final Pageable pageable) {
|
||||
public Page<Action> findActionsByTarget(final String rsqlParam, final String controllerId,
|
||||
final Pageable pageable) {
|
||||
|
||||
final Specification<JpaAction> byTargetSpec = createSpecificationFor(target, rsqlParam);
|
||||
final Specification<JpaAction> byTargetSpec = createSpecificationFor(controllerId, rsqlParam);
|
||||
final Page<JpaAction> actions = actionRepository.findAll(byTargetSpec, pageable);
|
||||
return convertAcPage(actions, pageable);
|
||||
}
|
||||
|
||||
private Specification<JpaAction> createSpecificationFor(final Target target, final String rsqlParam) {
|
||||
private Specification<JpaAction> createSpecificationFor(final String controllerId, final String rsqlParam) {
|
||||
final Specification<JpaAction> spec = RSQLUtility.parse(rsqlParam, ActionFields.class, virtualPropertyReplacer);
|
||||
return (root, query, cb) -> cb.and(spec.toPredicate(root, query, cb),
|
||||
cb.equal(root.get(JpaAction_.target), target));
|
||||
cb.equal(root.get(JpaAction_.target).get(JpaTarget_.controllerId), controllerId));
|
||||
}
|
||||
|
||||
private static Page<Action> convertAcPage(final Page<JpaAction> findAll, final Pageable pageable) {
|
||||
@@ -646,28 +599,23 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Action> findActionsByTarget(final Target foundTarget, final Pageable pageable) {
|
||||
return actionRepository.findByTarget(pageable, (JpaTarget) foundTarget);
|
||||
public List<Action> findActiveActionsByTarget(final String controllerId) {
|
||||
return actionRepository.findByActiveAndTarget(controllerId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Action> findActiveActionsByTarget(final Target target) {
|
||||
return actionRepository.findByActiveAndTarget((JpaTarget) target, true);
|
||||
public List<Action> findInActiveActionsByTarget(final String controllerId) {
|
||||
return actionRepository.findByActiveAndTarget(controllerId, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Action> findInActiveActionsByTarget(final Target target) {
|
||||
return actionRepository.findByActiveAndTarget((JpaTarget) target, false);
|
||||
public Long countActionsByTarget(final String controllerId) {
|
||||
return actionRepository.countByTargetControllerId(controllerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countActionsByTarget(final Target target) {
|
||||
return actionRepository.countByTarget((JpaTarget) target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countActionsByTarget(final String rsqlParam, final Target target) {
|
||||
return actionRepository.count(createSpecificationFor(target, rsqlParam));
|
||||
public Long countActionsByTarget(final String rsqlParam, final String controllerId) {
|
||||
return actionRepository.count(createSpecificationFor(controllerId, rsqlParam));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -683,18 +631,13 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ActionStatus> findActionStatusByAction(final Pageable pageReq, final Action action) {
|
||||
return actionStatusRepository.findByAction(pageReq, (JpaAction) action);
|
||||
public Page<ActionStatus> findActionStatusByAction(final Pageable pageReq, final Long actionId) {
|
||||
return actionStatusRepository.findByActionId(pageReq, actionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ActionStatus> findActionStatusByActionWithMessages(final Pageable pageReq, final Action action) {
|
||||
return actionStatusRepository.getByAction(pageReq, (JpaAction) action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Action> findActionsByRolloutAndStatus(final Rollout rollout, final Action.Status actionStatus) {
|
||||
return actionRepository.findByRolloutAndStatus((JpaRollout) rollout, actionStatus);
|
||||
public Page<ActionStatus> findActionStatusByActionWithMessages(final Pageable pageReq, final Long actionId) {
|
||||
return actionStatusRepository.getByActionId(pageReq, actionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -717,8 +660,8 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Action> findActionsByDistributionSet(final Pageable pageable, final DistributionSet ds) {
|
||||
return actionRepository.findByDistributionSet(pageable, (JpaDistributionSet) ds);
|
||||
public Slice<Action> findActionsByDistributionSet(final Pageable pageable, final Long dsId) {
|
||||
return actionRepository.findByDistributionSetId(pageable, dsId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
@@ -36,9 +37,7 @@ import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.repository.jpa.builder.JpaDistributionSetCreate;
|
||||
import org.eclipse.hawkbit.repository.jpa.builder.JpaDistributionSetTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.jpa.executor.AfterTransactionCommitExecutor;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.DsMetadataCompositeKey;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSetMetadata_;
|
||||
@@ -50,7 +49,6 @@ import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetSpecification;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.DistributionSetTypeSpecification;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.SpecificationsBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||
@@ -114,9 +112,6 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
private AfterTransactionCommitExecutor afterCommit;
|
||||
|
||||
@Autowired
|
||||
private TenantAware tenantAware;
|
||||
|
||||
@@ -195,14 +190,14 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
if (update.isRequiredMigrationStep() != null
|
||||
&& !update.isRequiredMigrationStep().equals(set.isRequiredMigrationStep())) {
|
||||
checkDistributionSetIsAssignedToTargets(set);
|
||||
checkDistributionSetIsAssignedToTargets(update.getId());
|
||||
set.setRequiredMigrationStep(update.isRequiredMigrationStep());
|
||||
}
|
||||
|
||||
if (update.getType() != null) {
|
||||
final DistributionSetType type = findDistributionSetTypeWithExceptionIfNotFound(update.getType());
|
||||
if (!type.getId().equals(set.getType().getId())) {
|
||||
checkDistributionSetIsAssignedToTargets(set);
|
||||
checkDistributionSetIsAssignedToTargets(update.getId());
|
||||
|
||||
set.setType(type);
|
||||
}
|
||||
@@ -251,7 +246,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public void deleteDistributionSet(final Long... distributionSetIDs) {
|
||||
public void deleteDistributionSet(final Collection<Long> distributionSetIDs) {
|
||||
final List<Long> assigned = distributionSetRepository
|
||||
.findAssignedToTargetDistributionSetsById(distributionSetIDs);
|
||||
assigned.addAll(distributionSetRepository.findAssignedToRolloutDistributionSetsById(distributionSetIDs));
|
||||
@@ -264,7 +259,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
// mark the rest as hard delete
|
||||
final List<Long> toHardDelete = Arrays.stream(distributionSetIDs).filter(setId -> !assigned.contains(setId))
|
||||
final List<Long> toHardDelete = distributionSetIDs.stream().filter(setId -> !assigned.contains(setId))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// hard delete the rest if exists
|
||||
@@ -274,10 +269,9 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
distributionSetRepository.deleteByIdIn(toHardDelete);
|
||||
}
|
||||
|
||||
Arrays.stream(distributionSetIDs)
|
||||
.forEach(dsId -> eventPublisher
|
||||
.publishEvent(new DistributionSetDeletedEvent(tenantAware.getCurrentTenant(), dsId,
|
||||
JpaDistributionSet.class.getName(), applicationContext.getId())));
|
||||
distributionSetIDs.forEach(
|
||||
dsId -> eventPublisher.publishEvent(new DistributionSetDeletedEvent(tenantAware.getCurrentTenant(),
|
||||
dsId, JpaDistributionSet.class.getName(), applicationContext.getId())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -316,7 +310,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
throw new EntityNotFoundException("Not all given software modules where found.");
|
||||
}
|
||||
|
||||
checkDistributionSetIsAssignedToTargets(set);
|
||||
checkDistributionSetIsAssignedToTargets(setId);
|
||||
|
||||
modules.forEach(set::addModule);
|
||||
|
||||
@@ -330,7 +324,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
final JpaDistributionSet set = findDistributionSetAndThrowExceptionIfNotFound(setId);
|
||||
final JpaSoftwareModule module = findSoftwareModuleAndThrowExceptionIfNotFound(moduleId);
|
||||
|
||||
checkDistributionSetIsAssignedToTargets(set);
|
||||
checkDistributionSetIsAssignedToTargets(setId);
|
||||
|
||||
set.removeModule(module);
|
||||
|
||||
@@ -349,7 +343,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
update.getColour().ifPresent(type::setColour);
|
||||
|
||||
if (hasModules(update)) {
|
||||
checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(type);
|
||||
checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(update.getId());
|
||||
|
||||
update.getMandatory().ifPresent(
|
||||
mand -> softwareModuleTypeRepository.findByIdIn(mand).forEach(type::addMandatoryModuleType));
|
||||
@@ -378,7 +372,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
throw new EntityNotFoundException("Not all given software module types where found.");
|
||||
}
|
||||
|
||||
checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(type);
|
||||
checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(dsTypeId);
|
||||
|
||||
modules.forEach(type::addMandatoryModuleType);
|
||||
|
||||
@@ -399,18 +393,17 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
throw new EntityNotFoundException("Not all given software module types where found.");
|
||||
}
|
||||
|
||||
checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(type);
|
||||
checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(dsTypeId);
|
||||
|
||||
modules.forEach(type::addOptionalModuleType);
|
||||
|
||||
return distributionSetTypeRepository.save(type);
|
||||
}
|
||||
|
||||
private void checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(final JpaDistributionSetType type) {
|
||||
if (distributionSetRepository.countByType(type) > 0) {
|
||||
private void checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(final Long type) {
|
||||
if (distributionSetRepository.countByTypeId(type) > 0) {
|
||||
throw new EntityReadOnlyException(String.format(
|
||||
"distribution set type %s is already assigned to distribution sets and cannot be changed",
|
||||
type.getName()));
|
||||
"distribution set type %s is already assigned to distribution sets and cannot be changed", type));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -421,7 +414,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
public DistributionSetType unassignSoftwareModuleType(final Long dsTypeId, final Long softwareModuleTypeId) {
|
||||
final JpaDistributionSetType type = findDistributionSetTypeAndThrowExceptionIfNotFound(dsTypeId);
|
||||
|
||||
checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(type);
|
||||
checkDistributionSetTypeSoftwareModuleTypesIsAllowedToModify(dsTypeId);
|
||||
|
||||
type.removeModuleType(softwareModuleTypeId);
|
||||
|
||||
@@ -604,15 +597,17 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public void deleteDistributionSetType(final DistributionSetType ty) {
|
||||
final JpaDistributionSetType type = (JpaDistributionSetType) ty;
|
||||
public void deleteDistributionSetType(final Long typeId) {
|
||||
|
||||
if (distributionSetRepository.countByType(type) > 0) {
|
||||
final JpaDistributionSetType toDelete = entityManager.merge(type);
|
||||
final JpaDistributionSetType toDelete = Optional.ofNullable(distributionSetTypeRepository.findOne(typeId))
|
||||
.orElseThrow(() -> new EntityNotFoundException(
|
||||
"DistributionSet Type with given ID " + typeId + " does not exist"));
|
||||
|
||||
if (distributionSetRepository.countByTypeId(typeId) > 0) {
|
||||
toDelete.setDeleted(true);
|
||||
distributionSetTypeRepository.save(toDelete);
|
||||
} else {
|
||||
distributionSetTypeRepository.delete(type.getId());
|
||||
distributionSetTypeRepository.delete(typeId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -725,13 +720,13 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributionSet findDistributionSetByAction(final Action action) {
|
||||
return distributionSetRepository.findByAction((JpaAction) action);
|
||||
public DistributionSet findDistributionSetByAction(final Long actionId) {
|
||||
return distributionSetRepository.findByActionId(actionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDistributionSetInUse(final DistributionSet distributionSet) {
|
||||
return actionRepository.countByDistributionSet((JpaDistributionSet) distributionSet) > 0;
|
||||
public boolean isDistributionSetInUse(final Long setId) {
|
||||
return actionRepository.countByDistributionSetId(setId) > 0;
|
||||
}
|
||||
|
||||
private static List<Specification<JpaDistributionSet>> buildDistributionSetSpecifications(
|
||||
@@ -776,11 +771,10 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
return specList;
|
||||
}
|
||||
|
||||
private void checkDistributionSetIsAssignedToTargets(final JpaDistributionSet distributionSet) {
|
||||
if (actionRepository.countByDistributionSet(distributionSet) > 0) {
|
||||
throw new EntityReadOnlyException(
|
||||
String.format("distribution set %s:%s is already assigned to targets and cannot be changed",
|
||||
distributionSet.getName(), distributionSet.getVersion()));
|
||||
private void checkDistributionSetIsAssignedToTargets(final Long distributionSet) {
|
||||
if (actionRepository.countByDistributionSetId(distributionSet) > 0) {
|
||||
throw new EntityReadOnlyException(String.format(
|
||||
"distribution set %s is already assigned to targets and cannot be changed", distributionSet));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -822,10 +816,15 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public List<DistributionSet> assignTag(final Collection<Long> dsIds, final DistributionSetTag tag) {
|
||||
public List<DistributionSet> assignTag(final Collection<Long> dsIds, final Long dsTagId) {
|
||||
final List<JpaDistributionSet> allDs = findDistributionSetListWithDetails(dsIds);
|
||||
|
||||
allDs.forEach(ds -> ds.addTag(tag));
|
||||
final DistributionSetTag distributionSetTag = Optional
|
||||
.ofNullable(tagManagement.findDistributionSetTagById(dsTagId))
|
||||
.orElseThrow(() -> new EntityNotFoundException(
|
||||
"DistributionSet Tag with given ID " + dsTagId + " not found."));
|
||||
|
||||
allDs.forEach(ds -> ds.addTag(distributionSetTag));
|
||||
|
||||
return Collections
|
||||
.unmodifiableList(allDs.stream().map(distributionSetRepository::save).collect(Collectors.toList()));
|
||||
@@ -834,19 +833,34 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public List<DistributionSet> unAssignAllDistributionSetsByTag(final DistributionSetTag tag) {
|
||||
public List<DistributionSet> unAssignAllDistributionSetsByTag(final Long dsTagId) {
|
||||
|
||||
final DistributionSetTag distributionSetTag = Optional
|
||||
.ofNullable(tagManagement.findDistributionSetTagById(dsTagId))
|
||||
.orElseThrow(() -> new EntityNotFoundException(
|
||||
"DistributionSet Tag with given ID " + dsTagId + " not found."));
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
final Collection<JpaDistributionSet> distributionSets = (Collection) tag.getAssignedToDistributionSet();
|
||||
final Collection<JpaDistributionSet> distributionSets = (Collection) distributionSetTag
|
||||
.getAssignedToDistributionSet();
|
||||
|
||||
return Collections.unmodifiableList(unAssignTag(distributionSets, tag));
|
||||
return Collections.unmodifiableList(unAssignTag(distributionSets, distributionSetTag));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public DistributionSet unAssignTag(final Long dsId, final DistributionSetTag distributionSetTag) {
|
||||
public DistributionSet unAssignTag(final Long dsId, final Long dsTagId) {
|
||||
final List<JpaDistributionSet> allDs = findDistributionSetListWithDetails(Arrays.asList(dsId));
|
||||
|
||||
if (allDs.isEmpty()) {
|
||||
throw new EntityNotFoundException("DistributionSet with given ID " + dsId + " not found.");
|
||||
}
|
||||
|
||||
final DistributionSetTag distributionSetTag = Optional
|
||||
.ofNullable(tagManagement.findDistributionSetTagById(dsTagId))
|
||||
.orElseThrow(() -> new EntityNotFoundException(
|
||||
"DistributionSet Tag with given ID " + dsTagId + " not found."));
|
||||
final List<JpaDistributionSet> unAssignTag = unAssignTag(allDs, distributionSetTag);
|
||||
return unAssignTag.isEmpty() ? null : unAssignTag.get(0);
|
||||
}
|
||||
@@ -869,22 +883,17 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public void deleteDistributionSet(final DistributionSet set) {
|
||||
deleteDistributionSet(set.getId());
|
||||
public void deleteDistributionSet(final Long setId) {
|
||||
if (!distributionSetRepository.exists(setId)) {
|
||||
throw new EntityNotFoundException("DistributionSet with given ID " + setId + " does not exist.");
|
||||
}
|
||||
|
||||
deleteDistributionSet(Lists.newArrayList(setId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public DistributionSetTagAssignmentResult toggleTagAssignment(final Collection<DistributionSet> sets,
|
||||
final DistributionSetTag tag) {
|
||||
return toggleTagAssignment(sets.stream().map(DistributionSet::getId).collect(Collectors.toList()),
|
||||
tag.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countDistributionSetsByType(final DistributionSetType type) {
|
||||
return distributionSetRepository.countByType((JpaDistributionSetType) type);
|
||||
public Long countDistributionSetsByType(final Long typeId) {
|
||||
return distributionSetRepository.countByTypeId(typeId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository.jpa;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
@@ -25,6 +26,7 @@ import javax.validation.constraints.NotNull;
|
||||
import org.eclipse.hawkbit.repository.RolloutGroupFields;
|
||||
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetFields;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaAction_;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup;
|
||||
@@ -149,7 +151,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findRolloutGroupTargets(final RolloutGroup rolloutGroup, final String rsqlParam,
|
||||
public Page<Target> findRolloutGroupTargets(final Long rolloutGroupId, final String rsqlParam,
|
||||
final Pageable pageable) {
|
||||
|
||||
final Specification<JpaTarget> rsqlSpecification = RSQLUtility.parse(rsqlParam, TargetFields.class,
|
||||
@@ -158,19 +160,25 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
return convertTPage(targetRepository.findAll((root, query, criteriaBuilder) -> {
|
||||
final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = root.join(JpaTarget_.rolloutTargetGroup);
|
||||
return criteriaBuilder.and(rsqlSpecification.toPredicate(root, query, criteriaBuilder),
|
||||
criteriaBuilder.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup), rolloutGroup));
|
||||
criteriaBuilder.equal(
|
||||
rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id),
|
||||
rolloutGroupId));
|
||||
}, pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findRolloutGroupTargets(final RolloutGroup rolloutGroup, final Pageable page) {
|
||||
public Page<Target> findRolloutGroupTargets(final Long rolloutGroupId, final Pageable page) {
|
||||
final JpaRolloutGroup rolloutGroup = Optional.ofNullable(rolloutGroupRepository.findOne(rolloutGroupId))
|
||||
.orElseThrow(() -> new EntityNotFoundException(
|
||||
"Rollout Group with given ID " + rolloutGroupId + " not found."));
|
||||
|
||||
if (isRolloutStatusReady(rolloutGroup)) {
|
||||
// in case of status ready the action has not been created yet and
|
||||
// the relation information between target and rollout-group is
|
||||
// stored in the #TargetRolloutGroup.
|
||||
return targetRepository.findByRolloutTargetGroupRolloutGroupId(rolloutGroup.getId(), page);
|
||||
return targetRepository.findByRolloutTargetGroupRolloutGroupId(rolloutGroupId, page);
|
||||
}
|
||||
return targetRepository.findByActionsRolloutGroup((JpaRolloutGroup) rolloutGroup, page);
|
||||
return targetRepository.findByActionsRolloutGroupId(rolloutGroupId, page);
|
||||
}
|
||||
|
||||
private static boolean isRolloutStatusReady(final RolloutGroup rolloutGroup) {
|
||||
@@ -179,7 +187,7 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
|
||||
@Override
|
||||
public Page<TargetWithActionStatus> findAllTargetsWithActionStatus(final PageRequest pageRequest,
|
||||
final RolloutGroup rolloutGroup) {
|
||||
final Long rolloutGroupId) {
|
||||
|
||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
||||
@@ -193,12 +201,13 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
|
||||
final Root<RolloutTargetGroup> countQueryFrom = countQuery.distinct(true).from(RolloutTargetGroup.class);
|
||||
countQueryFrom.join(RolloutTargetGroup_.target);
|
||||
countQueryFrom.join(RolloutTargetGroup_.actions, JoinType.LEFT);
|
||||
countQuery.select(cb.count(countQueryFrom))
|
||||
.where(cb.equal(countQueryFrom.get(RolloutTargetGroup_.rolloutGroup), rolloutGroup));
|
||||
countQuery.select(cb.count(countQueryFrom)).where(cb
|
||||
.equal(countQueryFrom.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id), rolloutGroupId));
|
||||
final Long totalCount = entityManager.createQuery(countQuery).getSingleResult();
|
||||
|
||||
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetJoin, actionJoin.get(JpaAction_.status))
|
||||
.where(cb.equal(targetRoot.get(RolloutTargetGroup_.rolloutGroup), rolloutGroup));
|
||||
.where(cb.equal(targetRoot.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id),
|
||||
rolloutGroupId));
|
||||
final List<TargetWithActionStatus> targetWithActionStatus = entityManager.createQuery(multiselect)
|
||||
.setFirstResult(pageRequest.getOffset()).setMaxResults(pageRequest.getPageSize()).getResultList()
|
||||
.stream().map(o -> new TargetWithActionStatus((Target) o[0], (Action.Status) o[1]))
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -32,6 +33,7 @@ import org.eclipse.hawkbit.repository.exception.ConstraintViolationException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.RolloutIllegalStateException;
|
||||
import org.eclipse.hawkbit.repository.jpa.executor.AfterTransactionCommitExecutor;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaRollout;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaRollout_;
|
||||
@@ -41,6 +43,7 @@ import org.eclipse.hawkbit.repository.jpa.rollout.condition.RolloutGroupConditio
|
||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
|
||||
@@ -336,8 +339,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
groupTargetFilter = baseFilter + ";" + group.getTargetFilterQuery();
|
||||
}
|
||||
|
||||
final List<RolloutGroup> readyGroups = RolloutHelper.getGroupsByStatusIncludingGroup(rollout,
|
||||
RolloutGroupStatus.READY, group);
|
||||
final List<Long> readyGroups = RolloutHelper.getGroupsByStatusIncludingGroup(rollout, RolloutGroupStatus.READY,
|
||||
group);
|
||||
|
||||
final long targetsInGroupFilter = targetManagement
|
||||
.countAllTargetsByTargetFilterQueryAndNotInRolloutGroups(readyGroups, groupTargetFilter);
|
||||
@@ -383,7 +386,7 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
|
||||
return runInNewCountingTransaction("assignTargetsToRolloutGroup", status -> {
|
||||
final PageRequest pageRequest = new PageRequest(0, Math.toIntExact(limit));
|
||||
final List<RolloutGroup> readyGroups = RolloutHelper.getGroupsByStatusIncludingGroup(rollout,
|
||||
final List<Long> readyGroups = RolloutHelper.getGroupsByStatusIncludingGroup(rollout,
|
||||
RolloutGroupStatus.READY, group);
|
||||
final Page<Target> targets = targetManagement
|
||||
.findAllTargetsByTargetFilterQueryAndNotInRolloutGroups(pageRequest, readyGroups, targetFilter);
|
||||
@@ -558,16 +561,57 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
final ActionType actionType = rollout.getActionType();
|
||||
final long forceTime = rollout.getForcedTime();
|
||||
|
||||
final Page<Target> targets = targetManagement.findAllTargetsInRolloutGroupWithoutAction(pageRequest, group);
|
||||
final Page<Target> targets = targetManagement.findAllTargetsInRolloutGroupWithoutAction(pageRequest,
|
||||
groupId);
|
||||
if (targets.getTotalElements() > 0) {
|
||||
deploymentManagement.createScheduledAction(targets.getContent(), distributionSet, actionType, forceTime,
|
||||
rollout, group);
|
||||
createScheduledAction(targets.getContent(), distributionSet, actionType, forceTime, rollout, group);
|
||||
}
|
||||
|
||||
return targets.getNumberOfElements();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an action entry into the action repository. In case of existing
|
||||
* scheduled actions the scheduled actions gets canceled. A scheduled action
|
||||
* is created in-active.
|
||||
*
|
||||
* @param targets
|
||||
* the targets to create scheduled actions for
|
||||
* @param distributionSet
|
||||
* the distribution set for the actions
|
||||
* @param actionType
|
||||
* the action type for the action
|
||||
* @param forcedTime
|
||||
* the forcedTime of the action
|
||||
* @param rollout
|
||||
* the roll out for this action
|
||||
* @param rolloutGroup
|
||||
* the roll out group for this action
|
||||
*/
|
||||
private void createScheduledAction(final Collection<Target> targets, final DistributionSet distributionSet,
|
||||
final ActionType actionType, final Long forcedTime, final Rollout rollout,
|
||||
final RolloutGroup rolloutGroup) {
|
||||
// cancel all current scheduled actions for this target. E.g. an action
|
||||
// is already scheduled and a next action is created then cancel the
|
||||
// current scheduled action to cancel. E.g. a new scheduled action is
|
||||
// created.
|
||||
final List<Long> targetIds = targets.stream().map(t -> t.getId()).collect(Collectors.toList());
|
||||
actionRepository.switchStatus(Action.Status.CANCELED, targetIds, false, Action.Status.SCHEDULED);
|
||||
targets.forEach(target -> {
|
||||
final JpaAction action = new JpaAction();
|
||||
action.setTarget(target);
|
||||
action.setActive(false);
|
||||
action.setDistributionSet(distributionSet);
|
||||
action.setActionType(actionType);
|
||||
action.setForcedTime(forcedTime);
|
||||
action.setStatus(Status.SCHEDULED);
|
||||
action.setRollout(rollout);
|
||||
action.setRolloutGroup(rolloutGroup);
|
||||
actionRepository.save(action);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
@Modifying
|
||||
@@ -903,7 +947,11 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFinishedPercentForRunningGroup(final Long rolloutId, final RolloutGroup rolloutGroup) {
|
||||
public float getFinishedPercentForRunningGroup(final Long rolloutId, final Long rolloutGroupId) {
|
||||
final RolloutGroup rolloutGroup = Optional.ofNullable(rolloutGroupRepository.findOne(rolloutGroupId))
|
||||
.orElseThrow(() -> new EntityNotFoundException(
|
||||
"Rollout group with given ID " + rolloutGroupId + " not found."));
|
||||
|
||||
final long totalGroup = rolloutGroup.getTotalTargets();
|
||||
final Long finished = actionRepository.countByRolloutIdAndRolloutGroupIdAndStatus(rolloutId,
|
||||
rolloutGroup.getId(), Action.Status.FINISHED);
|
||||
|
||||
@@ -55,7 +55,6 @@ import org.eclipse.hawkbit.repository.jpa.specifications.SoftwareModuleSpecifica
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.SpecificationsBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.AssignedSoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.MetaData;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
@@ -204,9 +203,9 @@ public class JpaSoftwareManagement implements SoftwareManagement {
|
||||
|
||||
@Override
|
||||
public SoftwareModule findSoftwareModuleByNameAndVersion(final String name, final String version,
|
||||
final SoftwareModuleType type) {
|
||||
final Long typeId) {
|
||||
|
||||
return softwareModuleRepository.findOneByNameAndVersionAndType(name, version, (JpaSoftwareModuleType) type);
|
||||
return softwareModuleRepository.findOneByNameAndVersionAndTypeId(name, version, typeId);
|
||||
}
|
||||
|
||||
private boolean isUnassigned(final JpaSoftwareModule bsmMerged) {
|
||||
@@ -225,7 +224,7 @@ public class JpaSoftwareManagement implements SoftwareManagement {
|
||||
|
||||
private void deleteGridFsArtifacts(final JpaSoftwareModule swModule) {
|
||||
for (final Artifact localArtifact : swModule.getArtifacts()) {
|
||||
artifactManagement.clearArtifactBinary(localArtifact);
|
||||
artifactManagement.clearArtifactBinary(localArtifact.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,22 +491,23 @@ public class JpaSoftwareManagement implements SoftwareManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public void deleteSoftwareModuleType(final SoftwareModuleType ty) {
|
||||
final JpaSoftwareModuleType type = (JpaSoftwareModuleType) ty;
|
||||
public void deleteSoftwareModuleType(final Long typeId) {
|
||||
final JpaSoftwareModuleType toDelete = Optional.ofNullable(softwareModuleTypeRepository.findOne(typeId))
|
||||
.orElseThrow(() -> new EntityNotFoundException(
|
||||
"Software Module Type with giben ID " + typeId + " does not exist."));
|
||||
|
||||
if (softwareModuleRepository.countByType(type) > 0
|
||||
|| distributionSetTypeRepository.countByElementsSmType(type) > 0) {
|
||||
final JpaSoftwareModuleType toDelete = entityManager.merge(type);
|
||||
if (softwareModuleRepository.countByType(toDelete) > 0
|
||||
|| distributionSetTypeRepository.countByElementsSmType(toDelete) > 0) {
|
||||
toDelete.setDeleted(true);
|
||||
softwareModuleTypeRepository.save(toDelete);
|
||||
} else {
|
||||
softwareModuleTypeRepository.delete(type.getId());
|
||||
softwareModuleTypeRepository.delete(toDelete);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SoftwareModule> findSoftwareModuleByAssignedTo(final Pageable pageable, final DistributionSet set) {
|
||||
return softwareModuleRepository.findByAssignedTo(pageable, (JpaDistributionSet) set);
|
||||
public Page<SoftwareModule> findSoftwareModuleByAssignedTo(final Pageable pageable, final Long setId) {
|
||||
return softwareModuleRepository.findByAssignedToId(pageable, setId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -97,7 +97,7 @@ public class JpaTagManagement implements TagManagement {
|
||||
public void deleteTargetTag(final String targetTagName) {
|
||||
final JpaTargetTag tag = targetTagRepository.findByNameEquals(targetTagName);
|
||||
|
||||
targetRepository.findByTag(tag).forEach(set -> {
|
||||
targetRepository.findByTag(tag.getId()).forEach(set -> {
|
||||
set.removeTag(tag);
|
||||
targetRepository.save(set);
|
||||
});
|
||||
|
||||
@@ -13,8 +13,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetFields;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryFields;
|
||||
@@ -45,6 +43,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* JPA implementation of {@link TargetFilterQueryManagement}.
|
||||
@@ -54,18 +53,24 @@ import com.google.common.base.Strings;
|
||||
@Validated
|
||||
public class JpaTargetFilterQueryManagement implements TargetFilterQueryManagement {
|
||||
|
||||
@Autowired
|
||||
private TargetFilterQueryRepository targetFilterQueryRepository;
|
||||
private final TargetFilterQueryRepository targetFilterQueryRepository;
|
||||
|
||||
private final VirtualPropertyReplacer virtualPropertyReplacer;
|
||||
|
||||
private final DistributionSetManagement distributionSetManagement;
|
||||
|
||||
@Autowired
|
||||
private VirtualPropertyReplacer virtualPropertyReplacer;
|
||||
JpaTargetFilterQueryManagement(final TargetFilterQueryRepository targetFilterQueryRepository,
|
||||
final VirtualPropertyReplacer virtualPropertyReplacer,
|
||||
final DistributionSetManagement distributionSetManagement) {
|
||||
this.targetFilterQueryRepository = targetFilterQueryRepository;
|
||||
this.virtualPropertyReplacer = virtualPropertyReplacer;
|
||||
this.distributionSetManagement = distributionSetManagement;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private DistributionSetManagement distributionSetManagement;
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
@Override
|
||||
public TargetFilterQuery createTargetFilterQuery(final TargetFilterQueryCreate c) {
|
||||
final JpaTargetFilterQueryCreate create = (JpaTargetFilterQueryCreate) c;
|
||||
|
||||
@@ -109,8 +114,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetFilterQuery> findTargetFilterQueryByFilter(@NotNull final Pageable pageable,
|
||||
final String rsqlFilter) {
|
||||
public Page<TargetFilterQuery> findTargetFilterQueryByFilter(final Pageable pageable, final String rsqlFilter) {
|
||||
List<Specification<JpaTargetFilterQuery>> specList = Collections.emptyList();
|
||||
if (!Strings.isNullOrEmpty(rsqlFilter)) {
|
||||
specList = Collections.singletonList(
|
||||
@@ -120,18 +124,14 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(@NotNull final Pageable pageable,
|
||||
final DistributionSet distributionSet) {
|
||||
return findTargetFilterQueryByAutoAssignDS(pageable, distributionSet, null);
|
||||
}
|
||||
public Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(final Pageable pageable, final Long setId,
|
||||
final String rsqlFilter) {
|
||||
final List<Specification<JpaTargetFilterQuery>> specList = Lists.newArrayListWithExpectedSize(2);
|
||||
|
||||
final DistributionSet distributionSet = findDistributionSetAndThrowExceptionIfNotFound(setId);
|
||||
|
||||
specList.add(TargetFilterQuerySpecification.byAutoAssignDS(distributionSet));
|
||||
|
||||
@Override
|
||||
public Page<TargetFilterQuery> findTargetFilterQueryByAutoAssignDS(@NotNull final Pageable pageable,
|
||||
final DistributionSet distributionSet, final String rsqlFilter) {
|
||||
final List<Specification<JpaTargetFilterQuery>> specList = new ArrayList<>(2);
|
||||
if (distributionSet != null) {
|
||||
specList.add(TargetFilterQuerySpecification.byAutoAssignDS(distributionSet));
|
||||
}
|
||||
if (!Strings.isNullOrEmpty(rsqlFilter)) {
|
||||
specList.add(RSQLUtility.parse(rsqlFilter, TargetFilterQueryFields.class, virtualPropertyReplacer));
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<TargetFilterQuery> findTargetFilterQueryWithAutoAssignDS(@NotNull final Pageable pageable) {
|
||||
public Page<TargetFilterQuery> findTargetFilterQueryWithAutoAssignDS(final Pageable pageable) {
|
||||
final List<Specification<JpaTargetFilterQuery>> specList = Collections
|
||||
.singletonList(TargetFilterQuerySpecification.withAutoAssignDS());
|
||||
return convertPage(findTargetFilterQueryByCriteriaAPI(pageable, specList), pageable);
|
||||
|
||||
@@ -49,7 +49,6 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaTarget_;
|
||||
import org.eclipse.hawkbit.repository.jpa.rsql.RSQLUtility;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.SpecificationsBuilder;
|
||||
import org.eclipse.hawkbit.repository.jpa.specifications.TargetSpecifications;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
||||
@@ -90,6 +89,9 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Autowired
|
||||
private TargetRepository targetRepository;
|
||||
|
||||
@Autowired
|
||||
private TargetFilterQueryRepository targetFilterQueryRepository;
|
||||
|
||||
@Autowired
|
||||
private TargetTagRepository targetTagRepository;
|
||||
|
||||
@@ -160,7 +162,12 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Target> findTargetsAll(final TargetFilterQuery targetFilterQuery, final Pageable pageable) {
|
||||
public Slice<Target> findTargetsByTargetFilterQuery(final Long targetFilterQueryId, final Pageable pageable) {
|
||||
final TargetFilterQuery targetFilterQuery = Optional
|
||||
.ofNullable(targetFilterQueryRepository.findOne(targetFilterQueryId))
|
||||
.orElseThrow(() -> new EntityNotFoundException(
|
||||
"TargetFilterQuery with given ID" + targetFilterQueryId + " not found"));
|
||||
|
||||
return findTargetsBySpec(
|
||||
RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class, virtualPropertyReplacer), pageable);
|
||||
}
|
||||
@@ -203,13 +210,6 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
return targetRepository.save(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public void deleteTargets(final Long... targetIDs) {
|
||||
deleteTargets(Lists.newArrayList(targetIDs));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
@@ -220,6 +220,18 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
targetId, JpaTarget.class.getName(), applicationContext.getId())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public void deleteTarget(final String controllerID) {
|
||||
final Long targetId = Optional.ofNullable(targetRepository.findByControllerId(controllerID))
|
||||
.orElseThrow(
|
||||
() -> new EntityNotFoundException("Target with given ID " + controllerID + " does not exist."))
|
||||
.getId();
|
||||
|
||||
targetRepository.delete(targetId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findTargetByAssignedDistributionSet(final Long distributionSetID, final Pageable pageReq) {
|
||||
return targetRepository.findByAssignedDistributionSetId(pageReq, distributionSetID);
|
||||
@@ -340,14 +352,6 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
return targetRepository.count(SpecificationsBuilder.combineWithAnd(specList));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public TargetTagAssignmentResult toggleTagAssignment(final Collection<Target> targets, final TargetTag tag) {
|
||||
return toggleTagAssignment(
|
||||
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), tag.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
@@ -384,10 +388,13 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public List<Target> assignTag(final Collection<String> controllerIds, final TargetTag tag) {
|
||||
public List<Target> assignTag(final Collection<String> controllerIds, final Long tagId) {
|
||||
final List<JpaTarget> allTargets = targetRepository
|
||||
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(controllerIds));
|
||||
|
||||
final JpaTargetTag tag = Optional.ofNullable(targetTagRepository.findOne(tagId))
|
||||
.orElseThrow(() -> new EntityNotFoundException("Tag with given ID " + tagId + "does not exist"));
|
||||
|
||||
allTargets.forEach(target -> target.addTag(tag));
|
||||
return Collections
|
||||
.unmodifiableList(allTargets.stream().map(targetRepository::save).collect(Collectors.toList()));
|
||||
@@ -406,17 +413,29 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public List<Target> unAssignAllTargetsByTag(final TargetTag tag) {
|
||||
public List<Target> unAssignAllTargetsByTag(final Long targetTagId) {
|
||||
|
||||
final TargetTag tag = Optional.ofNullable(targetTagRepository.findOne(targetTagId)).orElseThrow(
|
||||
() -> new EntityNotFoundException("TargetTag with given ID " + targetTagId + " does not exist."));
|
||||
|
||||
if (tag.getAssignedToTargets().isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return unAssignTag(tag.getAssignedToTargets(), tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||
public Target unAssignTag(final String controllerID, final TargetTag targetTag) {
|
||||
public Target unAssignTag(final String controllerID, final Long targetTagId) {
|
||||
final List<Target> allTargets = Collections.unmodifiableList(targetRepository
|
||||
.findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(Arrays.asList(controllerID))));
|
||||
final List<Target> unAssignTag = unAssignTag(allTargets, targetTag);
|
||||
|
||||
final TargetTag tag = Optional.ofNullable(targetTagRepository.findOne(targetTagId)).orElseThrow(
|
||||
() -> new EntityNotFoundException("TargetTag with given ID " + targetTagId + " does not exist."));
|
||||
|
||||
final List<Target> unAssignTag = unAssignTag(allTargets, tag);
|
||||
return unAssignTag.isEmpty() ? null : unAssignTag.get(0);
|
||||
}
|
||||
|
||||
@@ -489,16 +508,6 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
return targetRepository.countByTargetInfoInstalledDistributionSetId(distId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TargetIdName> findAllTargetIds() {
|
||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
final CriteriaQuery<TargetIdName> query = cb.createQuery(TargetIdName.class);
|
||||
final Root<JpaTarget> targetRoot = query.from(JpaTarget.class);
|
||||
return entityManager.createQuery(query.multiselect(targetRoot.get(JpaTarget_.id),
|
||||
targetRoot.get(JpaTarget_.controllerId), targetRoot.get(JpaTarget_.name))).getResultList();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TargetIdName> findAllTargetIdsByFilters(final Pageable pageRequest,
|
||||
final Collection<TargetUpdateStatus> filterByStatus, final Boolean overdueState,
|
||||
@@ -535,7 +544,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
public List<TargetIdName> findAllTargetIdsByTargetFilterQuery(final Pageable pageRequest,
|
||||
final TargetFilterQuery targetFilterQuery) {
|
||||
final String targetFilterQuery) {
|
||||
final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
final CriteriaQuery<Object[]> query = cb.createQuery(Object[].class);
|
||||
final Root<JpaTarget> targetRoot = query.from(JpaTarget.class);
|
||||
@@ -548,7 +557,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
final CriteriaQuery<Object[]> multiselect = query.multiselect(targetRoot.get(JpaTarget_.id),
|
||||
targetRoot.get(JpaTarget_.controllerId), targetRoot.get(JpaTarget_.name), targetRoot.get(sortProperty));
|
||||
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class,
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||
virtualPropertyReplacer);
|
||||
final Predicate[] specificationsForMultiSelect = specificationsToPredicate(Lists.newArrayList(spec), targetRoot,
|
||||
multiselect, cb);
|
||||
@@ -565,9 +574,9 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
public Page<Target> findAllTargetsByTargetFilterQueryAndNonDS(@NotNull final Pageable pageRequest,
|
||||
final Long distributionSetId, @NotNull final TargetFilterQuery targetFilterQuery) {
|
||||
final Long distributionSetId, @NotNull final String targetFilterQuery) {
|
||||
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class,
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||
virtualPropertyReplacer);
|
||||
|
||||
return findTargetsBySpec(
|
||||
@@ -579,8 +588,8 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Target> findAllTargetsByTargetFilterQueryAndNotInRolloutGroups(@NotNull final Pageable pageRequest,
|
||||
final List<RolloutGroup> groups, @NotNull final String targetFilterQuery) {
|
||||
public Page<Target> findAllTargetsByTargetFilterQueryAndNotInRolloutGroups(final Pageable pageRequest,
|
||||
final Collection<Long> groups, final String targetFilterQuery) {
|
||||
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||
virtualPropertyReplacer);
|
||||
@@ -592,28 +601,26 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
|
||||
@Override
|
||||
public Page<Target> findAllTargetsInRolloutGroupWithoutAction(@NotNull final Pageable pageRequest,
|
||||
@NotNull final RolloutGroup group) {
|
||||
@NotNull final Long group) {
|
||||
return findTargetsBySpec(
|
||||
(root, cq, cb) -> TargetSpecifications.hasNoActionInRolloutGroup(group).toPredicate(root, cq, cb),
|
||||
pageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countAllTargetsByTargetFilterQueryAndNotInRolloutGroups(final List<RolloutGroup> groups,
|
||||
@NotNull final String targetFilterQuery) {
|
||||
public Long countAllTargetsByTargetFilterQueryAndNotInRolloutGroups(final Collection<Long> groups,
|
||||
final String targetFilterQuery) {
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||
virtualPropertyReplacer);
|
||||
final List<Specification<JpaTarget>> specList = new ArrayList<>(2);
|
||||
specList.add(spec);
|
||||
specList.add(TargetSpecifications.isNotInRolloutGroups(groups));
|
||||
final List<Specification<JpaTarget>> specList = Lists.newArrayList(spec,
|
||||
TargetSpecifications.isNotInRolloutGroups(groups));
|
||||
|
||||
return countByCriteriaAPI(specList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countTargetsByTargetFilterQueryAndNonDS(final Long distributionSetId,
|
||||
@NotNull final TargetFilterQuery targetFilterQuery) {
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class,
|
||||
public Long countTargetsByTargetFilterQueryAndNonDS(final Long distributionSetId, final String targetFilterQuery) {
|
||||
final Specification<JpaTarget> spec = RSQLUtility.parse(targetFilterQuery, TargetFields.class,
|
||||
virtualPropertyReplacer);
|
||||
final List<Specification<JpaTarget>> specList = new ArrayList<>(2);
|
||||
specList.add(spec);
|
||||
@@ -654,11 +661,16 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Override
|
||||
public List<Target> findTargetsByTag(final String tagName) {
|
||||
final JpaTargetTag tag = targetTagRepository.findByNameEquals(tagName);
|
||||
return Collections.unmodifiableList(targetRepository.findByTag(tag));
|
||||
return Collections.unmodifiableList(targetRepository.findByTag(tag.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countTargetByTargetFilterQuery(final TargetFilterQuery targetFilterQuery) {
|
||||
public Long countTargetByTargetFilterQuery(final Long targetFilterQueryId) {
|
||||
final TargetFilterQuery targetFilterQuery = Optional
|
||||
.ofNullable(targetFilterQueryRepository.findOne(targetFilterQueryId))
|
||||
.orElseThrow(() -> new EntityNotFoundException(
|
||||
"TargetFilterQuery with given ID" + targetFilterQueryId + " not found"));
|
||||
|
||||
final Specification<JpaTarget> specs = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class,
|
||||
virtualPropertyReplacer);
|
||||
return targetRepository.count(specs);
|
||||
|
||||
@@ -61,6 +61,7 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.repository.model.helper.SystemManagementHolder;
|
||||
import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder;
|
||||
import org.eclipse.hawkbit.repository.rsql.RsqlValidationOracle;
|
||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||
@@ -354,13 +355,24 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
||||
|
||||
/**
|
||||
* {@link JpaTargetFilterQueryManagement} bean.
|
||||
*
|
||||
* @param targetFilterQueryRepository
|
||||
* to query entity access
|
||||
* @param virtualPropertyReplacer
|
||||
* for RSQL handling
|
||||
* @param distributionSetManagement
|
||||
* for auto assign DS access
|
||||
*
|
||||
* @return a new {@link TargetFilterQueryManagement}
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public TargetFilterQueryManagement targetFilterQueryManagement() {
|
||||
return new JpaTargetFilterQueryManagement();
|
||||
public TargetFilterQueryManagement targetFilterQueryManagement(
|
||||
final TargetFilterQueryRepository targetFilterQueryRepository,
|
||||
final VirtualPropertyReplacer virtualPropertyReplacer,
|
||||
final DistributionSetManagement distributionSetManagement) {
|
||||
return new JpaTargetFilterQueryManagement(targetFilterQueryRepository, virtualPropertyReplacer,
|
||||
distributionSetManagement);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -176,11 +176,11 @@ final class RolloutHelper {
|
||||
* the group to add
|
||||
* @return list of groups
|
||||
*/
|
||||
static List<RolloutGroup> getGroupsByStatusIncludingGroup(final Rollout rollout,
|
||||
static List<Long> getGroupsByStatusIncludingGroup(final Rollout rollout,
|
||||
final RolloutGroup.RolloutGroupStatus status, final RolloutGroup group) {
|
||||
return rollout.getRolloutGroups().stream()
|
||||
.filter(innerGroup -> innerGroup.getStatus().equals(status) || innerGroup.equals(group))
|
||||
.collect(Collectors.toList());
|
||||
.map(RolloutGroup::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,12 +50,12 @@ public interface SoftwareModuleRepository
|
||||
* to be filtered on
|
||||
* @param version
|
||||
* to be filtered on
|
||||
* @param type
|
||||
* @param typeId
|
||||
* to be filtered on
|
||||
* @return the found {@link SoftwareModule} with the given name AND version
|
||||
* AND type
|
||||
*/
|
||||
JpaSoftwareModule findOneByNameAndVersionAndType(String name, String version, JpaSoftwareModuleType type);
|
||||
JpaSoftwareModule findOneByNameAndVersionAndTypeId(String name, String version, Long typeId);
|
||||
|
||||
/**
|
||||
* deletes the {@link SoftwareModule}s with the given IDs.
|
||||
@@ -77,12 +77,12 @@ public interface SoftwareModuleRepository
|
||||
/**
|
||||
* @param pageable
|
||||
* the page request to page the result set
|
||||
* @param set
|
||||
* @param setId
|
||||
* to search for
|
||||
* @return all {@link SoftwareModule}s that are assigned to given
|
||||
* {@link DistributionSet}.
|
||||
*/
|
||||
Page<SoftwareModule> findByAssignedTo(Pageable pageable, JpaDistributionSet set);
|
||||
Page<SoftwareModule> findByAssignedToId(Pageable pageable, Long setId);
|
||||
|
||||
/**
|
||||
* @param pageable
|
||||
|
||||
@@ -12,9 +12,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
@@ -63,12 +61,12 @@ public interface TargetRepository extends BaseEntityRepository<JpaTarget, Long>,
|
||||
/**
|
||||
* Finds {@link Target}s by assigned {@link Tag}.
|
||||
*
|
||||
* @param tag
|
||||
* @param tagId
|
||||
* to be found
|
||||
* @return list of found targets
|
||||
*/
|
||||
@Query(value = "SELECT DISTINCT t FROM JpaTarget t JOIN t.tags tt WHERE tt = :tag")
|
||||
List<JpaTarget> findByTag(@Param("tag") final JpaTargetTag tag);
|
||||
@Query(value = "SELECT DISTINCT t FROM JpaTarget t JOIN t.tags tt WHERE tt.id = :tag")
|
||||
List<JpaTarget> findByTag(@Param("tag") final Long tagId);
|
||||
|
||||
/**
|
||||
* Finds all {@link Target}s based on given {@link Target#getControllerId()}
|
||||
@@ -190,11 +188,11 @@ public interface TargetRepository extends BaseEntityRepository<JpaTarget, Long>,
|
||||
* Finds all targets related to a target rollout group stored for a specific
|
||||
* rollout.
|
||||
*
|
||||
* @param rolloutGroup
|
||||
* @param rolloutGroupId
|
||||
* the rollout group the targets should belong to
|
||||
* @param page
|
||||
* the page request parameter
|
||||
* @return a page of all targets related to a rollout group
|
||||
*/
|
||||
Page<Target> findByActionsRolloutGroup(JpaRolloutGroup rolloutGroup, Pageable page);
|
||||
Page<Target> findByActionsRolloutGroupId(Long rolloutGroupId, Pageable page);
|
||||
}
|
||||
|
||||
@@ -77,8 +77,9 @@ public class AutoAssignChecker {
|
||||
* @param transactionManager
|
||||
* to run transactions
|
||||
*/
|
||||
public AutoAssignChecker(TargetFilterQueryManagement targetFilterQueryManagement, TargetManagement targetManagement,
|
||||
DeploymentManagement deploymentManagement, PlatformTransactionManager transactionManager) {
|
||||
public AutoAssignChecker(final TargetFilterQueryManagement targetFilterQueryManagement,
|
||||
final TargetManagement targetManagement, final DeploymentManagement deploymentManagement,
|
||||
final PlatformTransactionManager transactionManager) {
|
||||
this.targetFilterQueryManagement = targetFilterQueryManagement;
|
||||
this.targetManagement = targetManagement;
|
||||
this.deploymentManagement = deploymentManagement;
|
||||
@@ -97,12 +98,12 @@ public class AutoAssignChecker {
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void check() {
|
||||
|
||||
PageRequest pageRequest = new PageRequest(0, PAGE_SIZE);
|
||||
final PageRequest pageRequest = new PageRequest(0, PAGE_SIZE);
|
||||
|
||||
Page<TargetFilterQuery> filterQueries = targetFilterQueryManagement
|
||||
final Page<TargetFilterQuery> filterQueries = targetFilterQueryManagement
|
||||
.findTargetFilterQueryWithAutoAssignDS(pageRequest);
|
||||
|
||||
for (TargetFilterQuery filterQuery : filterQueries) {
|
||||
for (final TargetFilterQuery filterQuery : filterQueries) {
|
||||
checkByTargetFilterQueryAndAssignDS(filterQuery);
|
||||
}
|
||||
|
||||
@@ -116,9 +117,9 @@ public class AutoAssignChecker {
|
||||
* @param targetFilterQuery
|
||||
* the target filter query
|
||||
*/
|
||||
private void checkByTargetFilterQueryAndAssignDS(TargetFilterQuery targetFilterQuery) {
|
||||
private void checkByTargetFilterQueryAndAssignDS(final TargetFilterQuery targetFilterQuery) {
|
||||
try {
|
||||
DistributionSet distributionSet = targetFilterQuery.getAutoAssignDistributionSet();
|
||||
final DistributionSet distributionSet = targetFilterQuery.getAutoAssignDistributionSet();
|
||||
|
||||
int count;
|
||||
do {
|
||||
@@ -142,11 +143,12 @@ public class AutoAssignChecker {
|
||||
* distribution set id to assign
|
||||
* @return count of targets
|
||||
*/
|
||||
private int runTransactionalAssignment(TargetFilterQuery targetFilterQuery, Long dsId) {
|
||||
private int runTransactionalAssignment(final TargetFilterQuery targetFilterQuery, final Long dsId) {
|
||||
final String actionMessage = String.format(ACTION_MESSAGE, targetFilterQuery.getName());
|
||||
return transactionTemplate.execute(status -> {
|
||||
List<TargetWithActionType> targets = getTargetsWithActionType(targetFilterQuery, dsId, PAGE_SIZE);
|
||||
int count = targets.size();
|
||||
final List<TargetWithActionType> targets = getTargetsWithActionType(targetFilterQuery.getQuery(), dsId,
|
||||
PAGE_SIZE);
|
||||
final int count = targets.size();
|
||||
if (count > 0) {
|
||||
deploymentManagement.assignDistributionSet(dsId, targets, actionMessage);
|
||||
}
|
||||
@@ -167,10 +169,10 @@ public class AutoAssignChecker {
|
||||
* maximum amount of targets to retrieve
|
||||
* @return list of targets with action type
|
||||
*/
|
||||
private List<TargetWithActionType> getTargetsWithActionType(TargetFilterQuery targetFilterQuery, Long dsId,
|
||||
int count) {
|
||||
Page<Target> targets = targetManagement.findAllTargetsByTargetFilterQueryAndNonDS(new PageRequest(0, count),
|
||||
dsId, targetFilterQuery);
|
||||
private List<TargetWithActionType> getTargetsWithActionType(final String targetFilterQuery, final Long dsId,
|
||||
final int count) {
|
||||
final Page<Target> targets = targetManagement
|
||||
.findAllTargetsByTargetFilterQueryAndNonDS(new PageRequest(0, count), dsId, targetFilterQuery);
|
||||
|
||||
return targets.getContent().stream().map(t -> new TargetWithActionType(t.getControllerId(),
|
||||
Action.ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME)).collect(Collectors.toList());
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet_;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule_;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
@@ -49,15 +48,13 @@ public final class ActionSpecifications {
|
||||
* assigned
|
||||
* @return a specification to use with spring JPA
|
||||
*/
|
||||
public static Specification<JpaAction> hasTargetAssignedArtifact(final Target target,
|
||||
final Artifact localArtifact) {
|
||||
public static Specification<JpaAction> hasTargetAssignedArtifact(final Target target, final Long localArtifact) {
|
||||
return (actionRoot, query, criteriaBuilder) -> {
|
||||
final Join<JpaAction, JpaDistributionSet> dsJoin = actionRoot.join(JpaAction_.distributionSet);
|
||||
final SetJoin<JpaDistributionSet, JpaSoftwareModule> modulesJoin = dsJoin.join(JpaDistributionSet_.modules);
|
||||
final ListJoin<JpaSoftwareModule, JpaArtifact> artifactsJoin = modulesJoin
|
||||
.join(JpaSoftwareModule_.artifacts);
|
||||
return criteriaBuilder.and(
|
||||
criteriaBuilder.equal(artifactsJoin.get(JpaArtifact_.filename), localArtifact.getFilename()),
|
||||
return criteriaBuilder.and(criteriaBuilder.equal(artifactsJoin.get(JpaArtifact_.id), localArtifact),
|
||||
criteriaBuilder.equal(actionRoot.get(JpaAction_.target), target));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaAction_;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet_;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaRolloutGroup_;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetInfo;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetInfo_;
|
||||
@@ -135,14 +136,13 @@ public final class TargetSpecifications {
|
||||
public static Specification<JpaTarget> isOverdue(final long overdueTimestamp) {
|
||||
return (targetRoot, query, cb) -> {
|
||||
final Join<JpaTarget, JpaTargetInfo> targetInfoJoin = targetRoot.join(JpaTarget_.targetInfo);
|
||||
return cb.lessThanOrEqualTo(
|
||||
targetInfoJoin.get(JpaTargetInfo_.lastTargetQuery), overdueTimestamp);
|
||||
return cb.lessThanOrEqualTo(targetInfoJoin.get(JpaTargetInfo_.lastTargetQuery), overdueTimestamp);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Specification} for retrieving {@link Target}s by
|
||||
* "like controllerId or like name or like description".
|
||||
* {@link Specification} for retrieving {@link Target}s by "like
|
||||
* controllerId or like name or like description".
|
||||
*
|
||||
* @param searchText
|
||||
* to be filtered on
|
||||
@@ -158,8 +158,8 @@ public final class TargetSpecifications {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Specification} for retrieving {@link Target}s by
|
||||
* "like controllerId".
|
||||
* {@link Specification} for retrieving {@link Target}s by "like
|
||||
* controllerId".
|
||||
*
|
||||
* @param distributionId
|
||||
* to be filtered on
|
||||
@@ -195,8 +195,8 @@ public final class TargetSpecifications {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Specification} for retrieving {@link Target}s by
|
||||
* "has no tag names"or "has at least on of the given tag names".
|
||||
* {@link Specification} for retrieving {@link Target}s by "has no tag
|
||||
* names"or "has at least on of the given tag names".
|
||||
*
|
||||
* @param tagNames
|
||||
* to be filtered on
|
||||
@@ -242,8 +242,8 @@ public final class TargetSpecifications {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Specification} for retrieving {@link Target}s that don't have the given
|
||||
* distribution set in their action history
|
||||
* {@link Specification} for retrieving {@link Target}s that don't have the
|
||||
* given distribution set in their action history
|
||||
*
|
||||
* @param distributionSetId
|
||||
* the ID of the distribution set which must not be assigned
|
||||
@@ -267,11 +267,12 @@ public final class TargetSpecifications {
|
||||
* the {@link RolloutGroup}s
|
||||
* @return the {@link Target} {@link Specification}
|
||||
*/
|
||||
public static Specification<JpaTarget> isNotInRolloutGroups(final List<RolloutGroup> groups) {
|
||||
public static Specification<JpaTarget> isNotInRolloutGroups(final Collection<Long> groups) {
|
||||
return (targetRoot, query, cb) -> {
|
||||
ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = targetRoot.join(JpaTarget_.rolloutTargetGroup,
|
||||
JoinType.LEFT);
|
||||
Predicate inRolloutGroups = rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).in(groups);
|
||||
final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = targetRoot
|
||||
.join(JpaTarget_.rolloutTargetGroup, JoinType.LEFT);
|
||||
final Predicate inRolloutGroups = rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup)
|
||||
.get(JpaRolloutGroup_.id).in(groups);
|
||||
rolloutTargetJoin.on(inRolloutGroups);
|
||||
return cb.isNull(rolloutTargetJoin.get(RolloutTargetGroup_.target));
|
||||
};
|
||||
@@ -285,14 +286,15 @@ public final class TargetSpecifications {
|
||||
* the {@link RolloutGroup}
|
||||
* @return the {@link Target} {@link Specification}
|
||||
*/
|
||||
public static Specification<JpaTarget> hasNoActionInRolloutGroup(final RolloutGroup group) {
|
||||
public static Specification<JpaTarget> hasNoActionInRolloutGroup(final Long group) {
|
||||
return (targetRoot, query, cb) -> {
|
||||
ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = targetRoot.join(JpaTarget_.rolloutTargetGroup,
|
||||
JoinType.INNER);
|
||||
rolloutTargetJoin.on(cb.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup), group));
|
||||
final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = targetRoot
|
||||
.join(JpaTarget_.rolloutTargetGroup, JoinType.INNER);
|
||||
rolloutTargetJoin.on(
|
||||
cb.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(JpaRolloutGroup_.id), group));
|
||||
|
||||
final ListJoin<JpaTarget, JpaAction> actionsJoin = targetRoot.join(JpaTarget_.actions, JoinType.LEFT);
|
||||
actionsJoin.on(cb.equal(actionsJoin.get(JpaAction_.rolloutGroup), group));
|
||||
actionsJoin.on(cb.equal(actionsJoin.get(JpaAction_.rolloutGroup).get(JpaRolloutGroup_.id), group));
|
||||
|
||||
return cb.isNull(actionsJoin.get(JpaAction_.id));
|
||||
};
|
||||
|
||||
@@ -8,15 +8,22 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.eclipse.hawkbit.cache.TenantAwareCacheManager;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaRollout;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
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.util.AbstractIntegrationTest;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -83,7 +90,18 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
|
||||
protected TenantConfigurationProperties tenantConfigurationProperties;
|
||||
|
||||
@Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED)
|
||||
public List<Action> findActionsByRolloutAndStatus(final Rollout rollout, final Action.Status actionStatus) {
|
||||
return actionRepository.findByRolloutAndStatus((JpaRollout) rollout, actionStatus);
|
||||
protected List<Action> findActionsByRolloutAndStatus(final Rollout rollout, final Action.Status actionStatus) {
|
||||
return actionRepository.findByRolloutIdAndStatus(rollout.getId(), actionStatus);
|
||||
}
|
||||
|
||||
protected TargetTagAssignmentResult toggleTagAssignment(final Collection<Target> targets, final TargetTag tag) {
|
||||
return targetManagement.toggleTagAssignment(
|
||||
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), tag.getName());
|
||||
}
|
||||
|
||||
public DistributionSetTagAssignmentResult toggleTagAssignment(final Collection<DistributionSet> sets,
|
||||
final DistributionSetTag tag) {
|
||||
return distributionSetManagement.toggleTagAssignment(
|
||||
sets.stream().map(DistributionSet::getId).collect(Collectors.toList()), tag.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Artifact result = artifactManagement.createArtifact(new ByteArrayInputStream(random),
|
||||
testdataFactory.createSoftwareModuleOs().getId(), "file1", false);
|
||||
|
||||
try (InputStream fileInputStream = artifactManagement.loadArtifactBinary(result).getFileInputStream()) {
|
||||
try (InputStream fileInputStream = artifactManagement.loadArtifactBinary(result.getId()).getFileInputStream()) {
|
||||
assertTrue("The stored binary matches the given binary",
|
||||
IOUtils.contentEquals(new ByteArrayInputStream(random), fileInputStream));
|
||||
}
|
||||
@@ -225,7 +225,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Trys and fails to load an artifact without required permission. Checks if expected InsufficientPermissionException is thrown.")
|
||||
public void loadArtifactBinaryWithoutDownloadArtifactThrowsPermissionDenied() {
|
||||
try {
|
||||
artifactManagement.loadArtifactBinary(new JpaArtifact());
|
||||
artifactManagement.loadArtifactBinary(1L);
|
||||
fail("Should not have worked with missing permission.");
|
||||
} catch (final InsufficientPermissionException e) {
|
||||
|
||||
|
||||
@@ -59,7 +59,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
savedTarget = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getAssignedEntity().iterator()
|
||||
.next();
|
||||
final JpaAction savedAction = (JpaAction) deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
|
||||
final JpaAction savedAction = (JpaAction) deploymentManagement
|
||||
.findActiveActionsByTarget(savedTarget.getControllerId()).get(0);
|
||||
|
||||
assertThat(targetManagement.findTargetByControllerID(savedTarget.getControllerId()).getTargetInfo()
|
||||
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||
@@ -75,7 +76,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
|
||||
assertThat(actionStatusRepository.findAll(pageReq).getNumberOfElements()).isEqualTo(3);
|
||||
assertThat(deploymentManagement.findActionStatusByAction(pageReq, savedAction).getNumberOfElements())
|
||||
assertThat(deploymentManagement.findActionStatusByAction(pageReq, savedAction.getId()).getNumberOfElements())
|
||||
.isEqualTo(3);
|
||||
}
|
||||
|
||||
@@ -105,7 +106,7 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
Target savedTarget = testdataFactory.createTarget();
|
||||
savedTarget = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getAssignedEntity().iterator()
|
||||
.next();
|
||||
Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
|
||||
Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId()).get(0);
|
||||
|
||||
// test and verify
|
||||
savedAction = controllerManagament.addUpdateActionStatus(
|
||||
@@ -153,7 +154,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).getTargetInfo()
|
||||
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(actionStatusRepository.findAll(pageReq).getNumberOfElements()).isEqualTo(3);
|
||||
assertThat(deploymentManagement.findActionStatusByAction(pageReq, action).getNumberOfElements()).isEqualTo(3);
|
||||
assertThat(deploymentManagement.findActionStatusByAction(pageReq, action.getId()).getNumberOfElements())
|
||||
.isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -170,7 +172,8 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).getTargetInfo()
|
||||
.getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(actionStatusRepository.findAll(pageReq).getNumberOfElements()).isEqualTo(4);
|
||||
assertThat(deploymentManagement.findActionStatusByAction(pageReq, action).getNumberOfElements()).isEqualTo(4);
|
||||
assertThat(deploymentManagement.findActionStatusByAction(pageReq, action.getId()).getNumberOfElements())
|
||||
.isEqualTo(4);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
actionStatusRepository.save(new JpaActionStatus(action, Status.RUNNING, System.currentTimeMillis()));
|
||||
|
||||
final List<ActionWithStatusCount> findActionsWithStatusCountByTarget = deploymentManagement
|
||||
.findActionsWithStatusCountByTargetOrderByIdDesc(testTarget.get(0));
|
||||
.findActionsWithStatusCountByTargetOrderByIdDesc(testTarget.get(0).getControllerId());
|
||||
|
||||
assertThat(findActionsWithStatusCountByTarget).as("wrong action size").hasSize(1);
|
||||
assertThat(findActionsWithStatusCountByTarget.get(0).getActionStatusCount()).as("wrong action status size")
|
||||
@@ -134,7 +134,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSetTag tag = tagManagement
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("Tag1"));
|
||||
|
||||
final List<DistributionSet> assignedDS = distributionSetManagement.assignTag(assignDS, tag);
|
||||
final List<DistributionSet> assignedDS = distributionSetManagement.assignTag(assignDS, tag.getId());
|
||||
assertThat(assignedDS.size()).as("assigned ds has wrong size").isEqualTo(4);
|
||||
assignedDS.forEach(ds -> assertThat(ds.getTags().size()).as("ds has wrong tag size").isEqualTo(1));
|
||||
|
||||
@@ -142,11 +142,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(assignedDS.size()).as("assigned ds has wrong size")
|
||||
.isEqualTo(findDistributionSetTag.getAssignedToDistributionSet().size());
|
||||
|
||||
assertThat(distributionSetManagement.unAssignTag(Long.valueOf(100), findDistributionSetTag))
|
||||
.as("unassign tag result should be null").isNull();
|
||||
|
||||
final DistributionSet unAssignDS = distributionSetManagement.unAssignTag(assignDS.get(0),
|
||||
findDistributionSetTag);
|
||||
findDistributionSetTag.getId());
|
||||
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);
|
||||
findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1");
|
||||
@@ -154,7 +151,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.isEqualTo(3);
|
||||
|
||||
final List<DistributionSet> unAssignTargets = distributionSetManagement
|
||||
.unAssignAllDistributionSetsByTag(findDistributionSetTag);
|
||||
.unAssignAllDistributionSetsByTag(findDistributionSetTag.getId());
|
||||
findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1");
|
||||
assertThat(findDistributionSetTag.getAssignedToDistributionSet().size()).as("ds tag has wrong ds size")
|
||||
.isEqualTo(0);
|
||||
@@ -178,10 +175,9 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
targets = assignDistributionSet(cancelDs, targets).getAssignedEntity();
|
||||
targets = assignDistributionSet(cancelDs2, targets).getAssignedEntity();
|
||||
|
||||
targetManagement.findAllTargetIds().forEach(targetIdName -> {
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(
|
||||
targetManagement.findTargetByControllerID(targetIdName.getControllerId())))
|
||||
.as("active action has wrong size").hasSize(2);
|
||||
targetManagement.findTargetsAll(pageReq).getContent().forEach(targetIdName -> {
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(targetIdName.getControllerId()))
|
||||
.as("active action has wrong size").hasSize(2);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -208,8 +204,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(5);
|
||||
|
||||
// we cancel second -> back to first
|
||||
deploymentManagement.cancelAction(secondAction,
|
||||
targetManagement.findTargetByControllerID(target.getControllerId()));
|
||||
deploymentManagement.cancelAction(secondAction.getId());
|
||||
secondAction = (JpaAction) deploymentManagement.findActionWithDetails(secondAction.getId());
|
||||
// confirm cancellation
|
||||
controllerManagement.addCancelActionStatus(
|
||||
@@ -221,8 +216,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.as("wrong update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
// we cancel first -> back to installed
|
||||
deploymentManagement.cancelAction(firstAction,
|
||||
targetManagement.findTargetByControllerID(target.getControllerId()));
|
||||
deploymentManagement.cancelAction(firstAction.getId());
|
||||
firstAction = (JpaAction) deploymentManagement.findActionWithDetails(firstAction.getId());
|
||||
// confirm cancellation
|
||||
controllerManagement.addCancelActionStatus(
|
||||
@@ -257,8 +251,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(5);
|
||||
|
||||
// we cancel first -> second is left
|
||||
deploymentManagement.cancelAction(firstAction,
|
||||
targetManagement.findTargetByControllerID(target.getControllerId()));
|
||||
deploymentManagement.cancelAction(firstAction.getId());
|
||||
// confirm cancellation
|
||||
firstAction = (JpaAction) deploymentManagement.findActionWithDetails(firstAction.getId());
|
||||
controllerManagement.addCancelActionStatus(
|
||||
@@ -270,8 +263,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.as("wrong target update status").isEqualTo(TargetUpdateStatus.PENDING);
|
||||
|
||||
// we cancel second -> remain assigned until finished cancellation
|
||||
deploymentManagement.cancelAction(secondAction,
|
||||
targetManagement.findTargetByControllerID(target.getControllerId()));
|
||||
deploymentManagement.cancelAction(secondAction.getId());
|
||||
secondAction = (JpaAction) deploymentManagement.findActionWithDetails(secondAction.getId());
|
||||
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(8);
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet())
|
||||
@@ -308,10 +300,10 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
target = targetManagement.findTargetByControllerID(target.getControllerId());
|
||||
|
||||
// force quit assignment
|
||||
deploymentManagement.cancelAction(assigningAction, target);
|
||||
deploymentManagement.cancelAction(assigningAction.getId());
|
||||
assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId());
|
||||
|
||||
deploymentManagement.forceQuitAction(assigningAction);
|
||||
deploymentManagement.forceQuitAction(assigningAction.getId());
|
||||
|
||||
assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId());
|
||||
|
||||
@@ -343,7 +335,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// force quit assignment
|
||||
try {
|
||||
deploymentManagement.forceQuitAction(assigningAction);
|
||||
deploymentManagement.forceQuitAction(assigningAction.getId());
|
||||
fail("expected ForceQuitActionNotAllowedException");
|
||||
} catch (final ForceQuitActionNotAllowedException ex) {
|
||||
}
|
||||
@@ -404,12 +396,14 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
for (final Target myt : savedNakedTargets) {
|
||||
final Target t = targetManagement.findTargetByControllerID(myt.getControllerId());
|
||||
assertThat(deploymentManagement.findActionsByTarget(t)).as("action should be empty").isEmpty();
|
||||
assertThat(deploymentManagement.countActionsByTarget(t.getControllerId())).as("action should be empty")
|
||||
.isEqualTo(0L);
|
||||
}
|
||||
|
||||
for (final Target myt : savedDeployedTargets) {
|
||||
final Target t = targetManagement.findTargetByControllerID(myt.getControllerId());
|
||||
final List<Action> activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(t);
|
||||
final List<Action> activeActionsByTarget = deploymentManagement
|
||||
.findActiveActionsByTarget(t.getControllerId());
|
||||
assertThat(activeActionsByTarget).as("action should not be empty").isNotEmpty();
|
||||
assertThat(t.getTargetInfo().getUpdateStatus()).as("wrong target update status")
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
@@ -544,9 +538,9 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final JpaDistributionSet dsC = (JpaDistributionSet) deployResWithDsC.getDistributionSets().get(0);
|
||||
|
||||
// retrieving the UpdateActions created by the assignments
|
||||
actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(0);
|
||||
actionRepository.findByDistributionSet(pageRequest, dsB).getContent().get(0);
|
||||
actionRepository.findByDistributionSet(pageRequest, dsC).getContent().get(0);
|
||||
actionRepository.findByDistributionSetId(pageRequest, dsA.getId()).getContent().get(0);
|
||||
actionRepository.findByDistributionSetId(pageRequest, dsB.getId()).getContent().get(0);
|
||||
actionRepository.findByDistributionSetId(pageRequest, dsC.getId()).getContent().get(0);
|
||||
|
||||
// verifying the correctness of the assignments
|
||||
for (final Target t : deployResWithDsA.getDeployedTargets()) {
|
||||
@@ -581,7 +575,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.getInstalledDistributionSet()).as("installed ds is wrong").isEqualTo(dsA);
|
||||
assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus())
|
||||
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(t)).as("no actions should be active").hasSize(0);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(t.getControllerId()))
|
||||
.as("no actions should be active").hasSize(0);
|
||||
}
|
||||
|
||||
// deploy dsA to the target which already have dsB deployed -> must
|
||||
@@ -590,7 +585,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
// UpdateAction for dsA
|
||||
final Iterable<Target> deployed2DS = assignDistributionSet(dsA, deployResWithDsB.getDeployedTargets())
|
||||
.getAssignedEntity();
|
||||
actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(1);
|
||||
actionRepository.findByDistributionSetId(pageRequest, dsA.getId()).getContent().get(1);
|
||||
|
||||
// get final updated version of targets
|
||||
final List<Target> deployResWithDsBTargets = targetManagement.findTargetByControllerID(deployResWithDsB
|
||||
@@ -661,8 +656,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
Collections.singletonList("blabla alles gut"));
|
||||
}
|
||||
// try to delete again
|
||||
distributionSetManagement.deleteDistributionSet(deploymentResult.getDistributionSetIDs()
|
||||
.toArray(new Long[deploymentResult.getDistributionSetIDs().size()]));
|
||||
distributionSetManagement.deleteDistributionSet(deploymentResult.getDistributionSetIDs());
|
||||
// verify that the result is the same, even though distributionSet dsA
|
||||
// has been installed
|
||||
// successfully and no activeAction is referring to created distribution
|
||||
@@ -699,9 +693,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(targetManagement.countTargetsAll()).as("size of targets is wrong").isNotZero();
|
||||
assertThat(actionStatusRepository.count()).as("size of action status is wrong").isNotZero();
|
||||
|
||||
targetManagement
|
||||
.deleteTargets(deploymentResult.getUndeployedTargetIDs().toArray(new Long[noOfUndeployedTargets]));
|
||||
targetManagement.deleteTargets(deploymentResult.getDeployedTargetIDs().toArray(new Long[noOfDeployedTargets]));
|
||||
targetManagement.deleteTargets(deploymentResult.getUndeployedTargetIDs());
|
||||
targetManagement.deleteTargets(deploymentResult.getDeployedTargetIDs());
|
||||
|
||||
assertThat(targetManagement.countTargetsAll()).as("size of targets should be zero").isZero();
|
||||
assertThat(actionStatusRepository.count()).as("size of action status is wrong").isZero();
|
||||
@@ -726,25 +719,28 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).getOptLockRevision());
|
||||
|
||||
// verifying that the assignment is correct
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(targ).size()).as("Active target actions are wrong")
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(targ.getControllerId()).size())
|
||||
.as("Active target actions are wrong").isEqualTo(1);
|
||||
assertThat(deploymentManagement.countActionsByTarget(targ.getControllerId())).as("Target actions are wrong")
|
||||
.isEqualTo(1);
|
||||
assertThat(deploymentManagement.findActionsByTarget(targ).size()).as("Target actions are wrong").isEqualTo(1);
|
||||
assertThat(targ.getTargetInfo().getUpdateStatus()).as("UpdateStatus of target is wrong")
|
||||
.isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(targ.getAssignedDistributionSet()).as("Assigned distribution set of target is wrong").isEqualTo(dsA);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet())
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(targ.getControllerId()).get(0).getDistributionSet())
|
||||
.as("Distribution set of actionn is wrong").isEqualTo(dsA);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet())
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(targ.getControllerId()).get(0).getDistributionSet())
|
||||
.as("Installed distribution set of action should be null").isNotNull();
|
||||
|
||||
final Page<Action> updAct = actionRepository.findByDistributionSet(pageReq, (JpaDistributionSet) dsA);
|
||||
final Page<Action> updAct = actionRepository.findByDistributionSetId(pageReq, dsA.getId());
|
||||
controllerManagament.addUpdateActionStatus(
|
||||
entityFactory.actionStatus().create(updAct.getContent().get(0).getId()).status(Status.FINISHED));
|
||||
|
||||
targ = targetManagement.findTargetByControllerID(targ.getControllerId());
|
||||
|
||||
assertEquals("active target actions are wrong", 0, deploymentManagement.findActiveActionsByTarget(targ).size());
|
||||
assertEquals("active actions are wrong", 1, deploymentManagement.findInActiveActionsByTarget(targ).size());
|
||||
assertEquals("active target actions are wrong", 0,
|
||||
deploymentManagement.findActiveActionsByTarget(targ.getControllerId()).size());
|
||||
assertEquals("active actions are wrong", 1,
|
||||
deploymentManagement.findInActiveActionsByTarget(targ.getControllerId()).size());
|
||||
|
||||
assertEquals("tagret update status is not correct", TargetUpdateStatus.IN_SYNC,
|
||||
targ.getTargetInfo().getUpdateStatus());
|
||||
@@ -755,7 +751,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
targ = targs.iterator().next();
|
||||
|
||||
assertEquals("active actions are wrong", 1, deploymentManagement.findActiveActionsByTarget(targ).size());
|
||||
assertEquals("active actions are wrong", 1,
|
||||
deploymentManagement.findActiveActionsByTarget(targ.getControllerId()).size());
|
||||
assertEquals("target status is wrong", TargetUpdateStatus.PENDING,
|
||||
targetManagement.findTargetByControllerID(targ.getControllerId()).getTargetInfo().getUpdateStatus());
|
||||
assertEquals("wrong assigned ds", dsB, targ.getAssignedDistributionSet());
|
||||
@@ -763,7 +760,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
targetManagement.findTargetByControllerIDWithDetails(targ.getControllerId()).getTargetInfo()
|
||||
.getInstalledDistributionSet().getId());
|
||||
assertEquals("Active ds is wrong", dsB,
|
||||
deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet());
|
||||
deploymentManagement.findActiveActionsByTarget(targ.getControllerId()).get(0).getDistributionSet());
|
||||
|
||||
}
|
||||
|
||||
@@ -892,7 +889,8 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
for (final TargetAssignDistributionSetEvent event : events) {
|
||||
if (event.getControllerId().equals(myt.getControllerId())) {
|
||||
found = true;
|
||||
final List<Action> activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(myt);
|
||||
final List<Action> activeActionsByTarget = deploymentManagement
|
||||
.findActiveActionsByTarget(myt.getControllerId());
|
||||
assertThat(activeActionsByTarget).as("size of active actions for target is wrong").isNotEmpty();
|
||||
assertThat(event.getActionId()).as("Action id in database and event do not match")
|
||||
.isEqualTo(activeActionsByTarget.get(0).getId());
|
||||
|
||||
@@ -149,7 +149,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
entityFactory.distributionSetType().create().key("delete").name("to be deleted"));
|
||||
|
||||
assertThat(distributionSetTypeRepository.findAll()).contains(hardDelete);
|
||||
distributionSetManagement.deleteDistributionSetType(hardDelete);
|
||||
distributionSetManagement.deleteDistributionSetType(hardDelete.getId());
|
||||
|
||||
assertThat(distributionSetTypeRepository.findAll()).doesNotContain(hardDelete);
|
||||
}
|
||||
@@ -165,7 +165,7 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
distributionSetManagement.createDistributionSet(
|
||||
entityFactory.distributionSet().create().name("softdeleted").version("1").type(softDelete.getKey()));
|
||||
|
||||
distributionSetManagement.deleteDistributionSetType(softDelete);
|
||||
distributionSetManagement.deleteDistributionSetType(softDelete.getId());
|
||||
assertThat(distributionSetManagement.findDistributionSetTypeByKey("softdeleted").isDeleted()).isEqualTo(true);
|
||||
}
|
||||
|
||||
@@ -430,14 +430,14 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
dsDeleted.getModules().stream().map(SoftwareModule::getId).collect(Collectors.toList())));
|
||||
|
||||
assignDistributionSet(dsDeleted, Lists.newArrayList(testdataFactory.createTargets(5)));
|
||||
distributionSetManagement.deleteDistributionSet(dsDeleted);
|
||||
distributionSetManagement.deleteDistributionSet(dsDeleted.getId());
|
||||
dsDeleted = distributionSetManagement.findDistributionSetById(dsDeleted.getId());
|
||||
|
||||
ds100Group1 = distributionSetManagement.toggleTagAssignment(ds100Group1, dsTagA).getAssignedEntity();
|
||||
ds100Group1 = toggleTagAssignment(ds100Group1, dsTagA).getAssignedEntity();
|
||||
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName());
|
||||
ds100Group1 = distributionSetManagement.toggleTagAssignment(ds100Group1, dsTagB).getAssignedEntity();
|
||||
ds100Group1 = toggleTagAssignment(ds100Group1, dsTagB).getAssignedEntity();
|
||||
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName());
|
||||
ds100Group2 = distributionSetManagement.toggleTagAssignment(ds100Group2, dsTagA).getAssignedEntity();
|
||||
ds100Group2 = toggleTagAssignment(ds100Group2, dsTagA).getAssignedEntity();
|
||||
dsTagA = distributionSetTagRepository.findByNameEquals(dsTagA.getName());
|
||||
|
||||
// check setup
|
||||
@@ -722,7 +722,8 @@ public class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// delete assigned ds
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
||||
distributionSetManagement.deleteDistributionSet(dsToTargetAssigned.getId(), dsToRolloutAssigned.getId());
|
||||
distributionSetManagement
|
||||
.deleteDistributionSet(Lists.newArrayList(dsToTargetAssigned.getId(), dsToRolloutAssigned.getId()));
|
||||
|
||||
// not assigned so not marked as deleted
|
||||
assertThat(distributionSetRepository.findAll()).hasSize(4);
|
||||
|
||||
@@ -139,8 +139,7 @@ public class ReportManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Target createTarget = testdataFactory.createTarget("t" + month);
|
||||
final DistributionSetAssignmentResult result = assignDistributionSet(distributionSet,
|
||||
Lists.newArrayList(createTarget));
|
||||
controllerManagament.registerRetrieved(
|
||||
deploymentManagement.findActionWithDetails(result.getActions().get(0)),
|
||||
controllerManagament.registerRetrieved(result.getActions().get(0),
|
||||
"Controller retrieved update action and should start now the download.");
|
||||
}
|
||||
DataReportSeries<LocalDate> feedbackReceivedOverTime = reportManagement
|
||||
@@ -161,8 +160,7 @@ public class ReportManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Target createTarget = testdataFactory.createTarget("t2" + month);
|
||||
final DistributionSetAssignmentResult result = assignDistributionSet(distributionSet,
|
||||
Lists.newArrayList(createTarget));
|
||||
controllerManagament.registerRetrieved(
|
||||
deploymentManagement.findActionWithDetails(result.getActions().get(0)),
|
||||
controllerManagament.registerRetrieved(result.getActions().get(0),
|
||||
"Controller retrieved update action and should start now the download.");
|
||||
}
|
||||
feedbackReceivedOverTime = reportManagement.feedbackReceivedOverTime(DateTypes.perMonth(), from, to);
|
||||
|
||||
@@ -202,13 +202,13 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Step("Finish three actions of the rollout group and delete two targets")
|
||||
private void finishActionAndDeleteTargetsOfFirstRunningGroup(final Rollout createdRollout) {
|
||||
// finish group one by finishing targets and deleting targets
|
||||
final List<Action> runningActions = deploymentManagement.findActionsByRolloutAndStatus(createdRollout,
|
||||
final List<Action> runningActions = actionRepository.findByRolloutIdAndStatus(createdRollout.getId(),
|
||||
Status.RUNNING);
|
||||
finishAction(runningActions.get(0));
|
||||
finishAction(runningActions.get(1));
|
||||
finishAction(runningActions.get(2));
|
||||
targetManagement.deleteTargets(runningActions.get(3).getTarget().getId(),
|
||||
runningActions.get(4).getTarget().getId());
|
||||
targetManagement.deleteTargets(Lists.newArrayList(runningActions.get(3).getTarget().getId(),
|
||||
runningActions.get(4).getTarget().getId()));
|
||||
}
|
||||
|
||||
@Step("Check the status of the rollout groups, second group should be in running status")
|
||||
@@ -223,22 +223,22 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Step("Finish one action of the rollout group and delete four targets")
|
||||
private void finishActionAndDeleteTargetsOfSecondRunningGroup(final Rollout createdRollout) {
|
||||
final List<Action> runningActions = deploymentManagement.findActionsByRolloutAndStatus(createdRollout,
|
||||
final List<Action> runningActions = actionRepository.findByRolloutIdAndStatus(createdRollout.getId(),
|
||||
Status.RUNNING);
|
||||
finishAction(runningActions.get(0));
|
||||
targetManagement.deleteTargets(runningActions.get(1).getTarget().getId(),
|
||||
runningActions.get(2).getTarget().getId(), runningActions.get(3).getTarget().getId(),
|
||||
runningActions.get(4).getTarget().getId());
|
||||
targetManagement.deleteTargets(
|
||||
Lists.newArrayList(runningActions.get(1).getTarget().getId(), runningActions.get(2).getTarget().getId(),
|
||||
runningActions.get(3).getTarget().getId(), runningActions.get(4).getTarget().getId()));
|
||||
|
||||
}
|
||||
|
||||
@Step("Delete all targets of the rollout group")
|
||||
private void deleteAllTargetsFromThirdGroup(final Rollout createdRollout) {
|
||||
final List<Action> runningActions = deploymentManagement.findActionsByRolloutAndStatus(createdRollout,
|
||||
final List<Action> runningActions = actionRepository.findByRolloutIdAndStatus(createdRollout.getId(),
|
||||
Status.SCHEDULED);
|
||||
targetManagement.deleteTargets(runningActions.get(0).getTarget().getId(),
|
||||
targetManagement.deleteTargets(Lists.newArrayList(runningActions.get(0).getTarget().getId(),
|
||||
runningActions.get(1).getTarget().getId(), runningActions.get(2).getTarget().getId(),
|
||||
runningActions.get(3).getTarget().getId(), runningActions.get(4).getTarget().getId());
|
||||
runningActions.get(3).getTarget().getId(), runningActions.get(4).getTarget().getId()));
|
||||
}
|
||||
|
||||
@Step("Check the status of the rollout groups and the rollout")
|
||||
@@ -549,7 +549,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// 5 targets are in the group and the DS has been assigned
|
||||
final List<RolloutGroup> rolloutGroups = createdRollout.getRolloutGroups();
|
||||
final Page<Target> targets = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(0),
|
||||
final Page<Target> targets = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(0).getId(),
|
||||
new OffsetBasedPageRequest(0, 20, new Sort(Direction.ASC, "id")));
|
||||
final List<Target> targetList = targets.getContent();
|
||||
assertThat(targetList.size()).isEqualTo(5);
|
||||
@@ -922,14 +922,14 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId());
|
||||
|
||||
float percent = rolloutManagement.getFinishedPercentForRunningGroup(myRollout.getId(),
|
||||
myRollout.getRolloutGroups().get(0));
|
||||
myRollout.getRolloutGroups().get(0).getId());
|
||||
assertThat(percent).isEqualTo(40);
|
||||
|
||||
changeStatusForRunningActions(myRollout, Status.FINISHED, 3);
|
||||
rolloutManagement.checkRunningRollouts(0);
|
||||
|
||||
percent = rolloutManagement.getFinishedPercentForRunningGroup(myRollout.getId(),
|
||||
myRollout.getRolloutGroups().get(0));
|
||||
myRollout.getRolloutGroups().get(0).getId());
|
||||
assertThat(percent).isEqualTo(100);
|
||||
|
||||
changeStatusForRunningActions(myRollout, Status.FINISHED, 4);
|
||||
@@ -937,7 +937,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutManagement.checkRunningRollouts(0);
|
||||
|
||||
percent = rolloutManagement.getFinishedPercentForRunningGroup(myRollout.getId(),
|
||||
myRollout.getRolloutGroups().get(1));
|
||||
myRollout.getRolloutGroups().get(1).getId());
|
||||
assertThat(percent).isEqualTo(80);
|
||||
}
|
||||
|
||||
@@ -966,19 +966,19 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
myRollout = rolloutManagement.findRolloutById(myRollout.getId());
|
||||
final List<RolloutGroup> rolloutGroups = myRollout.getRolloutGroups();
|
||||
|
||||
Page<Target> targetPage = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(0), rsqlParam,
|
||||
new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "controllerId")));
|
||||
Page<Target> targetPage = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(0).getId(),
|
||||
rsqlParam, new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "controllerId")));
|
||||
final List<Target> targetlistGroup1 = targetPage.getContent();
|
||||
assertThat(targetlistGroup1.size()).isEqualTo(5);
|
||||
assertThat(targetlistGroup1.get(0).getControllerId()).isEqualTo("MyRollout--00000");
|
||||
|
||||
targetPage = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(1), rsqlParam,
|
||||
targetPage = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(1).getId(), rsqlParam,
|
||||
new OffsetBasedPageRequest(0, 100, new Sort(Direction.DESC, "controllerId")));
|
||||
final List<Target> targetlistGroup2 = targetPage.getContent();
|
||||
assertThat(targetlistGroup2.size()).isEqualTo(5);
|
||||
assertThat(targetlistGroup2.get(0).getControllerId()).isEqualTo("MyRollout--00009");
|
||||
|
||||
targetPage = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(2), rsqlParam,
|
||||
targetPage = rolloutGroupManagement.findRolloutGroupTargets(rolloutGroups.get(2).getId(), rsqlParam,
|
||||
new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "controllerId")));
|
||||
final List<Target> targetlistGroup3 = targetPage.getContent();
|
||||
assertThat(targetlistGroup3.size()).isEqualTo(5);
|
||||
|
||||
@@ -249,7 +249,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
|
||||
appType, type);
|
||||
|
||||
// delete unassigned
|
||||
softwareManagement.deleteSoftwareModuleType(type);
|
||||
softwareManagement.deleteSoftwareModuleType(type.getId());
|
||||
assertThat(softwareManagement.findSoftwareModuleTypesAll(pageReq)).hasSize(3).contains(osType, runtimeType,
|
||||
appType);
|
||||
assertThat(softwareModuleTypeRepository.findAll()).hasSize(3).contains((JpaSoftwareModuleType) osType,
|
||||
@@ -265,7 +265,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
|
||||
entityFactory.softwareModule().create().type(type).name("Test SM").version("1.0"));
|
||||
|
||||
// delete assigned
|
||||
softwareManagement.deleteSoftwareModuleType(type);
|
||||
softwareManagement.deleteSoftwareModuleType(type.getId());
|
||||
assertThat(softwareManagement.findSoftwareModuleTypesAll(pageReq)).hasSize(3).contains(osType, runtimeType,
|
||||
appType);
|
||||
|
||||
@@ -348,7 +348,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
|
||||
assignDistributionSet(disSet, Lists.newArrayList(target));
|
||||
|
||||
// [STEP4]: Delete the DistributionSet
|
||||
distributionSetManagement.deleteDistributionSet(disSet);
|
||||
distributionSetManagement.deleteDistributionSet(disSet.getId());
|
||||
|
||||
// [STEP5]: Delete the assigned SoftwareModule
|
||||
softwareManagement.deleteSoftwareModule(assignedModule.getId());
|
||||
@@ -694,7 +694,7 @@ public class SoftwareManagementTest extends AbstractJpaIntegrationTest {
|
||||
.create().name("set").version("1").modules(Lists.newArrayList(one.getId(), deleted.getId())));
|
||||
softwareManagement.deleteSoftwareModule(deleted.getId());
|
||||
|
||||
assertThat(softwareManagement.findSoftwareModuleByAssignedTo(pageReq, set).getContent())
|
||||
assertThat(softwareManagement.findSoftwareModuleByAssignedTo(pageReq, set.getId()).getContent())
|
||||
.as("Found this number of modules").hasSize(2);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,22 +68,22 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSetTag tagX = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("X"));
|
||||
final DistributionSetTag tagY = tagManagement.createDistributionSetTag(entityFactory.tag().create().name("Y"));
|
||||
|
||||
distributionSetManagement.toggleTagAssignment(dsAs, tagA);
|
||||
distributionSetManagement.toggleTagAssignment(dsBs, tagB);
|
||||
distributionSetManagement.toggleTagAssignment(dsCs, tagC);
|
||||
toggleTagAssignment(dsAs, tagA);
|
||||
toggleTagAssignment(dsBs, tagB);
|
||||
toggleTagAssignment(dsCs, tagC);
|
||||
|
||||
distributionSetManagement.toggleTagAssignment(dsABs, tagManagement.findDistributionSetTag(tagA.getName()));
|
||||
distributionSetManagement.toggleTagAssignment(dsABs, tagManagement.findDistributionSetTag(tagB.getName()));
|
||||
toggleTagAssignment(dsABs, tagManagement.findDistributionSetTag(tagA.getName()));
|
||||
toggleTagAssignment(dsABs, tagManagement.findDistributionSetTag(tagB.getName()));
|
||||
|
||||
distributionSetManagement.toggleTagAssignment(dsACs, tagManagement.findDistributionSetTag(tagA.getName()));
|
||||
distributionSetManagement.toggleTagAssignment(dsACs, tagManagement.findDistributionSetTag(tagC.getName()));
|
||||
toggleTagAssignment(dsACs, tagManagement.findDistributionSetTag(tagA.getName()));
|
||||
toggleTagAssignment(dsACs, tagManagement.findDistributionSetTag(tagC.getName()));
|
||||
|
||||
distributionSetManagement.toggleTagAssignment(dsBCs, tagManagement.findDistributionSetTag(tagB.getName()));
|
||||
distributionSetManagement.toggleTagAssignment(dsBCs, tagManagement.findDistributionSetTag(tagC.getName()));
|
||||
toggleTagAssignment(dsBCs, tagManagement.findDistributionSetTag(tagB.getName()));
|
||||
toggleTagAssignment(dsBCs, tagManagement.findDistributionSetTag(tagC.getName()));
|
||||
|
||||
distributionSetManagement.toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagA.getName()));
|
||||
distributionSetManagement.toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagB.getName()));
|
||||
distributionSetManagement.toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagC.getName()));
|
||||
toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagA.getName()));
|
||||
toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagB.getName()));
|
||||
toggleTagAssignment(dsABCs, tagManagement.findDistributionSetTag(tagC.getName()));
|
||||
|
||||
DistributionSetFilterBuilder distributionSetFilterBuilder;
|
||||
|
||||
@@ -164,7 +164,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
.createDistributionSetTag(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||
|
||||
// toggle A only -> A is now assigned
|
||||
DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(groupA, tag);
|
||||
DistributionSetTagAssignmentResult result = toggleTagAssignment(groupA, tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement
|
||||
@@ -174,7 +174,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||
|
||||
// toggle A+B -> A is still assigned and B is assigned as well
|
||||
result = distributionSetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(distributionSetManagement
|
||||
@@ -184,7 +184,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(result.getDistributionSetTag()).isEqualTo(tag);
|
||||
|
||||
// toggle A+B -> both unassigned
|
||||
result = distributionSetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssignedEntity()).isEmpty();
|
||||
@@ -206,7 +206,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
.createTargetTag(entityFactory.tag().create().name("tag1").description("tagdesc1"));
|
||||
|
||||
// toggle A only -> A is now assigned
|
||||
TargetTagAssignmentResult result = targetManagement.toggleTagAssignment(groupA, tag);
|
||||
TargetTagAssignmentResult result = toggleTagAssignment(groupA, tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
|
||||
@@ -216,7 +216,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
// toggle A+B -> A is still assigned and B is assigned as well
|
||||
result = targetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssigned()).isEqualTo(20);
|
||||
assertThat(result.getAssignedEntity()).containsAll(targetManagement.findTargetsByControllerIDsWithTags(
|
||||
@@ -226,7 +226,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(result.getTargetTag()).isEqualTo(tag);
|
||||
|
||||
// toggle A+B -> both unassigned
|
||||
result = targetManagement.toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
result = toggleTagAssignment(concat(groupA, groupB), tag);
|
||||
assertThat(result.getAlreadyAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssigned()).isEqualTo(0);
|
||||
assertThat(result.getAssignedEntity()).isEmpty();
|
||||
@@ -439,7 +439,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<Target> targets = testdataFactory.createTargets(20);
|
||||
final Iterable<TargetTag> tags = testdataFactory.createTargetTags(20, "");
|
||||
|
||||
tags.forEach(tag -> targetManagement.toggleTagAssignment(targets, tag));
|
||||
tags.forEach(tag -> toggleTagAssignment(targets, tag));
|
||||
|
||||
return targetTagRepository.findAll();
|
||||
}
|
||||
@@ -449,7 +449,7 @@ public class TagManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Collection<DistributionSet> sets = testdataFactory.createDistributionSets(20);
|
||||
final Iterable<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(20);
|
||||
|
||||
tags.forEach(tag -> distributionSetManagement.toggleTagAssignment(sets, tag));
|
||||
tags.forEach(tag -> toggleTagAssignment(sets, tag));
|
||||
|
||||
return tagManagement.findAllDistributionSetTags();
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryByName(filterName);
|
||||
assertEquals("Returns correct distribution set", distributionSet, tfq.getAutoAssignDistributionSet());
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(distributionSet);
|
||||
distributionSetManagement.deleteDistributionSet(distributionSet.getId());
|
||||
|
||||
// Check if auto assign distribution set is null
|
||||
tfq = targetFilterQueryManagement.findTargetFilterQueryByName(filterName);
|
||||
@@ -181,7 +181,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.findTargetFilterQueryByName(filterName);
|
||||
assertEquals("Returns correct distribution set", distributionSet, tfq.getAutoAssignDistributionSet());
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(distributionSet);
|
||||
distributionSetManagement.deleteDistributionSet(distributionSet.getId());
|
||||
|
||||
// Check if distribution set is still in the database with deleted flag
|
||||
assertTrue("Distribution set should be deleted",
|
||||
@@ -225,7 +225,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
|
||||
// check if find works
|
||||
Page<TargetFilterQuery> tfqList = targetFilterQueryManagement
|
||||
.findTargetFilterQueryByAutoAssignDS(new PageRequest(0, 500), distributionSet);
|
||||
.findTargetFilterQueryByAutoAssignDS(new PageRequest(0, 500), distributionSet.getId(), null);
|
||||
assertThat(1L).as("Target filter query").isEqualTo(tfqList.getTotalElements());
|
||||
|
||||
assertEquals("Returns correct target filter query", tfq.getId(), tfqList.iterator().next().getId());
|
||||
@@ -234,7 +234,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
|
||||
// check if find works for two
|
||||
tfqList = targetFilterQueryManagement.findTargetFilterQueryByAutoAssignDS(new PageRequest(0, 500),
|
||||
distributionSet);
|
||||
distributionSet.getId(), null);
|
||||
assertThat(2L).as("Target filter query count").isEqualTo(tfqList.getTotalElements());
|
||||
Iterator<TargetFilterQuery> iterator = tfqList.iterator();
|
||||
assertEquals("Returns correct target filter query 1", tfq.getId(), iterator.next().getId());
|
||||
@@ -242,7 +242,7 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
|
||||
// check if find works with name filter
|
||||
tfqList = targetFilterQueryManagement.findTargetFilterQueryByAutoAssignDS(new PageRequest(0, 500),
|
||||
distributionSet, "name==" + filterName);
|
||||
distributionSet.getId(), "name==" + filterName);
|
||||
assertThat(1L).as("Target filter query count").isEqualTo(tfqList.getTotalElements());
|
||||
|
||||
assertEquals("Returns correct target filter query", tfq2.getId(), tfqList.iterator().next().getId());
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.FilterParams;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetFilterQuery;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
@@ -65,7 +64,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final String targetDsAIdPref = "targ-A";
|
||||
List<Target> targAs = testdataFactory.createTargets(100, targetDsAIdPref,
|
||||
targetDsAIdPref.concat(" description"), lastTargetQueryNotOverdue);
|
||||
targAs = targetManagement.toggleTagAssignment(targAs, targTagX).getAssignedEntity();
|
||||
targAs = toggleTagAssignment(targAs, targTagX).getAssignedEntity();
|
||||
|
||||
final Target targSpecialName = targetManagement
|
||||
.updateTarget(entityFactory.target().update(targAs.get(0).getControllerId()).name("targ-A-special"));
|
||||
@@ -74,15 +73,15 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
List<Target> targBs = testdataFactory.createTargets(100, targetDsBIdPref,
|
||||
targetDsBIdPref.concat(" description"), lastTargetQueryAlwaysOverdue);
|
||||
|
||||
targBs = targetManagement.toggleTagAssignment(targBs, targTagY).getAssignedEntity();
|
||||
targBs = targetManagement.toggleTagAssignment(targBs, targTagW).getAssignedEntity();
|
||||
targBs = toggleTagAssignment(targBs, targTagY).getAssignedEntity();
|
||||
targBs = toggleTagAssignment(targBs, targTagW).getAssignedEntity();
|
||||
|
||||
final String targetDsCIdPref = "targ-C";
|
||||
List<Target> targCs = testdataFactory.createTargets(100, targetDsCIdPref,
|
||||
targetDsCIdPref.concat(" description"), lastTargetQueryAlwaysOverdue);
|
||||
|
||||
targCs = targetManagement.toggleTagAssignment(targCs, targTagZ).getAssignedEntity();
|
||||
targCs = targetManagement.toggleTagAssignment(targCs, targTagW).getAssignedEntity();
|
||||
targCs = toggleTagAssignment(targCs, targTagZ).getAssignedEntity();
|
||||
targCs = toggleTagAssignment(targCs, targTagW).getAssignedEntity();
|
||||
|
||||
final String targetDsDIdPref = "targ-D";
|
||||
final List<Target> targDs = testdataFactory.createTargets(100, targetDsDIdPref,
|
||||
@@ -175,15 +174,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
installedSet.getId(), Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, null, installedSet.getId(),
|
||||
Boolean.FALSE, new String[0])).as("has number of elements").hasSize(1)
|
||||
.as("and contains the following elements").containsExactly(expectedIdName)
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findAllTargetIdsByTargetFilterQuery(pageReq, new JpaTargetFilterQuery("test", query)));
|
||||
.as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
|
||||
}
|
||||
|
||||
@@ -201,15 +198,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
Boolean.FALSE, targTagW.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, both, null, null, null, Boolean.FALSE,
|
||||
targTagW.getName())).as("has number of elements").hasSize(200).as("and contains the following elements")
|
||||
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||
new JpaTargetFilterQuery("test", query)));
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
private static List<TargetIdName> convertToIdNames(final List<Target> expected) {
|
||||
@@ -236,15 +230,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
Boolean.FALSE, targTagW.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, null, null, Boolean.FALSE,
|
||||
targTagW.getName())).as("has number of elements").hasSize(2).as("and contains the following elements")
|
||||
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||
new JpaTargetFilterQuery("test", query)));
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -262,15 +253,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
setA.getId(), Boolean.FALSE, targTagW.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, null, null, Boolean.FALSE,
|
||||
targTagW.getName())).as("has number of elements").hasSize(2).as("and contains the following elements")
|
||||
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||
new JpaTargetFilterQuery("test", query)));
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -287,15 +275,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
setA.getId(), Boolean.FALSE, targTagW.getName())))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, "%targ-B%", setA.getId(),
|
||||
Boolean.FALSE, targTagW.getName())).as("has number of elements").hasSize(1)
|
||||
.as("and contains the following elements").containsExactly(expectedIdName)
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findAllTargetIdsByTargetFilterQuery(pageReq, new JpaTargetFilterQuery("test", query)));
|
||||
.as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -313,15 +299,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
setA.getId(), Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, "%targ-A%", setA.getId(),
|
||||
Boolean.FALSE, new String[0])).as("has number of elements").hasSize(1)
|
||||
.as("and contains the following elements").containsExactly(expectedIdName)
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findAllTargetIdsByTargetFilterQuery(pageReq, new JpaTargetFilterQuery("test", query)));
|
||||
.as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -339,15 +323,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
setA.getId(), Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, null, setA.getId(), Boolean.FALSE,
|
||||
new String[0])).as("has number of elements").hasSize(3).as("and contains the following elements")
|
||||
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||
new JpaTargetFilterQuery("test", query)));
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -363,15 +344,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, pending, null, null, null, Boolean.FALSE,
|
||||
new String[0])).as("has number of elements").hasSize(3).as("and contains the following elements")
|
||||
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||
new JpaTargetFilterQuery("test", query)));
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -389,15 +367,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
null, Boolean.FALSE, targTagW.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, null, "%targ-B%", null, Boolean.FALSE,
|
||||
targTagW.getName())).as("has number of elements").hasSize(99).as("and contains the following elements")
|
||||
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||
new JpaTargetFilterQuery("test", query)));
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -414,15 +389,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
null, Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, null, "%targ-A%", null, Boolean.FALSE,
|
||||
new String[0])).as("has number of elements").hasSize(99).as("and contains the following elements")
|
||||
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||
new JpaTargetFilterQuery("test", query)));
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -438,14 +410,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(unknown, null, null,
|
||||
setA.getId(), Boolean.FALSE, new String[0])))
|
||||
.as("and filter query returns the same result")
|
||||
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size())
|
||||
.as("and NAMED filter query returns the same result").hasSize(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent().size());
|
||||
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, null, null, setA.getId(), Boolean.FALSE,
|
||||
new String[0])).as("has number of elements").hasSize(0)
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findAllTargetIdsByTargetFilterQuery(pageReq, new JpaTargetFilterQuery("test", query)));
|
||||
.as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -462,15 +432,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
Boolean.FALSE, targTagY.getName(), targTagW.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, null, null, null, Boolean.FALSE,
|
||||
targTagY.getName(), targTagW.getName())).as("has number of elements").hasSize(198)
|
||||
.as("and contains the following elements").containsAll(expectedIdNames)
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findAllTargetIdsByTargetFilterQuery(pageReq, new JpaTargetFilterQuery("test", query)));
|
||||
.as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -486,15 +454,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, null, null, null, Boolean.FALSE,
|
||||
new String[0])).as("has number of elements").hasSize(397).as("and contains the following elements")
|
||||
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||
new JpaTargetFilterQuery("test", query)));
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -512,15 +477,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
null, Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, unknown, Boolean.TRUE, null, null, Boolean.FALSE,
|
||||
new String[0])).as("has number of elements").hasSize(198).as("and contains the following elements")
|
||||
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||
new JpaTargetFilterQuery("test", query)));
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -537,15 +499,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
setA.getId(), Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, "%targ-A%", setA.getId(),
|
||||
Boolean.FALSE, new String[0])).as("has number of elements").hasSize(1)
|
||||
.as("and contains the following elements").containsExactly(expectedIdName)
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findAllTargetIdsByTargetFilterQuery(pageReq, new JpaTargetFilterQuery("test", query)));
|
||||
.as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -561,15 +521,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
setA.getId(), Boolean.FALSE, new String[0])))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, null, setA.getId(), Boolean.FALSE,
|
||||
new String[0])).as("has number of elements").hasSize(3).as("and contains the following elements")
|
||||
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||
new JpaTargetFilterQuery("test", query)));
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -583,14 +540,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, "%targ-C%",
|
||||
setA.getId(), Boolean.FALSE, targTagX.getName())))
|
||||
.as("and filter query returns the same result")
|
||||
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size())
|
||||
.as("and NAMED filter query returns the same result").hasSize(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent().size());
|
||||
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, "%targ-C%", setA.getId(),
|
||||
Boolean.FALSE, targTagX.getName())).as("has number of elements").hasSize(0)
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findAllTargetIdsByTargetFilterQuery(pageReq, new JpaTargetFilterQuery("test", query)));
|
||||
.as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -604,14 +559,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, "%targ-A%",
|
||||
setA.getId(), Boolean.FALSE, targTagW.getName())))
|
||||
.as("and filter query returns the same result")
|
||||
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size())
|
||||
.as("and NAMED filter query returns the same result").hasSize(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent().size());
|
||||
.hasSize(targetManagement.findTargetsAll(query, pageReq).getContent().size());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, "%targ-A%", setA.getId(),
|
||||
Boolean.FALSE, targTagW.getName())).as("has number of elements").hasSize(0)
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findAllTargetIdsByTargetFilterQuery(pageReq, new JpaTargetFilterQuery("test", query)));
|
||||
.as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -628,32 +581,25 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
setA.getId(), Boolean.FALSE, targTagW.getName())))
|
||||
.as("and contains the following elements").containsExactly(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, "%targ-C%", setA.getId(),
|
||||
Boolean.FALSE, targTagW.getName())).as("has number of elements").hasSize(1)
|
||||
.as("and contains the following elements").containsExactly(expectedIdName)
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findAllTargetIdsByTargetFilterQuery(pageReq, new JpaTargetFilterQuery("test", query)));
|
||||
.as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
}
|
||||
|
||||
@Step
|
||||
private void verifyThat1TargetHasNameAndId(final String name, final String controllerId) {
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(pageReq, null, null, name, null, Boolean.FALSE)
|
||||
.getContent()).as("has number of elements").hasSize(1)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, name,
|
||||
null, Boolean.FALSE)));
|
||||
assertThat(targetManagement.findTargetByFilters(pageReq, null, null, name, null, Boolean.FALSE).getContent())
|
||||
.as("has number of elements").hasSize(1).as("that number is also returned by count query").hasSize(Ints
|
||||
.saturatedCast(targetManagement.countTargetByFilters(null, null, name, null, Boolean.FALSE)));
|
||||
|
||||
assertThat(targetManagement
|
||||
.findTargetByFilters(pageReq, null, null, controllerId, null, Boolean.FALSE)
|
||||
.getContent()).as("has number of elements").hasSize(1)
|
||||
.as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(targetManagement.countTargetByFilters(null, null, controllerId,
|
||||
null, Boolean.FALSE)));
|
||||
assertThat(targetManagement.findTargetByFilters(pageReq, null, null, controllerId, null, Boolean.FALSE)
|
||||
.getContent()).as("has number of elements").hasSize(1).as("that number is also returned by count query")
|
||||
.hasSize(Ints.saturatedCast(
|
||||
targetManagement.countTargetByFilters(null, null, controllerId, null, Boolean.FALSE)));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -669,15 +615,13 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
Boolean.FALSE, targTagY.getName(), targTagW.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, "%targ-B%", null, Boolean.FALSE,
|
||||
targTagY.getName(), targTagW.getName())).as("has number of elements").hasSize(100)
|
||||
.as("and contains the following elements").containsAll(expectedIdNames)
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findAllTargetIdsByTargetFilterQuery(pageReq, new JpaTargetFilterQuery("test", query)));
|
||||
.as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
|
||||
}
|
||||
|
||||
@@ -700,15 +644,12 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
Boolean.FALSE, targTagD.getName())))
|
||||
.as("and contains the following elements").containsAll(expected)
|
||||
.as("and filter query returns the same result")
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent())
|
||||
.as("and NAMED filter query returns the same result").containsAll(targetManagement
|
||||
.findTargetsAll(new JpaTargetFilterQuery("test", query), pageReq).getContent());
|
||||
.containsAll(targetManagement.findTargetsAll(query, pageReq).getContent());
|
||||
|
||||
assertThat(targetManagement.findAllTargetIdsByFilters(pageReq, null, null, null, null, Boolean.FALSE,
|
||||
targTagD.getName())).as("has number of elements").hasSize(200).as("and contains the following elements")
|
||||
.containsAll(expectedIdNames).as("and NAMED filter query returns the same result")
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq,
|
||||
new JpaTargetFilterQuery("test", query)));
|
||||
.containsAll(targetManagement.findAllTargetIdsByTargetFilterQuery(pageReq, query));
|
||||
|
||||
}
|
||||
|
||||
@@ -842,7 +783,7 @@ public class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
assignDistributionSet(assignedSet, assignedTargets);
|
||||
|
||||
final List<Target> result = targetManagement
|
||||
.findAllTargetsByTargetFilterQueryAndNonDS(pageReq, assignedSet.getId(), tfq).getContent();
|
||||
.findAllTargetsByTargetFilterQueryAndNonDS(pageReq, assignedSet.getId(), tfq.getQuery()).getContent();
|
||||
assertThat(result).as("count of targets").hasSize(unassignedTargets.size()).as("contains all targets")
|
||||
.containsAll(unassignedTargets);
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.test.matcher.Expect;
|
||||
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
|
||||
@@ -195,7 +194,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final TargetTag targetTag = tagManagement.createTargetTag(entityFactory.tag().create().name("Tag1"));
|
||||
|
||||
final List<Target> assignedTargets = targetManagement.assignTag(assignTarget, targetTag);
|
||||
final List<Target> assignedTargets = targetManagement.assignTag(assignTarget, targetTag.getId());
|
||||
assertThat(assignedTargets.size()).as("Assigned targets are wrong").isEqualTo(4);
|
||||
assignedTargets.forEach(target -> assertThat(target.getTags().size()).isEqualTo(1));
|
||||
|
||||
@@ -203,16 +202,16 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(assignedTargets.size()).as("Assigned targets are wrong")
|
||||
.isEqualTo(findTargetTag.getAssignedToTargets().size());
|
||||
|
||||
assertThat(targetManagement.unAssignTag("NotExist", findTargetTag)).as("Unassign target does not work")
|
||||
assertThat(targetManagement.unAssignTag("NotExist", findTargetTag.getId())).as("Unassign target does not work")
|
||||
.isNull();
|
||||
|
||||
final Target unAssignTarget = targetManagement.unAssignTag("targetId123", findTargetTag);
|
||||
final Target unAssignTarget = targetManagement.unAssignTag("targetId123", findTargetTag.getId());
|
||||
assertThat(unAssignTarget.getControllerId()).as("Controller id is wrong").isEqualTo("targetId123");
|
||||
assertThat(unAssignTarget.getTags()).as("Tag size is wrong").isEmpty();
|
||||
findTargetTag = tagManagement.findTargetTag("Tag1");
|
||||
assertThat(findTargetTag.getAssignedToTargets()).as("Assigned targets are wrong").hasSize(3);
|
||||
|
||||
final List<Target> unAssignTargets = targetManagement.unAssignAllTargetsByTag(findTargetTag);
|
||||
final List<Target> unAssignTargets = targetManagement.unAssignAllTargetsByTag(findTargetTag.getId());
|
||||
findTargetTag = tagManagement.findTargetTag("Tag1");
|
||||
assertThat(findTargetTag.getAssignedToTargets()).as("Unassigned targets are wrong").isEmpty();
|
||||
assertThat(unAssignTargets).as("Unassigned targets are wrong").hasSize(3);
|
||||
@@ -226,12 +225,12 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
public void deleteAndCreateTargets() {
|
||||
Target target = targetManagement.createTarget(entityFactory.target().create().controllerId("targetId123"));
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(1);
|
||||
targetManagement.deleteTargets(target.getId());
|
||||
targetManagement.deleteTargets(Lists.newArrayList(target.getId()));
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
|
||||
|
||||
target = createTargetWithAttributes("4711");
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(1);
|
||||
targetManagement.deleteTargets(target.getId());
|
||||
targetManagement.deleteTargets(Lists.newArrayList(target.getId()));
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
|
||||
|
||||
final List<Long> targets = new ArrayList<>();
|
||||
@@ -241,7 +240,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
targets.add(createTargetWithAttributes("" + (i * i + 1000)).getId());
|
||||
}
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(10);
|
||||
targetManagement.deleteTargets(targets.toArray(new Long[targets.size()]));
|
||||
targetManagement.deleteTargets(targets);
|
||||
assertThat(targetManagement.countTargetsAll()).as("target count is wrong").isEqualTo(0);
|
||||
}
|
||||
|
||||
@@ -522,7 +521,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
targetManagement.deleteTargets(extra.getId());
|
||||
targetManagement.deleteTarget(extra.getControllerId());
|
||||
|
||||
final int numberToDelete = 50;
|
||||
final Iterable<Target> targetsToDelete = limit(firstList, numberToDelete);
|
||||
@@ -550,11 +549,11 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
final int noT1Tags = 3;
|
||||
final List<TargetTag> t1Tags = testdataFactory.createTargetTags(noT1Tags, "tag1");
|
||||
|
||||
t1Tags.forEach(tag -> targetManagement.assignTag(Lists.newArrayList(t1.getControllerId()), tag));
|
||||
t1Tags.forEach(tag -> targetManagement.assignTag(Lists.newArrayList(t1.getControllerId()), tag.getId()));
|
||||
|
||||
final Target t2 = testdataFactory.createTarget("id-2");
|
||||
final List<TargetTag> t2Tags = testdataFactory.createTargetTags(noT2Tags, "tag2");
|
||||
t2Tags.forEach(tag -> targetManagement.assignTag(Lists.newArrayList(t2.getControllerId()), tag));
|
||||
t2Tags.forEach(tag -> targetManagement.assignTag(Lists.newArrayList(t2.getControllerId()), tag.getId()));
|
||||
|
||||
final Target t11 = targetManagement.findTargetByControllerID(t1.getControllerId());
|
||||
assertThat(t11.getTags()).as("Tag size is wrong").hasSize(noT1Tags).containsAll(t1Tags);
|
||||
@@ -587,16 +586,16 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("X"));
|
||||
|
||||
// doing different assignments
|
||||
targetManagement.toggleTagAssignment(tagATargets, tagA);
|
||||
targetManagement.toggleTagAssignment(tagBTargets, tagB);
|
||||
targetManagement.toggleTagAssignment(tagCTargets, tagC);
|
||||
toggleTagAssignment(tagATargets, tagA);
|
||||
toggleTagAssignment(tagBTargets, tagB);
|
||||
toggleTagAssignment(tagCTargets, tagC);
|
||||
|
||||
targetManagement.toggleTagAssignment(tagABTargets, tagA);
|
||||
targetManagement.toggleTagAssignment(tagABTargets, tagB);
|
||||
toggleTagAssignment(tagABTargets, tagA);
|
||||
toggleTagAssignment(tagABTargets, tagB);
|
||||
|
||||
targetManagement.toggleTagAssignment(tagABCTargets, tagA);
|
||||
targetManagement.toggleTagAssignment(tagABCTargets, tagB);
|
||||
targetManagement.toggleTagAssignment(tagABCTargets, tagC);
|
||||
toggleTagAssignment(tagABCTargets, tagA);
|
||||
toggleTagAssignment(tagABCTargets, tagB);
|
||||
toggleTagAssignment(tagABCTargets, tagC);
|
||||
|
||||
assertThat(targetManagement.countTargetByFilters(null, null, null, null, Boolean.FALSE, "X"))
|
||||
.as("Target count is wrong").isEqualTo(0);
|
||||
@@ -655,20 +654,20 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<Target> targBCs = testdataFactory.createTargets(7, "target-id-BC", "first description");
|
||||
final List<Target> targABCs = testdataFactory.createTargets(17, "target-id-ABC", "first description");
|
||||
|
||||
targetManagement.toggleTagAssignment(targAs, targTagA);
|
||||
targetManagement.toggleTagAssignment(targABs, targTagA);
|
||||
targetManagement.toggleTagAssignment(targACs, targTagA);
|
||||
targetManagement.toggleTagAssignment(targABCs, targTagA);
|
||||
toggleTagAssignment(targAs, targTagA);
|
||||
toggleTagAssignment(targABs, targTagA);
|
||||
toggleTagAssignment(targACs, targTagA);
|
||||
toggleTagAssignment(targABCs, targTagA);
|
||||
|
||||
targetManagement.toggleTagAssignment(targBs, targTagB);
|
||||
targetManagement.toggleTagAssignment(targABs, targTagB);
|
||||
targetManagement.toggleTagAssignment(targBCs, targTagB);
|
||||
targetManagement.toggleTagAssignment(targABCs, targTagB);
|
||||
toggleTagAssignment(targBs, targTagB);
|
||||
toggleTagAssignment(targABs, targTagB);
|
||||
toggleTagAssignment(targBCs, targTagB);
|
||||
toggleTagAssignment(targABCs, targTagB);
|
||||
|
||||
targetManagement.toggleTagAssignment(targCs, targTagC);
|
||||
targetManagement.toggleTagAssignment(targACs, targTagC);
|
||||
targetManagement.toggleTagAssignment(targBCs, targTagC);
|
||||
targetManagement.toggleTagAssignment(targABCs, targTagC);
|
||||
toggleTagAssignment(targCs, targTagC);
|
||||
toggleTagAssignment(targACs, targTagC);
|
||||
toggleTagAssignment(targBCs, targTagC);
|
||||
toggleTagAssignment(targABCs, targTagC);
|
||||
|
||||
checkTargetHasTags(true, targAs, targTagA);
|
||||
checkTargetHasTags(true, targBs, targTagB);
|
||||
@@ -677,10 +676,10 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
checkTargetHasTags(true, targBCs, targTagB, targTagC);
|
||||
checkTargetHasTags(true, targABCs, targTagA, targTagB, targTagC);
|
||||
|
||||
targetManagement.toggleTagAssignment(targCs, targTagC);
|
||||
targetManagement.toggleTagAssignment(targACs, targTagC);
|
||||
targetManagement.toggleTagAssignment(targBCs, targTagC);
|
||||
targetManagement.toggleTagAssignment(targABCs, targTagC);
|
||||
toggleTagAssignment(targCs, targTagC);
|
||||
toggleTagAssignment(targACs, targTagC);
|
||||
toggleTagAssignment(targBCs, targTagC);
|
||||
toggleTagAssignment(targABCs, targTagC);
|
||||
|
||||
checkTargetHasTags(true, targAs, targTagA); // 0
|
||||
checkTargetHasTags(true, targBs, targTagB);
|
||||
@@ -704,7 +703,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final List<Target> targAs = testdataFactory.createTargets(25, "target-id-A", "first description");
|
||||
|
||||
targetManagement.toggleTagAssignment(targAs, targTagA);
|
||||
toggleTagAssignment(targAs, targTagA);
|
||||
|
||||
assertThat(targetManagement.findTargetsByControllerIDsWithTags(
|
||||
targAs.stream().map(Target::getControllerId).collect(Collectors.toList()))).as("Target count is wrong")
|
||||
@@ -718,21 +717,6 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
.as("Tags not correctly assigned").containsOnly(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test the optimized quere for retrieving all ID/name pairs of targets.")
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 25) })
|
||||
public void findAllTargetIdNamePaiss() {
|
||||
final List<Target> targAs = testdataFactory.createTargets(25, "target-id-A", "first description");
|
||||
final String[] createdTargetIds = targAs.stream().map(Target::getControllerId)
|
||||
.toArray(size -> new String[size]);
|
||||
|
||||
final List<TargetIdName> findAllTargetIdNames = targetManagement.findAllTargetIds();
|
||||
final List<String> findAllTargetIds = findAllTargetIdNames.stream().map(TargetIdName::getControllerId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
assertThat(findAllTargetIds).as("Target list has wrong content").containsOnly(createdTargetIds);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test that NO TAG functionality which gives all targets with no tag assigned.")
|
||||
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1),
|
||||
@@ -742,7 +726,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final TargetTag targTagA = tagManagement.createTargetTag(entityFactory.tag().create().name("Targ-A-Tag"));
|
||||
final List<Target> targAs = testdataFactory.createTargets(25, "target-id-A", "first description");
|
||||
targetManagement.toggleTagAssignment(targAs, targTagA);
|
||||
toggleTagAssignment(targAs, targTagA);
|
||||
|
||||
testdataFactory.createTargets(25, "target-id-B", "first description");
|
||||
|
||||
@@ -750,7 +734,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<Target> targetsListWithNoTag = targetManagement
|
||||
.findTargetByFilters(pageReq, null, null, null, null, Boolean.TRUE, tagNames).getContent();
|
||||
|
||||
assertThat(50).as("Total targets").isEqualTo(targetManagement.findAllTargetIds().size());
|
||||
assertThat(50L).as("Total targets").isEqualTo(targetManagement.countTargetsAll());
|
||||
assertThat(25).as("Targets with no tag").isEqualTo(targetsListWithNoTag.size());
|
||||
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class AutoAssignCheckerTest extends AbstractJpaIntegrationTest {
|
||||
verifyThatTargetsHaveDistributionSetAssignment(setB, targets.subList(10, 20), targetsCount);
|
||||
|
||||
// Count the number of targets that will be assigned with setA
|
||||
assertThat(targetManagement.countTargetsByTargetFilterQueryAndNonDS(setA.getId(), targetFilterQuery))
|
||||
assertThat(targetManagement.countTargetsByTargetFilterQueryAndNonDS(setA.getId(), targetFilterQuery.getQuery()))
|
||||
.isEqualTo(90);
|
||||
|
||||
// Run the check
|
||||
|
||||
@@ -82,7 +82,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
public void targetDeletedEventIsPublished() throws InterruptedException {
|
||||
final Target createdTarget = testdataFactory.createTarget("12345");
|
||||
|
||||
targetManagement.deleteTargets(createdTarget.getId());
|
||||
targetManagement.deleteTarget("12345");
|
||||
|
||||
final TargetDeletedEvent targetDeletedEvent = eventListener.waitForEvent(TargetDeletedEvent.class, 1,
|
||||
TimeUnit.SECONDS);
|
||||
@@ -106,7 +106,7 @@ public class RepositoryEntityEventTest extends AbstractJpaIntegrationTest {
|
||||
public void distributionSetDeletedEventIsPublished() throws InterruptedException {
|
||||
final DistributionSet createDistributionSet = testdataFactory.createDistributionSet();
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(createDistributionSet);
|
||||
distributionSetManagement.deleteDistributionSet(createDistributionSet.getId());
|
||||
|
||||
final DistributionSetDeletedEvent dsDeletedEvent = eventListener.waitForEvent(DistributionSetDeletedEvent.class,
|
||||
1, TimeUnit.SECONDS);
|
||||
|
||||
@@ -105,7 +105,7 @@ public class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModuleType type = softwareManagement
|
||||
.createSoftwareModuleType(entityFactory.softwareModuleType().create().name("test").key("test"));
|
||||
|
||||
softwareManagement.deleteSoftwareModuleType(type);
|
||||
softwareManagement.deleteSoftwareModuleType(type.getId());
|
||||
assertThat(entityInterceptor.getEntity()).isNotNull();
|
||||
assertThat(entityInterceptor.getEntity()).isEqualTo(type);
|
||||
}
|
||||
|
||||
@@ -83,9 +83,9 @@ public class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) {
|
||||
|
||||
final Slice<Action> findEnitity = deploymentManagement.findActionsByTarget(rsqlParam, target,
|
||||
final Slice<Action> findEnitity = deploymentManagement.findActionsByTarget(rsqlParam, target.getControllerId(),
|
||||
new PageRequest(0, 100));
|
||||
final long countAllEntities = deploymentManagement.countActionsByTarget(rsqlParam, target);
|
||||
final long countAllEntities = deploymentManagement.countActionsByTarget(rsqlParam, target.getControllerId());
|
||||
assertThat(findEnitity).isNotNull();
|
||||
assertThat(countAllEntities).isEqualTo(expectedEntities);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class RSQLDistributionSetFieldTest extends AbstractJpaIntegrationTest {
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("Tag3"));
|
||||
tagManagement.createDistributionSetTag(entityFactory.tag().create().name("Tag4"));
|
||||
|
||||
distributionSetManagement.assignTag(Arrays.asList(ds.getId(), ds2.getId()), targetTag);
|
||||
distributionSetManagement.assignTag(Arrays.asList(ds.getId(), ds2.getId()), targetTag.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -64,7 +64,8 @@ public class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("Tag3"));
|
||||
tagManagement.createTargetTag(entityFactory.tag().create().name("Tag4"));
|
||||
|
||||
targetManagement.assignTag(Arrays.asList(target.getControllerId(), target2.getControllerId()), targetTag);
|
||||
targetManagement.assignTag(Arrays.asList(target.getControllerId(), target2.getControllerId()),
|
||||
targetTag.getId());
|
||||
|
||||
assignDistributionSet(ds.getId(), target.getControllerId());
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ package org.eclipse.hawkbit.repository.jpa.tenancy;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
@@ -19,6 +21,8 @@ import org.junit.Test;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Slice;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
@@ -122,12 +126,12 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
final Target createTargetForTenant = createTargetForTenant(controllerAnotherTenant, anotherTenant);
|
||||
|
||||
// ensure target cannot be deleted by 'mytenant'
|
||||
targetManagement.deleteTargets(createTargetForTenant.getId());
|
||||
targetManagement.deleteTargets(Lists.newArrayList(createTargetForTenant.getId()));
|
||||
Slice<Target> targetsForAnotherTenant = findTargetsForTenant(anotherTenant);
|
||||
assertThat(targetsForAnotherTenant).hasSize(1);
|
||||
|
||||
// ensure another tenant can delete the target
|
||||
deleteTargetsForTenant(anotherTenant, createTargetForTenant.getId());
|
||||
deleteTargetsForTenant(anotherTenant, Lists.newArrayList(createTargetForTenant.getId()));
|
||||
targetsForAnotherTenant = findTargetsForTenant(anotherTenant);
|
||||
assertThat(targetsForAnotherTenant).hasSize(0);
|
||||
}
|
||||
@@ -165,7 +169,7 @@ public class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
|
||||
() -> targetManagement.findTargetsAll(pageReq));
|
||||
}
|
||||
|
||||
private void deleteTargetsForTenant(final String tenant, final Long... targetIds) throws Exception {
|
||||
private void deleteTargetsForTenant(final String tenant, final Collection<Long> targetIds) throws Exception {
|
||||
securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("user", tenant), () -> {
|
||||
targetManagement.deleteTargets(targetIds);
|
||||
return null;
|
||||
|
||||
@@ -265,7 +265,7 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware {
|
||||
Target savedTarget = testdataFactory.createTarget(controllerId);
|
||||
savedTarget = assignDistributionSet(ds.getId(), savedTarget.getControllerId()).getAssignedEntity().iterator()
|
||||
.next();
|
||||
Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget).get(0);
|
||||
Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId()).get(0);
|
||||
|
||||
savedAction = controllerManagament.addUpdateActionStatus(
|
||||
entityFactory.actionStatus().create(savedAction.getId()).status(Action.Status.RUNNING));
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -44,6 +45,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
@@ -307,10 +309,7 @@ public class TestdataFactory {
|
||||
|
||||
final DistributionSet set = createDistributionSet(prefix, version, false);
|
||||
|
||||
final List<DistributionSet> sets = new ArrayList<>();
|
||||
sets.add(set);
|
||||
|
||||
tags.forEach(tag -> distributionSetManagement.toggleTagAssignment(sets, tag));
|
||||
tags.forEach(tag -> distributionSetManagement.toggleTagAssignment(Arrays.asList(set.getId()), tag.getName()));
|
||||
|
||||
return distributionSetManagement.findDistributionSetById(set.getId());
|
||||
|
||||
@@ -900,7 +899,8 @@ public class TestdataFactory {
|
||||
final Collection<String> msgs) {
|
||||
final List<Action> result = new ArrayList<>();
|
||||
for (final Target target : targets) {
|
||||
final List<Action> findByTarget = deploymentManagement.findActionsByTarget(target);
|
||||
final List<Action> findByTarget = deploymentManagement
|
||||
.findActionsByTarget(target.getControllerId(), new PageRequest(0, 400)).getContent();
|
||||
for (final Action action : findByTarget) {
|
||||
result.add(sendUpdateActionStatusToTarget(status, action, msgs));
|
||||
}
|
||||
|
||||
@@ -239,8 +239,8 @@ public class UploadViewConfirmationWindowLayout extends AbstractConfirmationWind
|
||||
final int deleteSWModuleTypeCount = artifactUploadState.getSelectedDeleteSWModuleTypes().size();
|
||||
for (final String swModuleTypeName : artifactUploadState.getSelectedDeleteSWModuleTypes()) {
|
||||
|
||||
softwareManagement
|
||||
.deleteSoftwareModuleType(softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName));
|
||||
softwareManagement.deleteSoftwareModuleType(
|
||||
softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName).getId());
|
||||
}
|
||||
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
|
||||
+ i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount }));
|
||||
|
||||
@@ -227,7 +227,7 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
|
||||
|
||||
final SoftwareManagement swMgmtService = SpringContextHelper.getBean(SoftwareManagement.class);
|
||||
final SoftwareModule swModule = swMgmtService.findSoftwareModuleByNameAndVersion(name, version,
|
||||
swMgmtService.findSoftwareModuleTypeByName(type));
|
||||
swMgmtService.findSoftwareModuleTypeByName(type).getId());
|
||||
|
||||
if (swModule != null) {
|
||||
uiNotifcation.displayValidationError(
|
||||
|
||||
@@ -32,7 +32,7 @@ public class SoftwareModuleFilters implements Serializable {
|
||||
private String searchText;
|
||||
|
||||
public Optional<SoftwareModuleType> getSoftwareModuleType() {
|
||||
return softwareModuleType == null ? Optional.empty() : Optional.of(softwareModuleType);
|
||||
return Optional.ofNullable(softwareModuleType);
|
||||
}
|
||||
|
||||
public void setSoftwareModuleType(final SoftwareModuleType softwareModuleType) {
|
||||
@@ -40,7 +40,7 @@ public class SoftwareModuleFilters implements Serializable {
|
||||
}
|
||||
|
||||
public Optional<String> getSearchText() {
|
||||
return searchText == null ? Optional.empty() : Optional.of(searchText);
|
||||
return Optional.ofNullable(searchText);
|
||||
}
|
||||
|
||||
public void setSearchText(final String searchText) {
|
||||
|
||||
@@ -183,7 +183,7 @@ public class SoftwareModuleDetailsTable extends Table {
|
||||
private void unassignSW(final ClickEvent event, final DistributionSet distributionSet,
|
||||
final Set<SoftwareModule> alreadyAssignedSwModules) {
|
||||
final SoftwareModule unAssignedSw = getSoftwareModule(event.getButton().getId(), alreadyAssignedSwModules);
|
||||
if (distributionSetManagement.isDistributionSetInUse(distributionSet)) {
|
||||
if (distributionSetManagement.isDistributionSetInUse(distributionSet.getId())) {
|
||||
uiNotification.displayValidationError(i18n.get("message.error.notification.ds.target.assigned",
|
||||
distributionSet.getName(), distributionSet.getVersion()));
|
||||
} else {
|
||||
|
||||
@@ -406,7 +406,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
|
||||
final DistributionSetTypeUpdate update = entityFactory.distributionSetType().update(existingType.getId())
|
||||
.description(tagDesc.getValue())
|
||||
.colour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview()));
|
||||
if (distributionSetManagement.countDistributionSetsByType(existingType) <= 0 && null != itemIds
|
||||
if (distributionSetManagement.countDistributionSetsByType(existingType.getId()) <= 0 && null != itemIds
|
||||
&& !itemIds.isEmpty()) {
|
||||
|
||||
update.mandatory(itemIds.stream().filter(itemId -> isMandatoryModuleType(selectedTable.getItem(itemId)))
|
||||
@@ -509,7 +509,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
|
||||
if (null != selectedTypeTag) {
|
||||
tagDesc.setValue(selectedTypeTag.getDescription());
|
||||
typeKey.setValue(selectedTypeTag.getKey());
|
||||
if (distributionSetManagement.countDistributionSetsByType(selectedTypeTag) <= 0) {
|
||||
if (distributionSetManagement.countDistributionSetsByType(selectedTypeTag.getId()) <= 0) {
|
||||
distTypeSelectLayout.setEnabled(true);
|
||||
selectedTable.setEnabled(true);
|
||||
} else {
|
||||
|
||||
@@ -345,7 +345,7 @@ public class DistributionSetTable extends AbstractNamedVersionTable<Distribution
|
||||
return false;
|
||||
}
|
||||
|
||||
if (distributionSetManagement.isDistributionSetInUse(ds)) {
|
||||
if (distributionSetManagement.isDistributionSetInUse(ds.getId())) {
|
||||
notification.displayValidationError(
|
||||
i18n.get("message.error.notification.ds.target.assigned", ds.getName(), ds.getVersion()));
|
||||
return false;
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.vaadin.spring.events.EventBus.UIEventBus;
|
||||
import org.vaadin.spring.events.EventScope;
|
||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.vaadin.data.Container;
|
||||
import com.vaadin.data.Item;
|
||||
@@ -275,8 +276,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
||||
final int deleteSWModuleTypeCount = manageDistUIState.getSelectedDeleteSWModuleTypes().size();
|
||||
for (final String swModuleTypeName : manageDistUIState.getSelectedDeleteSWModuleTypes()) {
|
||||
|
||||
softwareManagement
|
||||
.deleteSoftwareModuleType(softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName));
|
||||
softwareManagement.deleteSoftwareModuleType(
|
||||
softwareManagement.findSoftwareModuleTypeByName(swModuleTypeName).getId());
|
||||
}
|
||||
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
|
||||
+ i18n.get("message.sw.module.type.delete", new Object[] { deleteSWModuleTypeCount }));
|
||||
@@ -370,7 +371,7 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
||||
|
||||
}
|
||||
|
||||
dsManagement.deleteDistributionSet(deletedIds);
|
||||
dsManagement.deleteDistributionSet(Lists.newArrayList(deletedIds));
|
||||
|
||||
addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE
|
||||
+ i18n.get("message.dist.deleted", deletedIds.length));
|
||||
@@ -461,7 +462,8 @@ public class DistributionsConfirmationWindowLayout extends AbstractConfirmationW
|
||||
final int deleteDistTypeCount = manageDistUIState.getSelectedDeleteDistSetTypes().size();
|
||||
for (final String deleteDistTypeName : manageDistUIState.getSelectedDeleteDistSetTypes()) {
|
||||
|
||||
dsManagement.deleteDistributionSetType(dsManagement.findDistributionSetTypeByName(deleteDistTypeName));
|
||||
dsManagement
|
||||
.deleteDistributionSetType(dsManagement.findDistributionSetTypeByName(deleteDistTypeName).getId());
|
||||
}
|
||||
addToConsolitatedMsg(FontAwesome.TASKS.getHtml() + SPUILabelDefinitions.HTML_SPACE
|
||||
+ i18n.get("message.dist.type.delete", new Object[] { deleteDistTypeCount }));
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ManageDistFilters implements Serializable {
|
||||
}
|
||||
|
||||
public Optional<String> getSearchText() {
|
||||
return searchText == null ? Optional.empty() : Optional.of(searchText);
|
||||
return Optional.ofNullable(searchText);
|
||||
}
|
||||
|
||||
public void setSearchText(final String searchText) {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ManageSoftwareModuleFilters implements Serializable {
|
||||
* @return the softwareModuleType
|
||||
*/
|
||||
public Optional<SoftwareModuleType> getSoftwareModuleType() {
|
||||
return softwareModuleType == null ? Optional.empty() : Optional.of(softwareModuleType);
|
||||
return Optional.ofNullable(softwareModuleType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ public class ManageSoftwareModuleFilters implements Serializable {
|
||||
* @return the searchText
|
||||
*/
|
||||
public Optional<String> getSearchText() {
|
||||
return searchText == null ? Optional.empty() : Optional.of(searchText);
|
||||
return Optional.ofNullable(searchText);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -242,7 +242,7 @@ public class DistributionSetSelectWindow
|
||||
setContent(layout);
|
||||
|
||||
final Long targetsCount = targetManagement.countTargetsByTargetFilterQueryAndNonDS(distributionSetId,
|
||||
targetFilterQuery);
|
||||
targetFilterQuery.getQuery());
|
||||
Label mainTextLabel;
|
||||
if (targetsCount == 0) {
|
||||
mainTextLabel = new Label(i18n.get("message.confirm.assign.consequences.none"));
|
||||
|
||||
@@ -122,7 +122,7 @@ public class FilterManagementUIState implements Serializable {
|
||||
* @return the tfQuery
|
||||
*/
|
||||
public Optional<TargetFilterQuery> getTfQuery() {
|
||||
return targetFilterQuery == null ? Optional.empty() : Optional.of(targetFilterQuery);
|
||||
return Optional.ofNullable(targetFilterQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +142,7 @@ public class FilterManagementUIState implements Serializable {
|
||||
}
|
||||
|
||||
public Optional<String> getCustomFilterSearchText() {
|
||||
return targetFilterSearchText == null ? Optional.empty() : Optional.of(targetFilterSearchText);
|
||||
return Optional.ofNullable(targetFilterSearchText);
|
||||
}
|
||||
|
||||
public void setCustomFilterSearchText(final String updateCustomFilterSearchText) {
|
||||
|
||||
@@ -220,7 +220,7 @@ public class ActionHistoryTable extends TreeTable {
|
||||
if (target != null) {
|
||||
/* service method to create action history for target */
|
||||
final List<ActionWithStatusCount> actionHistory = deploymentManagement
|
||||
.findActionsWithStatusCountByTargetOrderByIdDesc(target);
|
||||
.findActionsWithStatusCountByTargetOrderByIdDesc(target.getControllerId());
|
||||
|
||||
addDetailsToContainer(actionHistory);
|
||||
}
|
||||
@@ -437,9 +437,9 @@ public class ActionHistoryTable extends TreeTable {
|
||||
new Sort(Direction.DESC, ActionStatusFields.ID.getFieldName()));
|
||||
final Page<ActionStatus> actionStatusList;
|
||||
if (managementUIState.isActionHistoryMaximized()) {
|
||||
actionStatusList = deploymentManagement.findActionStatusByActionWithMessages(pageReq, action);
|
||||
actionStatusList = deploymentManagement.findActionStatusByActionWithMessages(pageReq, actionId);
|
||||
} else {
|
||||
actionStatusList = deploymentManagement.findActionStatusByAction(pageReq, action);
|
||||
actionStatusList = deploymentManagement.findActionStatusByAction(pageReq, actionId);
|
||||
}
|
||||
final List<ActionStatus> content = actionStatusList.getContent();
|
||||
/*
|
||||
@@ -793,9 +793,8 @@ public class ActionHistoryTable extends TreeTable {
|
||||
// service call to cancel the active action
|
||||
private boolean cancelActiveAction(final Long actionId) {
|
||||
if (actionId != null) {
|
||||
final Action activeAction = deploymentManagement.findAction(actionId);
|
||||
try {
|
||||
deploymentManagement.cancelAction(activeAction, target);
|
||||
deploymentManagement.cancelAction(actionId);
|
||||
return true;
|
||||
} catch (final CancelActionNotAllowedException e) {
|
||||
LOG.info("Cancel action not allowed exception :{}", e);
|
||||
@@ -808,9 +807,8 @@ public class ActionHistoryTable extends TreeTable {
|
||||
// service call to cancel the active action
|
||||
private boolean forceQuitActiveAction(final Long actionId) {
|
||||
if (actionId != null) {
|
||||
final Action activeAction = deploymentManagement.findAction(actionId);
|
||||
try {
|
||||
deploymentManagement.forceQuitAction(activeAction);
|
||||
deploymentManagement.forceQuitAction(actionId);
|
||||
return true;
|
||||
} catch (final CancelActionNotAllowedException e) {
|
||||
LOG.info("Force Cancel action not allowed exception :{}", e);
|
||||
|
||||
@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.ui.management.footer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -381,10 +380,11 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
|
||||
}
|
||||
|
||||
private void deleteAllDistributions(final ConfirmationTab tab) {
|
||||
final Set<Long> deletedIds = new HashSet<>();
|
||||
managementUIState.getDeletedDistributionList().forEach(distIdName -> deletedIds.add(distIdName.getId()));
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(deletedIds.toArray(new Long[deletedIds.size()]));
|
||||
final Collection<Long> deletedIds = managementUIState.getDeletedDistributionList().stream()
|
||||
.map(DistributionSetIdName::getId).collect(Collectors.toList());
|
||||
|
||||
distributionSetManagement.deleteDistributionSet(deletedIds);
|
||||
eventBus.publish(this, new DistributionTableEvent(BaseEntityEventType.REMOVE_ENTITY, deletedIds));
|
||||
|
||||
addToConsolitatedMsg(FontAwesome.TRASH_O.getHtml() + SPUILabelDefinitions.HTML_SPACE
|
||||
@@ -411,7 +411,7 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin
|
||||
}
|
||||
}
|
||||
|
||||
private void unPinDeletedDS(final Set<Long> deletedDsIds, final Long pinnedDsId) {
|
||||
private void unPinDeletedDS(final Collection<Long> deletedDsIds, final Long pinnedDsId) {
|
||||
if (deletedDsIds.contains(pinnedDsId)) {
|
||||
managementUIState.getTargetTableFilters().setPinnedDistId(null);
|
||||
eventBus.publish(this, PinUnpinEvent.UNPIN_DISTRIBUTION);
|
||||
|
||||
@@ -60,7 +60,7 @@ public class DistributionTableFilters implements Serializable {
|
||||
}
|
||||
|
||||
public Optional<Long> getDistId() {
|
||||
return distId == null ? Optional.empty() : Optional.of(distId);
|
||||
return Optional.ofNullable(distId);
|
||||
}
|
||||
|
||||
public void setDistId(final Long distId) {
|
||||
@@ -68,7 +68,7 @@ public class DistributionTableFilters implements Serializable {
|
||||
}
|
||||
|
||||
public Optional<String> getPinnedTargetId() {
|
||||
return pinnedTargetId == null ? Optional.empty() : Optional.of(pinnedTargetId);
|
||||
return Optional.ofNullable(pinnedTargetId);
|
||||
}
|
||||
|
||||
public void setPinnedTargetId(final String pinnedTargetId) {
|
||||
@@ -76,7 +76,7 @@ public class DistributionTableFilters implements Serializable {
|
||||
}
|
||||
|
||||
public Optional<String> getSearchText() {
|
||||
return searchText == null ? Optional.empty() : Optional.of(searchText);
|
||||
return Optional.ofNullable(searchText);
|
||||
}
|
||||
|
||||
public void setSearchText(final String searchText) {
|
||||
|
||||
@@ -13,7 +13,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
|
||||
|
||||
@@ -44,7 +43,7 @@ public class TargetTableFilters implements Serializable {
|
||||
/**
|
||||
* Custom target filter query use dto filter target table.
|
||||
*/
|
||||
private TargetFilterQuery targetFilterQuery;
|
||||
private Long targetFilterQuery;
|
||||
/**
|
||||
* Flag for NO TAG button status.
|
||||
*/
|
||||
@@ -61,7 +60,7 @@ public class TargetTableFilters implements Serializable {
|
||||
* @return the progressBarCurrentValue
|
||||
*/
|
||||
public Optional<Float> getProgressBarCurrentValue() {
|
||||
return progressBarCurrentValue != null ? Optional.of(progressBarCurrentValue) : Optional.empty();
|
||||
return Optional.ofNullable(progressBarCurrentValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +75,7 @@ public class TargetTableFilters implements Serializable {
|
||||
* @return the targetsCreatedCount
|
||||
*/
|
||||
public Optional<Long> getTargetsCreatedCount() {
|
||||
return targetsCreatedCount != null ? Optional.of(targetsCreatedCount) : Optional.empty();
|
||||
return Optional.ofNullable(targetsCreatedCount);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,15 +95,15 @@ public class TargetTableFilters implements Serializable {
|
||||
}
|
||||
|
||||
public Optional<String> getSearchText() {
|
||||
return searchText == null ? Optional.empty() : Optional.of(searchText);
|
||||
return Optional.ofNullable(searchText);
|
||||
}
|
||||
|
||||
public Optional<DistributionSetIdName> getDistributionSet() {
|
||||
return distributionSet == null ? Optional.empty() : Optional.of(distributionSet);
|
||||
return Optional.ofNullable(distributionSet);
|
||||
}
|
||||
|
||||
public Optional<Long> getPinnedDistId() {
|
||||
return pinnedDistId == null ? Optional.empty() : Optional.of(pinnedDistId);
|
||||
return Optional.ofNullable(pinnedDistId);
|
||||
}
|
||||
|
||||
public void setSearchText(final String searchText) {
|
||||
@@ -151,15 +150,15 @@ public class TargetTableFilters implements Serializable {
|
||||
/**
|
||||
* @return the targetFilterQuery
|
||||
*/
|
||||
public Optional<TargetFilterQuery> getTargetFilterQuery() {
|
||||
return targetFilterQuery == null ? Optional.empty() : Optional.of(targetFilterQuery);
|
||||
public Optional<Long> getTargetFilterQuery() {
|
||||
return Optional.ofNullable(targetFilterQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targetFilterQuery
|
||||
* the targetFilterQuery to set
|
||||
*/
|
||||
public void setTargetFilterQuery(final TargetFilterQuery targetFilterQuery) {
|
||||
public void setTargetFilterQuery(final Long targetFilterQuery) {
|
||||
this.targetFilterQuery = targetFilterQuery;
|
||||
}
|
||||
|
||||
@@ -167,7 +166,7 @@ public class TargetTableFilters implements Serializable {
|
||||
return isOverdueFilterEnabled;
|
||||
}
|
||||
|
||||
public void setOverdueFilterEnabled(boolean isOverdueFilterEnabled) {
|
||||
public void setOverdueFilterEnabled(final boolean isOverdueFilterEnabled) {
|
||||
this.isOverdueFilterEnabled = isOverdueFilterEnabled;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
new OffsetBasedPageRequest(startIndex, SPUIDefinitions.PAGE_SIZE, sort), pinnedDistId,
|
||||
new FilterParams(distributionId, status, overdueState, searchText, noTagClicked, targetTags));
|
||||
} else if (null != targetFilterQuery) {
|
||||
targetBeans = getTargetManagement().findTargetsAll(targetFilterQuery,
|
||||
targetBeans = getTargetManagement().findTargetsByTargetFilterQuery(targetFilterQuery.getId(),
|
||||
new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort));
|
||||
} else if (!isAnyFilterSelected()) {
|
||||
targetBeans = getTargetManagement().findTargetsAll(
|
||||
@@ -189,7 +189,7 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
|
||||
final long totSize = getTargetManagement().countTargetsAll();
|
||||
long size;
|
||||
if (null != targetFilterQuery) {
|
||||
size = getTargetManagement().countTargetByTargetFilterQuery(targetFilterQuery);
|
||||
size = getTargetManagement().countTargetByTargetFilterQuery(targetFilterQuery.getId());
|
||||
} else if (!isAnyFilterSelected()) {
|
||||
size = totSize;
|
||||
} else {
|
||||
|
||||
@@ -53,7 +53,7 @@ public class CustomTargetTagFilterButtonClick extends AbstractFilterSingleButton
|
||||
protected void filterClicked(final Button clickedButton) {
|
||||
final TargetFilterQuery targetFilterQuery = this.targetFilterQueryManagement
|
||||
.findTargetFilterQueryById((Long) clickedButton.getData());
|
||||
this.managementUIState.getTargetTableFilters().setTargetFilterQuery(targetFilterQuery);
|
||||
this.managementUIState.getTargetTableFilters().setTargetFilterQuery(targetFilterQuery.getId());
|
||||
this.eventBus.publish(this, TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,8 +119,7 @@ public class TargetFilterQueryButtons extends Table {
|
||||
}
|
||||
|
||||
private boolean isClickedByDefault(final Long id) {
|
||||
return managementUIState.getTargetTableFilters().getTargetFilterQuery().map(q -> q.getId().equals(id))
|
||||
.orElse(false);
|
||||
return managementUIState.getTargetTableFilters().getTargetFilterQuery().map(q -> q.equals(id)).orElse(false);
|
||||
}
|
||||
|
||||
private Button createFilterButton(final Long id, final String name, final Object itemId) {
|
||||
|
||||
@@ -137,7 +137,7 @@ public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup>
|
||||
|
||||
private String calculateFinishedPercentage(final RolloutGroup rolloutGroup) {
|
||||
return HawkbitCommonUtil.formattingFinishedPercentage(rolloutGroup, getRolloutManagement()
|
||||
.getFinishedPercentForRunningGroup(rolloutGroup.getRollout().getId(), rolloutGroup));
|
||||
.getFinishedPercentForRunningGroup(rolloutGroup.getRollout().getId(), rolloutGroup.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -84,8 +84,8 @@ public class RolloutGroupTargetsBeanQuery extends AbstractBeanQuery<ProxyTarget>
|
||||
}
|
||||
|
||||
return rolloutGroup.map(group -> getProxyRolloutGroupTargetsList(getRolloutGroupManagement()
|
||||
.findAllTargetsWithActionStatus(new PageRequest(startIndex / count, count), group).getContent()))
|
||||
.orElse(Collections.emptyList());
|
||||
.findAllTargetsWithActionStatus(new PageRequest(startIndex / count, count), group.getId())
|
||||
.getContent())).orElse(Collections.emptyList());
|
||||
}
|
||||
|
||||
private static List<ProxyTarget> getProxyRolloutGroupTargetsList(
|
||||
@@ -136,7 +136,7 @@ public class RolloutGroupTargetsBeanQuery extends AbstractBeanQuery<ProxyTarget>
|
||||
|
||||
if (rolloutGroup.isPresent()) {
|
||||
firstPageTargetSets = getRolloutGroupManagement().findAllTargetsWithActionStatus(
|
||||
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), rolloutGroup.get());
|
||||
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), rolloutGroup.get().getId());
|
||||
size = firstPageTargetSets.getTotalElements();
|
||||
}
|
||||
getRolloutUIState().setRolloutGroupTargetsTotalCount(size);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class RolloutUIState implements Serializable {
|
||||
* @return the searchText
|
||||
*/
|
||||
public Optional<String> getSearchText() {
|
||||
return null != searchText ? Optional.of(searchText) : Optional.empty();
|
||||
return Optional.ofNullable(searchText);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ public class RolloutUIState implements Serializable {
|
||||
* @return the rolloutId
|
||||
*/
|
||||
public Optional<Long> getRolloutId() {
|
||||
return rolloutId != null ? Optional.of(rolloutId) : Optional.empty();
|
||||
return Optional.ofNullable(rolloutId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ public class RolloutUIState implements Serializable {
|
||||
* @return the rolloutGroup
|
||||
*/
|
||||
public Optional<RolloutGroup> getRolloutGroup() {
|
||||
return rolloutGroup == null ? Optional.empty() : Optional.of(rolloutGroup);
|
||||
return Optional.ofNullable(rolloutGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +140,7 @@ public class RolloutUIState implements Serializable {
|
||||
* @return the rolloutName
|
||||
*/
|
||||
public Optional<String> getRolloutName() {
|
||||
return rolloutName == null ? Optional.empty() : Optional.of(rolloutName);
|
||||
return Optional.ofNullable(rolloutName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +185,7 @@ public class RolloutUIState implements Serializable {
|
||||
* @return rolloutDistributionSet
|
||||
*/
|
||||
public Optional<String> getRolloutDistributionSet() {
|
||||
return rolloutDistributionSet == null ? Optional.empty() : Optional.of(rolloutDistributionSet);
|
||||
return Optional.ofNullable(rolloutDistributionSet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user