Extend event for entity events (#1250)

* Extend event information by it's first interface class and improve constructing the event by providing the directly only.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>

* Check if entity interface is assignable from TenantAwareBaseEntity.

Signed-off-by: Michael Herdt <Michael.Herdt@bosch.io>
This commit is contained in:
Michael Herdt
2022-04-25 15:39:44 +02:00
committed by GitHub
parent 0e6ef2e468
commit 59932b1d6f
38 changed files with 98 additions and 58 deletions

View File

@@ -219,7 +219,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
void sendUpdateAttributesRequest() { void sendUpdateAttributesRequest() {
final String amqpUri = "amqp://anyhost"; final String amqpUri = "amqp://anyhost";
final TargetAttributesRequestedEvent targetAttributesRequestedEvent = new TargetAttributesRequestedEvent(TENANT, final TargetAttributesRequestedEvent targetAttributesRequestedEvent = new TargetAttributesRequestedEvent(TENANT,
1L, CONTROLLER_ID, amqpUri, Target.class.getName(), serviceMatcher.getServiceId()); 1L, CONTROLLER_ID, amqpUri, Target.class, serviceMatcher.getServiceId());
amqpMessageDispatcherService.targetTriggerUpdateAttributes(targetAttributesRequestedEvent); amqpMessageDispatcherService.targetTriggerUpdateAttributes(targetAttributesRequestedEvent);
@@ -247,7 +247,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
// setup // setup
final String amqpUri = "amqp://anyhost"; final String amqpUri = "amqp://anyhost";
final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, amqpUri, final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, amqpUri,
Target.class.getName(), serviceMatcher.getServiceId()); Target.class, serviceMatcher.getServiceId());
// test // test
amqpMessageDispatcherService.targetDelete(targetDeletedEvent); amqpMessageDispatcherService.targetDelete(targetDeletedEvent);
@@ -264,7 +264,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
// setup // setup
final String noAmqpUri = "http://anyhost"; final String noAmqpUri = "http://anyhost";
final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, noAmqpUri, final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, noAmqpUri,
Target.class.getName(), serviceMatcher.getServiceId()); Target.class, serviceMatcher.getServiceId());
// test // test
amqpMessageDispatcherService.targetDelete(targetDeletedEvent); amqpMessageDispatcherService.targetDelete(targetDeletedEvent);
@@ -280,7 +280,7 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
// setup // setup
final String noAmqpUri = null; final String noAmqpUri = null;
final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, noAmqpUri, final TargetDeletedEvent targetDeletedEvent = new TargetDeletedEvent(TENANT, 1L, CONTROLLER_ID, noAmqpUri,
Target.class.getName(), serviceMatcher.getServiceId()); Target.class, serviceMatcher.getServiceId());
// test // test
amqpMessageDispatcherService.targetDelete(targetDeletedEvent); amqpMessageDispatcherService.targetDelete(targetDeletedEvent);

View File

