Improve Spring Bus usage (remove stream direct use) (#2521)

* Improve Spring Bus usage (remove stream direct use)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>

* Remove getApplicaton when creating remote events

---------

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-07-02 08:32:55 +03:00
committed by GitHub
parent 65c81a3e90
commit affae1026a
104 changed files with 327 additions and 837 deletions

View File

@@ -212,8 +212,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
(length, shippedSinceLastEvent, total) -> { (length, shippedSinceLastEvent, total) -> {
if (actionStatus != null) { if (actionStatus != null) {
eventPublisher.publishEvent(new DownloadProgressEvent( eventPublisher.publishEvent(new DownloadProgressEvent(
tenantAware.getCurrentTenant(), actionStatus.getId(), shippedSinceLastEvent, tenantAware.getCurrentTenant(), actionStatus.getId(), shippedSinceLastEvent));
serviceMatcher != null ? serviceMatcher.getBusId() : bus.getId()));
} }
}); });
} }

View File

@@ -47,8 +47,6 @@ import org.eclipse.hawkbit.repository.test.TestConfiguration;
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest; import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
import org.eclipse.hawkbit.rest.RestConfiguration; import org.eclipse.hawkbit.rest.RestConfiguration;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.TestPropertySource;
@@ -58,7 +56,6 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@ContextConfiguration( @ContextConfiguration(
classes = { DdiApiConfiguration.class, RestConfiguration.class, RepositoryApplicationConfiguration.class, TestConfiguration.class }) classes = { DdiApiConfiguration.class, RestConfiguration.class, RepositoryApplicationConfiguration.class, TestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
@TestPropertySource(locations = "classpath:/ddi-test.properties") @TestPropertySource(locations = "classpath:/ddi-test.properties")
public abstract class AbstractDDiApiIntegrationTest extends AbstractRestIntegrationTest { public abstract class AbstractDDiApiIntegrationTest extends AbstractRestIntegrationTest {

View File

@@ -32,11 +32,6 @@
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<!-- Database --> <!-- Database -->
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>

View File

@@ -82,7 +82,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
private Target testTarget; private Target testTarget;
@BeforeEach @BeforeEach
public void beforeEach() { void beforeEach() {
testTarget = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID) testTarget = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)
.securityToken(TEST_TOKEN).address(AMQP_URI.toString())); .securityToken(TEST_TOKEN).address(AMQP_URI.toString()));
@@ -126,8 +126,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
final Action action = createAction(createDistributionSet); final Action action = createAction(createDistributionSet);
final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent( final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent(action);
action, serviceMatcher.getBusId());
amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent); amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent);
final Message sendMessage = getCaptureAddressEvent(targetAssignDistributionSetEvent); final Message sendMessage = getCaptureAddressEvent(targetAssignDistributionSetEvent);
final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage, final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage,
@@ -175,8 +174,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
Mockito.when(rabbitTemplate.convertSendAndReceive(any())).thenReturn(receivedList); Mockito.when(rabbitTemplate.convertSendAndReceive(any())).thenReturn(receivedList);
final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent( final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent(action);
action, serviceMatcher.getBusId());
amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent); amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent);
final Message sendMessage = getCaptureAddressEvent(targetAssignDistributionSetEvent); final Message sendMessage = getCaptureAddressEvent(targetAssignDistributionSetEvent);
final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage, final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage,
@@ -215,8 +213,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
@Test @Test
void sendUpdateAttributesRequest() { void sendUpdateAttributesRequest() {
final String amqpUri = "amqp://anyhost"; final String amqpUri = "amqp://anyhost";
final TargetAttributesRequestedEvent targetAttributesRequestedEvent = new TargetAttributesRequestedEvent(TENANT, final TargetAttributesRequestedEvent targetAttributesRequestedEvent = new TargetAttributesRequestedEvent(
1L, CONTROLLER_ID, amqpUri, Target.class, serviceMatcher.getBusId()); TENANT,1L, Target.class, CONTROLLER_ID, amqpUri);
amqpMessageDispatcherService.targetTriggerUpdateAttributes(targetAttributesRequestedEvent); amqpMessageDispatcherService.targetTriggerUpdateAttributes(targetAttributesRequestedEvent);
@@ -233,10 +231,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
when(action.getId()).thenReturn(1L); when(action.getId()).thenReturn(1L);
when(action.getTenant()).thenReturn(TENANT); when(action.getTenant()).thenReturn(TENANT);
when(action.getTarget()).thenReturn(testTarget); when(action.getTarget()).thenReturn(testTarget);
final CancelTargetAssignmentEvent cancelTargetAssignmentDistributionSetEvent = new CancelTargetAssignmentEvent( final CancelTargetAssignmentEvent cancelTargetAssignmentDistributionSetEvent = new CancelTargetAssignmentEvent(action);
action, serviceMatcher.getBusId()); amqpMessageDispatcherService.targetCancelAssignmentToDistributionSet(cancelTargetAssignmentDistributionSetEvent);
amqpMessageDispatcherService
.targetCancelAssignmentToDistributionSet(cancelTargetAssignmentDistributionSetEvent);
final Message sendMessage = createArgumentCapture(AMQP_URI); final Message sendMessage = createArgumentCapture(AMQP_URI);
assertCancelMessage(sendMessage); assertCancelMessage(sendMessage);
@@ -250,8 +246,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
// setup // setup
final String amqpUri = "amqp://anyhost"; final String amqpUri = "amqp://anyhost";
final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, amqpUri, final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, Target.class, CONTROLLER_ID, amqpUri);
Target.class, serviceMatcher.getBusId());
// test // test
amqpMessageDispatcherService.targetDelete(targetDeletedEvent); amqpMessageDispatcherService.targetDelete(targetDeletedEvent);
@@ -269,8 +264,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
// setup // setup
final String noAmqpUri = "http://anyhost"; final String noAmqpUri = "http://anyhost";
final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, noAmqpUri, final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, Target.class, CONTROLLER_ID, noAmqpUri);
Target.class, serviceMatcher.getBusId());
// test // test
amqpMessageDispatcherService.targetDelete(targetDeletedEvent); amqpMessageDispatcherService.targetDelete(targetDeletedEvent);
@@ -287,8 +281,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
// setup // setup
final String noAmqpUri = null; final String noAmqpUri = null;
final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, noAmqpUri, final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, Target.class, CONTROLLER_ID, noAmqpUri);
Target.class, serviceMatcher.getBusId());
// test // test
amqpMessageDispatcherService.targetDelete(targetDeletedEvent); amqpMessageDispatcherService.targetDelete(targetDeletedEvent);

View File

