Merge branch 'feature_enable_push_in_deployment_view' of
https://github.com/bsinno/hawkbit/ into feature_enable_push_in_deployment_view Conflicts: hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java
This commit is contained in:
@@ -28,7 +28,6 @@ import org.eclipse.hawkbit.repository.DistributionSetMetadataFields;
|
|||||||
import org.eclipse.hawkbit.repository.DistributionSetTypeFields;
|
import org.eclipse.hawkbit.repository.DistributionSetTypeFields;
|
||||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||||
import org.eclipse.hawkbit.repository.TagManagement;
|
import org.eclipse.hawkbit.repository.TagManagement;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
|
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagAssigmentResultEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetTagAssigmentResultEvent;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityLockedException;
|
import org.eclipse.hawkbit.repository.exception.EntityLockedException;
|
||||||
@@ -55,7 +54,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
|||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageImpl;
|
import org.springframework.data.domain.PageImpl;
|
||||||
@@ -104,9 +102,6 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AfterTransactionCommitExecutor afterCommit;
|
private AfterTransactionCommitExecutor afterCommit;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TenantAware tenantAware;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DistributionSet findDistributionSetByIdWithDetails(final Long distid) {
|
public DistributionSet findDistributionSetByIdWithDetails(final Long distid) {
|
||||||
return distributionSetRepository.findOne(DistributionSetSpecification.byId(distid));
|
return distributionSetRepository.findOne(DistributionSetSpecification.byId(distid));
|
||||||
@@ -198,10 +193,6 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
// handle the empty list
|
// handle the empty list
|
||||||
distributionSetRepository.deleteByIdIn(toHardDelete);
|
distributionSetRepository.deleteByIdIn(toHardDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
afterCommit.afterCommit(
|
|
||||||
() -> eventBus.post(new DistributionDeletedEvent(tenantAware.getCurrentTenant(), distributionSetIDs)));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -527,14 +518,12 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
|
||||||
@Modifying
|
@Modifying
|
||||||
public void deleteDistributionSetMetadata(final DistributionSet distributionSet, final String key) {
|
public void deleteDistributionSetMetadata(final DistributionSet distributionSet, final String key) {
|
||||||
entityManager.merge((JpaDistributionSet) distributionSet).setLastModifiedAt(0L);
|
|
||||||
distributionSetMetadataRepository.delete(new DsMetadataCompositeKey(distributionSet, key));
|
distributionSetMetadataRepository.delete(new DsMetadataCompositeKey(distributionSet, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(final Long distributionSetId,
|
public Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(final Long distributionSetId,
|
||||||
final Pageable pageable) {
|
final Pageable pageable) {
|
||||||
|
|
||||||
return convertMdPage(distributionSetMetadataRepository
|
return convertMdPage(distributionSetMetadataRepository
|
||||||
.findAll((Specification<JpaDistributionSetMetadata>) (root, query, cb) -> cb.equal(
|
.findAll((Specification<JpaDistributionSetMetadata>) (root, query, cb) -> cb.equal(
|
||||||
root.get(JpaDistributionSetMetadata_.distributionSet).get(JpaDistributionSet_.id),
|
root.get(JpaDistributionSetMetadata_.distributionSet).get(JpaDistributionSet_.id),
|
||||||
@@ -544,7 +533,6 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(final Long distributionSetId) {
|
public List<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(final Long distributionSetId) {
|
||||||
|
|
||||||
return new ArrayList<DistributionSetMetadata>(distributionSetMetadataRepository
|
return new ArrayList<DistributionSetMetadata>(distributionSetMetadataRepository
|
||||||
.findAll((Specification<JpaDistributionSetMetadata>) (root, query, cb) -> cb.equal(
|
.findAll((Specification<JpaDistributionSetMetadata>) (root, query, cb) -> cb.equal(
|
||||||
root.get(JpaDistributionSetMetadata_.distributionSet).get(JpaDistributionSet_.id),
|
root.get(JpaDistributionSetMetadata_.distributionSet).get(JpaDistributionSet_.id),
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import javax.persistence.criteria.Root;
|
|||||||
|
|
||||||
import org.eclipse.hawkbit.repository.TargetFields;
|
import org.eclipse.hawkbit.repository.TargetFields;
|
||||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetDeletedEvent;
|
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagAssigmentResultEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.TargetTagAssigmentResultEvent;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||||
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
||||||
@@ -49,7 +48,6 @@ import org.eclipse.hawkbit.repository.model.TargetIdName;
|
|||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -98,10 +96,6 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AfterTransactionCommitExecutor afterCommit;
|
private AfterTransactionCommitExecutor afterCommit;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TenantAware tenantAware;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Target findTargetByControllerID(final String controllerId) {
|
public Target findTargetByControllerID(final String controllerId) {
|
||||||
@@ -208,14 +202,12 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
// hibernate session.
|
// hibernate session.
|
||||||
final List<Long> targetsForCurrentTenant = targetRepository.findAll(Lists.newArrayList(targetIDs)).stream()
|
final List<Long> targetsForCurrentTenant = targetRepository.findAll(Lists.newArrayList(targetIDs)).stream()
|
||||||
.map(Target::getId).collect(Collectors.toList());
|
.map(Target::getId).collect(Collectors.toList());
|
||||||
if (!targetsForCurrentTenant.isEmpty()) {
|
if (!targetsForCurrentTenant.isEmpty()) {
|
||||||
targetInfoRepository.deleteByTargetIdIn(targetsForCurrentTenant);
|
targetInfoRepository.deleteByTargetIdIn(targetsForCurrentTenant);
|
||||||
targetRepository.deleteByIdIn(targetsForCurrentTenant);
|
targetRepository.deleteByIdIn(targetsForCurrentTenant);
|
||||||
targetsForCurrentTenant.forEach(targetId -> notifyTargetDeleted(
|
}
|
||||||
tenantAware.getCurrentTenant(), targetId));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<Target> findTargetByAssignedDistributionSet(final Long distributionSetID, final Pageable pageReq) {
|
public Page<Target> findTargetByAssignedDistributionSet(final Long distributionSetID, final Pageable pageReq) {
|
||||||
return targetRepository.findByAssignedDistributionSetId(pageReq, distributionSetID);
|
return targetRepository.findByAssignedDistributionSetId(pageReq, distributionSetID);
|
||||||
@@ -659,9 +651,5 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
}
|
}
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void notifyTargetDeleted(final String tenant, final Long targetId) {
|
|
||||||
afterCommit.afterCommit(() -> eventBus.post(new TargetDeletedEvent(tenant, targetId)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.model;
|
package org.eclipse.hawkbit.repository.jpa.model;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.model.helper.AfterTransactionCommitExecutorHolder;
|
||||||
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
||||||
import org.eclipse.persistence.descriptors.DescriptorEventAdapter;
|
import org.eclipse.persistence.descriptors.DescriptorEventAdapter;
|
||||||
|
|
||||||
@@ -19,21 +20,34 @@ public class EntityPropertyChangeListener extends DescriptorEventAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postInsert(final DescriptorEvent event) {
|
public void postInsert(final DescriptorEvent event) {
|
||||||
|
|
||||||
final Object object = event.getObject();
|
final Object object = event.getObject();
|
||||||
if (object instanceof EventAwareEntity) {
|
if (isEventAwareEntity(object)) {
|
||||||
((EventAwareEntity) object).fireCreateEvent(object,event);
|
doNotifiy(() -> ((EventAwareEntity) object).fireCreateEvent(event));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postUpdate(final DescriptorEvent event) {
|
public void postUpdate(final DescriptorEvent event) {
|
||||||
|
|
||||||
final Object object = event.getObject();
|
final Object object = event.getObject();
|
||||||
if (object instanceof EventAwareEntity) {
|
if (isEventAwareEntity(object)) {
|
||||||
((EventAwareEntity) object).fireUpdateEvent(object,event);
|
doNotifiy(() -> ((EventAwareEntity) object).fireUpdateEvent(event));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postDelete(final DescriptorEvent event) {
|
||||||
|
final Object object = event.getObject();
|
||||||
|
if (isEventAwareEntity(object)) {
|
||||||
|
doNotifiy(() -> ((EventAwareEntity) object).fireDeleteEvent(event));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isEventAwareEntity(final Object object) {
|
||||||
|
return object instanceof EventAwareEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doNotifiy(final Runnable runnable) {
|
||||||
|
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||||
*
|
*
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.repository.jpa.model;
|
package org.eclipse.hawkbit.repository.jpa.model;
|
||||||
|
|
||||||
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
import org.eclipse.persistence.descriptors.DescriptorEvent;
|
||||||
|
|
||||||
public interface EventAwareEntity<T> {
|
public interface EventAwareEntity {
|
||||||
|
|
||||||
public void fireCreateEvent(T t,DescriptorEvent descriptorEvent);
|
void fireCreateEvent(DescriptorEvent descriptorEvent);
|
||||||
|
|
||||||
public void fireUpdateEvent(T t,DescriptorEvent descriptorEvent);
|
void fireUpdateEvent(DescriptorEvent descriptorEvent);
|
||||||
|
|
||||||
public void fireDeleteEvent(T t,DescriptorEvent descriptorEvent);
|
void fireDeleteEvent(DescriptorEvent descriptorEvent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import javax.persistence.Table;
|
|||||||
|
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.ActionCreatedEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.ActionCreatedEvent;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.ActionPropertyChangeEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.ActionPropertyChangeEvent;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.AfterTransactionCommitExecutorHolder;
|
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.EntityPropertyChangeHelper;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.EntityPropertyChangeHelper;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.Action;
|
import org.eclipse.hawkbit.repository.model.Action;
|
||||||
@@ -55,7 +54,7 @@ import org.eclipse.persistence.descriptors.DescriptorEvent;
|
|||||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||||
// sub entities
|
// sub entities
|
||||||
@SuppressWarnings("squid:S2160")
|
@SuppressWarnings("squid:S2160")
|
||||||
public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Action, EventAwareEntity<JpaAction> {
|
public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Action, EventAwareEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@@ -178,23 +177,19 @@ public class JpaAction extends AbstractJpaTenantAwareBaseEntity implements Actio
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireCreateEvent(final JpaAction jpaAction, final DescriptorEvent descriptorEvent) {
|
public void fireCreateEvent(final DescriptorEvent descriptorEvent) {
|
||||||
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit()
|
EventBusHolder.getInstance().getEventBus().post(new ActionCreatedEvent(this));
|
||||||
.afterCommit(() -> EventBusHolder.getInstance().getEventBus().post(new ActionCreatedEvent(jpaAction)));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireUpdateEvent(final JpaAction jpaAction, final DescriptorEvent descriptorEvent) {
|
public void fireUpdateEvent(final DescriptorEvent descriptorEvent) {
|
||||||
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(
|
EventBusHolder.getInstance().getEventBus().post(new ActionPropertyChangeEvent(this,
|
||||||
() -> EventBusHolder.getInstance().getEventBus().post(new ActionPropertyChangeEvent(jpaAction,
|
EntityPropertyChangeHelper.getChangeSet(Action.class, descriptorEvent)));
|
||||||
EntityPropertyChangeHelper.getChangeSet(Action.class, descriptorEvent))));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireDeleteEvent(final JpaAction jpaAction, final DescriptorEvent descriptorEvent) {
|
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
|
||||||
|
// there is no action deletion
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -33,11 +34,13 @@ import javax.persistence.OneToMany;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.UniqueConstraint;
|
import javax.persistence.UniqueConstraint;
|
||||||
|
|
||||||
|
import org.eclipse.hawkbit.repository.eventbus.event.AbstractPropertyChangeEvent;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.DistributionCreatedEvent;
|
||||||
|
import org.eclipse.hawkbit.repository.eventbus.event.DistributionDeletedEvent;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.DistributionSetUpdateEvent;
|
||||||
import org.eclipse.hawkbit.repository.exception.DistributionSetTypeUndefinedException;
|
import org.eclipse.hawkbit.repository.exception.DistributionSetTypeUndefinedException;
|
||||||
import org.eclipse.hawkbit.repository.exception.UnsupportedSoftwareModuleForThisDistributionSetException;
|
import org.eclipse.hawkbit.repository.exception.UnsupportedSoftwareModuleForThisDistributionSetException;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.AfterTransactionCommitExecutorHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.EntityPropertyChangeHelper;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.Action;
|
import org.eclipse.hawkbit.repository.model.Action;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||||
@@ -66,11 +69,12 @@ import org.eclipse.persistence.descriptors.DescriptorEvent;
|
|||||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||||
// sub entities
|
// sub entities
|
||||||
@SuppressWarnings("squid:S2160")
|
@SuppressWarnings("squid:S2160")
|
||||||
public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity
|
public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implements DistributionSet, EventAwareEntity {
|
||||||
implements DistributionSet, EventAwareEntity<JpaDistributionSet> {
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static final String COMPLETE = "complete";
|
private static final String COMPLETE_PROPERTY = "complete";
|
||||||
|
|
||||||
|
private static final String DELETED_PROPERTY = "deleted";
|
||||||
|
|
||||||
@Column(name = "required_migration_step")
|
@Column(name = "required_migration_step")
|
||||||
private boolean requiredMigrationStep;
|
private boolean requiredMigrationStep;
|
||||||
@@ -288,22 +292,29 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireCreateEvent(final JpaDistributionSet jpaDistributionSet, final DescriptorEvent descriptorEvent) {
|
public void fireCreateEvent(final DescriptorEvent descriptorEvent) {
|
||||||
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(() -> EventBusHolder
|
EventBusHolder.getInstance().getEventBus().post(new DistributionCreatedEvent(this));
|
||||||
.getInstance().getEventBus().post(new DistributionCreatedEvent(jpaDistributionSet)));
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fireUpdateEvent(final DescriptorEvent descriptorEvent) {
|
||||||
|
|
||||||
|
final Map<String, AbstractPropertyChangeEvent<JpaDistributionSet>.Values> changeSet = EntityPropertyChangeHelper
|
||||||
|
.getChangeSet(JpaDistributionSet.class, descriptorEvent);
|
||||||
|
EventBusHolder.getInstance().getEventBus().post(new DistributionSetUpdateEvent(this));
|
||||||
|
|
||||||
|
if (changeSet.containsKey(DELETED_PROPERTY)) {
|
||||||
|
final Boolean newDeleted = (Boolean) changeSet.get(DELETED_PROPERTY).getNewValue();
|
||||||
|
if (newDeleted) {
|
||||||
|
EventBusHolder.getInstance().getEventBus().post(new DistributionDeletedEvent(getTenant(), getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireUpdateEvent(final JpaDistributionSet jpaDistributionSet, final DescriptorEvent descriptorEvent) {
|
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
|
||||||
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(() -> EventBusHolder
|
EventBusHolder.getInstance().getEventBus().post(new DistributionDeletedEvent(getTenant(), getId()));
|
||||||
.getInstance().getEventBus().post(new DistributionSetUpdateEvent(jpaDistributionSet)));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fireDeleteEvent(final JpaDistributionSet jpaDistributionSet, final DescriptorEvent descriptorEvent) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import javax.persistence.UniqueConstraint;
|
|||||||
import org.eclipse.hawkbit.repository.eventbus.event.RolloutPropertyChangeEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.RolloutPropertyChangeEvent;
|
||||||
import org.eclipse.hawkbit.repository.jpa.cache.CacheField;
|
import org.eclipse.hawkbit.repository.jpa.cache.CacheField;
|
||||||
import org.eclipse.hawkbit.repository.jpa.cache.CacheKeys;
|
import org.eclipse.hawkbit.repository.jpa.cache.CacheKeys;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.AfterTransactionCommitExecutorHolder;
|
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.EntityPropertyChangeHelper;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.EntityPropertyChangeHelper;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||||
@@ -49,7 +48,7 @@ import org.eclipse.persistence.descriptors.DescriptorEvent;
|
|||||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||||
// sub entities
|
// sub entities
|
||||||
@SuppressWarnings("squid:S2160")
|
@SuppressWarnings("squid:S2160")
|
||||||
public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, EventAwareEntity<JpaRollout> {
|
public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, EventAwareEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -203,21 +202,20 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, Event
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireCreateEvent(final JpaRollout jpaRollout, final DescriptorEvent descriptorEvent) {
|
public void fireCreateEvent(final DescriptorEvent descriptorEvent) {
|
||||||
|
// there is no rollout creation event
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fireUpdateEvent(final DescriptorEvent descriptorEvent) {
|
||||||
|
EventBusHolder.getInstance().getEventBus().post(new RolloutPropertyChangeEvent(this,
|
||||||
|
EntityPropertyChangeHelper.getChangeSet(Rollout.class, descriptorEvent)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireUpdateEvent(final JpaRollout jpaRollout, final DescriptorEvent descriptorEvent) {
|
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
|
||||||
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(
|
// there is no rollout deletion event
|
||||||
() -> EventBusHolder.getInstance().getEventBus().post(new RolloutPropertyChangeEvent(jpaRollout,
|
|
||||||
EntityPropertyChangeHelper.getChangeSet(Rollout.class, descriptorEvent))));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fireDeleteEvent(final JpaRollout jpaRollout, final DescriptorEvent descriptorEvent) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import javax.persistence.Transient;
|
|||||||
import javax.persistence.UniqueConstraint;
|
import javax.persistence.UniqueConstraint;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.RolloutGroupPropertyChangeEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.RolloutGroupPropertyChangeEvent;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.AfterTransactionCommitExecutorHolder;
|
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.EntityPropertyChangeHelper;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.EntityPropertyChangeHelper;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||||
@@ -45,7 +44,7 @@ import org.eclipse.persistence.descriptors.DescriptorEvent;
|
|||||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||||
// sub entities
|
// sub entities
|
||||||
@SuppressWarnings("squid:S2160")
|
@SuppressWarnings("squid:S2160")
|
||||||
public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGroup, EventAwareEntity<JpaRolloutGroup> {
|
public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGroup, EventAwareEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -242,21 +241,18 @@ public class JpaRolloutGroup extends AbstractJpaNamedEntity implements RolloutGr
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireCreateEvent(final JpaRolloutGroup jpaRolloutGroup, final DescriptorEvent descriptorEvent) {
|
public void fireCreateEvent(final DescriptorEvent descriptorEvent) {
|
||||||
|
// there is no RolloutGroup created event
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireUpdateEvent(final JpaRolloutGroup jpaRolloutGroup, final DescriptorEvent descriptorEvent) {
|
public void fireUpdateEvent(final DescriptorEvent descriptorEvent) {
|
||||||
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit()
|
EventBusHolder.getInstance().getEventBus().post(new RolloutGroupPropertyChangeEvent(this,
|
||||||
.afterCommit(() -> EventBusHolder.getInstance().getEventBus()
|
EntityPropertyChangeHelper.getChangeSet(RolloutGroup.class, descriptorEvent)));
|
||||||
.post(new RolloutGroupPropertyChangeEvent(jpaRolloutGroup,
|
|
||||||
EntityPropertyChangeHelper.getChangeSet(RolloutGroup.class, descriptorEvent))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireDeleteEvent(final JpaRolloutGroup jpaRolloutGroup, final DescriptorEvent descriptorEvent) {
|
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
|
||||||
|
// there is no RolloutGroup deleted event
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ import javax.validation.constraints.Size;
|
|||||||
|
|
||||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.TargetCreatedEvent;
|
||||||
|
import org.eclipse.hawkbit.repository.eventbus.event.TargetDeletedEvent;
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetUpdatedEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.TargetUpdatedEvent;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.AfterTransactionCommitExecutorHolder;
|
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.SecurityChecker;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.SecurityChecker;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.SecurityTokenGeneratorHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.SecurityTokenGeneratorHolder;
|
||||||
@@ -69,8 +69,7 @@ import org.springframework.data.domain.Persistable;
|
|||||||
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
// exception squid:S2160 - BaseEntity equals/hashcode is handling correctly for
|
||||||
// sub entities
|
// sub entities
|
||||||
@SuppressWarnings("squid:S2160")
|
@SuppressWarnings("squid:S2160")
|
||||||
public class JpaTarget extends AbstractJpaNamedEntity
|
public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Long>, Target, EventAwareEntity {
|
||||||
implements Persistable<Long>, Target, EventAwareEntity<JpaTarget> {
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Column(name = "controller_id", length = 64)
|
@Column(name = "controller_id", length = 64)
|
||||||
@@ -239,21 +238,17 @@ public class JpaTarget extends AbstractJpaNamedEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireCreateEvent(final JpaTarget jpaTarget, final DescriptorEvent descriptorEvent) {
|
public void fireCreateEvent(final DescriptorEvent descriptorEvent) {
|
||||||
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit()
|
EventBusHolder.getInstance().getEventBus().post(new TargetCreatedEvent(this));
|
||||||
.afterCommit(() -> EventBusHolder.getInstance().getEventBus().post(new TargetCreatedEvent(jpaTarget)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireUpdateEvent(final JpaTarget jpaTarget, final DescriptorEvent descriptorEvent) {
|
public void fireUpdateEvent(final DescriptorEvent descriptorEvent) {
|
||||||
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit()
|
EventBusHolder.getInstance().getEventBus().post(new TargetUpdatedEvent(this));
|
||||||
.afterCommit(() -> EventBusHolder.getInstance().getEventBus().post(new TargetUpdatedEvent(jpaTarget)));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireDeleteEvent(final JpaTarget jpaTarget, final DescriptorEvent descriptorEvent) {
|
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
|
||||||
|
EventBusHolder.getInstance().getEventBus().post(new TargetDeletedEvent(getTenant(), getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ import javax.persistence.Transient;
|
|||||||
|
|
||||||
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
|
import org.eclipse.hawkbit.repository.eventbus.event.TargetInfoUpdateEvent;
|
||||||
import org.eclipse.hawkbit.repository.exception.InvalidTargetAddressException;
|
import org.eclipse.hawkbit.repository.exception.InvalidTargetAddressException;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.AfterTransactionCommitExecutorHolder;
|
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.SystemSecurityContextHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.SystemSecurityContextHolder;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.TenantConfigurationManagementHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.TenantConfigurationManagementHolder;
|
||||||
@@ -70,7 +69,7 @@ import org.springframework.data.domain.Persistable;
|
|||||||
@Index(name = "sp_idx_target_info_02", columnList = "target_id,update_status") })
|
@Index(name = "sp_idx_target_info_02", columnList = "target_id,update_status") })
|
||||||
@Entity
|
@Entity
|
||||||
@EntityListeners(EntityPropertyChangeListener.class)
|
@EntityListeners(EntityPropertyChangeListener.class)
|
||||||
public class JpaTargetInfo implements Persistable<Long>, TargetInfo, EventAwareEntity<JpaTargetInfo> {
|
public class JpaTargetInfo implements Persistable<Long>, TargetInfo, EventAwareEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(TargetInfo.class);
|
private static final Logger LOG = LoggerFactory.getLogger(TargetInfo.class);
|
||||||
@@ -329,17 +328,17 @@ public class JpaTargetInfo implements Persistable<Long>, TargetInfo, EventAwareE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireCreateEvent(final JpaTargetInfo jpaTargetInfo, final DescriptorEvent descriptorEvent) {
|
public void fireCreateEvent(final DescriptorEvent descriptorEvent) {
|
||||||
// there is no target info created event
|
// there is no target info created event
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireUpdateEvent(final JpaTargetInfo jpaTargetInfo, final DescriptorEvent descriptorEvent) {
|
public void fireUpdateEvent(final DescriptorEvent descriptorEvent) {
|
||||||
AfterTransactionCommitExecutorHolder.getInstance().getAfterCommit().afterCommit(
|
EventBusHolder.getInstance().getEventBus().post(new TargetInfoUpdateEvent(this));
|
||||||
() -> EventBusHolder.getInstance().getEventBus().post(new TargetInfoUpdateEvent(jpaTargetInfo)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireDeleteEvent(final JpaTargetInfo jpaTargetInfo, final DescriptorEvent descriptorEvent) {
|
public void fireDeleteEvent(final DescriptorEvent descriptorEvent) {
|
||||||
|
// there is no target info deleted event
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user