@@ -20,6 +20,11 @@ public interface EntityIdEvent extends TenantAwareEvent {
*/ */
String getEntityClass(); String getEntityClass();
/**
* @return the class of entities interface
*/
String getInterfaceClass();
/** /**
* @return the ID of the entity of this event. * @return the ID of the entity of this event.
*/ */

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/** /**
* Defines the remote event for deletion of {@link DistributionSet}. * Defines the remote event for deletion of {@link DistributionSet}.
@@ -35,8 +36,8 @@ public class DistributionSetDeletedEvent extends RemoteIdEvent implements Entity
* @param applicationId * @param applicationId
* the origin application id * the origin application id
*/ */
public DistributionSetDeletedEvent(final String tenant, final Long entityId, final String entityClass, public DistributionSetDeletedEvent(final String tenant, final Long entityId,
final String applicationId) { final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId); super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/** /**
* Defines the the remote event of delete a {@link DistributionSetTag}. * Defines the the remote event of delete a {@link DistributionSetTag}.
@@ -38,8 +39,8 @@ public class DistributionSetTagDeletedEvent extends RemoteIdEvent implements Ent
* the origin application id * the origin application id
*/ */
public DistributionSetTagDeletedEvent(final String tenant, final Long entityId, final String entityClass, public DistributionSetTagDeletedEvent(final String tenant, final Long entityId,
final String applicationId) { final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId); super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/** /**
* *
@@ -38,8 +39,8 @@ public class DistributionSetTypeDeletedEvent extends RemoteIdEvent implements En
* @param applicationId * @param applicationId
* the origin application id * the origin application id
*/ */
public DistributionSetTypeDeletedEvent(final String tenant, final Long entityId, final String entityClass, public DistributionSetTypeDeletedEvent(final String tenant, final Long entityId,
final String applicationId) { final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId); super(entityId, tenant, entityClass, applicationId);
} }

View File

@@ -8,6 +8,10 @@
*/ */
package org.eclipse.hawkbit.repository.event.remote; package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
import java.util.Arrays;
/** /**
* An base definition class for an event which contains an id. * An base definition class for an event which contains an id.
* *
@@ -20,6 +24,8 @@ public class RemoteIdEvent extends RemoteTenantAwareEvent {
private String entityClass; private String entityClass;
private String interfaceClass;
/** /**
* Default constructor. * Default constructor.
*/ */
@@ -39,13 +45,21 @@ public class RemoteIdEvent extends RemoteTenantAwareEvent {
* @param applicationId * @param applicationId
* the origin application id * the origin application id
*/ */
protected RemoteIdEvent(final Long entityId, final String tenant, final String entityClass, protected RemoteIdEvent(final Long entityId, final String tenant,
final String applicationId) { final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, applicationId); super(entityId, tenant, applicationId);
this.entityClass = entityClass; this.entityClass = entityClass.getName();
this.interfaceClass = entityClass.isInterface() ? entityClass.getName()
: getInterfaceEntity(entityClass).getName();
this.entityId = entityId; 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 the entityClass * @return the entityClass
*/ */
@@ -57,4 +71,7 @@ public class RemoteIdEvent extends RemoteTenantAwareEvent {
return entityId; return entityId;
} }
public String getInterfaceClass() {
return interfaceClass;
}
} }

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/** /**
* *
@@ -38,8 +39,8 @@ public class RolloutDeletedEvent extends RemoteIdEvent implements EntityDeletedE
* @param applicationId * @param applicationId
* the origin application id * the origin application id
*/ */
public RolloutDeletedEvent(final String tenant, final Long entityId, final String entityClass, public RolloutDeletedEvent(final String tenant, final Long entityId,
final String applicationId) { final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId); super(entityId, tenant, entityClass, applicationId);
} }

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.RolloutGroup; import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/** /**
* *
@@ -38,8 +39,8 @@ public class RolloutGroupDeletedEvent extends RemoteIdEvent implements EntityDel
* @param applicationId * @param applicationId
* the origin application id * the origin application id
*/ */
public RolloutGroupDeletedEvent(final String tenant, final Long entityId, final String entityClass, public RolloutGroupDeletedEvent(final String tenant, final Long entityId,
final String applicationId) { final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId); super(entityId, tenant, entityClass, applicationId);
} }

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/** /**
* *
@@ -38,8 +39,8 @@ public class SoftwareModuleDeletedEvent extends RemoteIdEvent implements EntityD
* @param applicationId * @param applicationId
* the origin application id * the origin application id
*/ */
public SoftwareModuleDeletedEvent(final String tenant, final Long entityId, final String entityClass, public SoftwareModuleDeletedEvent(final String tenant, final Long entityId,
final String applicationId) { final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId); super(entityId, tenant, entityClass, applicationId);
} }

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/** /**
* *
@@ -38,8 +39,8 @@ public class SoftwareModuleTypeDeletedEvent extends RemoteIdEvent implements Ent
* @param applicationId * @param applicationId
* the origin application id * the origin application id
*/ */
public SoftwareModuleTypeDeletedEvent(final String tenant, final Long entityId, final String entityClass, public SoftwareModuleTypeDeletedEvent(final String tenant, final Long entityId,
final String applicationId) { final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId); super(entityId, tenant, entityClass, applicationId);
} }

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.repository.event.remote; package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/** /**
* Defines the remote event of triggering attribute updates of a {@link Target}. * Defines the remote event of triggering attribute updates of a {@link Target}.
@@ -42,7 +43,8 @@ public class TargetAttributesRequestedEvent extends RemoteIdEvent {
* the origin application id * the origin application id
*/ */
public TargetAttributesRequestedEvent(final String tenant, final Long entityId, final String controllerId, public TargetAttributesRequestedEvent(final String tenant, final Long entityId, final String controllerId,
final String targetAddress, final String entityClass, final String applicationId) { final String targetAddress, final Class<? extends TenantAwareBaseEntity> entityClass,
final String applicationId) {
super(entityId, tenant, entityClass, applicationId); super(entityId, tenant, entityClass, applicationId);
this.controllerId = controllerId; this.controllerId = controllerId;
this.targetAddress = targetAddress; this.targetAddress = targetAddress;

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/** /**
* *
@@ -44,7 +45,8 @@ public class TargetDeletedEvent extends RemoteIdEvent implements EntityDeletedEv
* the origin application id * the origin application id
*/ */
public TargetDeletedEvent(final String tenant, final Long entityId, final String controllerId, public TargetDeletedEvent(final String tenant, final Long entityId, final String controllerId,
final String targetAddress, final String entityClass, final String applicationId) { final String targetAddress, final Class<? extends TenantAwareBaseEntity> entityClass,
final String applicationId) {
super(entityId, tenant, entityClass, applicationId); super(entityId, tenant, entityClass, applicationId);
this.controllerId = controllerId; this.controllerId = controllerId;
this.targetAddress = targetAddress; this.targetAddress = targetAddress;

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/** /**
* *
@@ -37,8 +38,8 @@ public class TargetFilterQueryDeletedEvent extends RemoteIdEvent implements Enti
* @param applicationId * @param applicationId
* the origin application id * the origin application id
*/ */
public TargetFilterQueryDeletedEvent(final String tenant, final Long entityId, final String entityClass, public TargetFilterQueryDeletedEvent(final String tenant, final Long entityId,
final String applicationId) { final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId); super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.repository.model.TargetTag;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/** /**
* Defines the remote event of delete a {@link TargetTag}. * Defines the remote event of delete a {@link TargetTag}.
@@ -38,8 +39,8 @@ public class TargetTagDeletedEvent extends RemoteIdEvent implements EntityDelete
* @param applicationId * @param applicationId
* the origin application id * the origin application id
*/ */
public TargetTagDeletedEvent(final String tenant, final Long entityId, final String entityClass, public TargetTagDeletedEvent(final String tenant, final Long entityId,
final String applicationId) { final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId); super(entityId, tenant, entityClass, applicationId);
} }
} }

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.TargetType; import org.eclipse.hawkbit.repository.model.TargetType;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/** /**
* *
@@ -38,8 +39,8 @@ public class TargetTypeDeletedEvent extends RemoteIdEvent implements EntityDelet
* @param applicationId * @param applicationId
* the origin application id * the origin application id
*/ */
public TargetTypeDeletedEvent(final String tenant, final Long entityId, final String entityClass, public TargetTypeDeletedEvent(final String tenant, final Long entityId,
final String applicationId) { final Class<? extends TenantAwareBaseEntity> entityClass, final String applicationId) {
super(entityId, tenant, entityClass, applicationId); super(entityId, tenant, entityClass, applicationId);
} }

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.repository.event.remote; package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent; import org.eclipse.hawkbit.repository.event.entity.EntityDeletedEvent;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
/** /**
* *
@@ -43,7 +44,8 @@ public class TenantConfigurationDeletedEvent extends RemoteIdEvent implements En
* the origin application id * the origin application id
*/ */
public TenantConfigurationDeletedEvent(final String tenant, final Long entityId, final String configKey, public TenantConfigurationDeletedEvent(final String tenant, final Long entityId, final String configKey,
final String configValue, final String entityClass, final String applicationId) { final String configValue, final Class<? extends TenantAwareBaseEntity> entityClass,
final String applicationId) {
super(entityId, tenant, entityClass, applicationId); super(entityId, tenant, entityClass, applicationId);
this.configKey = configKey; this.configKey = configKey;
this.configValue = configValue; this.configValue = configValue;

View File

@@ -49,7 +49,7 @@ public class RemoteEntityEvent<E extends TenantAwareBaseEntity> extends RemoteId
* the origin application id * the origin application id
*/ */
protected RemoteEntityEvent(final E baseEntity, final String applicationId) { protected RemoteEntityEvent(final E baseEntity, final String applicationId) {
super(baseEntity.getId(), baseEntity.getTenant(), baseEntity.getClass().getName(), applicationId); super(baseEntity.getId(), baseEntity.getTenant(), baseEntity.getClass(), applicationId);
this.entity = baseEntity; this.entity = baseEntity;
} }

View File

@@ -76,7 +76,7 @@ public class RepositoryManagementMethodPreAuthorizeAnnotatedTest {
} }
final PreAuthorize annotation = method.getAnnotation(PreAuthorize.class); final PreAuthorize annotation = method.getAnnotation(PreAuthorize.class);
assertThat(annotation).as("The public method " + method.getName() + " in class " + clazz.getName() assertThat(annotation).as("The public method " + method.getName() + " in class " + clazz.getName()
+ " is not annoated with @PreAuthorize, security leak?").isNotNull(); + " is not annotated with @PreAuthorize, security leak?").isNotNull();
} }
} }