@@ -58,8 +58,6 @@ import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties; import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.test.RabbitListenerTestHarness; import org.springframework.amqp.rabbit.test.RabbitListenerTestHarness;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@@ -69,7 +67,6 @@ import org.springframework.util.CollectionUtils;
@ContextConfiguration(classes = { @ContextConfiguration(classes = {
DmfApiConfiguration.class, DmfTestConfiguration.class, DmfApiConfiguration.class, DmfTestConfiguration.class,
RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class }) RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegrationTest { abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegrationTest {
protected static final String TENANT_EXIST = "DEFAULT"; protected static final String TENANT_EXIST = "DEFAULT";

View File

@@ -28,8 +28,6 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.junit.RabbitAvailable; import org.springframework.amqp.rabbit.junit.RabbitAvailable;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
@@ -37,7 +35,6 @@ import org.springframework.test.context.ContextConfiguration;
@Slf4j @Slf4j
@RabbitAvailable @RabbitAvailable
@ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class, TestConfiguration.class }) @ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class, TestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
// Dirty context is necessary to create a new vhost and recreate all necessary beans after every test class. // Dirty context is necessary to create a new vhost and recreate all necessary beans after every test class.
@DirtiesContext(classMode = ClassMode.AFTER_CLASS) @DirtiesContext(classMode = ClassMode.AFTER_CLASS)
@SuppressWarnings("java:S6813") // constructor injects are not possible for test classes @SuppressWarnings("java:S6813") // constructor injects are not possible for test classes

View File

@@ -32,11 +32,6 @@
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<!-- Database --> <!-- Database -->
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>

View File

@@ -27,15 +27,12 @@ import org.eclipse.hawkbit.repository.test.TestConfiguration;
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest; import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
import org.eclipse.hawkbit.rest.RestConfiguration; import org.eclipse.hawkbit.rest.RestConfiguration;
import org.json.JSONObject; import org.json.JSONObject;
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.TestPropertySource;
import org.springframework.test.web.servlet.ResultMatcher; import org.springframework.test.web.servlet.ResultMatcher;
@ContextConfiguration( @ContextConfiguration(
classes = { MgmtApiConfiguration.class, RestConfiguration.class, RepositoryApplicationConfiguration.class, TestConfiguration.class }) classes = { MgmtApiConfiguration.class, RestConfiguration.class, RepositoryApplicationConfiguration.class, TestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
@TestPropertySource(locations = "classpath:/mgmt-test.properties") @TestPropertySource(locations = "classpath:/mgmt-test.properties")
public abstract class AbstractManagementApiIntegrationTest extends AbstractRestIntegrationTest { public abstract class AbstractManagementApiIntegrationTest extends AbstractRestIntegrationTest {

View File

@@ -34,8 +34,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.hateoas.MediaTypes; import org.springframework.hateoas.MediaTypes;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
@@ -70,7 +68,6 @@ import org.springframework.web.context.WebApplicationContext;
@AutoConfigureMockMvc @AutoConfigureMockMvc
@ContextConfiguration(classes = { MgmtApiConfiguration.class, RestConfiguration.class, @ContextConfiguration(classes = { MgmtApiConfiguration.class, RestConfiguration.class,
RepositoryApplicationConfiguration.class, TestConfiguration.class }) RepositoryApplicationConfiguration.class, TestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
/** /**
* Feature: Component Tests - Management API<br/> * Feature: Component Tests - Management API<br/>
* Story: Basic auth Userinfo Resource * Story: Basic auth Userinfo Resource

View File

@@ -32,11 +32,6 @@
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<!-- Database --> <!-- Database -->
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>

View File

@@ -24,28 +24,25 @@ The Management API can be accessed via http://localhost:8080/rest/v1
## Enable Clustering (experimental) ## Enable Clustering (experimental)
Clustering in hawkBit is based on _Spring Cloud Bus_. It is not enabled in the example app by default. Clustering in hawkBit is based on _Spring Cloud Bus_. It is enabled by default in microservice apps and disabled (by default) in the
monolith app. To enable it for monolith app you should set (via environment, system properties or properties files) the following:
Add to your `pom.xml` : Add to your `pom.xml` :
```xml ```properties
<dependency> spring.autoconfigure.exclude=
<groupId>org.springframework.cloud</groupId> spring.cloud.bus.enabled=true
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
``` ```
Optional as well is the addition of [Protostuff](https://github.com/protostuff/protostuff) based message payload Optional as well is the addition of [Protostuff](https://github.com/protostuff/protostuff) based message payload
serialization for improved performance. serialization for improved performance. To enable it set (via environment, system properties or properties files):
Add to your `application.properties` :
```properties ```properties
spring.cloud.stream.bindings.springCloudBusInput.content-type=application/binary+protostuff spring.cloud.stream.bindings.springCloudBusInput.content-type=application/binary+protostuff
spring.cloud.stream.bindings.springCloudBusOutput.content-type=application/binary+protostuff spring.cloud.stream.bindings.springCloudBusOutput.content-type=application/binary+protostuff
``` ```
Add to your `pom.xml` : and add to your `pom.xml` :
```xml ```xml
<dependency> <dependency>

View File

@@ -39,29 +39,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId> <artifactId>spring-cloud-starter-bus-amqp</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-rsa</artifactId>
</exclusion>
<exclusion>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-context</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -7,7 +7,7 @@
* *
* SPDX-License-Identifier: EPL-2.0 * SPDX-License-Identifier: EPL-2.0
*/ */
package org.eclipse.hawkbit.repository.model.helper; package org.eclipse.hawkbit.repository.event;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
@@ -55,17 +55,17 @@ public final class EventPublisherHolder {
} }
/** /**
* @return the service origin Id coming either from {@link ServiceMatcher} when available or {@link BusProperties} * @return the service origin Id coming either from {@link ServiceMatcher} when available or {@link BusProperties} otherwise.
* otherwise.
*/ */
public String getApplicationId() { public String getApplicationId() {
String id = null; String id = null;
if (serviceMatcher != null) { if (serviceMatcher != null) {
id = serviceMatcher.getBusId(); id = serviceMatcher.getBusId();
} }
if (id == null) { if (id == null && bus != null) {
id = bus.getId(); id = bus.getId();
} }
return id; // due to a bug (?) in Spring Cloud, we cannot pass null for applicationId
return id == null ? "" : id;
} }
} }

View File

@@ -38,14 +38,13 @@ public abstract class AbstractAssignmentEvent extends RemoteTenantAwareEvent {
private final Map<String, ActionProperties> actions = new HashMap<>(); private final Map<String, ActionProperties> actions = new HashMap<>();
protected AbstractAssignmentEvent(final Object source, final Action a, final String applicationId) { protected AbstractAssignmentEvent(final Action a) {
super(source, a.getTenant(), applicationId); super(a.getTenant(), null);
actions.put(a.getTarget().getControllerId(), new ActionProperties(a)); actions.put(a.getTarget().getControllerId(), new ActionProperties(a));
} }
protected AbstractAssignmentEvent(final Object source, final String tenant, final List<Action> a, protected AbstractAssignmentEvent(final String tenant, final Object source, final List<Action> a) {
final String applicationId) { super(tenant, source);
super(source, tenant, applicationId);
actions.putAll(a.stream() actions.putAll(a.stream()
.collect(Collectors.toMap(action -> action.getTarget().getControllerId(), ActionProperties::new))); .collect(Collectors.toMap(action -> action.getTarget().getControllerId(), ActionProperties::new)));
} }
@@ -53,4 +52,4 @@ public abstract class AbstractAssignmentEvent extends RemoteTenantAwareEvent {
public Optional<ActionProperties> getActionPropertiesForController(final String controllerId) { public Optional<ActionProperties> getActionPropertiesForController(final String controllerId) {
return Optional.ofNullable(actions.get(controllerId)); return Optional.ofNullable(actions.get(controllerId));
} }
} }

View File

@@ -24,11 +24,11 @@ public class CancelTargetAssignmentEvent extends AbstractAssignmentEvent {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public CancelTargetAssignmentEvent(final Action a, final String applicationId) { public CancelTargetAssignmentEvent(final Action a) {
super(applicationId, a, applicationId); super(a);
} }
public CancelTargetAssignmentEvent(final String tenant, final List<Action> a, final String applicationId) { public CancelTargetAssignmentEvent(final String tenant, final List<Action> a) {
super(applicationId, tenant, a, applicationId); super(tenant, null, a);
} }
} }

View File

@@ -25,15 +25,7 @@ public class DistributionSetDeletedEvent extends RemoteIdEvent implements Entity
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public DistributionSetDeletedEvent(final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass) {
* Constructor. super(tenant, entityId, entityClass);
*
* @param tenant the tenant
* @param entityId the entity id
* @param applicationId the origin application id
*/
public DistributionSetDeletedEvent(final String tenant, final Long entityId,
final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -25,17 +25,7 @@ public class DistributionSetTagDeletedEvent extends RemoteIdEvent implements Ent
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public DistributionSetTagDeletedEvent(final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass) {
* Constructor for json serialization. super(tenant, entityId, entityClass);
*
* @param tenant the tenant
* @param entityId the entity id
* @param entityClass the entity class
* @param applicationId the origin application id
*/
public DistributionSetTagDeletedEvent(
final String tenant, final Long entityId,
final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -25,16 +25,7 @@ public class DistributionSetTypeDeletedEvent extends RemoteIdEvent implements En
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public DistributionSetTypeDeletedEvent(final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass) {
* Constructor for json serialization. super(tenant, entityId, entityClass);
*
* @param tenant the tenant
* @param entityId the entity id
* @param entityClass the entity class
* @param applicationId the origin application id
*/
public DistributionSetTypeDeletedEvent(final String tenant, final Long entityId,
final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -34,11 +34,9 @@ public class DownloadProgressEvent extends RemoteTenantAwareEvent {
* @param tenant the tenant * @param tenant the tenant
* @param actionStatusId of the {@link ActionStatus} the download belongs to * @param actionStatusId of the {@link ActionStatus} the download belongs to
* @param shippedBytesSinceLast the shippedBytesSinceLast * @param shippedBytesSinceLast the shippedBytesSinceLast
* @param applicationId the application id.
*/ */
public DownloadProgressEvent(final String tenant, final Long actionStatusId, final long shippedBytesSinceLast, public DownloadProgressEvent(final String tenant, final Long actionStatusId, final long shippedBytesSinceLast) {
final String applicationId) { super(tenant, actionStatusId);
super(actionStatusId, tenant, applicationId);
this.shippedBytesSinceLast = shippedBytesSinceLast; this.shippedBytesSinceLast = shippedBytesSinceLast;
} }

View File

@@ -10,6 +10,7 @@
package org.eclipse.hawkbit.repository.event.remote; package org.eclipse.hawkbit.repository.event.remote;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
* A singleton bean which holds the event entity manager to have autowiring in the events. * A singleton bean which holds the event entity manager to have autowiring in the events.
*/ */
@NoArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
@SuppressWarnings("java:S6548") // java:S6548 - singleton holder ensures static access to spring resources in some places @SuppressWarnings("java:S6548") // java:S6548 - singleton holder ensures static access to spring resources in some places
public final class EventEntityManagerHolder { public final class EventEntityManagerHolder {
@@ -35,11 +37,4 @@ public final class EventEntityManagerHolder {
public void setEventEntityManager(final EventEntityManager eventEntityManager) { public void setEventEntityManager(final EventEntityManager eventEntityManager) {
this.eventEntityManager = eventEntityManager; this.eventEntityManager = eventEntityManager;
} }
/**
* @return the eventEntityManager
*/
public EventEntityManager getEventEntityManager() {
return eventEntityManager;
}
} }

View File

@@ -32,10 +32,9 @@ public class MultiActionAssignEvent extends MultiActionEvent {
* Constructor. * Constructor.
* *
* @param tenant tenant the event is scoped to * @param tenant tenant the event is scoped to
* @param applicationId the application id
* @param actions the actions of the deployment action * @param actions the actions of the deployment action
*/ */
public MultiActionAssignEvent(String tenant, String applicationId, List<Action> actions) { public MultiActionAssignEvent(String tenant, List<Action> actions) {
super(tenant, applicationId, actions); super(tenant, actions);
} }
} }

View File

@@ -28,14 +28,7 @@ public class MultiActionCancelEvent extends MultiActionEvent {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public MultiActionCancelEvent(String tenant, List<Action> actions) {
* Constructor. super(tenant, actions);
*
* @param tenant tenant the event is scoped to
* @param applicationId the application id
* @param actions the actions to be canceled
*/
public MultiActionCancelEvent(String tenant, String applicationId, List<Action> actions) {
super(tenant, applicationId, actions);
} }
} }

View File

@@ -27,10 +27,10 @@ import org.eclipse.hawkbit.repository.model.Target;
* Generic deployment event for the Multi-Assignments feature. The event payload holds a list of controller IDs identifying the targets which * Generic deployment event for the Multi-Assignments feature. The event payload holds a list of controller IDs identifying the targets which
* are affected by a deployment action (e.g. a software assignment (update) or a cancellation of an update). * are affected by a deployment action (e.g. a software assignment (update) or a cancellation of an update).
*/ */
@NoArgsConstructor(access = AccessLevel.PROTECTED) // for serialization libs like jackson
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
@NoArgsConstructor(access = AccessLevel.PROTECTED) // for serialization libs like jackson
public abstract class MultiActionEvent extends RemoteTenantAwareEvent implements Iterable<String> { public abstract class MultiActionEvent extends RemoteTenantAwareEvent implements Iterable<String> {
@Serial @Serial
@@ -39,15 +39,8 @@ public abstract class MultiActionEvent extends RemoteTenantAwareEvent implements
private final List<String> controllerIds = new ArrayList<>(); private final List<String> controllerIds = new ArrayList<>();
private final List<Long> actionIds = new ArrayList<>(); private final List<Long> actionIds = new ArrayList<>();
/** protected MultiActionEvent(final String tenant, final List<Action> actions) {
* Constructor. super(tenant, null);
*
* @param tenant tenant the event is scoped to
* @param applicationId the application id
* @param actions the actions involved
*/
protected MultiActionEvent(String tenant, String applicationId, List<Action> actions) {
super(applicationId, tenant, applicationId);
this.controllerIds.addAll(getControllerIdsFromActions(actions)); this.controllerIds.addAll(getControllerIdsFromActions(actions));
this.actionIds.addAll(getIdsFromActions(actions)); this.actionIds.addAll(getIdsFromActions(actions));
} }

View File

@@ -32,31 +32,18 @@ public class RemoteIdEvent extends RemoteTenantAwareEvent {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long entityId; private Long entityId;
private String entityClass; private String entityClass;
private String interfaceClass; private String interfaceClass;
/** protected RemoteIdEvent(final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass) {
* Constructor for json serialization. super(tenant, entityId);
*
* @param entityId the entity Id
* @param tenant the tenant
* @param entityClass the entity class
* @param applicationId the origin application id
*/
protected RemoteIdEvent(final Long entityId, final String tenant,
final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, applicationId);
this.entityClass = entityClass.getName(); this.entityClass = entityClass.getName();
this.interfaceClass = entityClass.isInterface() ? entityClass.getName() this.interfaceClass = entityClass.isInterface() ? entityClass.getName() : getInterfaceEntity(entityClass).getName();
: getInterfaceEntity(entityClass).getName();
this.entityId = entityId; this.entityId = entityId;
} }
private static Class<?> getInterfaceEntity(final Class<? extends TenantAwareBaseEntity> baseEntity) { private static Class<?> getInterfaceEntity(final Class<? extends TenantAwareBaseEntity> baseEntity) {
final Class<?>[] interfaces = baseEntity.getInterfaces(); final Class<?>[] interfaces = baseEntity.getInterfaces();
return Arrays.stream(interfaces).filter(TenantAwareBaseEntity.class::isAssignableFrom).findFirst() return Arrays.stream(interfaces).filter(TenantAwareBaseEntity.class::isAssignableFrom).findFirst().orElse(baseEntity);
.orElse(baseEntity);
} }
} }

View File

@@ -11,12 +11,12 @@ package org.eclipse.hawkbit.repository.event.remote;
import java.io.Serial; import java.io.Serial;
import com.cronutils.utils.StringUtils;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.ToString; import lombok.ToString;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.TenantAwareEvent; import org.eclipse.hawkbit.repository.event.TenantAwareEvent;
import org.springframework.cloud.bus.event.RemoteApplicationEvent; import org.springframework.cloud.bus.event.RemoteApplicationEvent;
@@ -25,10 +25,10 @@ import org.springframework.cloud.bus.event.RemoteApplicationEvent;
* distributed events. All the necessary information of distributing events to * distributed events. All the necessary information of distributing events to
* other nodes. * other nodes.
*/ */
@NoArgsConstructor(access = AccessLevel.PROTECTED) // for serialization libs like jackson
@Getter @Getter
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
@NoArgsConstructor(access = AccessLevel.PROTECTED) // for serialization libs like jackson
public class RemoteTenantAwareEvent extends RemoteApplicationEvent implements TenantAwareEvent { public class RemoteTenantAwareEvent extends RemoteApplicationEvent implements TenantAwareEvent {
@Serial @Serial
@@ -36,16 +36,12 @@ public class RemoteTenantAwareEvent extends RemoteApplicationEvent implements Te
private String tenant; private String tenant;
/** public RemoteTenantAwareEvent(final String tenant, final Object source) {
* Constructor. super(source == null ? getApplicationId() : source, getApplicationId(), DEFAULT_DESTINATION_FACTORY.getDestination(null));
*
* @param source the for the remote event.
* @param tenant the tenant
* @param applicationId the applicationId
*/
public RemoteTenantAwareEvent(final Object source, final String tenant, final String applicationId) {
// due to a bug in Spring Cloud, we cannot pass null for applicationId
super(source, applicationId != null ? applicationId : StringUtils.EMPTY, DEFAULT_DESTINATION_FACTORY.getDestination(null));
this.tenant = tenant; this.tenant = tenant;
} }
private static String getApplicationId() {
return EventPublisherHolder.getInstance().getApplicationId();
}
} }

View File

@@ -25,16 +25,7 @@ public class RolloutDeletedEvent extends RemoteIdEvent implements EntityDeletedE
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public RolloutDeletedEvent(final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass) {
* Constructor for json serialization. super(tenant, entityId, entityClass);
*
* @param tenant the tenant
* @param entityId the entity id
* @param entityClass the entity class
* @param applicationId the origin application id
*/
public RolloutDeletedEvent(final String tenant, final Long entityId,
final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -25,16 +25,7 @@ public class RolloutGroupDeletedEvent extends RemoteIdEvent implements EntityDel
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public RolloutGroupDeletedEvent(final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass) {
* Constructor for json serialization. super(tenant, entityId, entityClass);
*
* @param tenant the tenant
* @param entityId the entity id
* @param entityClass the entity class
* @param applicationId the origin application id
*/
public RolloutGroupDeletedEvent(final String tenant, final Long entityId,
final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -34,18 +34,8 @@ public class RolloutStoppedEvent extends RemoteTenantAwareEvent {
private Collection<Long> rolloutGroupIds; private Collection<Long> rolloutGroupIds;
private long rolloutId; private long rolloutId;
/** public RolloutStoppedEvent(final String tenant, final long rolloutId, final Collection<Long> rolloutGroupIds) {
* Constructor for json serialization. super(tenant, rolloutId);
*
* @param tenant the tenant
* @param applicationId the entity id
* @param rolloutId the entity class (and source)
* @param rolloutGroupIds the rollouts group ids
*/
public RolloutStoppedEvent(
final String tenant, final String applicationId, final long rolloutId,
final Collection<Long> rolloutGroupIds) {
super(rolloutId, tenant, applicationId);
this.rolloutId = rolloutId; this.rolloutId = rolloutId;
this.rolloutGroupIds = rolloutGroupIds; this.rolloutGroupIds = rolloutGroupIds;
} }

View File

@@ -25,16 +25,7 @@ public class SoftwareModuleDeletedEvent extends RemoteIdEvent implements EntityD
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public SoftwareModuleDeletedEvent(final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass) {
* Constructor for json serialization. super(tenant, entityId, entityClass);
*
* @param tenant the tenant
* @param entityId the entity id
* @param entityClass the entity class
* @param applicationId the origin application id
*/
public SoftwareModuleDeletedEvent(final String tenant, final Long entityId,
final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -25,16 +25,7 @@ public class SoftwareModuleTypeDeletedEvent extends RemoteIdEvent implements Ent
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public SoftwareModuleTypeDeletedEvent(final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass) {
* Constructor for json serialization. super(tenant, entityId, entityClass);
*
* @param tenant the tenant
* @param entityId the entity id
* @param entityClass the entity class
* @param applicationId the origin application id
*/
public SoftwareModuleTypeDeletedEvent(final String tenant, final Long entityId,
final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -40,26 +40,17 @@ public class TargetAssignDistributionSetEvent extends AbstractAssignmentEvent {
* @param tenant of the event * @param tenant of the event
* @param distributionSetId of the set that was assigned * @param distributionSetId of the set that was assigned
* @param a the actions and the targets * @param a the actions and the targets
* @param applicationId the application id.
* @param maintenanceWindowAvailable see {@link Action#isMaintenanceWindowAvailable()} * @param maintenanceWindowAvailable see {@link Action#isMaintenanceWindowAvailable()}
*/ */
public TargetAssignDistributionSetEvent(final String tenant, final long distributionSetId, final List<Action> a, public TargetAssignDistributionSetEvent(
final String applicationId, final boolean maintenanceWindowAvailable) { final String tenant, final long distributionSetId, final List<Action> a, final boolean maintenanceWindowAvailable) {
super(distributionSetId, tenant, super(tenant, distributionSetId,
a.stream().filter(action -> action.getDistributionSet().getId().longValue() == distributionSetId).toList(), a.stream().filter(action -> action.getDistributionSet().getId().longValue() == distributionSetId).toList());
applicationId);
this.distributionSetId = distributionSetId; this.distributionSetId = distributionSetId;
this.maintenanceWindowAvailable = maintenanceWindowAvailable; this.maintenanceWindowAvailable = maintenanceWindowAvailable;
} }
/** public TargetAssignDistributionSetEvent(final Action action) {
* Constructor. this(action.getTenant(), action.getDistributionSet().getId(), Collections.singletonList(action), action.isMaintenanceWindowAvailable());
*
* @param action the action created for this assignment
* @param applicationId the application id
*/
public TargetAssignDistributionSetEvent(final Action action, final String applicationId) {
this(action.getTenant(), action.getDistributionSet().getId(), Collections.singletonList(action), applicationId,
action.isMaintenanceWindowAvailable());
} }
} }

View File

@@ -33,20 +33,10 @@ public class TargetAttributesRequestedEvent extends RemoteIdEvent {
private String controllerId; private String controllerId;
private String targetAddress; private String targetAddress;
/** public TargetAttributesRequestedEvent(
* Constructor json serialization final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass,
* final String controllerId, final String targetAddress) {
* @param tenant the tenant super(tenant, entityId, entityClass);
* @param entityId the entity id
* @param controllerId the controllerId of the target
* @param targetAddress the target address
* @param entityClass the entity class
* @param applicationId the origin application id
*/
public TargetAttributesRequestedEvent(final String tenant, final Long entityId, final String controllerId,
final String targetAddress, final Class<? extends TenantAwareBaseEntity> entityClass,
final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
this.controllerId = controllerId; this.controllerId = controllerId;
this.targetAddress = targetAddress; this.targetAddress = targetAddress;
} }

View File

@@ -34,18 +34,10 @@ public class TargetDeletedEvent extends RemoteIdEvent implements EntityDeletedEv
private String controllerId; private String controllerId;
private String targetAddress; private String targetAddress;
/** public TargetDeletedEvent(
* @param tenant the tenant final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass,
* @param entityId the entity id final String controllerId, final String targetAddress) {
* @param controllerId the controllerId of the target super(tenant, entityId, entityClass);
* @param targetAddress the target address
* @param entityClass the entity class
* @param applicationId the origin application id
*/
public TargetDeletedEvent(final String tenant, final Long entityId, final String controllerId,
final String targetAddress, final Class<? extends TenantAwareBaseEntity> entityClass,
final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
this.controllerId = controllerId; this.controllerId = controllerId;
this.targetAddress = targetAddress; this.targetAddress = targetAddress;
} }

View File

@@ -25,14 +25,7 @@ public class TargetFilterQueryDeletedEvent extends RemoteIdEvent implements Enti
@Serial @Serial
private static final long serialVersionUID = 2L; private static final long serialVersionUID = 2L;
/** public TargetFilterQueryDeletedEvent(final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass) {
* @param tenant the tenant super(tenant, entityId, entityClass);
* @param entityId the entity id
* @param entityClass the entity class
* @param applicationId the origin application id
*/
public TargetFilterQueryDeletedEvent(final String tenant, final Long entityId,
final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -32,14 +32,13 @@ public class TargetPollEvent extends RemoteTenantAwareEvent {
private String controllerId; private String controllerId;
private String targetAddress; private String targetAddress;
public TargetPollEvent(final String controllerId, final String tenant, final String applicationId) { public TargetPollEvent(final String controllerId, final String tenant) {
super(controllerId, tenant, applicationId); super(tenant, controllerId);
this.controllerId = controllerId; this.controllerId = controllerId;
} }
public TargetPollEvent(final Target target, final String applicationId) { public TargetPollEvent(final Target target) {
super(target.getControllerId(), target.getTenant(), applicationId); this(target.getControllerId(), target.getTenant());
this.controllerId = target.getControllerId();
this.targetAddress = target.getAddress().toString(); this.targetAddress = target.getAddress().toString();
} }
} }

View File

@@ -25,16 +25,7 @@ public class TargetTagDeletedEvent extends RemoteIdEvent implements EntityDelete
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public TargetTagDeletedEvent(final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass) {
* Constructor for json serialization. super(tenant, entityId, entityClass);
*
* @param tenant the tenant
* @param entityId the entity id
* @param entityClass the entity class
* @param applicationId the origin application id
*/
public TargetTagDeletedEvent(final String tenant, final Long entityId,
final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -25,16 +25,7 @@ public class TargetTypeDeletedEvent extends RemoteIdEvent implements EntityDelet
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public TargetTypeDeletedEvent(final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass) {
* Constructor for json serialization. super(tenant, entityId, entityClass);
*
* @param tenant the tenant
* @param entityId the entity id
* @param entityClass the entity class
* @param applicationId the origin application id
*/
public TargetTypeDeletedEvent(final String tenant, final Long entityId,
final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -28,24 +28,16 @@ import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
public class TenantConfigurationDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent { public class TenantConfigurationDeletedEvent extends RemoteIdEvent implements EntityDeletedEvent {
@Serial @Serial
private static final long serialVersionUID = 2L; private static final long serialVersionUID = 1L;
private String configKey; private String configKey;
@ToString.Exclude @ToString.Exclude
private String configValue; private String configValue;
/** public TenantConfigurationDeletedEvent(
* @param tenant the tenant final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass,
* @param entityId the entity id final String configKey, final String configValue) {
* @param configKey the config key super(tenant, entityId, entityClass);
* @param configValue the config value
* @param entityClass the entity class
* @param applicationId the origin application id
*/
public TenantConfigurationDeletedEvent(final String tenant, final Long entityId, final String configKey,
final String configValue, final Class<? extends TenantAwareBaseEntity> entityClass,
final String applicationId) {
super(entityId, tenant, entityClass, applicationId);
this.configKey = configKey; this.configKey = configKey;
this.configValue = configValue; this.configValue = configValue;
} }

View File

@@ -15,6 +15,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
import org.springframework.lang.Nullable;
/** /**
* Defines the remote event of creating a new {@link Action}. * Defines the remote event of creating a new {@link Action}.
@@ -32,28 +33,17 @@ public abstract class AbstractActionEvent extends RemoteEntityEvent<Action> {
private final Long rolloutGroupId; private final Long rolloutGroupId;
/** /**
* Default constructor. * Default constructor for serialization libs like jackson.
*/ */
protected AbstractActionEvent() { protected AbstractActionEvent() {
// for serialization libs like jackson
this.targetId = null; this.targetId = null;
this.rolloutId = null; this.rolloutId = null;
this.rolloutGroupId = null; this.rolloutGroupId = null;
} }
/**
* Constructor
*
* @param action the created action
* @param targetId targetId identifier (optional)
* @param rolloutId rollout identifier (optional)
* @param rolloutGroupId rollout group identifier (optional)
* @param applicationId the origin application id
*/
protected AbstractActionEvent( protected AbstractActionEvent(
final Action action, final Long targetId, final Long rolloutId, final Action action, @Nullable final Long targetId, @Nullable final Long rolloutId, @Nullable final Long rolloutGroupId) {
final Long rolloutGroupId, final String applicationId) { super(action);
super(action, applicationId);
this.targetId = targetId; this.targetId = targetId;
this.rolloutId = rolloutId; this.rolloutId = rolloutId;
this.rolloutGroupId = rolloutGroupId; this.rolloutGroupId = rolloutGroupId;

View File

@@ -25,16 +25,14 @@ public abstract class AbstractRolloutGroupEvent extends RemoteEntityEvent<Rollou
private final Long rolloutId; private final Long rolloutId;
/** /**
* Default constructor. * Default constructor for serialization libs like jackson.
*/ */
protected AbstractRolloutGroupEvent() { protected AbstractRolloutGroupEvent() {
// for serialization libs like jackson
this.rolloutId = null; this.rolloutId = null;
} }
protected AbstractRolloutGroupEvent(final RolloutGroup rolloutGroup, final Long rolloutId, protected AbstractRolloutGroupEvent(final RolloutGroup rolloutGroup, final Long rolloutId) {
final String applicationId) { super(rolloutGroup);
super(rolloutGroup, applicationId);
this.rolloutId = rolloutId; this.rolloutId = rolloutId;
} }
@@ -49,13 +47,16 @@ public abstract class AbstractRolloutGroupEvent extends RemoteEntityEvent<Rollou
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
if (this == o) if (this == o) {
return true; return true;
if (o == null || getClass() != o.getClass()) }
if (o == null || getClass() != o.getClass()) {
return false; return false;
if (!super.equals(o)) }
if (!super.equals(o)) {
return false; return false;
}
final AbstractRolloutGroupEvent that = (AbstractRolloutGroupEvent) o; final AbstractRolloutGroupEvent that = (AbstractRolloutGroupEvent) o;
return Objects.equals(rolloutId, that.rolloutId); return Objects.equals(rolloutId, that.rolloutId);
} }
} }

View File

@@ -24,17 +24,7 @@ public class ActionCreatedEvent extends AbstractActionEvent implements EntityCre
@Serial @Serial
private static final long serialVersionUID = 2L; private static final long serialVersionUID = 2L;
/** public ActionCreatedEvent(final Action action, final Long targetId, final Long rolloutId, final Long rolloutGroupId) {
* Constructor super(action, targetId, rolloutId, rolloutGroupId);
*
* @param action the created action
* @param targetId targetId identifier (optional)
* @param rolloutId rollout identifier (optional)
* @param rolloutGroupId rollout group identifier (optional)
* @param applicationId the origin application id
*/
public ActionCreatedEvent(
final Action action, final Long targetId, final Long rolloutId, final Long rolloutGroupId, final String applicationId) {
super(action, targetId, rolloutId, rolloutGroupId, applicationId);
} }
} }

View File

@@ -24,17 +24,7 @@ public class ActionUpdatedEvent extends AbstractActionEvent implements EntityUpd
@Serial @Serial
private static final long serialVersionUID = 2L; private static final long serialVersionUID = 2L;
/** public ActionUpdatedEvent(final Action action, final Long targetId, final Long rolloutId, final Long rolloutGroupId) {
* Constructor super(action, targetId, rolloutId, rolloutGroupId);
*
* @param action the updated action
* @param targetId targetId identifier (optional)
* @param rolloutId rollout identifier (optional)
* @param rolloutGroupId rollout group identifier (optional)
* @param applicationId the origin application id
*/
public ActionUpdatedEvent(
final Action action, final Long targetId, final Long rolloutId, final Long rolloutGroupId, final String applicationId) {
super(action, targetId, rolloutId, rolloutGroupId, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class DistributionSetCreatedEvent extends RemoteEntityEvent<DistributionS
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public DistributionSetCreatedEvent(final DistributionSet distributionSet) {
* Constructor. super(distributionSet);
*
* @param distributionSet the created distributionSet
* @param applicationId the origin application id
*/
public DistributionSetCreatedEvent(final DistributionSet distributionSet, final String applicationId) {
super(distributionSet, applicationId);
} }
} }

View File

@@ -25,13 +25,7 @@ public class DistributionSetTagCreatedEvent extends RemoteEntityEvent<Distributi
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public DistributionSetTagCreatedEvent(final DistributionSetTag distributionSetTag) {
* Constructor. super(distributionSetTag);
*
* @param tag the tag which is deleted
* @param applicationId the origin application id
*/
public DistributionSetTagCreatedEvent(final DistributionSetTag tag, final String applicationId) {
super(tag, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class DistributionSetTagUpdatedEvent extends RemoteEntityEvent<Distributi
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public DistributionSetTagUpdatedEvent(final DistributionSetTag distributionSetTag) {
* Constructor. super(distributionSetTag);
*
* @param tag tag the tag which is updated
* @param applicationId the applicationID
*/
public DistributionSetTagUpdatedEvent(final DistributionSetTag tag, final String applicationId) {
super(tag, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class DistributionSetTypeCreatedEvent extends RemoteEntityEvent<Distribut
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public DistributionSetTypeCreatedEvent(final DistributionSetType distributionSetType) {
* Constructor. super(distributionSetType);
*
* @param baseEntity the DistributionSetType
* @param applicationId the origin application id
*/
public DistributionSetTypeCreatedEvent(final DistributionSetType baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -25,13 +25,7 @@ public class DistributionSetTypeUpdatedEvent extends RemoteEntityEvent<Distribut
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public DistributionSetTypeUpdatedEvent(final DistributionSetType distributionSetType) {
* Constructor. super(distributionSetType);
*
* @param baseEntity DistributionSetType
* @param applicationId the origin application id
*/
public DistributionSetTypeUpdatedEvent(final DistributionSetType baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -31,12 +31,11 @@ public class DistributionSetUpdatedEvent extends RemoteEntityEvent<DistributionS
/** /**
* Constructor. * Constructor.
* *
* @param ds Distribution Set * @param distributionSet Distribution Set
* @param applicationId the origin application id
* @param complete <code>true</code> if {@link DistributionSet} is after the update {@link DistributionSet#isComplete()} * @param complete <code>true</code> if {@link DistributionSet} is after the update {@link DistributionSet#isComplete()}
*/ */
public DistributionSetUpdatedEvent(final DistributionSet ds, final String applicationId, final boolean complete) { public DistributionSetUpdatedEvent(final DistributionSet distributionSet, final boolean complete) {
super(ds, applicationId); super(distributionSet);
this.complete = complete; this.complete = complete;
} }

View File

@@ -36,14 +36,8 @@ public class RemoteEntityEvent<E extends TenantAwareBaseEntity> extends RemoteId
private transient E entity; private transient E entity;
/** protected RemoteEntityEvent(final E baseEntity) {
* Constructor. super(baseEntity.getTenant(), baseEntity.getId(), baseEntity.getClass());
*
* @param baseEntity the base entity
* @param applicationId the origin application id
*/
protected RemoteEntityEvent(final E baseEntity, final String applicationId) {
super(baseEntity.getId(), baseEntity.getTenant(), baseEntity.getClass(), applicationId);
this.entity = baseEntity; this.entity = baseEntity;
} }

View File

@@ -24,13 +24,7 @@ public class RolloutCreatedEvent extends RemoteEntityEvent<Rollout> implements E
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public RolloutCreatedEvent(final Rollout rollout) {
* Constructor. super(rollout);
*
* @param baseEntity the Rollout
* @param applicationId the origin application id
*/
public RolloutCreatedEvent(final Rollout baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -25,14 +25,7 @@ public class RolloutGroupCreatedEvent extends AbstractRolloutGroupEvent implemen
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public RolloutGroupCreatedEvent(final RolloutGroup rolloutGroup, final Long rolloutId) {
* Constructor super(rolloutGroup, rolloutId);
*
* @param rolloutGroup the updated rolloutGroup
* @param rolloutId of the related rollout
* @param applicationId the origin application id
*/
public RolloutGroupCreatedEvent(final RolloutGroup rolloutGroup, final Long rolloutId, final String applicationId) {
super(rolloutGroup, rolloutId, applicationId);
} }
} }

View File

@@ -24,14 +24,7 @@ public class RolloutGroupUpdatedEvent extends AbstractRolloutGroupEvent implemen
@Serial @Serial
private static final long serialVersionUID = 2L; private static final long serialVersionUID = 2L;
/** public RolloutGroupUpdatedEvent(final RolloutGroup rolloutGroup, final Long rolloutId) {
* Constructor super(rolloutGroup, rolloutId);
*
* @param rolloutGroup the updated rolloutGroup
* @param rolloutId of the related rollout
* @param applicationId the origin application id
*/
public RolloutGroupUpdatedEvent(final RolloutGroup rolloutGroup, final Long rolloutId, final String applicationId) {
super(rolloutGroup, rolloutId, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class RolloutUpdatedEvent extends RemoteEntityEvent<Rollout> implements E
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public RolloutUpdatedEvent(final Rollout rollout) {
* Constructor super(rollout);
*
* @param rollout the updated rollout
* @param applicationId the origin application id
*/
public RolloutUpdatedEvent(final Rollout rollout, final String applicationId) {
super(rollout, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class SoftwareModuleCreatedEvent extends RemoteEntityEvent<SoftwareModule
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public SoftwareModuleCreatedEvent(final SoftwareModule softwareModule) {
* Constructor. super(softwareModule);
*
* @param baseEntity the software module
* @param applicationId the origin application id
*/
public SoftwareModuleCreatedEvent(final SoftwareModule baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class SoftwareModuleTypeCreatedEvent extends RemoteEntityEvent<SoftwareMo
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public SoftwareModuleTypeCreatedEvent(final SoftwareModuleType softwareModuleType) {
* Constructor. super(softwareModuleType);
*
* @param baseEntity the SoftwareModuleType
* @param applicationId the origin application id
*/
public SoftwareModuleTypeCreatedEvent(final SoftwareModuleType baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class SoftwareModuleTypeUpdatedEvent extends RemoteEntityEvent<SoftwareMo
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public SoftwareModuleTypeUpdatedEvent(final SoftwareModuleType softwareModuleType) {
* Constructor. super(softwareModuleType);
*
* @param baseEntity SoftwareModuleType entity
* @param applicationId the origin application id
*/
public SoftwareModuleTypeUpdatedEvent(final SoftwareModuleType baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class SoftwareModuleUpdatedEvent extends RemoteEntityEvent<SoftwareModule
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public SoftwareModuleUpdatedEvent(final SoftwareModule softwareModule) {
* Constructor. super(softwareModule);
*
* @param baseEntity the software module
* @param applicationId the origin application id
*/
public SoftwareModuleUpdatedEvent(final SoftwareModule baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class TargetCreatedEvent extends RemoteEntityEvent<Target> implements Ent
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public TargetCreatedEvent(final Target target) {
* Constructor. super(target);
*
* @param baseEntity the target
* @param applicationId the origin application id
*/
public TargetCreatedEvent(final Target baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class TargetFilterQueryCreatedEvent extends RemoteEntityEvent<TargetFilte
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public TargetFilterQueryCreatedEvent(final TargetFilterQuery targetFilterQuery) {
* Constructor. super(targetFilterQuery);
*
* @param baseEntity the TargetFilterQuery
* @param applicationId the origin application id
*/
public TargetFilterQueryCreatedEvent(final TargetFilterQuery baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class TargetFilterQueryUpdatedEvent extends RemoteEntityEvent<TargetFilte
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public TargetFilterQueryUpdatedEvent(final TargetFilterQuery targetFilterQuery) {
* Constructor. super(targetFilterQuery);
*
* @param baseEntity TargetFilterQuery entity
* @param applicationId the origin application id
*/
public TargetFilterQueryUpdatedEvent(final TargetFilterQuery baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class TargetTagCreatedEvent extends RemoteEntityEvent<TargetTag> implemen
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public TargetTagCreatedEvent(final TargetTag targetTag) {
* Constructor. super(targetTag);
*
* @param tag the tag which is deleted
* @param applicationId the origin application id
*/
public TargetTagCreatedEvent(final TargetTag tag, final String applicationId) {
super(tag, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class TargetTagUpdatedEvent extends RemoteEntityEvent<TargetTag> implemen
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public TargetTagUpdatedEvent(final TargetTag targetTag) {
* Constructor. super(targetTag);
*
* @param tag the tag which is updated
* @param applicationId the origin application id
*/
public TargetTagUpdatedEvent(final TargetTag tag, final String applicationId) {
super(tag, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class TargetTypeCreatedEvent extends RemoteEntityEvent<TargetType> implem
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public TargetTypeCreatedEvent(final TargetType targetType) {
* Constructor. super(targetType);
*
* @param baseEntity the TargetType
* @param applicationId the origin application id
*/
public TargetTypeCreatedEvent(final TargetType baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class TargetTypeUpdatedEvent extends RemoteEntityEvent<TargetType> implem
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public TargetTypeUpdatedEvent(final TargetType targetType) {
* Constructor. super(targetType);
*
* @param baseEntity TargetType
* @param applicationId the origin application id
*/
public TargetTypeUpdatedEvent(final TargetType baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class TargetUpdatedEvent extends RemoteEntityEvent<Target> implements Ent
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public TargetUpdatedEvent(final Target target) {
* Constructor. super(target);
*
* @param baseEntity Target entity
* @param applicationId the origin application id
*/
public TargetUpdatedEvent(final Target baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class TenantConfigurationCreatedEvent extends RemoteEntityEvent<TenantCon
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public TenantConfigurationCreatedEvent(final TenantConfiguration tenantConfiguration) {
* Constructor. super(tenantConfiguration);
*
* @param baseEntity the tenantConfiguration
* @param applicationId the origin application id
*/
public TenantConfigurationCreatedEvent(final TenantConfiguration baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -24,13 +24,7 @@ public class TenantConfigurationUpdatedEvent extends RemoteEntityEvent<TenantCon
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** public TenantConfigurationUpdatedEvent(final TenantConfiguration tenantConfiguration) {
* Constructor. super(tenantConfiguration);
*
* @param baseEntity the tenantConfiguration
* @param applicationId the origin application id
*/
public TenantConfigurationUpdatedEvent(final TenantConfiguration baseEntity, final String applicationId) {
super(baseEntity, applicationId);
} }
} }

View File

@@ -14,8 +14,8 @@ import java.util.concurrent.Executor;
import io.protostuff.ProtostuffIOUtil; import io.protostuff.ProtostuffIOUtil;
import io.protostuff.Schema; import io.protostuff.Schema;
import org.eclipse.hawkbit.repository.event.ApplicationEventFilter; import org.eclipse.hawkbit.repository.event.ApplicationEventFilter;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.RemoteTenantAwareEvent; import org.eclipse.hawkbit.repository.event.remote.RemoteTenantAwareEvent;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
@@ -61,8 +61,7 @@ public class EventPublisherConfiguration {
} }
/** /**
* Bean for creating a singleton instance of the * Bean for creating a singleton instance of the {@link EventPublisherHolder}
* {@link EventPublisherHolder}
* *
* @return the singleton instance of the {@link EventPublisherHolder} * @return the singleton instance of the {@link EventPublisherHolder}
*/ */

View File

@@ -13,6 +13,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import java.io.Serial;
import java.util.HashMap; import java.util.HashMap;
import org.eclipse.hawkbit.repository.event.remote.entity.RemoteEntityEvent; import org.eclipse.hawkbit.repository.event.remote.entity.RemoteEntityEvent;
@@ -49,7 +50,7 @@ class BusProtoStuffMessageConverterTest {
*/ */
@Test @Test
void successfullySerializeAndDeserializeEvent() { void successfullySerializeAndDeserializeEvent() {
final TargetCreatedEvent targetCreatedEvent = new TargetCreatedEvent(targetMock, "1"); final TargetCreatedEvent targetCreatedEvent = new TargetCreatedEvent(targetMock);
// serialize // serialize
final Object serializedEvent = underTest.convertToInternal(targetCreatedEvent, final Object serializedEvent = underTest.convertToInternal(targetCreatedEvent,
new MessageHeaders(new HashMap<>()), null); new MessageHeaders(new HashMap<>()), null);
@@ -68,7 +69,7 @@ class BusProtoStuffMessageConverterTest {
*/ */
@Test @Test
void missingEventTypeMappingThrowsMessageConversationException() { void missingEventTypeMappingThrowsMessageConversationException() {
final DummyRemoteEntityEvent dummyEvent = new DummyRemoteEntityEvent(targetMock, "applicationId"); final DummyRemoteEntityEvent dummyEvent = new DummyRemoteEntityEvent(targetMock);
final MessageHeaders messageHeaders = new MessageHeaders(new HashMap<>()); final MessageHeaders messageHeaders = new MessageHeaders(new HashMap<>());
assertThatExceptionOfType(MessageConversionException.class) assertThatExceptionOfType(MessageConversionException.class)
@@ -79,13 +80,13 @@ class BusProtoStuffMessageConverterTest {
/** /**
* Test event with which non-existing mapping to serialize. * Test event with which non-existing mapping to serialize.
*/ */
private final class DummyRemoteEntityEvent extends RemoteEntityEvent<Target> { private static final class DummyRemoteEntityEvent extends RemoteEntityEvent<Target> {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private DummyRemoteEntityEvent(final Target target, final String applicationId) { private DummyRemoteEntityEvent(final Target target) {
super(target, applicationId); super(target);
} }
} }
} }

View File

@@ -33,6 +33,7 @@ import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutHelper; import org.eclipse.hawkbit.repository.RolloutHelper;
import org.eclipse.hawkbit.repository.RolloutManagement; import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.RolloutStoppedEvent; import org.eclipse.hawkbit.repository.event.remote.RolloutStoppedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent;
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException; import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
@@ -62,7 +63,6 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondit
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus; import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition; import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.eclipse.hawkbit.security.SpringSecurityAuditorAware; import org.eclipse.hawkbit.security.SpringSecurityAuditorAware;
import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.TenantAware;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
@@ -113,7 +113,6 @@ public class JpaRolloutExecutor implements RolloutExecutor {
private final EntityManager entityManager; private final EntityManager entityManager;
private final PlatformTransactionManager txManager; private final PlatformTransactionManager txManager;
private final AfterTransactionCommitExecutor afterCommit; private final AfterTransactionCommitExecutor afterCommit;
private final EventPublisherHolder eventPublisherHolder;
private final TenantAware tenantAware; private final TenantAware tenantAware;
private final RepositoryProperties repositoryProperties; private final RepositoryProperties repositoryProperties;
private final Map<Long, AtomicLong> lastDynamicGroupFill = new ConcurrentHashMap<>(); private final Map<Long, AtomicLong> lastDynamicGroupFill = new ConcurrentHashMap<>();
@@ -127,7 +126,7 @@ public class JpaRolloutExecutor implements RolloutExecutor {
final RolloutManagement rolloutManagement, final QuotaManagement quotaManagement, final RolloutManagement rolloutManagement, final QuotaManagement quotaManagement,
final RolloutGroupEvaluationManager evaluationManager, final RolloutApprovalStrategy rolloutApprovalStrategy, final RolloutGroupEvaluationManager evaluationManager, final RolloutApprovalStrategy rolloutApprovalStrategy,
final EntityManager entityManager, final PlatformTransactionManager txManager, final EntityManager entityManager, final PlatformTransactionManager txManager,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
final TenantAware tenantAware, final RepositoryProperties repositoryProperties) { final TenantAware tenantAware, final RepositoryProperties repositoryProperties) {
this.actionRepository = actionRepository; this.actionRepository = actionRepository;
this.rolloutGroupRepository = rolloutGroupRepository; this.rolloutGroupRepository = rolloutGroupRepository;
@@ -143,7 +142,6 @@ public class JpaRolloutExecutor implements RolloutExecutor {
this.entityManager = entityManager; this.entityManager = entityManager;
this.txManager = txManager; this.txManager = txManager;
this.afterCommit = afterCommit; this.afterCommit = afterCommit;
this.eventPublisherHolder = eventPublisherHolder;
this.tenantAware = tenantAware; this.tenantAware = tenantAware;
this.repositoryProperties = repositoryProperties; this.repositoryProperties = repositoryProperties;
} }
@@ -309,8 +307,8 @@ public class JpaRolloutExecutor implements RolloutExecutor {
rolloutRepository.save(rollout); rolloutRepository.save(rollout);
final List<Long> groupIds = rollout.getRolloutGroups().stream().map(RolloutGroup::getId).toList(); final List<Long> groupIds = rollout.getRolloutGroups().stream().map(RolloutGroup::getId).toList();
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher().publishEvent(new RolloutStoppedEvent( afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutStoppedEvent(
tenantAware.getCurrentTenant(), eventPublisherHolder.getApplicationId(), rollout.getId(), groupIds))); tenantAware.getCurrentTenant(), rollout.getId(), groupIds)));
} }
private void handleReadyRollout(final Rollout rollout) { private void handleReadyRollout(final Rollout rollout) {
@@ -374,8 +372,8 @@ public class JpaRolloutExecutor implements RolloutExecutor {
.map(Action::getId) .map(Action::getId)
.toList(); .toList();
actionRepository.deleteByIdIn(actionIds); actionRepository.deleteByIdIn(actionIds);
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher() afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new RolloutUpdatedEvent(rollout, eventPublisherHolder.getApplicationId()))); .publishEvent(new RolloutUpdatedEvent(rollout)));
} catch (final RuntimeException e) { } catch (final RuntimeException e) {
log.error("Exception during deletion of actions of rollout {}", rollout, e); log.error("Exception during deletion of actions of rollout {}", rollout, e);
} }

View File

@@ -152,7 +152,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TargetType; import org.eclipse.hawkbit.repository.model.TargetType;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder; import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder;
import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder; import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder;
import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder; import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder;
@@ -623,12 +622,12 @@ public class RepositoryApplicationConfiguration {
final RolloutGroupRepository rolloutGroupRepository, final RolloutGroupRepository rolloutGroupRepository,
final TargetFilterQueryRepository targetFilterQueryRepository, final TargetFilterQueryRepository targetFilterQueryRepository,
final TargetTypeRepository targetTypeRepository, final TargetTagRepository targetTagRepository, final TargetTypeRepository targetTypeRepository, final TargetTagRepository targetTagRepository,
final EventPublisherHolder eventPublisherHolder, final TenantAware tenantAware, final TenantAware tenantAware,
final VirtualPropertyReplacer virtualPropertyReplacer, final VirtualPropertyReplacer virtualPropertyReplacer,
final JpaProperties properties, final DistributionSetManagement distributionSetManagement) { final JpaProperties properties, final DistributionSetManagement distributionSetManagement) {
return new JpaTargetManagement(entityManager, distributionSetManagement, quotaManagement, targetRepository, return new JpaTargetManagement(entityManager, distributionSetManagement, quotaManagement, targetRepository,
targetTypeRepository, rolloutGroupRepository, targetFilterQueryRepository, targetTypeRepository, rolloutGroupRepository, targetFilterQueryRepository,
targetTagRepository, eventPublisherHolder, tenantAware, virtualPropertyReplacer, targetTagRepository, tenantAware, virtualPropertyReplacer,
properties.getDatabase()); properties.getDatabase());
} }
@@ -743,12 +742,12 @@ public class RepositoryApplicationConfiguration {
final RolloutManagement rolloutManagement, final QuotaManagement quotaManagement, final RolloutManagement rolloutManagement, final QuotaManagement quotaManagement,
final RolloutGroupEvaluationManager evaluationManager, final RolloutApprovalStrategy rolloutApprovalStrategy, final RolloutGroupEvaluationManager evaluationManager, final RolloutApprovalStrategy rolloutApprovalStrategy,
final EntityManager entityManager, final PlatformTransactionManager txManager, final EntityManager entityManager, final PlatformTransactionManager txManager,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
final TenantAware tenantAware, final RepositoryProperties repositoryProperties) { final TenantAware tenantAware, final RepositoryProperties repositoryProperties) {
return new JpaRolloutExecutor(actionRepository, rolloutGroupRepository, rolloutTargetGroupRepository, return new JpaRolloutExecutor(actionRepository, rolloutGroupRepository, rolloutTargetGroupRepository,
rolloutRepository, targetManagement, deploymentManagement, rolloutGroupManagement, rolloutManagement, rolloutRepository, targetManagement, deploymentManagement, rolloutGroupManagement, rolloutManagement,
quotaManagement, evaluationManager, rolloutApprovalStrategy, entityManager, txManager, afterCommit, quotaManagement, evaluationManager, rolloutApprovalStrategy, entityManager, txManager, afterCommit,
eventPublisherHolder, tenantAware, repositoryProperties); tenantAware, repositoryProperties);
} }
@Bean @Bean
@@ -764,14 +763,14 @@ public class RepositoryApplicationConfiguration {
final DistributionSetManagement distributionSetManagement, final DistributionSetManagement distributionSetManagement,
final TenantConfigurationManagement tenantConfigurationManagement, final TenantConfigurationManagement tenantConfigurationManagement,
final QuotaManagement quotaManagement, final QuotaManagement quotaManagement,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
final VirtualPropertyReplacer virtualPropertyReplacer, final VirtualPropertyReplacer virtualPropertyReplacer,
final SystemSecurityContext systemSecurityContext, final ContextAware contextAware, final JpaProperties properties, final SystemSecurityContext systemSecurityContext, final ContextAware contextAware, final JpaProperties properties,
final RepositoryProperties repositoryProperties) { final RepositoryProperties repositoryProperties) {
return new JpaRolloutManagement(rolloutRepository, rolloutGroupRepository, rolloutApprovalStrategy, return new JpaRolloutManagement(rolloutRepository, rolloutGroupRepository, rolloutApprovalStrategy,
startNextRolloutGroupAction, rolloutStatusCache, actionRepository, targetManagement, startNextRolloutGroupAction, rolloutStatusCache, actionRepository, targetManagement,
distributionSetManagement, tenantConfigurationManagement, quotaManagement, afterCommit, distributionSetManagement, tenantConfigurationManagement, quotaManagement, afterCommit,
eventPublisherHolder, virtualPropertyReplacer, systemSecurityContext, contextAware, properties.getDatabase(), virtualPropertyReplacer, systemSecurityContext, contextAware, properties.getDatabase(),
repositoryProperties); repositoryProperties);
} }
@@ -816,14 +815,14 @@ public class RepositoryApplicationConfiguration {
final ActionRepository actionRepository, final ActionRepository actionRepository,
final DistributionSetManagement distributionSetManagement, final TargetRepository targetRepository, final DistributionSetManagement distributionSetManagement, final TargetRepository targetRepository,
final ActionStatusRepository actionStatusRepository, final AuditorAware<String> auditorProvider, final ActionStatusRepository actionStatusRepository, final AuditorAware<String> auditorProvider,
final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit, final AfterTransactionCommitExecutor afterCommit,
final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager, final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager,
final TenantConfigurationManagement tenantConfigurationManagement, final QuotaManagement quotaManagement, final TenantConfigurationManagement tenantConfigurationManagement, final QuotaManagement quotaManagement,
final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final AuditorAware<String> auditorAware, final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final AuditorAware<String> auditorAware,
final JpaProperties properties, final RepositoryProperties repositoryProperties) { final JpaProperties properties, final RepositoryProperties repositoryProperties) {
return new JpaDeploymentManagement(entityManager, actionRepository, distributionSetManagement, targetRepository, actionStatusRepository, return new JpaDeploymentManagement(entityManager, actionRepository, distributionSetManagement, targetRepository, actionStatusRepository,
auditorProvider, auditorProvider,
eventPublisherHolder, afterCommit, virtualPropertyReplacer, txManager, tenantConfigurationManagement, afterCommit, virtualPropertyReplacer, txManager, tenantConfigurationManagement,
quotaManagement, systemSecurityContext, tenantAware, auditorAware, properties.getDatabase(), repositoryProperties); quotaManagement, systemSecurityContext, tenantAware, auditorAware, properties.getDatabase(), repositoryProperties);
} }
@@ -853,13 +852,13 @@ public class RepositoryApplicationConfiguration {
final DistributionSetManagement distributionSetManagement, final DistributionSetManagement distributionSetManagement,
final TenantConfigurationManagement tenantConfigurationManagement, final TenantConfigurationManagement tenantConfigurationManagement,
final PlatformTransactionManager txManager, final EntityFactory entityFactory, final EntityManager entityManager, final PlatformTransactionManager txManager, final EntityFactory entityFactory, final EntityManager entityManager,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware,
final ScheduledExecutorService executorService) { final ScheduledExecutorService executorService) {
return new JpaControllerManagement(actionRepository, actionStatusRepository, quotaManagement, repositoryProperties, return new JpaControllerManagement(actionRepository, actionStatusRepository, quotaManagement, repositoryProperties,
targetRepository, targetTypeManagement, deploymentManagement, confirmationManagement, softwareModuleRepository, targetRepository, targetTypeManagement, deploymentManagement, confirmationManagement, softwareModuleRepository,
softwareModuleMetadataRepository, distributionSetManagement, tenantConfigurationManagement, txManager, softwareModuleMetadataRepository, distributionSetManagement, tenantConfigurationManagement, txManager,
entityFactory, entityManager, afterCommit, eventPublisherHolder, systemSecurityContext, tenantAware, entityFactory, entityManager, afterCommit, systemSecurityContext, tenantAware,
executorService); executorService);
} }

View File

@@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
import org.eclipse.hawkbit.repository.QuotaManagement; import org.eclipse.hawkbit.repository.QuotaManagement;
import org.eclipse.hawkbit.repository.RepositoryConstants; import org.eclipse.hawkbit.repository.RepositoryConstants;
import org.eclipse.hawkbit.repository.RepositoryProperties; import org.eclipse.hawkbit.repository.RepositoryProperties;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.CancelTargetAssignmentEvent; import org.eclipse.hawkbit.repository.event.remote.CancelTargetAssignmentEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent;
import org.eclipse.hawkbit.repository.jpa.configuration.Constants; import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
@@ -33,7 +34,6 @@ 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.JpaDistributionSet_; import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet_;
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget; import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget_;
import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository; import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository;
import org.eclipse.hawkbit.repository.jpa.repository.ActionStatusRepository; import org.eclipse.hawkbit.repository.jpa.repository.ActionStatusRepository;
import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository; import org.eclipse.hawkbit.repository.jpa.repository.TargetRepository;
@@ -46,7 +46,6 @@ import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetWithActionType; import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@@ -59,7 +58,6 @@ public abstract class AbstractDsAssignmentStrategy {
protected final TargetRepository targetRepository; protected final TargetRepository targetRepository;
protected final AfterTransactionCommitExecutor afterCommit; protected final AfterTransactionCommitExecutor afterCommit;
protected final EventPublisherHolder eventPublisherHolder;
protected final ActionRepository actionRepository; protected final ActionRepository actionRepository;
private final ActionStatusRepository actionStatusRepository; private final ActionStatusRepository actionStatusRepository;
@@ -71,13 +69,12 @@ public abstract class AbstractDsAssignmentStrategy {
@SuppressWarnings("java:S107") @SuppressWarnings("java:S107")
AbstractDsAssignmentStrategy( AbstractDsAssignmentStrategy(
final TargetRepository targetRepository, final TargetRepository targetRepository,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository, final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig, final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig,
final BooleanSupplier confirmationFlowConfig, final RepositoryProperties repositoryProperties) { final BooleanSupplier confirmationFlowConfig, final RepositoryProperties repositoryProperties) {
this.targetRepository = targetRepository; this.targetRepository = targetRepository;
this.afterCommit = afterCommit; this.afterCommit = afterCommit;
this.eventPublisherHolder = eventPublisherHolder;
this.actionRepository = actionRepository; this.actionRepository = actionRepository;
this.actionStatusRepository = actionStatusRepository; this.actionStatusRepository = actionStatusRepository;
this.quotaManagement = quotaManagement; this.quotaManagement = quotaManagement;
@@ -131,8 +128,7 @@ public abstract class AbstractDsAssignmentStrategy {
} }
protected void sendTargetUpdatedEvent(final JpaTarget target) { protected void sendTargetUpdatedEvent(final JpaTarget target) {
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher() afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetUpdatedEvent(target)));
.publishEvent(new TargetUpdatedEvent(target, eventPublisherHolder.getApplicationId())));
} }
/** /**
@@ -215,8 +211,8 @@ public abstract class AbstractDsAssignmentStrategy {
* @param action the action of the assignment * @param action the action of the assignment
*/ */
protected void cancelAssignDistributionSetEvent(final Action action) { protected void cancelAssignDistributionSetEvent(final Action action) {
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher().publishEvent( afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
new CancelTargetAssignmentEvent(action, eventPublisherHolder.getApplicationId()))); .publishEvent(new CancelTargetAssignmentEvent(action)));
} }
protected boolean isMultiAssignmentsEnabled() { protected boolean isMultiAssignmentsEnabled() {
@@ -292,9 +288,8 @@ public abstract class AbstractDsAssignmentStrategy {
return; return;
} }
final String tenant = actions.get(0).getTenant(); final String tenant = actions.get(0).getTenant();
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher() afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new CancelTargetAssignmentEvent(tenant, .publishEvent(new CancelTargetAssignmentEvent(tenant, actions)));
actions, eventPublisherHolder.getApplicationId())));
} }
private void assertActionsPerTargetQuota(final Target target, final int requested) { private void assertActionsPerTargetQuota(final Target target, final int requested) {

View File

@@ -58,6 +58,7 @@ import org.eclipse.hawkbit.repository.TargetTypeManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.UpdateMode; import org.eclipse.hawkbit.repository.UpdateMode;
import org.eclipse.hawkbit.repository.builder.ActionStatusCreate; import org.eclipse.hawkbit.repository.builder.ActionStatusCreate;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.CancelTargetAssignmentEvent; import org.eclipse.hawkbit.repository.event.remote.CancelTargetAssignmentEvent;
import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent;
import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent; import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent;
@@ -98,7 +99,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetType; import org.eclipse.hawkbit.repository.model.TargetType;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.TenantAware;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
@@ -144,7 +144,6 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
private final EntityFactory entityFactory; private final EntityFactory entityFactory;
private final EntityManager entityManager; private final EntityManager entityManager;
private final AfterTransactionCommitExecutor afterCommit; private final AfterTransactionCommitExecutor afterCommit;
private final EventPublisherHolder eventPublisherHolder;
private final SystemSecurityContext systemSecurityContext; private final SystemSecurityContext systemSecurityContext;
private final TenantAware tenantAware; private final TenantAware tenantAware;
@@ -158,7 +157,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
final DistributionSetManagement distributionSetManagement, final DistributionSetManagement distributionSetManagement,
final TenantConfigurationManagement tenantConfigurationManagement, final TenantConfigurationManagement tenantConfigurationManagement,
final PlatformTransactionManager txManager, final EntityFactory entityFactory, final EntityManager entityManager, final PlatformTransactionManager txManager, final EntityFactory entityFactory, final EntityManager entityManager,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware,
final ScheduledExecutorService executorService) { final ScheduledExecutorService executorService) {
super(actionRepository, actionStatusRepository, quotaManagement, repositoryProperties); super(actionRepository, actionStatusRepository, quotaManagement, repositoryProperties);
@@ -175,7 +174,6 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
this.entityFactory = entityFactory; this.entityFactory = entityFactory;
this.entityManager = entityManager; this.entityManager = entityManager;
this.afterCommit = afterCommit; this.afterCommit = afterCommit;
this.eventPublisherHolder = eventPublisherHolder;
this.systemSecurityContext = systemSecurityContext; this.systemSecurityContext = systemSecurityContext;
this.tenantAware = tenantAware; this.tenantAware = tenantAware;
@@ -678,8 +676,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
final Target result = targetRepository.save(jpaTarget); final Target result = targetRepository.save(jpaTarget);
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher() afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetPollEvent(result)));
.publishEvent(new TargetPollEvent(result, eventPublisherHolder.getApplicationId())));
return result; return result;
} }
@@ -728,8 +725,8 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
pollChunks.forEach(chunk -> { pollChunks.forEach(chunk -> {
setLastTargetQuery(tenant, System.currentTimeMillis(), chunk); setLastTargetQuery(tenant, System.currentTimeMillis(), chunk);
chunk.forEach(controllerId -> afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher() chunk.forEach(controllerId -> afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetPollEvent(controllerId, tenant, eventPublisherHolder.getApplicationId())))); .publishEvent(new TargetPollEvent(controllerId, tenant))));
}); });
return null; return null;
@@ -788,8 +785,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
toUpdate.setUpdateStatus(TargetUpdateStatus.REGISTERED); toUpdate.setUpdateStatus(TargetUpdateStatus.REGISTERED);
} }
toUpdate.setLastTargetQuery(System.currentTimeMillis()); toUpdate.setLastTargetQuery(System.currentTimeMillis());
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher() afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetPollEvent(toUpdate)));
.publishEvent(new TargetPollEvent(toUpdate, eventPublisherHolder.getApplicationId())));
return targetRepository.save(toUpdate); return targetRepository.save(toUpdate);
} }
return toUpdate; return toUpdate;
@@ -835,10 +831,10 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
private void requestControllerAttributes(final JpaTarget target) { private void requestControllerAttributes(final JpaTarget target) {
target.setRequestControllerAttributes(true); target.setRequestControllerAttributes(true);
eventPublisherHolder.getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(), .publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(),
target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null, JpaTarget.class, target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null
JpaTarget.class, eventPublisherHolder.getApplicationId())); ));
} }
private void handleErrorOnAction(final JpaAction mergedAction, final JpaTarget mergedTarget) { private void handleErrorOnAction(final JpaAction mergedAction, final JpaTarget mergedTarget) {
@@ -937,8 +933,8 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
} }
private void cancelAssignDistributionSetEvent(final Action action) { private void cancelAssignDistributionSetEvent(final Action action) {
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher() afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new CancelTargetAssignmentEvent(action, eventPublisherHolder.getApplicationId()))); .publishEvent(new CancelTargetAssignmentEvent(action)));
} }
/** /**

View File

@@ -86,7 +86,6 @@ import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetType; import org.eclipse.hawkbit.repository.model.TargetType;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.TargetWithActionType; import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer; import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.TenantAware;
@@ -167,7 +166,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
final EntityManager entityManager, final ActionRepository actionRepository, final EntityManager entityManager, final ActionRepository actionRepository,
final DistributionSetManagement distributionSetManagement, final TargetRepository targetRepository, final DistributionSetManagement distributionSetManagement, final TargetRepository targetRepository,
final ActionStatusRepository actionStatusRepository, final AuditorAware<String> auditorProvider, final ActionStatusRepository actionStatusRepository, final AuditorAware<String> auditorProvider,
final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit, final AfterTransactionCommitExecutor afterCommit,
final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager, final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager,
final TenantConfigurationManagement tenantConfigurationManagement, final QuotaManagement quotaManagement, final TenantConfigurationManagement tenantConfigurationManagement, final QuotaManagement quotaManagement,
final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final AuditorAware<String> auditorAware, final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final AuditorAware<String> auditorAware,
@@ -179,11 +178,11 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
this.auditorProvider = auditorProvider; this.auditorProvider = auditorProvider;
this.virtualPropertyReplacer = virtualPropertyReplacer; this.virtualPropertyReplacer = virtualPropertyReplacer;
this.txManager = txManager; this.txManager = txManager;
onlineDsAssignmentStrategy = new OnlineDsAssignmentStrategy(targetRepository, afterCommit, eventPublisherHolder, onlineDsAssignmentStrategy = new OnlineDsAssignmentStrategy(targetRepository, afterCommit,
actionRepository, actionStatusRepository, quotaManagement, this::isMultiAssignmentsEnabled, actionRepository, actionStatusRepository, quotaManagement, this::isMultiAssignmentsEnabled,
this::isConfirmationFlowEnabled, repositoryProperties); this::isConfirmationFlowEnabled, repositoryProperties);
offlineDsAssignmentStrategy = new OfflineDsAssignmentStrategy(targetRepository, afterCommit, offlineDsAssignmentStrategy = new OfflineDsAssignmentStrategy(targetRepository, afterCommit,
eventPublisherHolder, actionRepository, actionStatusRepository, quotaManagement, actionRepository, actionStatusRepository, quotaManagement,
this::isMultiAssignmentsEnabled, this::isConfirmationFlowEnabled, repositoryProperties); this::isMultiAssignmentsEnabled, this::isConfirmationFlowEnabled, repositoryProperties);
this.tenantConfigurationManagement = tenantConfigurationManagement; this.tenantConfigurationManagement = tenantConfigurationManagement;
this.systemSecurityContext = systemSecurityContext; this.systemSecurityContext = systemSecurityContext;

View File

@@ -44,6 +44,7 @@ import org.eclipse.hawkbit.repository.builder.GenericRolloutUpdate;
import org.eclipse.hawkbit.repository.builder.RolloutCreate; import org.eclipse.hawkbit.repository.builder.RolloutCreate;
import org.eclipse.hawkbit.repository.builder.RolloutGroupCreate; import org.eclipse.hawkbit.repository.builder.RolloutGroupCreate;
import org.eclipse.hawkbit.repository.builder.RolloutUpdate; import org.eclipse.hawkbit.repository.builder.RolloutUpdate;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupCreatedEvent;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException; import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
@@ -77,7 +78,6 @@ import org.eclipse.hawkbit.repository.model.RolloutGroupsValidation;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TotalTargetCountActionStatus; import org.eclipse.hawkbit.repository.model.TotalTargetCountActionStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer; import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.springframework.dao.ConcurrencyFailureException; import org.springframework.dao.ConcurrencyFailureException;
@@ -120,7 +120,6 @@ public class JpaRolloutManagement implements RolloutManagement {
private final TenantConfigurationManagement tenantConfigurationManagement; private final TenantConfigurationManagement tenantConfigurationManagement;
private final QuotaManagement quotaManagement; private final QuotaManagement quotaManagement;
private final AfterTransactionCommitExecutor afterCommit; private final AfterTransactionCommitExecutor afterCommit;
private final EventPublisherHolder eventPublisherHolder;
private final VirtualPropertyReplacer virtualPropertyReplacer; private final VirtualPropertyReplacer virtualPropertyReplacer;
private final SystemSecurityContext systemSecurityContext; private final SystemSecurityContext systemSecurityContext;
private final ContextAware contextAware; private final ContextAware contextAware;
@@ -139,7 +138,7 @@ public class JpaRolloutManagement implements RolloutManagement {
final DistributionSetManagement distributionSetManagement, final DistributionSetManagement distributionSetManagement,
final TenantConfigurationManagement tenantConfigurationManagement, final TenantConfigurationManagement tenantConfigurationManagement,
final QuotaManagement quotaManagement, final QuotaManagement quotaManagement,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
final VirtualPropertyReplacer virtualPropertyReplacer, final VirtualPropertyReplacer virtualPropertyReplacer,
final SystemSecurityContext systemSecurityContext, final ContextAware contextAware, final Database database, final SystemSecurityContext systemSecurityContext, final ContextAware contextAware, final Database database,
final RepositoryProperties repositoryProperties) { final RepositoryProperties repositoryProperties) {
@@ -154,7 +153,6 @@ public class JpaRolloutManagement implements RolloutManagement {
this.tenantConfigurationManagement = tenantConfigurationManagement; this.tenantConfigurationManagement = tenantConfigurationManagement;
this.quotaManagement = quotaManagement; this.quotaManagement = quotaManagement;
this.afterCommit = afterCommit; this.afterCommit = afterCommit;
this.eventPublisherHolder = eventPublisherHolder;
this.virtualPropertyReplacer = virtualPropertyReplacer; this.virtualPropertyReplacer = virtualPropertyReplacer;
this.systemSecurityContext = systemSecurityContext; this.systemSecurityContext = systemSecurityContext;
this.contextAware = contextAware; this.contextAware = contextAware;
@@ -167,8 +165,8 @@ public class JpaRolloutManagement implements RolloutManagement {
} }
public void publishRolloutGroupCreatedEventAfterCommit(final RolloutGroup group, final Rollout rollout) { public void publishRolloutGroupCreatedEventAfterCommit(final RolloutGroup group, final Rollout rollout) {
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher().publishEvent( afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
new RolloutGroupCreatedEvent(group, rollout.getId(), eventPublisherHolder.getApplicationId()))); .publishEvent(new RolloutGroupCreatedEvent(group, rollout.getId())));
} }
@Override @Override

View File

@@ -42,6 +42,7 @@ import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.TimestampCalculator; import org.eclipse.hawkbit.repository.TimestampCalculator;
import org.eclipse.hawkbit.repository.builder.TargetCreate; import org.eclipse.hawkbit.repository.builder.TargetCreate;
import org.eclipse.hawkbit.repository.builder.TargetUpdate; import org.eclipse.hawkbit.repository.builder.TargetUpdate;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent;
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
@@ -73,7 +74,6 @@ import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetType; import org.eclipse.hawkbit.repository.model.TargetType;
import org.eclipse.hawkbit.repository.model.TargetTypeAssignmentResult; import org.eclipse.hawkbit.repository.model.TargetTypeAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer; import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
import org.eclipse.hawkbit.tenancy.TenantAware; import org.eclipse.hawkbit.tenancy.TenantAware;
import org.springframework.dao.ConcurrencyFailureException; import org.springframework.dao.ConcurrencyFailureException;
@@ -103,7 +103,6 @@ public class JpaTargetManagement implements TargetManagement {
private final RolloutGroupRepository rolloutGroupRepository; private final RolloutGroupRepository rolloutGroupRepository;
private final TargetFilterQueryRepository targetFilterQueryRepository; private final TargetFilterQueryRepository targetFilterQueryRepository;
private final TargetTagRepository targetTagRepository; private final TargetTagRepository targetTagRepository;
private final EventPublisherHolder eventPublisherHolder;
private final TenantAware tenantAware; private final TenantAware tenantAware;
private final VirtualPropertyReplacer virtualPropertyReplacer; private final VirtualPropertyReplacer virtualPropertyReplacer;
private final Database database; private final Database database;
@@ -114,7 +113,7 @@ public class JpaTargetManagement implements TargetManagement {
final TargetRepository targetRepository, final TargetTypeRepository targetTypeRepository, final TargetRepository targetRepository, final TargetTypeRepository targetTypeRepository,
final RolloutGroupRepository rolloutGroupRepository, final RolloutGroupRepository rolloutGroupRepository,
final TargetFilterQueryRepository targetFilterQueryRepository, final TargetFilterQueryRepository targetFilterQueryRepository,
final TargetTagRepository targetTagRepository, final EventPublisherHolder eventPublisherHolder, final TargetTagRepository targetTagRepository,
final TenantAware tenantAware, final VirtualPropertyReplacer virtualPropertyReplacer, final TenantAware tenantAware, final VirtualPropertyReplacer virtualPropertyReplacer,
final Database database) { final Database database) {
this.entityManager = entityManager; this.entityManager = entityManager;
@@ -125,7 +124,6 @@ public class JpaTargetManagement implements TargetManagement {
this.rolloutGroupRepository = rolloutGroupRepository; this.rolloutGroupRepository = rolloutGroupRepository;
this.targetFilterQueryRepository = targetFilterQueryRepository; this.targetFilterQueryRepository = targetFilterQueryRepository;
this.targetTagRepository = targetTagRepository; this.targetTagRepository = targetTagRepository;
this.eventPublisherHolder = eventPublisherHolder;
this.tenantAware = tenantAware; this.tenantAware = tenantAware;
this.virtualPropertyReplacer = virtualPropertyReplacer; this.virtualPropertyReplacer = virtualPropertyReplacer;
this.database = database; this.database = database;
@@ -649,11 +647,11 @@ public class JpaTargetManagement implements TargetManagement {
.ifPresent(acm -> acm.assertOperationAllowed(AccessController.Operation.UPDATE, target)); .ifPresent(acm -> acm.assertOperationAllowed(AccessController.Operation.UPDATE, target));
target.setRequestControllerAttributes(true); target.setRequestControllerAttributes(true);
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(() -> AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(() ->
eventPublisherHolder.getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetAttributesRequestedEvent( .publishEvent(new TargetAttributesRequestedEvent(
tenantAware.getCurrentTenant(), target.getId(), target.getControllerId(), tenantAware.getCurrentTenant(), target.getId(), JpaTarget.class, target.getControllerId(),
target.getAddress() != null ? target.getAddress().toString() : null, target.getAddress() != null ? target.getAddress().toString() : null
JpaTarget.class, eventPublisherHolder.getApplicationId()))); )));
} }
@Override @Override

View File

@@ -38,7 +38,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.TargetWithActionType; import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
/** /**
* AbstractDsAssignmentStrategy for offline assignments, i.e. not managed by * AbstractDsAssignmentStrategy for offline assignments, i.e. not managed by
@@ -48,11 +47,11 @@ public class OfflineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
OfflineDsAssignmentStrategy( OfflineDsAssignmentStrategy(
final TargetRepository targetRepository, final TargetRepository targetRepository,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository, final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig, final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig,
final BooleanSupplier confirmationFlowConfig, final RepositoryProperties repositoryProperties) { final BooleanSupplier confirmationFlowConfig, final RepositoryProperties repositoryProperties) {
super(targetRepository, afterCommit, eventPublisherHolder, actionRepository, actionStatusRepository, super(targetRepository, afterCommit, actionRepository, actionStatusRepository,
quotaManagement, multiAssignmentsConfig, confirmationFlowConfig, repositoryProperties); quotaManagement, multiAssignmentsConfig, confirmationFlowConfig, repositoryProperties);
} }

View File

@@ -21,6 +21,7 @@ import java.util.stream.Stream;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.eclipse.hawkbit.repository.QuotaManagement; import org.eclipse.hawkbit.repository.QuotaManagement;
import org.eclipse.hawkbit.repository.RepositoryProperties; import org.eclipse.hawkbit.repository.RepositoryProperties;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.MultiActionAssignEvent; import org.eclipse.hawkbit.repository.event.remote.MultiActionAssignEvent;
import org.eclipse.hawkbit.repository.event.remote.MultiActionCancelEvent; import org.eclipse.hawkbit.repository.event.remote.MultiActionCancelEvent;
import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent; import org.eclipse.hawkbit.repository.event.remote.TargetAssignDistributionSetEvent;
@@ -42,7 +43,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.TargetWithActionType; import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
/** /**
@@ -51,11 +51,11 @@ import org.springframework.util.CollectionUtils;
public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy { public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
OnlineDsAssignmentStrategy(final TargetRepository targetRepository, OnlineDsAssignmentStrategy(final TargetRepository targetRepository,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository, final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig, final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig,
final BooleanSupplier confirmationFlowConfig, final RepositoryProperties repositoryProperties) { final BooleanSupplier confirmationFlowConfig, final RepositoryProperties repositoryProperties) {
super(targetRepository, afterCommit, eventPublisherHolder, actionRepository, actionStatusRepository, super(targetRepository, afterCommit, actionRepository, actionStatusRepository,
quotaManagement, multiAssignmentsConfig, confirmationFlowConfig, repositoryProperties); quotaManagement, multiAssignmentsConfig, confirmationFlowConfig, repositoryProperties);
} }
@@ -225,9 +225,10 @@ public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
return; return;
} }
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher() afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetAssignDistributionSetEvent(tenant, distributionSetId, actions, .publishEvent(new TargetAssignDistributionSetEvent(
eventPublisherHolder.getApplicationId(), actions.get(0).isMaintenanceWindowAvailable()))); tenant, distributionSetId, actions,
actions.get(0).isMaintenanceWindowAvailable())));
} }
/** /**
@@ -238,20 +239,18 @@ public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
* @param actions assigned to the targets * @param actions assigned to the targets
*/ */
private void sendMultiActionCancelEvent(final String tenant, final List<Action> actions) { private void sendMultiActionCancelEvent(final String tenant, final List<Action> actions) {
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher() afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new MultiActionCancelEvent(tenant, eventPublisherHolder.getApplicationId(), actions))); .publishEvent(new MultiActionCancelEvent(tenant, actions)));
} }
/** /**
* Helper to fire a {@link MultiActionAssignEvent}. This method may only be * Helper to fire a {@link MultiActionAssignEvent}. This method may only be called if the Multi-Assignments feature is enabled.
* called if the Multi-Assignments feature is enabled.
* *
* @param tenant the event is scoped to * @param tenant the event is scoped to
* @param actions assigned to the targets * @param actions assigned to the targets
*/ */
private void sendMultiActionAssignEvent(final String tenant, final List<Action> actions) { private void sendMultiActionAssignEvent(final String tenant, final List<Action> actions) {
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher() afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new MultiActionAssignEvent(tenant, eventPublisherHolder.getApplicationId(), actions))); .publishEvent(new MultiActionAssignEvent(tenant, actions)));
} }
}
}

View File

@@ -9,6 +9,8 @@
*/ */
package org.eclipse.hawkbit.repository.jpa.model; package org.eclipse.hawkbit.repository.jpa.model;
import static org.eclipse.hawkbit.repository.model.BaseEntity.getIdOrNull;
import java.io.Serial; import java.io.Serial;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
@@ -43,6 +45,7 @@ import jakarta.validation.constraints.NotNull;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.eclipse.hawkbit.repository.MaintenanceScheduleHelper; import org.eclipse.hawkbit.repository.MaintenanceScheduleHelper;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.ActionCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.ActionUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.ActionUpdatedEvent;
import org.eclipse.hawkbit.repository.jpa.utils.MapAttributeConverter; import org.eclipse.hawkbit.repository.jpa.utils.MapAttributeConverter;
@@ -53,7 +56,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
/** /**
* JPA implementation of {@link Action}. * JPA implementation of {@link Action}.
@@ -262,17 +264,13 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
@Override @Override
public void fireCreateEvent() { public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new ActionCreatedEvent(this, BaseEntity.getIdOrNull(target), .publishEvent(new ActionCreatedEvent(this, getIdOrNull(target), getIdOrNull(rollout), getIdOrNull(rolloutGroup)));
BaseEntity.getIdOrNull(rollout), BaseEntity.getIdOrNull(rolloutGroup),
EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireUpdateEvent() { public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new ActionUpdatedEvent(this, BaseEntity.getIdOrNull(target), .publishEvent(new ActionUpdatedEvent(this, getIdOrNull(target), getIdOrNull(rollout), getIdOrNull(rolloutGroup)));
BaseEntity.getIdOrNull(rollout), BaseEntity.getIdOrNull(rolloutGroup),
EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override

View File

@@ -40,6 +40,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.ToString; import lombok.ToString;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetUpdatedEvent;
@@ -51,7 +52,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
/** /**
@@ -240,24 +240,22 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
@Override @Override
public void fireCreateEvent() { public void fireCreateEvent() {
publishEventWithEventPublisher( publishEventWithEventPublisher(
new DistributionSetCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId())); new DistributionSetCreatedEvent(this));
} }
@Override @Override
public void fireUpdateEvent() { public void fireUpdateEvent() {
publishEventWithEventPublisher( publishEventWithEventPublisher(
new DistributionSetUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId(), complete)); new DistributionSetUpdatedEvent(this, complete));
if (deleted) { if (deleted) {
publishEventWithEventPublisher(new DistributionSetDeletedEvent(getTenant(), getId(), getClass(), publishEventWithEventPublisher(new DistributionSetDeletedEvent(getTenant(), getId(), getClass()));
EventPublisherHolder.getInstance().getApplicationId()));
} }
} }
@Override @Override
public void fireDeleteEvent() { public void fireDeleteEvent() {
publishEventWithEventPublisher(new DistributionSetDeletedEvent(getTenant(), getId(), getClass(), publishEventWithEventPublisher(new DistributionSetDeletedEvent(getTenant(), getId(), getClass()));
EventPublisherHolder.getInstance().getApplicationId()));
} }
private static void publishEventWithEventPublisher(final ApplicationEvent event) { private static void publishEventWithEventPublisher(final ApplicationEvent event) {

View File

@@ -20,12 +20,12 @@ import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint; import jakarta.persistence.UniqueConstraint;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.DistributionSetTagDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetTagDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
/** /**
* A {@link DistributionSetTag} is used to describe DistributionSet attributes and use them also for filtering the DistributionSet list. * A {@link DistributionSetTag} is used to describe DistributionSet attributes and use them also for filtering the DistributionSet list.
@@ -60,20 +60,18 @@ public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag,
@Override @Override
public void fireCreateEvent() { public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTagCreatedEvent(this));
new DistributionSetTagCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireUpdateEvent() { public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTagUpdatedEvent(this));
new DistributionSetTagUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireDeleteEvent() { public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTagDeletedEvent( EventPublisherHolder.getInstance().getEventPublisher()
getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId())); .publishEvent(new DistributionSetTagDeletedEvent(getTenant(), getId(), getClass()));
} }
} }

View File

@@ -10,10 +10,8 @@
package org.eclipse.hawkbit.repository.jpa.model; package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial; import java.io.Serial;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -22,7 +20,6 @@ import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
import jakarta.persistence.Index; import jakarta.persistence.Index;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint; import jakarta.persistence.UniqueConstraint;
@@ -30,6 +27,7 @@ import jakarta.persistence.UniqueConstraint;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.DistributionSetTypeDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetTypeDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTypeCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTypeCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTypeUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTypeUpdatedEvent;
@@ -37,9 +35,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.TargetType;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.springframework.util.CollectionUtils;
/** /**
* A distribution set type defines which software module types can or have to be {@link DistributionSet}. * A distribution set type defines which software module types can or have to be {@link DistributionSet}.
@@ -126,20 +121,18 @@ public class JpaDistributionSetType extends AbstractJpaTypeEntity implements Dis
@Override @Override
public void fireCreateEvent() { public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTypeCreatedEvent(this));
new DistributionSetTypeCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireUpdateEvent() { public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTypeUpdatedEvent(this));
new DistributionSetTypeUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireDeleteEvent() { public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTypeDeletedEvent( EventPublisherHolder.getInstance().getEventPublisher()
getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId())); .publishEvent(new DistributionSetTypeDeletedEvent(getTenant(), getId(), getClass()));
} }
private JpaDistributionSetType setModuleType(final SoftwareModuleType smType, final boolean mandatory) { private JpaDistributionSetType setModuleType(final SoftwareModuleType smType, final boolean mandatory) {

View File

@@ -41,6 +41,7 @@ import jakarta.validation.constraints.Size;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.RolloutDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.RolloutDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.RolloutCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent;
@@ -52,7 +53,6 @@ import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
/** /**
* JPA implementation of a {@link Rollout}. * JPA implementation of a {@link Rollout}.
@@ -204,25 +204,21 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event
@Override @Override
public void fireCreateEvent() { public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutCreatedEvent(this));
.publishEvent(new RolloutCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireUpdateEvent() { public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutUpdatedEvent(this));
.publishEvent(new RolloutUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
if (deleted) { if (deleted) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutDeletedEvent(getTenant(), EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutDeletedEvent(getTenant(), getId(), getClass()));
getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }
@Override @Override
public void fireDeleteEvent() { public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutDeletedEvent(getTenant(), EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutDeletedEvent(getTenant(), getId(), getClass()));
getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
@Converter @Converter

View File

@@ -33,13 +33,13 @@ import jakarta.validation.constraints.Size;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.RolloutGroupDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.RolloutGroupDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.RolloutGroupUpdatedEvent;
import org.eclipse.hawkbit.repository.jpa.utils.MapAttributeConverter; import org.eclipse.hawkbit.repository.jpa.utils.MapAttributeConverter;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
/** /**
* JPA entity definition of persisting a group of an rollout. * JPA entity definition of persisting a group of an rollout.
@@ -193,14 +193,12 @@ public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGr
@Override @Override
public void fireUpdateEvent() { public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutGroupUpdatedEvent(this, getRollout().getId()));
new RolloutGroupUpdatedEvent(this, getRollout().getId(), EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireDeleteEvent() { public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutGroupDeletedEvent(getTenant(), getId(), getClass()));
new RolloutGroupDeletedEvent(getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
@Converter @Converter

View File

@@ -41,6 +41,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.ToString; import lombok.ToString;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.SoftwareModuleDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.SoftwareModuleDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleUpdatedEvent;
@@ -49,7 +50,6 @@ import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
/** /**
* Base Software Module that is supported by OS level provisioning mechanism on the edge controller, e.g. OS, JVM, AgentHub. * Base Software Module that is supported by OS level provisioning mechanism on the edge controller, e.g. OS, JVM, AgentHub.
@@ -199,24 +199,21 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
@Override @Override
public void fireCreateEvent() { public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleCreatedEvent(this));
new SoftwareModuleCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireUpdateEvent() { public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleUpdatedEvent(this));
new SoftwareModuleUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
if (deleted) { if (deleted) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleDeletedEvent( EventPublisherHolder.getInstance().getEventPublisher()
getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId())); .publishEvent(new SoftwareModuleDeletedEvent(getTenant(), getId(), getClass()));
} }
} }
@Override @Override
public void fireDeleteEvent() { public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleDeletedEvent(getTenant(), EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleDeletedEvent(getTenant(), getId(), getClass()));
getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }

View File

@@ -21,11 +21,11 @@ import jakarta.validation.constraints.Min;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.SoftwareModuleTypeDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.SoftwareModuleTypeDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleTypeCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleTypeCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleTypeUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleTypeUpdatedEvent;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
/** /**
* Type of software modules. * Type of software modules.
@@ -69,19 +69,17 @@ public class JpaSoftwareModuleType extends AbstractJpaTypeEntity implements Soft
@Override @Override
public void fireCreateEvent() { public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleTypeCreatedEvent(this));
new SoftwareModuleTypeCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireUpdateEvent() { public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleTypeUpdatedEvent(this));
new SoftwareModuleTypeUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireDeleteEvent() { public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleTypeDeletedEvent( EventPublisherHolder.getInstance().getEventPublisher()
getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId())); .publishEvent(new SoftwareModuleTypeDeletedEvent(getTenant(), getId(), getClass()));
} }
} }

View File

@@ -50,6 +50,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent;
@@ -61,7 +62,6 @@ import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TargetType; import org.eclipse.hawkbit.repository.model.TargetType;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder; import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder;
import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder; import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder;
import org.eclipse.hawkbit.security.SystemSecurityContext; import org.eclipse.hawkbit.security.SystemSecurityContext;
@@ -298,21 +298,18 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
@Override @Override
public void fireCreateEvent() { public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetCreatedEvent(this));
.publishEvent(new TargetCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireUpdateEvent() { public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetUpdatedEvent(this));
.publishEvent(new TargetUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireDeleteEvent() { public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetDeletedEvent(getTenant(), getId(), getControllerId(), address, .publishEvent(new TargetDeletedEvent(getTenant(), getId(), getClass(), getControllerId(), address));
getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
public List<RolloutTargetGroup> getRolloutTargetGroup() { public List<RolloutTargetGroup> getRolloutTargetGroup() {

View File

@@ -28,6 +28,7 @@ import jakarta.validation.constraints.Size;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.TargetFilterQueryDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetFilterQueryDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetFilterQueryCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetFilterQueryCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetFilterQueryUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetFilterQueryUpdatedEvent;
@@ -35,7 +36,6 @@ import org.eclipse.hawkbit.repository.model.Action.ActionType;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
/** /**
* Stored target filter. * Stored target filter.
@@ -115,19 +115,17 @@ public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity imple
@Override @Override
public void fireCreateEvent() { public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetFilterQueryCreatedEvent(this));
new TargetFilterQueryCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireUpdateEvent() { public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent( new TargetFilterQueryUpdatedEvent(this));
new TargetFilterQueryUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireDeleteEvent() { public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetFilterQueryDeletedEvent( EventPublisherHolder.getInstance().getEventPublisher()
getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId())); .publishEvent(new TargetFilterQueryDeletedEvent(getTenant(), getId(), getClass()));
} }
} }

View File

@@ -18,11 +18,11 @@ import jakarta.persistence.UniqueConstraint;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.ToString; import lombok.ToString;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.TargetTagDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetTagDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdatedEvent;
import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
/** /**
* A {@link TargetTag} is used to describe Target attributes and use them also for filtering the target list. * A {@link TargetTag} is used to describe Target attributes and use them also for filtering the target list.
@@ -47,19 +47,16 @@ public class JpaTargetTag extends JpaTag implements TargetTag, EventAwareEntity
@Override @Override
public void fireCreateEvent() { public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTagCreatedEvent(this));
.publishEvent(new TargetTagCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireUpdateEvent() { public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTagUpdatedEvent(this));
.publishEvent(new TargetTagUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireDeleteEvent() { public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTagDeletedEvent(getTenant(), EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTagDeletedEvent(getTenant(), getId(), getClass()));
getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }

View File

@@ -26,13 +26,13 @@ import jakarta.persistence.UniqueConstraint;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.ToString; import lombok.ToString;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.TargetTypeDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.TargetTypeDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTypeCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetTypeCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTypeUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetTypeUpdatedEvent;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetType; import org.eclipse.hawkbit.repository.model.TargetType;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
/** /**
* A target type defines which distribution set types can or have to be {@link Target}. * A target type defines which distribution set types can or have to be {@link Target}.
@@ -98,19 +98,16 @@ public class JpaTargetType extends AbstractJpaTypeEntity implements TargetType,
@Override @Override
public void fireCreateEvent() { public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTypeCreatedEvent(this));
new TargetTypeCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireUpdateEvent() { public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTypeUpdatedEvent(this));
new TargetTypeUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireDeleteEvent() { public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTypeDeletedEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTypeDeletedEvent(getTenant(), getId(), getClass()));
getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }

View File

@@ -22,11 +22,11 @@ import jakarta.validation.constraints.Size;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.remote.TenantConfigurationDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.TenantConfigurationDeletedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TenantConfigurationCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TenantConfigurationCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TenantConfigurationUpdatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TenantConfigurationUpdatedEvent;
import org.eclipse.hawkbit.repository.model.TenantConfiguration; import org.eclipse.hawkbit.repository.model.TenantConfiguration;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
/** /**
* A JPA entity which stores the tenant specific configuration. * A JPA entity which stores the tenant specific configuration.
@@ -63,20 +63,17 @@ public class JpaTenantConfiguration extends AbstractJpaTenantAwareBaseEntity imp
@Override @Override
public void fireCreateEvent() { public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TenantConfigurationCreatedEvent(this));
new TenantConfigurationCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireUpdateEvent() { public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TenantConfigurationUpdatedEvent(this));
new TenantConfigurationUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override
public void fireDeleteEvent() { public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TenantConfigurationDeletedEvent(getTenant(), getId(), getKey(), getValue(), .publishEvent(new TenantConfigurationDeletedEvent(getTenant(), getId(), getClass(), getKey(), getValue()));
getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }

View File

@@ -30,7 +30,6 @@ class RemoteIdEventTest extends AbstractRemoteEventTest {
private static final long ENTITY_ID = 1L; private static final long ENTITY_ID = 1L;
private static final String TENANT = "tenant"; private static final String TENANT = "tenant";
private static final Class<? extends TenantAwareBaseEntity> ENTITY_CLASS = JpaAction.class; private static final Class<? extends TenantAwareBaseEntity> ENTITY_CLASS = JpaAction.class;
private static final String NODE = "Node";
private static final String CONTROLLER_ID = "controller911"; private static final String CONTROLLER_ID = "controller911";
private static final String ADDRESS = "amqp://anyhost"; private static final String ADDRESS = "amqp://anyhost";
@@ -55,8 +54,7 @@ class RemoteIdEventTest extends AbstractRemoteEventTest {
*/ */
@Test @Test
void testTargetDeletedEvent() { void testTargetDeletedEvent() {
final TargetDeletedEvent deletedEvent = new TargetDeletedEvent(TENANT, ENTITY_ID, CONTROLLER_ID, ADDRESS, final TargetDeletedEvent deletedEvent = new TargetDeletedEvent(TENANT, ENTITY_ID, ENTITY_CLASS, CONTROLLER_ID, ADDRESS);
ENTITY_CLASS, NODE);
assertEntity(deletedEvent); assertEntity(deletedEvent);
} }
@@ -85,13 +83,12 @@ class RemoteIdEventTest extends AbstractRemoteEventTest {
} }
protected void assertAndCreateRemoteEvent(final Class<? extends RemoteIdEvent> eventType) { protected void assertAndCreateRemoteEvent(final Class<? extends RemoteIdEvent> eventType) {
final Constructor<?> constructor = Arrays.stream(eventType.getDeclaredConstructors()) final Constructor<?> constructor = Arrays.stream(eventType.getDeclaredConstructors())
.filter(con -> con.getParameterCount() == 4).findAny() .filter(con -> con.getParameterCount() == 3).findAny()
.orElseThrow(() -> new IllegalArgumentException("Given event is not RemoteIdEvent compatible")); .orElseThrow(() -> new IllegalArgumentException("Given event is not RemoteIdEvent compatible"));
try { try {
final RemoteIdEvent event = (RemoteIdEvent) constructor.newInstance(TENANT, ENTITY_ID, ENTITY_CLASS, NODE); final RemoteIdEvent event = (RemoteIdEvent) constructor.newInstance(TENANT, ENTITY_ID, ENTITY_CLASS);
assertEntity(event); assertEntity(event);
} catch (final ReflectiveOperationException e) { } catch (final ReflectiveOperationException e) {
fail("Exception should not happen " + e.getMessage()); fail("Exception should not happen " + e.getMessage());

View File

@@ -28,7 +28,6 @@ import org.junit.jupiter.api.Test;
class RemoteTenantAwareEventTest extends AbstractRemoteEventTest { class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
private static final String TENANT_DEFAULT = "DEFAULT"; private static final String TENANT_DEFAULT = "DEFAULT";
private static final String APPLICATION_ID_DEFAULT = "Node";
/** /**
* Verifies that a testMultiActionAssignEvent can be properly serialized and deserialized * Verifies that a testMultiActionAssignEvent can be properly serialized and deserialized
@@ -38,8 +37,7 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
final List<String> controllerIds = List.of("id0", "id1", "id2", "id3", "id4loooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnng"); final List<String> controllerIds = List.of("id0", "id1", "id2", "id3", "id4loooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnng");
final List<Action> actions = controllerIds.stream().map(this::createAction).toList(); final List<Action> actions = controllerIds.stream().map(this::createAction).toList();
final MultiActionAssignEvent assignEvent = new MultiActionAssignEvent(TENANT_DEFAULT, APPLICATION_ID_DEFAULT, final MultiActionAssignEvent assignEvent = new MultiActionAssignEvent(TENANT_DEFAULT, actions);
actions);
final MultiActionAssignEvent remoteAssignEventProtoStuff = createProtoStuffEvent(assignEvent); final MultiActionAssignEvent remoteAssignEventProtoStuff = createProtoStuffEvent(assignEvent);
assertThat(assignEvent).isEqualTo(remoteAssignEventProtoStuff); assertThat(assignEvent).isEqualTo(remoteAssignEventProtoStuff);
@@ -58,8 +56,7 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
final List<String> controllerIds = List.of("id0", "id1", "id2", "id3", "id4loooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnng"); final List<String> controllerIds = List.of("id0", "id1", "id2", "id3", "id4loooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnng");
final List<Action> actions = controllerIds.stream().map(this::createAction).toList(); final List<Action> actions = controllerIds.stream().map(this::createAction).toList();
final MultiActionCancelEvent cancelEvent = new MultiActionCancelEvent(TENANT_DEFAULT, APPLICATION_ID_DEFAULT, final MultiActionCancelEvent cancelEvent = new MultiActionCancelEvent(TENANT_DEFAULT, actions);
actions);
final MultiActionCancelEvent remoteCancelEventProtoStuff = createProtoStuffEvent(cancelEvent); final MultiActionCancelEvent remoteCancelEventProtoStuff = createProtoStuffEvent(cancelEvent);
assertThat(cancelEvent).isEqualTo(remoteCancelEventProtoStuff); assertThat(cancelEvent).isEqualTo(remoteCancelEventProtoStuff);
@@ -75,8 +72,7 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
*/ */
@Test @Test
void reloadDownloadProgressByRemoteEvent() { void reloadDownloadProgressByRemoteEvent() {
final DownloadProgressEvent downloadProgressEvent = new DownloadProgressEvent(TENANT_DEFAULT, 1L, 3L, final DownloadProgressEvent downloadProgressEvent = new DownloadProgressEvent(TENANT_DEFAULT, 1L, 3L);
APPLICATION_ID_DEFAULT);
final DownloadProgressEvent remoteEventProtoStuff = createProtoStuffEvent(downloadProgressEvent); final DownloadProgressEvent remoteEventProtoStuff = createProtoStuffEvent(downloadProgressEvent);
assertThat(downloadProgressEvent).isEqualTo(remoteEventProtoStuff); assertThat(downloadProgressEvent).isEqualTo(remoteEventProtoStuff);
@@ -104,8 +100,7 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
final Action action = actionRepository.save(generateAction); final Action action = actionRepository.save(generateAction);
final TargetAssignDistributionSetEvent assignmentEvent = new TargetAssignDistributionSetEvent( final TargetAssignDistributionSetEvent assignmentEvent = new TargetAssignDistributionSetEvent(
action.getTenant(), dsA.getId(), List.of(action), serviceMatcher.getBusId(), action.getTenant(), dsA.getId(), List.of(action), action.isMaintenanceWindowAvailable());
action.isMaintenanceWindowAvailable());
final TargetAssignDistributionSetEvent remoteEventProtoStuff = createProtoStuffEvent(assignmentEvent); final TargetAssignDistributionSetEvent remoteEventProtoStuff = createProtoStuffEvent(assignmentEvent);
assertTargetAssignDistributionSetEvent(action, remoteEventProtoStuff); assertTargetAssignDistributionSetEvent(action, remoteEventProtoStuff);
@@ -132,8 +127,7 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
final Action action = actionRepository.save(generateAction); final Action action = actionRepository.save(generateAction);
final CancelTargetAssignmentEvent cancelEvent = new CancelTargetAssignmentEvent(action, final CancelTargetAssignmentEvent cancelEvent = new CancelTargetAssignmentEvent(action);
serviceMatcher.getBusId());
final CancelTargetAssignmentEvent remoteEventProtoStuff = createProtoStuffEvent(cancelEvent); final CancelTargetAssignmentEvent remoteEventProtoStuff = createProtoStuffEvent(cancelEvent);
assertCancelTargetAssignmentEvent(action, remoteEventProtoStuff); assertCancelTargetAssignmentEvent(action, remoteEventProtoStuff);

View File

@@ -32,9 +32,7 @@ public abstract class AbstractRemoteEntityEventTest<E> extends AbstractRemoteEve
return event; return event;
} }
protected RemoteEntityEvent<?> createRemoteEvent(final E baseEntity, protected RemoteEntityEvent<?> createRemoteEvent(final E baseEntity, final Class<? extends RemoteEntityEvent<?>> eventType) {
final Class<? extends RemoteEntityEvent<?>> eventType) {
final int constructorParamCount = getConstructorParamCount(); final int constructorParamCount = getConstructorParamCount();
final Constructor<?> eventConstructor = findEventConstructorByParamCount(eventType, constructorParamCount); final Constructor<?> eventConstructor = findEventConstructorByParamCount(eventType, constructorParamCount);
final Object[] eventConstructorParams = getConstructorParams(baseEntity); final Object[] eventConstructorParams = getConstructorParams(baseEntity);
@@ -47,18 +45,17 @@ public abstract class AbstractRemoteEntityEventTest<E> extends AbstractRemoteEve
} }
protected int getConstructorParamCount() { protected int getConstructorParamCount() {
return 2; return 1;
} }
protected Constructor<?> findEventConstructorByParamCount(final Class<? extends RemoteEntityEvent<?>> eventType, protected Constructor<?> findEventConstructorByParamCount(final Class<? extends RemoteEntityEvent<?>> eventType, final int paramCount) {
final int paramCount) {
return Arrays.stream(eventType.getDeclaredConstructors()) return Arrays.stream(eventType.getDeclaredConstructors())
.filter(constructor -> constructor.getParameterCount() == paramCount).findAny() .filter(constructor -> constructor.getParameterCount() == paramCount).findAny()
.orElseThrow(() -> new IllegalArgumentException("No suitable constructor founded")); .orElseThrow(() -> new IllegalArgumentException("No suitable constructor found"));
} }
protected Object[] getConstructorParams(final E baseEntity) { protected Object[] getConstructorParams(final E baseEntity) {
return new Object[] { baseEntity, "Node" }; return new Object[] { baseEntity };
} }
protected RemoteEntityEvent<?> assertEntity(final E baseEntity, final RemoteEntityEvent<?> event) { protected RemoteEntityEvent<?> assertEntity(final E baseEntity, final RemoteEntityEvent<?> event) {

View File

@@ -45,12 +45,12 @@ class ActionEventTest extends AbstractRemoteEntityEventTest<Action> {
@Override @Override
protected int getConstructorParamCount() { protected int getConstructorParamCount() {
return 5; return 4;
} }
@Override @Override
protected Object[] getConstructorParams(final Action baseEntity) { protected Object[] getConstructorParams(final Action baseEntity) {
return new Object[] { baseEntity, 1L, 1L, 2L, "Node" }; return new Object[] { baseEntity, 1L, 1L, 2L };
} }
@Override @Override

View File

@@ -40,5 +40,4 @@ class DistributionSetTagEventTest extends AbstractRemoteEntityEventTest<Distribu
protected DistributionSetTag createEntity() { protected DistributionSetTag createEntity() {
return distributionSetTagManagement.create(entityFactory.tag().create().name("tag1")); return distributionSetTagManagement.create(entityFactory.tag().create().name("tag1"));
} }
}
}

View File

@@ -29,10 +29,8 @@ class DistributionSetUpdatedEventTest extends AbstractRemoteEntityEventTest<Dist
} }
@Override @Override
protected RemoteEntityEvent<?> createRemoteEvent(final DistributionSet baseEntity, protected RemoteEntityEvent<?> createRemoteEvent(final DistributionSet baseEntity, final Class<? extends RemoteEntityEvent<?>> eventType) {
final Class<? extends RemoteEntityEvent<?>> eventType) { return new DistributionSetUpdatedEvent(baseEntity, true);
return new DistributionSetUpdatedEvent(baseEntity, "1", true);
} }
@Override @Override
@@ -40,5 +38,4 @@ class DistributionSetUpdatedEventTest extends AbstractRemoteEntityEventTest<Dist
return distributionSetManagement.create(entityFactory.distributionSet().create() return distributionSetManagement.create(entityFactory.distributionSet().create()
.name("incomplete").version("2").description("incomplete").type("os")); .name("incomplete").version("2").description("incomplete").type("os"));
} }
}
}

View File

@@ -35,8 +35,7 @@ class RolloutGroupEventTest extends AbstractRemoteEntityEventTest<RolloutGroup>
*/ */
@Test @Test
void testRolloutGroupCreatedEvent() { void testRolloutGroupCreatedEvent() {
final RolloutGroupCreatedEvent createdEvent = (RolloutGroupCreatedEvent) assertAndCreateRemoteEvent( final RolloutGroupCreatedEvent createdEvent = (RolloutGroupCreatedEvent) assertAndCreateRemoteEvent(RolloutGroupCreatedEvent.class);
RolloutGroupCreatedEvent.class);
assertThat(createdEvent.getRolloutId()).isNotNull(); assertThat(createdEvent.getRolloutId()).isNotNull();
} }
@@ -50,12 +49,12 @@ class RolloutGroupEventTest extends AbstractRemoteEntityEventTest<RolloutGroup>
@Override @Override
protected int getConstructorParamCount() { protected int getConstructorParamCount() {
return 3; return 2;
} }
@Override @Override
protected Object[] getConstructorParams(final RolloutGroup baseEntity) { protected Object[] getConstructorParams(final RolloutGroup baseEntity) {
return new Object[] { baseEntity, 1L, "Node" }; return new Object[] { baseEntity, 1L };
} }
@Override @Override

View File

@@ -66,8 +66,6 @@ import org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties; import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.orm.jpa.vendor.Database; import org.springframework.orm.jpa.vendor.Database;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
@@ -76,7 +74,6 @@ import org.springframework.transaction.annotation.Transactional;
@Slf4j @Slf4j
@ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, TestConfiguration.class }) @ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, TestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
@TestPropertySource(locations = "classpath:/jpa-test.properties") @TestPropertySource(locations = "classpath:/jpa-test.properties")
@SuppressWarnings("java:S6813") // constructor injects are not possible for test classes @SuppressWarnings("java:S6813") // constructor injects are not possible for test classes
public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest { public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest {

View File

@@ -25,8 +25,6 @@ import org.eclipse.hawkbit.repository.test.TestConfiguration;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
@@ -37,7 +35,6 @@ import org.springframework.test.context.ContextConfiguration;
"spring.main.banner-mode=off", "spring.main.banner-mode=off",
"logging.level.root=ERROR" }) "logging.level.root=ERROR" })
@ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, TestConfiguration.class }) @ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, TestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
@Disabled("For manual run only, while playing around with RSQL to SQL") @Disabled("For manual run only, while playing around with RSQL to SQL")
@SuppressWarnings("java:S2699") // java:S2699 - manual test, don't actually does assertions @SuppressWarnings("java:S2699") // java:S2699 - manual test, don't actually does assertions
class RSQLToSQLTest { class RSQLToSQLTest {

Some files were not shown because too many files have changed in this diff Show More