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

@@ -0,0 +1,71 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.hawkbit.repository.event;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.bus.BusProperties;
import org.springframework.cloud.bus.ServiceMatcher;
import org.springframework.context.ApplicationEventPublisher;
/**
* A singleton bean which holds the event publisher and service origin id in order to publish remote application events.
* It can be used in beans not instantiated by spring e.g. JPA entities which cannot be auto-wired.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@SuppressWarnings("java:S6548") // java:S6548 - singleton holder ensures static access to spring resources in some places
public final class EventPublisherHolder {
private static final EventPublisherHolder SINGLETON = new EventPublisherHolder();
@Getter
private ApplicationEventPublisher eventPublisher;
private ServiceMatcher serviceMatcher;
private BusProperties bus;
/**
* @return the event publisher holder singleton instance
*/
public static EventPublisherHolder getInstance() {
return SINGLETON;
}
@Autowired // spring setter injection
public void setApplicationEventPublisher(final ApplicationEventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
@Autowired(required = false) // spring setter injection
public void setServiceMatcher(final ServiceMatcher serviceMatcher) {
this.serviceMatcher = serviceMatcher;
}
@Autowired // spring setter injection
public void setBusProperties(final BusProperties bus) {
this.bus = bus;
}
/**
* @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 && bus != null) {
id = bus.getId();
}
// 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);
}
}