View File

@@ -682,7 +682,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
eventPublisherHolder.getEventPublisher() eventPublisherHolder.getEventPublisher()
.publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(), .publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(),
target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null, target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null,
JpaTarget.class.getName(), eventPublisherHolder.getApplicationId())); JpaTarget.class, eventPublisherHolder.getApplicationId()));
} }
private void handleErrorOnAction(final JpaAction mergedAction, final JpaTarget mergedTarget) { private void handleErrorOnAction(final JpaAction mergedAction, final JpaTarget mergedTarget) {

View File

@@ -273,7 +273,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
afterCommit.afterCommit(() -> distributionSetIDs.forEach(dsId -> eventPublisherHolder.getEventPublisher() afterCommit.afterCommit(() -> distributionSetIDs.forEach(dsId -> eventPublisherHolder.getEventPublisher()
.publishEvent(new DistributionSetDeletedEvent(tenantAware.getCurrentTenant(), dsId, .publishEvent(new DistributionSetDeletedEvent(tenantAware.getCurrentTenant(), dsId,
JpaDistributionSet.class.getName(), eventPublisherHolder.getApplicationId())))); JpaDistributionSet.class, eventPublisherHolder.getApplicationId()))));
} }
@Override @Override

View File

@@ -354,7 +354,7 @@ public class JpaRolloutExecutor implements RolloutExecutor {
afterCommit.afterCommit(() -> groupIds.forEach(rolloutGroupId -> eventPublisherHolder.getEventPublisher() afterCommit.afterCommit(() -> groupIds.forEach(rolloutGroupId -> eventPublisherHolder.getEventPublisher()
.publishEvent(new RolloutGroupDeletedEvent(tenantAware.getCurrentTenant(), rolloutGroupId, .publishEvent(new RolloutGroupDeletedEvent(tenantAware.getCurrentTenant(), rolloutGroupId,
JpaRolloutGroup.class.getName(), eventPublisherHolder.getApplicationId())))); JpaRolloutGroup.class, eventPublisherHolder.getApplicationId()))));
} }
private boolean isRolloutComplete(final JpaRollout rollout) { private boolean isRolloutComplete(final JpaRollout rollout) {

View File

@@ -352,7 +352,7 @@ public class JpaTargetManagement implements TargetManagement {
.publishEvent(new TargetDeletedEvent(tenantAware.getCurrentTenant(), target.getId(), .publishEvent(new TargetDeletedEvent(tenantAware.getCurrentTenant(), target.getId(),
target.getControllerId(), target.getControllerId(),
Optional.ofNullable(target.getAddress()).map(URI::toString).orElse(null), Optional.ofNullable(target.getAddress()).map(URI::toString).orElse(null),
JpaTarget.class.getName(), eventPublisherHolder.getApplicationId())))); JpaTarget.class, eventPublisherHolder.getApplicationId()))));
} }
@Override @Override
@@ -836,7 +836,7 @@ public class JpaTargetManagement implements TargetManagement {
eventPublisherHolder.getEventPublisher() eventPublisherHolder.getEventPublisher()
.publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(), .publishEvent(new TargetAttributesRequestedEvent(tenantAware.getCurrentTenant(), target.getId(),
target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null, target.getControllerId(), target.getAddress() != null ? target.getAddress().toString() : null,
JpaTarget.class.getName(), eventPublisherHolder.getApplicationId())); JpaTarget.class, eventPublisherHolder.getApplicationId()));
} }
@Override @Override

