Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TargetInfo entity #453

Merged

Conversation

kaizimmerm
Copy link
Contributor

TargetInfo was historically there to allow a fork on the spring audit listener. The idea was that devices should not trigger an audit log write (only users). So TargetInfo contained all properties that are set by a device (controller). However, our security is much more evolved these days. So we can merge Target and TargetInfo back together and instead create a condition that ensures that audit data is not changed if data is written by a controller.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Conflicts:
	hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/TargetManagementTest.java
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
.publishEvent(new TargetUpdatedEvent(this, EventPublisherHolder.getInstance().getApplicationId()));
final ObjectChangeSet objectChanges = ((UpdateObjectQuery) descriptorEvent.getQuery()).getObjectChangeSet();

if (objectChanges.getChangedAttributeNames().stream()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move logic into caller

// through JQL
final JpaTarget target = (JpaTarget) action.getTarget();
target.setUpdateStatus(TargetUpdateStatus.PENDING);
entityManager.detach(target);

afterCommit.afterCommit(() -> eventPublisher
.publishEvent(new TargetUpdatedEvent(action.getTarget(), applicationContext.getId())));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use target reference for readability

Copy link
Contributor

@michahirsch michahirsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ignore event sending logic based on ignore changed fields can be moved to the caller EntityPropertyChangeListener then every entity class profits from it.

I would extend the EventAwareEntity with a method getIgnoreFields() or something.

* the parent rollout group the actions should reference. null
* references the first group
* @return the amount of started actions
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
long startScheduledActionsByRolloutGroupParent(@NotNull Rollout rollout, RolloutGroup rolloutGroupParent);
long startScheduledActionsByRolloutGroupParent(@NotNull Long rolloutId, Long rolloutGroupParentId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// check if we need to override running update actions
final Set<Long> overrideObsoleteUpdateActions = overrideObsoleteUpdateActions(
Collections.singletonList(action.getTarget().getId()));

if (action.getTarget().getAssignedDistributionSet() != null && action.getDistributionSet().getId()
.equals(action.getTarget().getAssignedDistributionSet().getId())) {
if (((JpaTarget) action.getTarget()).getAssignedDistributionSet() != null && action.getDistributionSet().getId()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For better reagability use a variable for the cast (JpaTarget) action.getTarget(). Then you have only 1 instead of 2 cast

Conflicts:
	hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
@kaizimmerm kaizimmerm merged commit 602fb78 into eclipse-hawkbit:master Mar 17, 2017
@kaizimmerm kaizimmerm deleted the feature_auditor_controller_aware branch March 17, 2017 11:18
@kaizimmerm kaizimmerm modified the milestone: 0.2.0M3 Apr 3, 2017
AmmarBikic pushed a commit to bosch-io/hawkbit that referenced this pull request Oct 2, 2020
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants