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) -> {
if (actionStatus != null) {
eventPublisher.publishEvent(new DownloadProgressEvent(
tenantAware.getCurrentTenant(), actionStatus.getId(), shippedSinceLastEvent,
serviceMatcher != null ? serviceMatcher.getBusId() : bus.getId()));
tenantAware.getCurrentTenant(), actionStatus.getId(), shippedSinceLastEvent));
}
});
}

View File

@@ -47,8 +47,6 @@ import org.eclipse.hawkbit.repository.test.TestConfiguration;
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
import org.eclipse.hawkbit.rest.RestConfiguration;
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.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
@@ -58,7 +56,6 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@ContextConfiguration(
classes = { DdiApiConfiguration.class, RestConfiguration.class, RepositoryApplicationConfiguration.class, TestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
@TestPropertySource(locations = "classpath:/ddi-test.properties")
public abstract class AbstractDDiApiIntegrationTest extends AbstractRestIntegrationTest {

View File

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

View File

@@ -82,7 +82,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
private Target testTarget;
@BeforeEach
public void beforeEach() {
void beforeEach() {
testTarget = targetManagement.create(entityFactory.target().create().controllerId(CONTROLLER_ID)
.securityToken(TEST_TOKEN).address(AMQP_URI.toString()));
@@ -126,8 +126,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
final Action action = createAction(createDistributionSet);
final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent(
action, serviceMatcher.getBusId());
final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent(action);
amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent);
final Message sendMessage = getCaptureAddressEvent(targetAssignDistributionSetEvent);
final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage,
@@ -175,8 +174,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
Mockito.when(rabbitTemplate.convertSendAndReceive(any())).thenReturn(receivedList);
final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent(
action, serviceMatcher.getBusId());
final TargetAssignDistributionSetEvent targetAssignDistributionSetEvent = new TargetAssignDistributionSetEvent(action);
amqpMessageDispatcherService.targetAssignDistributionSet(targetAssignDistributionSetEvent);
final Message sendMessage = getCaptureAddressEvent(targetAssignDistributionSetEvent);
final DmfDownloadAndUpdateRequest downloadAndUpdateRequest = assertDownloadAndInstallMessage(sendMessage,
@@ -215,8 +213,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
@Test
void sendUpdateAttributesRequest() {
final String amqpUri = "amqp://anyhost";
final TargetAttributesRequestedEvent targetAttributesRequestedEvent = new TargetAttributesRequestedEvent(TENANT,
1L, CONTROLLER_ID, amqpUri, Target.class, serviceMatcher.getBusId());
final TargetAttributesRequestedEvent targetAttributesRequestedEvent = new TargetAttributesRequestedEvent(
TENANT,1L, Target.class, CONTROLLER_ID, amqpUri);
amqpMessageDispatcherService.targetTriggerUpdateAttributes(targetAttributesRequestedEvent);
@@ -233,10 +231,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
when(action.getId()).thenReturn(1L);
when(action.getTenant()).thenReturn(TENANT);
when(action.getTarget()).thenReturn(testTarget);
final CancelTargetAssignmentEvent cancelTargetAssignmentDistributionSetEvent = new CancelTargetAssignmentEvent(
action, serviceMatcher.getBusId());
amqpMessageDispatcherService
.targetCancelAssignmentToDistributionSet(cancelTargetAssignmentDistributionSetEvent);
final CancelTargetAssignmentEvent cancelTargetAssignmentDistributionSetEvent = new CancelTargetAssignmentEvent(action);
amqpMessageDispatcherService.targetCancelAssignmentToDistributionSet(cancelTargetAssignmentDistributionSetEvent);
final Message sendMessage = createArgumentCapture(AMQP_URI);
assertCancelMessage(sendMessage);
@@ -250,8 +246,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
// setup
final String amqpUri = "amqp://anyhost";
final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, amqpUri,
Target.class, serviceMatcher.getBusId());
final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, Target.class, CONTROLLER_ID, amqpUri);
// test
amqpMessageDispatcherService.targetDelete(targetDeletedEvent);
@@ -269,8 +264,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
// setup
final String noAmqpUri = "http://anyhost";
final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, noAmqpUri,
Target.class, serviceMatcher.getBusId());
final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, Target.class, CONTROLLER_ID, noAmqpUri);
// test
amqpMessageDispatcherService.targetDelete(targetDeletedEvent);
@@ -287,8 +281,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
// setup
final String noAmqpUri = null;
final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, noAmqpUri,
Target.class, serviceMatcher.getBusId());
final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, Target.class, CONTROLLER_ID, noAmqpUri);
// test
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.rabbit.test.RabbitListenerTestHarness;
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.util.CollectionUtils;
@@ -69,7 +67,6 @@ import org.springframework.util.CollectionUtils;
@ContextConfiguration(classes = {
DmfApiConfiguration.class, DmfTestConfiguration.class,
RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegrationTest {
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.support.converter.Jackson2JsonMessageConverter;
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.ClassMode;
import org.springframework.test.context.ContextConfiguration;
@@ -37,7 +35,6 @@ import org.springframework.test.context.ContextConfiguration;
@Slf4j
@RabbitAvailable
@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.
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
@SuppressWarnings("java:S6813") // constructor injects are not possible for test classes

View File

@@ -32,11 +32,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<!-- Database -->
<dependency>
<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.RestConfiguration;
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.TestPropertySource;
import org.springframework.test.web.servlet.ResultMatcher;
@ContextConfiguration(
classes = { MgmtApiConfiguration.class, RestConfiguration.class, RepositoryApplicationConfiguration.class, TestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
@TestPropertySource(locations = "classpath:/mgmt-test.properties")
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.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
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.http.HttpHeaders;
import org.springframework.test.annotation.DirtiesContext;
@@ -70,7 +68,6 @@ import org.springframework.web.context.WebApplicationContext;
@AutoConfigureMockMvc
@ContextConfiguration(classes = { MgmtApiConfiguration.class, RestConfiguration.class,
RepositoryApplicationConfiguration.class, TestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
/**
* Feature: Component Tests - Management API<br/>
* Story: Basic auth Userinfo Resource

View File

@@ -32,11 +32,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<!-- Database -->
<dependency>
<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)
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` :
```xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
```properties
spring.autoconfigure.exclude=
spring.cloud.bus.enabled=true
```
Optional as well is the addition of [Protostuff](https://github.com/protostuff/protostuff) based message payload
serialization for improved performance.
Add to your `application.properties` :
serialization for improved performance. To enable it set (via environment, system properties or properties files):
```properties
spring.cloud.stream.bindings.springCloudBusInput.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
<dependency>

View File

@@ -39,29 +39,7 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</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>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>

View File

@@ -7,7 +7,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.hawkbit.repository.model.helper;
package org.eclipse.hawkbit.repository.event;
import lombok.AccessLevel;
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}
* otherwise.
* @return the service origin Id coming either from {@link ServiceMatcher} when available or {@link BusProperties} otherwise.
*/
public String getApplicationId() {
String id = null;
if (serviceMatcher != null) {
id = serviceMatcher.getBusId();
}
if (id == null) {
if (id == null && bus != null) {
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<>();
protected AbstractAssignmentEvent(final Object source, final Action a, final String applicationId) {
super(source, a.getTenant(), applicationId);
protected AbstractAssignmentEvent(final Action a) {
super(a.getTenant(), null);
actions.put(a.getTarget().getControllerId(), new ActionProperties(a));
}
protected AbstractAssignmentEvent(final Object source, final String tenant, final List<Action> a,
final String applicationId) {
super(source, tenant, applicationId);
protected AbstractAssignmentEvent(final String tenant, final Object source, final List<Action> a) {
super(tenant, source);
actions.putAll(a.stream()
.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) {
return Optional.ofNullable(actions.get(controllerId));
}
}
}

View File

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

View File

@@ -25,15 +25,7 @@ public class DistributionSetDeletedEvent extends RemoteIdEvent implements Entity
@Serial
private static final long serialVersionUID = 1L;
/**
* Constructor.
*
* @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);
public DistributionSetDeletedEvent(final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass) {
super(tenant, entityId, entityClass);
}
}

View File

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

View File

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

View File

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

View File

@@ -10,6 +10,7 @@
package org.eclipse.hawkbit.repository.event.remote;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
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.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
@SuppressWarnings("java:S6548") // java:S6548 - singleton holder ensures static access to spring resources in some places
public final class EventEntityManagerHolder {
@@ -35,11 +37,4 @@ public final class EventEntityManagerHolder {
public void setEventEntityManager(final 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.
*
* @param tenant tenant the event is scoped to
* @param applicationId the application id
* @param actions the actions of the deployment action
*/
public MultiActionAssignEvent(String tenant, String applicationId, List<Action> actions) {
super(tenant, applicationId, actions);
public MultiActionAssignEvent(String tenant, List<Action> actions) {
super(tenant, actions);
}
}

View File

@@ -28,14 +28,7 @@ public class MultiActionCancelEvent extends MultiActionEvent {
@Serial
private static final long serialVersionUID = 1L;
/**
* Constructor.
*
* @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);
public MultiActionCancelEvent(String tenant, List<Action> actions) {
super(tenant, 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
* 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
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@NoArgsConstructor(access = AccessLevel.PROTECTED) // for serialization libs like jackson
public abstract class MultiActionEvent extends RemoteTenantAwareEvent implements Iterable<String> {
@Serial
@@ -39,15 +39,8 @@ public abstract class MultiActionEvent extends RemoteTenantAwareEvent implements
private final List<String> controllerIds = new ArrayList<>();
private final List<Long> actionIds = new ArrayList<>();
/**
* Constructor.
*
* @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);
protected MultiActionEvent(final String tenant, final List<Action> actions) {
super(tenant, null);
this.controllerIds.addAll(getControllerIdsFromActions(actions));
this.actionIds.addAll(getIdsFromActions(actions));
}

View File

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

View File

@@ -11,12 +11,12 @@ package org.eclipse.hawkbit.repository.event.remote;
import java.io.Serial;
import com.cronutils.utils.StringUtils;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.eclipse.hawkbit.repository.event.EventPublisherHolder;
import org.eclipse.hawkbit.repository.event.TenantAwareEvent;
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
* other nodes.
*/
@NoArgsConstructor(access = AccessLevel.PROTECTED) // for serialization libs like jackson
@Getter
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@NoArgsConstructor(access = AccessLevel.PROTECTED) // for serialization libs like jackson
public class RemoteTenantAwareEvent extends RemoteApplicationEvent implements TenantAwareEvent {
@Serial
@@ -36,16 +36,12 @@ public class RemoteTenantAwareEvent extends RemoteApplicationEvent implements Te
private String tenant;
/**
* Constructor.
*
* @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));
public RemoteTenantAwareEvent(final String tenant, final Object source) {
super(source == null ? getApplicationId() : source, getApplicationId(), DEFAULT_DESTINATION_FACTORY.getDestination(null));
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
private static final long serialVersionUID = 1L;
/**
* Constructor for json serialization.
*
* @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);
public RolloutDeletedEvent(final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass) {
super(tenant, entityId, entityClass);
}
}

View File

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

View File

@@ -34,18 +34,8 @@ public class RolloutStoppedEvent extends RemoteTenantAwareEvent {
private Collection<Long> rolloutGroupIds;
private long rolloutId;
/**
* Constructor for json serialization.
*
* @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);
public RolloutStoppedEvent(final String tenant, final long rolloutId, final Collection<Long> rolloutGroupIds) {
super(tenant, rolloutId);
this.rolloutId = rolloutId;
this.rolloutGroupIds = rolloutGroupIds;
}

View File

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

View File

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

View File

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

View File

@@ -33,20 +33,10 @@ public class TargetAttributesRequestedEvent extends RemoteIdEvent {
private String controllerId;
private String targetAddress;
/**
* Constructor json serialization
*
* @param tenant the tenant
* @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);
public TargetAttributesRequestedEvent(
final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass,
final String controllerId, final String targetAddress) {
super(tenant, entityId, entityClass);
this.controllerId = controllerId;
this.targetAddress = targetAddress;
}

View File

@@ -34,18 +34,10 @@ public class TargetDeletedEvent extends RemoteIdEvent implements EntityDeletedEv
private String controllerId;
private String targetAddress;
/**
* @param tenant the tenant
* @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 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);
public TargetDeletedEvent(
final String tenant, final Long entityId, final Class<? extends TenantAwareBaseEntity> entityClass,
final String controllerId, final String targetAddress) {
super(tenant, entityId, entityClass);
this.controllerId = controllerId;
this.targetAddress = targetAddress;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -15,6 +15,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.eclipse.hawkbit.repository.model.Action;
import org.springframework.lang.Nullable;
/**
* 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;
/**
* Default constructor.
* Default constructor for serialization libs like jackson.
*/
protected AbstractActionEvent() {
// for serialization libs like jackson
this.targetId = null;
this.rolloutId = 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(
final Action action, final Long targetId, final Long rolloutId,
final Long rolloutGroupId, final String applicationId) {
super(action, applicationId);
final Action action, @Nullable final Long targetId, @Nullable final Long rolloutId, @Nullable final Long rolloutGroupId) {
super(action);
this.targetId = targetId;
this.rolloutId = rolloutId;
this.rolloutGroupId = rolloutGroupId;

View File

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

View File

@@ -24,17 +24,7 @@ public class ActionCreatedEvent extends AbstractActionEvent implements EntityCre
@Serial
private static final long serialVersionUID = 2L;
/**
* 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
*/
public ActionCreatedEvent(
final Action action, final Long targetId, final Long rolloutId, final Long rolloutGroupId, final String applicationId) {
super(action, targetId, rolloutId, rolloutGroupId, applicationId);
public ActionCreatedEvent(final Action action, final Long targetId, final Long rolloutId, final Long rolloutGroupId) {
super(action, targetId, rolloutId, rolloutGroupId);
}
}

View File

@@ -24,17 +24,7 @@ public class ActionUpdatedEvent extends AbstractActionEvent implements EntityUpd
@Serial
private static final long serialVersionUID = 2L;
/**
* Constructor
*
* @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);
public ActionUpdatedEvent(final Action action, final Long targetId, final Long rolloutId, final Long rolloutGroupId) {
super(action, targetId, rolloutId, rolloutGroupId);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -31,12 +31,11 @@ public class DistributionSetUpdatedEvent extends RemoteEntityEvent<DistributionS
/**
* Constructor.
*
* @param ds Distribution Set
* @param applicationId the origin application id
* @param distributionSet Distribution Set
* @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) {
super(ds, applicationId);
public DistributionSetUpdatedEvent(final DistributionSet distributionSet, final boolean complete) {
super(distributionSet);
this.complete = complete;
}

View File

@@ -36,14 +36,8 @@ public class RemoteEntityEvent<E extends TenantAwareBaseEntity> extends RemoteId
private transient E entity;
/**
* Constructor.
*
* @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);
protected RemoteEntityEvent(final E baseEntity) {
super(baseEntity.getTenant(), baseEntity.getId(), baseEntity.getClass());
this.entity = baseEntity;
}

View File

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

View File

@@ -25,14 +25,7 @@ public class RolloutGroupCreatedEvent extends AbstractRolloutGroupEvent implemen
@Serial
private static final long serialVersionUID = 1L;
/**
* Constructor
*
* @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);
public RolloutGroupCreatedEvent(final RolloutGroup rolloutGroup, final Long rolloutId) {
super(rolloutGroup, rolloutId);
}
}

View File

@@ -24,14 +24,7 @@ public class RolloutGroupUpdatedEvent extends AbstractRolloutGroupEvent implemen
@Serial
private static final long serialVersionUID = 2L;
/**
* Constructor
*
* @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);
public RolloutGroupUpdatedEvent(final RolloutGroup rolloutGroup, final Long rolloutId) {
super(rolloutGroup, rolloutId);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -14,8 +14,8 @@ import java.util.concurrent.Executor;
import io.protostuff.ProtostuffIOUtil;
import io.protostuff.Schema;
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.model.helper.EventPublisherHolder;
import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -61,8 +61,7 @@ public class EventPublisherConfiguration {
}
/**
* Bean for creating a singleton instance of the
* {@link EventPublisherHolder}
* Bean for creating a 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.mockito.Mockito.when;
import java.io.Serial;
import java.util.HashMap;
import org.eclipse.hawkbit.repository.event.remote.entity.RemoteEntityEvent;
@@ -49,7 +50,7 @@ class BusProtoStuffMessageConverterTest {
*/
@Test
void successfullySerializeAndDeserializeEvent() {
final TargetCreatedEvent targetCreatedEvent = new TargetCreatedEvent(targetMock, "1");
final TargetCreatedEvent targetCreatedEvent = new TargetCreatedEvent(targetMock);
// serialize
final Object serializedEvent = underTest.convertToInternal(targetCreatedEvent,
new MessageHeaders(new HashMap<>()), null);
@@ -68,7 +69,7 @@ class BusProtoStuffMessageConverterTest {
*/
@Test
void missingEventTypeMappingThrowsMessageConversationException() {
final DummyRemoteEntityEvent dummyEvent = new DummyRemoteEntityEvent(targetMock, "applicationId");
final DummyRemoteEntityEvent dummyEvent = new DummyRemoteEntityEvent(targetMock);
final MessageHeaders messageHeaders = new MessageHeaders(new HashMap<>());
assertThatExceptionOfType(MessageConversionException.class)
@@ -79,13 +80,13 @@ class BusProtoStuffMessageConverterTest {
/**
* 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 DummyRemoteEntityEvent(final Target target, final String applicationId) {
super(target, applicationId);
private DummyRemoteEntityEvent(final Target target) {
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.RolloutManagement;
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.entity.RolloutUpdatedEvent;
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.RolloutGroupSuccessCondition;
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.tenancy.TenantAware;
import org.springframework.data.domain.PageRequest;
@@ -113,7 +113,6 @@ public class JpaRolloutExecutor implements RolloutExecutor {
private final EntityManager entityManager;
private final PlatformTransactionManager txManager;
private final AfterTransactionCommitExecutor afterCommit;
private final EventPublisherHolder eventPublisherHolder;
private final TenantAware tenantAware;
private final RepositoryProperties repositoryProperties;
private final Map<Long, AtomicLong> lastDynamicGroupFill = new ConcurrentHashMap<>();
@@ -127,7 +126,7 @@ public class JpaRolloutExecutor implements RolloutExecutor {
final RolloutManagement rolloutManagement, final QuotaManagement quotaManagement,
final RolloutGroupEvaluationManager evaluationManager, final RolloutApprovalStrategy rolloutApprovalStrategy,
final EntityManager entityManager, final PlatformTransactionManager txManager,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder,
final AfterTransactionCommitExecutor afterCommit,
final TenantAware tenantAware, final RepositoryProperties repositoryProperties) {
this.actionRepository = actionRepository;
this.rolloutGroupRepository = rolloutGroupRepository;
@@ -143,7 +142,6 @@ public class JpaRolloutExecutor implements RolloutExecutor {
this.entityManager = entityManager;
this.txManager = txManager;
this.afterCommit = afterCommit;
this.eventPublisherHolder = eventPublisherHolder;
this.tenantAware = tenantAware;
this.repositoryProperties = repositoryProperties;
}
@@ -309,8 +307,8 @@ public class JpaRolloutExecutor implements RolloutExecutor {
rolloutRepository.save(rollout);
final List<Long> groupIds = rollout.getRolloutGroups().stream().map(RolloutGroup::getId).toList();
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher().publishEvent(new RolloutStoppedEvent(
tenantAware.getCurrentTenant(), eventPublisherHolder.getApplicationId(), rollout.getId(), groupIds)));
afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutStoppedEvent(
tenantAware.getCurrentTenant(), rollout.getId(), groupIds)));
}
private void handleReadyRollout(final Rollout rollout) {
@@ -374,8 +372,8 @@ public class JpaRolloutExecutor implements RolloutExecutor {
.map(Action::getId)
.toList();
actionRepository.deleteByIdIn(actionIds);
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher()
.publishEvent(new RolloutUpdatedEvent(rollout, eventPublisherHolder.getApplicationId())));
afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new RolloutUpdatedEvent(rollout)));
} catch (final RuntimeException 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.TargetFilterQuery;
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.TenantConfigurationManagementHolder;
import org.eclipse.hawkbit.repository.rsql.RsqlConfigHolder;
@@ -623,12 +622,12 @@ public class RepositoryApplicationConfiguration {
final RolloutGroupRepository rolloutGroupRepository,
final TargetFilterQueryRepository targetFilterQueryRepository,
final TargetTypeRepository targetTypeRepository, final TargetTagRepository targetTagRepository,
final EventPublisherHolder eventPublisherHolder, final TenantAware tenantAware,
final TenantAware tenantAware,
final VirtualPropertyReplacer virtualPropertyReplacer,
final JpaProperties properties, final DistributionSetManagement distributionSetManagement) {
return new JpaTargetManagement(entityManager, distributionSetManagement, quotaManagement, targetRepository,
targetTypeRepository, rolloutGroupRepository, targetFilterQueryRepository,
targetTagRepository, eventPublisherHolder, tenantAware, virtualPropertyReplacer,
targetTagRepository, tenantAware, virtualPropertyReplacer,
properties.getDatabase());
}
@@ -743,12 +742,12 @@ public class RepositoryApplicationConfiguration {
final RolloutManagement rolloutManagement, final QuotaManagement quotaManagement,
final RolloutGroupEvaluationManager evaluationManager, final RolloutApprovalStrategy rolloutApprovalStrategy,
final EntityManager entityManager, final PlatformTransactionManager txManager,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder,
final AfterTransactionCommitExecutor afterCommit,
final TenantAware tenantAware, final RepositoryProperties repositoryProperties) {
return new JpaRolloutExecutor(actionRepository, rolloutGroupRepository, rolloutTargetGroupRepository,
rolloutRepository, targetManagement, deploymentManagement, rolloutGroupManagement, rolloutManagement,
quotaManagement, evaluationManager, rolloutApprovalStrategy, entityManager, txManager, afterCommit,
eventPublisherHolder, tenantAware, repositoryProperties);
tenantAware, repositoryProperties);
}
@Bean
@@ -764,14 +763,14 @@ public class RepositoryApplicationConfiguration {
final DistributionSetManagement distributionSetManagement,
final TenantConfigurationManagement tenantConfigurationManagement,
final QuotaManagement quotaManagement,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder,
final AfterTransactionCommitExecutor afterCommit,
final VirtualPropertyReplacer virtualPropertyReplacer,
final SystemSecurityContext systemSecurityContext, final ContextAware contextAware, final JpaProperties properties,
final RepositoryProperties repositoryProperties) {
return new JpaRolloutManagement(rolloutRepository, rolloutGroupRepository, rolloutApprovalStrategy,
startNextRolloutGroupAction, rolloutStatusCache, actionRepository, targetManagement,
distributionSetManagement, tenantConfigurationManagement, quotaManagement, afterCommit,
eventPublisherHolder, virtualPropertyReplacer, systemSecurityContext, contextAware, properties.getDatabase(),
virtualPropertyReplacer, systemSecurityContext, contextAware, properties.getDatabase(),
repositoryProperties);
}
@@ -816,14 +815,14 @@ public class RepositoryApplicationConfiguration {
final ActionRepository actionRepository,
final DistributionSetManagement distributionSetManagement, final TargetRepository targetRepository,
final ActionStatusRepository actionStatusRepository, final AuditorAware<String> auditorProvider,
final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
final AfterTransactionCommitExecutor afterCommit,
final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager,
final TenantConfigurationManagement tenantConfigurationManagement, final QuotaManagement quotaManagement,
final SystemSecurityContext systemSecurityContext, final TenantAware tenantAware, final AuditorAware<String> auditorAware,
final JpaProperties properties, final RepositoryProperties repositoryProperties) {
return new JpaDeploymentManagement(entityManager, actionRepository, distributionSetManagement, targetRepository, actionStatusRepository,
auditorProvider,
eventPublisherHolder, afterCommit, virtualPropertyReplacer, txManager, tenantConfigurationManagement,
afterCommit, virtualPropertyReplacer, txManager, tenantConfigurationManagement,
quotaManagement, systemSecurityContext, tenantAware, auditorAware, properties.getDatabase(), repositoryProperties);
}
@@ -853,13 +852,13 @@ public class RepositoryApplicationConfiguration {
final DistributionSetManagement distributionSetManagement,
final TenantConfigurationManagement tenantConfigurationManagement,
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 ScheduledExecutorService executorService) {
return new JpaControllerManagement(actionRepository, actionStatusRepository, quotaManagement, repositoryProperties,
targetRepository, targetTypeManagement, deploymentManagement, confirmationManagement, softwareModuleRepository,
softwareModuleMetadataRepository, distributionSetManagement, tenantConfigurationManagement, txManager,
entityFactory, entityManager, afterCommit, eventPublisherHolder, systemSecurityContext, tenantAware,
entityFactory, entityManager, afterCommit, systemSecurityContext, tenantAware,
executorService);
}

View File

@@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
import org.eclipse.hawkbit.repository.QuotaManagement;
import org.eclipse.hawkbit.repository.RepositoryConstants;
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.entity.TargetUpdatedEvent;
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.JpaTarget;
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget_;
import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository;
import org.eclipse.hawkbit.repository.jpa.repository.ActionStatusRepository;
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.Target;
import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@@ -59,7 +58,6 @@ public abstract class AbstractDsAssignmentStrategy {
protected final TargetRepository targetRepository;
protected final AfterTransactionCommitExecutor afterCommit;
protected final EventPublisherHolder eventPublisherHolder;
protected final ActionRepository actionRepository;
private final ActionStatusRepository actionStatusRepository;
@@ -71,13 +69,12 @@ public abstract class AbstractDsAssignmentStrategy {
@SuppressWarnings("java:S107")
AbstractDsAssignmentStrategy(
final TargetRepository targetRepository,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder,
final AfterTransactionCommitExecutor afterCommit,
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig,
final BooleanSupplier confirmationFlowConfig, final RepositoryProperties repositoryProperties) {
this.targetRepository = targetRepository;
this.afterCommit = afterCommit;
this.eventPublisherHolder = eventPublisherHolder;
this.actionRepository = actionRepository;
this.actionStatusRepository = actionStatusRepository;
this.quotaManagement = quotaManagement;
@@ -131,8 +128,7 @@ public abstract class AbstractDsAssignmentStrategy {
}
protected void sendTargetUpdatedEvent(final JpaTarget target) {
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher()
.publishEvent(new TargetUpdatedEvent(target, eventPublisherHolder.getApplicationId())));
afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetUpdatedEvent(target)));
}
/**
@@ -215,8 +211,8 @@ public abstract class AbstractDsAssignmentStrategy {
* @param action the action of the assignment
*/
protected void cancelAssignDistributionSetEvent(final Action action) {
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher().publishEvent(
new CancelTargetAssignmentEvent(action, eventPublisherHolder.getApplicationId())));
afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new CancelTargetAssignmentEvent(action)));
}
protected boolean isMultiAssignmentsEnabled() {
@@ -292,9 +288,8 @@ public abstract class AbstractDsAssignmentStrategy {
return;
}
final String tenant = actions.get(0).getTenant();
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher()
.publishEvent(new CancelTargetAssignmentEvent(tenant,
actions, eventPublisherHolder.getApplicationId())));
afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new CancelTargetAssignmentEvent(tenant, actions)));
}
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.UpdateMode;
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.TargetAttributesRequestedEvent;
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.TargetType;
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.tenancy.TenantAware;
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 EntityManager entityManager;
private final AfterTransactionCommitExecutor afterCommit;
private final EventPublisherHolder eventPublisherHolder;
private final SystemSecurityContext systemSecurityContext;
private final TenantAware tenantAware;
@@ -158,7 +157,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
final DistributionSetManagement distributionSetManagement,
final TenantConfigurationManagement tenantConfigurationManagement,
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 ScheduledExecutorService executorService) {
super(actionRepository, actionStatusRepository, quotaManagement, repositoryProperties);
@@ -175,7 +174,6 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
this.entityFactory = entityFactory;
this.entityManager = entityManager;
this.afterCommit = afterCommit;
this.eventPublisherHolder = eventPublisherHolder;
this.systemSecurityContext = systemSecurityContext;
this.tenantAware = tenantAware;
@@ -678,8 +676,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
final Target result = targetRepository.save(jpaTarget);
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher()
.publishEvent(new TargetPollEvent(result, eventPublisherHolder.getApplicationId())));
afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetPollEvent(result)));
return result;
}
@@ -728,8 +725,8 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
pollChunks.forEach(chunk -> {
setLastTargetQuery(tenant, System.currentTimeMillis(), chunk);
chunk.forEach(controllerId -> afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher()
.publishEvent(new TargetPollEvent(controllerId, tenant, eventPublisherHolder.getApplicationId()))));
chunk.forEach(controllerId -> afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetPollEvent(controllerId, tenant))));
});
return null;
@@ -788,8 +785,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
toUpdate.setUpdateStatus(TargetUpdateStatus.REGISTERED);
}
toUpdate.setLastTargetQuery(System.currentTimeMillis());
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher()
.publishEvent(new TargetPollEvent(toUpdate, eventPublisherHolder.getApplicationId())));
afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetPollEvent(toUpdate)));
return targetRepository.save(toUpdate);
}
return toUpdate;
@@ -835,10 +831,10 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
private void requestControllerAttributes(final JpaTarget target) {
target.setRequestControllerAttributes(true);
eventPublisherHolder.getEventPublisher()
EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(),
target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null,
JpaTarget.class, eventPublisherHolder.getApplicationId()));
JpaTarget.class, target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null
));
}
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) {
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher()
.publishEvent(new CancelTargetAssignmentEvent(action, eventPublisherHolder.getApplicationId())));
afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
.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.TargetUpdateStatus;
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.security.SystemSecurityContext;
import org.eclipse.hawkbit.tenancy.TenantAware;
@@ -167,7 +166,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
final EntityManager entityManager, final ActionRepository actionRepository,
final DistributionSetManagement distributionSetManagement, final TargetRepository targetRepository,
final ActionStatusRepository actionStatusRepository, final AuditorAware<String> auditorProvider,
final EventPublisherHolder eventPublisherHolder, final AfterTransactionCommitExecutor afterCommit,
final AfterTransactionCommitExecutor afterCommit,
final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager,
final TenantConfigurationManagement tenantConfigurationManagement, final QuotaManagement quotaManagement,
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.virtualPropertyReplacer = virtualPropertyReplacer;
this.txManager = txManager;
onlineDsAssignmentStrategy = new OnlineDsAssignmentStrategy(targetRepository, afterCommit, eventPublisherHolder,
onlineDsAssignmentStrategy = new OnlineDsAssignmentStrategy(targetRepository, afterCommit,
actionRepository, actionStatusRepository, quotaManagement, this::isMultiAssignmentsEnabled,
this::isConfirmationFlowEnabled, repositoryProperties);
offlineDsAssignmentStrategy = new OfflineDsAssignmentStrategy(targetRepository, afterCommit,
eventPublisherHolder, actionRepository, actionStatusRepository, quotaManagement,
actionRepository, actionStatusRepository, quotaManagement,
this::isMultiAssignmentsEnabled, this::isConfirmationFlowEnabled, repositoryProperties);
this.tenantConfigurationManagement = tenantConfigurationManagement;
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.RolloutGroupCreate;
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.exception.EntityNotFoundException;
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.TotalTargetCountActionStatus;
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.security.SystemSecurityContext;
import org.springframework.dao.ConcurrencyFailureException;
@@ -120,7 +120,6 @@ public class JpaRolloutManagement implements RolloutManagement {
private final TenantConfigurationManagement tenantConfigurationManagement;
private final QuotaManagement quotaManagement;
private final AfterTransactionCommitExecutor afterCommit;
private final EventPublisherHolder eventPublisherHolder;
private final VirtualPropertyReplacer virtualPropertyReplacer;
private final SystemSecurityContext systemSecurityContext;
private final ContextAware contextAware;
@@ -139,7 +138,7 @@ public class JpaRolloutManagement implements RolloutManagement {
final DistributionSetManagement distributionSetManagement,
final TenantConfigurationManagement tenantConfigurationManagement,
final QuotaManagement quotaManagement,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder,
final AfterTransactionCommitExecutor afterCommit,
final VirtualPropertyReplacer virtualPropertyReplacer,
final SystemSecurityContext systemSecurityContext, final ContextAware contextAware, final Database database,
final RepositoryProperties repositoryProperties) {
@@ -154,7 +153,6 @@ public class JpaRolloutManagement implements RolloutManagement {
this.tenantConfigurationManagement = tenantConfigurationManagement;
this.quotaManagement = quotaManagement;
this.afterCommit = afterCommit;
this.eventPublisherHolder = eventPublisherHolder;
this.virtualPropertyReplacer = virtualPropertyReplacer;
this.systemSecurityContext = systemSecurityContext;
this.contextAware = contextAware;
@@ -167,8 +165,8 @@ public class JpaRolloutManagement implements RolloutManagement {
}
public void publishRolloutGroupCreatedEventAfterCommit(final RolloutGroup group, final Rollout rollout) {
afterCommit.afterCommit(() -> eventPublisherHolder.getEventPublisher().publishEvent(
new RolloutGroupCreatedEvent(group, rollout.getId(), eventPublisherHolder.getApplicationId())));
afterCommit.afterCommit(() -> EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new RolloutGroupCreatedEvent(group, rollout.getId())));
}
@Override

View File

@@ -42,6 +42,7 @@ import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.TimestampCalculator;
import org.eclipse.hawkbit.repository.builder.TargetCreate;
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.exception.EntityAlreadyExistsException;
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.TargetTypeAssignmentResult;
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.tenancy.TenantAware;
import org.springframework.dao.ConcurrencyFailureException;
@@ -103,7 +103,6 @@ public class JpaTargetManagement implements TargetManagement {
private final RolloutGroupRepository rolloutGroupRepository;
private final TargetFilterQueryRepository targetFilterQueryRepository;
private final TargetTagRepository targetTagRepository;
private final EventPublisherHolder eventPublisherHolder;
private final TenantAware tenantAware;
private final VirtualPropertyReplacer virtualPropertyReplacer;
private final Database database;
@@ -114,7 +113,7 @@ public class JpaTargetManagement implements TargetManagement {
final TargetRepository targetRepository, final TargetTypeRepository targetTypeRepository,
final RolloutGroupRepository rolloutGroupRepository,
final TargetFilterQueryRepository targetFilterQueryRepository,
final TargetTagRepository targetTagRepository, final EventPublisherHolder eventPublisherHolder,
final TargetTagRepository targetTagRepository,
final TenantAware tenantAware, final VirtualPropertyReplacer virtualPropertyReplacer,
final Database database) {
this.entityManager = entityManager;
@@ -125,7 +124,6 @@ public class JpaTargetManagement implements TargetManagement {
this.rolloutGroupRepository = rolloutGroupRepository;
this.targetFilterQueryRepository = targetFilterQueryRepository;
this.targetTagRepository = targetTagRepository;
this.eventPublisherHolder = eventPublisherHolder;
this.tenantAware = tenantAware;
this.virtualPropertyReplacer = virtualPropertyReplacer;
this.database = database;
@@ -649,11 +647,11 @@ public class JpaTargetManagement implements TargetManagement {
.ifPresent(acm -> acm.assertOperationAllowed(AccessController.Operation.UPDATE, target));
target.setRequestControllerAttributes(true);
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(() ->
eventPublisherHolder.getEventPublisher()
EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetAttributesRequestedEvent(
tenantAware.getCurrentTenant(), target.getId(), target.getControllerId(),
target.getAddress() != null ? target.getAddress().toString() : null,
JpaTarget.class, eventPublisherHolder.getApplicationId())));
tenantAware.getCurrentTenant(), target.getId(), JpaTarget.class, target.getControllerId(),
target.getAddress() != null ? target.getAddress().toString() : null
)));
}
@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.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
/**
* AbstractDsAssignmentStrategy for offline assignments, i.e. not managed by
@@ -48,11 +47,11 @@ public class OfflineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
OfflineDsAssignmentStrategy(
final TargetRepository targetRepository,
final AfterTransactionCommitExecutor afterCommit, final EventPublisherHolder eventPublisherHolder,
final AfterTransactionCommitExecutor afterCommit,
final ActionRepository actionRepository, final ActionStatusRepository actionStatusRepository,
final QuotaManagement quotaManagement, final BooleanSupplier multiAssignmentsConfig,
final BooleanSupplier confirmationFlowConfig, final RepositoryProperties repositoryProperties) {
super(targetRepository, afterCommit, eventPublisherHolder, actionRepository, actionStatusRepository,
super(targetRepository, afterCommit, actionRepository, actionStatusRepository,
quotaManagement, multiAssignmentsConfig, confirmationFlowConfig, repositoryProperties);
}

View File

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

View File

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

View File

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

View File

@@ -20,12 +20,12 @@ import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
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.entity.DistributionSetTagCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent;
import org.eclipse.hawkbit.repository.model.DistributionSet;
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.
@@ -60,20 +60,18 @@ public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag,
@Override
public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
new DistributionSetTagCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTagCreatedEvent(this));
}
@Override
public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
new DistributionSetTagUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTagUpdatedEvent(this));
}
@Override
public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTagDeletedEvent(
getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new DistributionSetTagDeletedEvent(getTenant(), getId(), getClass()));
}
}

View File

@@ -10,10 +10,8 @@
package org.eclipse.hawkbit.repository.jpa.model;
import java.io.Serial;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@@ -22,7 +20,6 @@ import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Index;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
@@ -30,6 +27,7 @@ import jakarta.persistence.UniqueConstraint;
import lombok.Getter;
import lombok.NoArgsConstructor;
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.entity.DistributionSetTypeCreatedEvent;
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.SoftwareModule;
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}.
@@ -126,20 +121,18 @@ public class JpaDistributionSetType extends AbstractJpaTypeEntity implements Dis
@Override
public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
new DistributionSetTypeCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTypeCreatedEvent(this));
}
@Override
public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
new DistributionSetTypeUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTypeUpdatedEvent(this));
}
@Override
public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTypeDeletedEvent(
getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new DistributionSetTypeDeletedEvent(getTenant(), getId(), getClass()));
}
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.NoArgsConstructor;
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.entity.RolloutCreatedEvent;
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.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
/**
* JPA implementation of a {@link Rollout}.
@@ -204,25 +204,21 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event
@Override
public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new RolloutCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutCreatedEvent(this));
}
@Override
public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new RolloutUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutUpdatedEvent(this));
if (deleted) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutDeletedEvent(getTenant(),
getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutDeletedEvent(getTenant(), getId(), getClass()));
}
}
@Override
public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutDeletedEvent(getTenant(),
getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutDeletedEvent(getTenant(), getId(), getClass()));
}
@Converter

View File

@@ -33,13 +33,13 @@ import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.NoArgsConstructor;
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.entity.RolloutGroupUpdatedEvent;
import org.eclipse.hawkbit.repository.jpa.utils.MapAttributeConverter;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
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.
@@ -193,14 +193,12 @@ public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGr
@Override
public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
new RolloutGroupUpdatedEvent(this, getRollout().getId(), EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutGroupUpdatedEvent(this, getRollout().getId()));
}
@Override
public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
new RolloutGroupDeletedEvent(getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutGroupDeletedEvent(getTenant(), getId(), getClass()));
}
@Converter

View File

@@ -41,6 +41,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
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.entity.SoftwareModuleCreatedEvent;
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.SoftwareModule;
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.
@@ -199,24 +199,21 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
@Override
public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
new SoftwareModuleCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleCreatedEvent(this));
}
@Override
public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
new SoftwareModuleUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleUpdatedEvent(this));
if (deleted) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleDeletedEvent(
getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new SoftwareModuleDeletedEvent(getTenant(), getId(), getClass()));
}
}
@Override
public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleDeletedEvent(getTenant(),
getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleDeletedEvent(getTenant(), getId(), getClass()));
}
}

View File

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

View File

@@ -50,6 +50,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
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.entity.TargetCreatedEvent;
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.TargetType;
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.TenantConfigurationManagementHolder;
import org.eclipse.hawkbit.security.SystemSecurityContext;
@@ -298,21 +298,18 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
@Override
public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetCreatedEvent(this));
}
@Override
public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetUpdatedEvent(this));
}
@Override
public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetDeletedEvent(getTenant(), getId(), getControllerId(), address,
getClass(), EventPublisherHolder.getInstance().getApplicationId()));
.publishEvent(new TargetDeletedEvent(getTenant(), getId(), getClass(), getControllerId(), address));
}
public List<RolloutTargetGroup> getRolloutTargetGroup() {

View File

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

View File

@@ -18,11 +18,11 @@ import jakarta.persistence.UniqueConstraint;
import lombok.NoArgsConstructor;
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.entity.TargetTagCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdatedEvent;
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.
@@ -47,19 +47,16 @@ public class JpaTargetTag extends JpaTag implements TargetTag, EventAwareEntity
@Override
public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetTagCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTagCreatedEvent(this));
}
@Override
public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetTagUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTagUpdatedEvent(this));
}
@Override
public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTagDeletedEvent(getTenant(),
getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTagDeletedEvent(getTenant(), getId(), getClass()));
}
}

View File

@@ -26,13 +26,13 @@ import jakarta.persistence.UniqueConstraint;
import lombok.NoArgsConstructor;
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.entity.TargetTypeCreatedEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTypeUpdatedEvent;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.Target;
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}.
@@ -98,19 +98,16 @@ public class JpaTargetType extends AbstractJpaTypeEntity implements TargetType,
@Override
public void fireCreateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
new TargetTypeCreatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTypeCreatedEvent(this));
}
@Override
public void fireUpdateEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(
new TargetTypeUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTypeUpdatedEvent(this));
}
@Override
public void fireDeleteEvent() {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTypeDeletedEvent(
getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTypeDeletedEvent(getTenant(), getId(), getClass()));
}
}

View File

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

View File

@@ -30,7 +30,6 @@ class RemoteIdEventTest extends AbstractRemoteEventTest {
private static final long ENTITY_ID = 1L;
private static final String TENANT = "tenant";
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 ADDRESS = "amqp://anyhost";
@@ -55,8 +54,7 @@ class RemoteIdEventTest extends AbstractRemoteEventTest {
*/
@Test
void testTargetDeletedEvent() {
final TargetDeletedEvent deletedEvent = new TargetDeletedEvent(TENANT, ENTITY_ID, CONTROLLER_ID, ADDRESS,
ENTITY_CLASS, NODE);
final TargetDeletedEvent deletedEvent = new TargetDeletedEvent(TENANT, ENTITY_ID, ENTITY_CLASS, CONTROLLER_ID, ADDRESS);
assertEntity(deletedEvent);
}
@@ -85,13 +83,12 @@ class RemoteIdEventTest extends AbstractRemoteEventTest {
}
protected void assertAndCreateRemoteEvent(final Class<? extends RemoteIdEvent> eventType) {
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"));
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);
} catch (final ReflectiveOperationException e) {
fail("Exception should not happen " + e.getMessage());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -66,8 +66,6 @@ import org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
import org.springframework.beans.factory.annotation.Autowired;
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.orm.jpa.vendor.Database;
import org.springframework.test.context.ContextConfiguration;
@@ -76,7 +74,6 @@ import org.springframework.transaction.annotation.Transactional;
@Slf4j
@ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, TestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
@TestPropertySource(locations = "classpath:/jpa-test.properties")
@SuppressWarnings("java:S6813") // constructor injects are not possible for test classes
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.Test;
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.ContextConfiguration;
@@ -37,7 +35,6 @@ import org.springframework.test.context.ContextConfiguration;
"spring.main.banner-mode=off",
"logging.level.root=ERROR" })
@ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, TestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
@Disabled("For manual run only, while playing around with RSQL to SQL")
@SuppressWarnings("java:S2699") // java:S2699 - manual test, don't actually does assertions
class RSQLToSQLTest {

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