View File

@@ -341,14 +341,14 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
new DistributionSetUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId(), complete)); new DistributionSetUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId(), complete));
if (isSoftDeleted(descriptorEvent)) { if (isSoftDeleted(descriptorEvent)) {
publishEventWithEventPublisher(new DistributionSetDeletedEvent(getTenant(), getId(), getClass().getName(), publishEventWithEventPublisher(new DistributionSetDeletedEvent(getTenant(), getId(), getClass(),
EventPublisherHolder.getInstance().getApplicationId())); EventPublisherHolder.getInstance().getApplicationId()));
} }
} }
@Override @Override
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
publishEventWithEventPublisher(new DistributionSetDeletedEvent(getTenant(), getId(), getClass().getName(), publishEventWithEventPublisher(new DistributionSetDeletedEvent(getTenant(), getId(), getClass(),
EventPublisherHolder.getInstance().getApplicationId())); EventPublisherHolder.getInstance().getApplicationId()));
} }

View File

@@ -89,7 +89,7 @@ public class JpaDistributionSetTag extends JpaTag implements DistributionSetTag,
@Override @Override
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTagDeletedEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTagDeletedEvent(
getTenant(), getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }

View File

@@ -260,6 +260,6 @@ public class JpaDistributionSetType extends AbstractJpaNamedEntity implements Di
@Override @Override
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTypeDeletedEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new DistributionSetTypeDeletedEvent(
getTenant(), getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }

View File

@@ -271,7 +271,7 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event
if (isSoftDeleted(descriptorEvent)) { if (isSoftDeleted(descriptorEvent)) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutDeletedEvent(getTenant(), EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutDeletedEvent(getTenant(),
getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }
@@ -288,7 +288,7 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event
@Override @Override
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutDeletedEvent(getTenant(), EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutDeletedEvent(getTenant(),
getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
@Override @Override

View File

@@ -296,6 +296,6 @@ public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGr
@Override @Override
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutGroupDeletedEvent(getTenant(), EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new RolloutGroupDeletedEvent(getTenant(),
getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }

View File

@@ -251,7 +251,7 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
if (isSoftDeleted(descriptorEvent)) { if (isSoftDeleted(descriptorEvent)) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleDeletedEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleDeletedEvent(
getTenant(), getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }
@@ -268,7 +268,7 @@ public class JpaSoftwareModule extends AbstractJpaNamedVersionedEntity implement
@Override @Override
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleDeletedEvent(getTenant(), EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleDeletedEvent(getTenant(),
getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }

View File

@@ -159,6 +159,6 @@ public class JpaSoftwareModuleType extends AbstractJpaNamedEntity implements Sof
@Override @Override
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleTypeDeletedEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new SoftwareModuleTypeDeletedEvent(
getTenant(), getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }

View File

@@ -505,6 +505,6 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Target, EventAw
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
EventPublisherHolder.getInstance().getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TargetDeletedEvent(getTenant(), getId(), getControllerId(), address, .publishEvent(new TargetDeletedEvent(getTenant(), getId(), getControllerId(), address,
getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }

View File

@@ -175,6 +175,6 @@ public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity
@Override @Override
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetFilterQueryDeletedEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetFilterQueryDeletedEvent(
getTenant(), getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }

View File

@@ -85,7 +85,7 @@ public class JpaTargetTag extends JpaTag implements TargetTag, EventAwareEntity
@Override @Override
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTagDeletedEvent(getTenant(), EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTagDeletedEvent(getTenant(),
getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }

View File

@@ -151,6 +151,6 @@ public class JpaTargetType extends AbstractJpaNamedEntity implements TargetType,
@Override @Override
public void fireDeleteEvent(DescriptorEvent descriptorEvent) { public void fireDeleteEvent(DescriptorEvent descriptorEvent) {
EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTypeDeletedEvent( EventPublisherHolder.getInstance().getEventPublisher().publishEvent(new TargetTypeDeletedEvent(
getTenant(), getId(), getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); getTenant(), getId(), getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }

View File

@@ -101,6 +101,6 @@ public class JpaTenantConfiguration extends AbstractJpaTenantAwareBaseEntity
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) { public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
EventPublisherHolder.getInstance().getEventPublisher() EventPublisherHolder.getInstance().getEventPublisher()
.publishEvent(new TenantConfigurationDeletedEvent(getTenant(), getId(), getKey(), getValue(), .publishEvent(new TenantConfigurationDeletedEvent(getTenant(), getId(), getKey(), getValue(),
getClass().getName(), EventPublisherHolder.getInstance().getApplicationId())); getClass(), EventPublisherHolder.getInstance().getApplicationId()));
} }
} }

View File

@@ -18,6 +18,8 @@ import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Story; import io.qameta.allure.Story;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@@ -32,7 +34,7 @@ public class RemoteIdEventTest extends AbstractRemoteEventTest {
private static String TENANT = "tenant"; private static String TENANT = "tenant";
private static String ENTIY_CLASS = "EntityClass"; private static Class<? extends TenantAwareBaseEntity> ENTITY_CLASS = JpaAction.class;
private static String NODE = "Node"; private static String NODE = "Node";
@@ -56,7 +58,7 @@ public class RemoteIdEventTest extends AbstractRemoteEventTest {
@Description("Verifies that the target id is correct reloaded") @Description("Verifies that the target id is correct reloaded")
public void testTargetDeletedEvent() { public void testTargetDeletedEvent() {
final TargetDeletedEvent deletedEvent = new TargetDeletedEvent(TENANT, ENTITY_ID, CONTROLLER_ID, ADDRESS, final TargetDeletedEvent deletedEvent = new TargetDeletedEvent(TENANT, ENTITY_ID, CONTROLLER_ID, ADDRESS,
ENTIY_CLASS, NODE); ENTITY_CLASS, NODE);
assertEntity(deletedEvent); assertEntity(deletedEvent);
} }
@@ -85,7 +87,7 @@ public class RemoteIdEventTest extends AbstractRemoteEventTest {
.orElseThrow(() -> new IllegalArgumentException("Given event is not RemoteIdEvent compatible")); .orElseThrow(() -> new IllegalArgumentException("Given event is not RemoteIdEvent compatible"));
try { try {
final RemoteIdEvent event = (RemoteIdEvent) constructor.newInstance(TENANT, ENTITY_ID, ENTIY_CLASS, NODE); final RemoteIdEvent event = (RemoteIdEvent) constructor.newInstance(TENANT, ENTITY_ID, ENTITY_CLASS, NODE);
assertEntity(event); assertEntity(event);
} catch (final ReflectiveOperationException e) { } catch (final ReflectiveOperationException e) {
fail("Exception should not happen " + e.getMessage()); fail("Exception should not happen " + e.getMessage());

View File

@@ -43,7 +43,7 @@ public class ActionChangedEvent extends RemoteIdEvent implements EntityUpdatedEv
*/ */
public ActionChangedEvent(final String tenant, final Long targetId, final Long entityId) { public ActionChangedEvent(final String tenant, final Long targetId, final Long entityId) {
// application id is not needed, because we compose the event ourselves // application id is not needed, because we compose the event ourselves
super(entityId, tenant, Action.class.getName(), null); super(entityId, tenant, Action.class, null);
this.targetId = targetId; this.targetId = targetId;
} }

View File

@@ -37,6 +37,6 @@ public class RolloutChangedEvent extends RemoteIdEvent implements EntityUpdatedE
*/ */
public RolloutChangedEvent(final String tenant, final Long entityId) { public RolloutChangedEvent(final String tenant, final Long entityId) {
// application id is not needed, because we compose the event ourselves // application id is not needed, because we compose the event ourselves
super(entityId, tenant, Rollout.class.getName(), null); super(entityId, tenant, Rollout.class, null);
} }
} }

View File

@@ -43,7 +43,7 @@ public class RolloutGroupChangedEvent extends RemoteIdEvent implements EntityUpd
*/ */
public RolloutGroupChangedEvent(final String tenant, final Long rolloutId, final Long entityId) { public RolloutGroupChangedEvent(final String tenant, final Long rolloutId, final Long entityId) {
// application id is not needed, because we compose the event ourselves // application id is not needed, because we compose the event ourselves
super(entityId, tenant, RolloutGroup.class.getName(), null); super(entityId, tenant, RolloutGroup.class, null);
this.rolloutId = rolloutId; this.rolloutId = rolloutId;
} }