From 68393f24e5462459ad7e2d11dc236aca4e55a16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Garc=C3=ADa?= Date: Thu, 29 Feb 2024 10:40:26 +0100 Subject: [PATCH] EEA / Streamlining publication and groups - issue metadata unpublication event when removing ALL group privileges from privileges dialog - improve check --- .../fao/geonet/api/records/MetadataSharingApi.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/services/src/main/java/org/fao/geonet/api/records/MetadataSharingApi.java b/services/src/main/java/org/fao/geonet/api/records/MetadataSharingApi.java index 8c56acdd86..033074fd7a 100644 --- a/services/src/main/java/org/fao/geonet/api/records/MetadataSharingApi.java +++ b/services/src/main/java/org/fao/geonet/api/records/MetadataSharingApi.java @@ -559,18 +559,18 @@ private void setOperations( } } - if (sharing.isClear() && !metadataUtils.isMetadataPublished(metadata.getId())) { - // Throw the metadata unpublish event, as when removing privileges, are not part of the parameters, + + java.util.Optional allGroupPrivsBefore = + sharingBefore.getPrivileges().stream().filter(p -> p.getGroup() == ReservedGroup.all.getId()).findFirst(); + boolean publishedBefore = allGroupPrivsBefore.get().getOperations().get(ReservedOperation.view.name()); + + if (sharing.isClear() && publishedBefore && !metadataUtils.isMetadataPublished(metadata.getId())) { + // Throw the metadata unpublish event, when removing privileges, are not part of the parameters, // not processed in setOperation / unsetOperation that triggers the metadata publish/unpublish events eventPublisher.publishEvent(new MetadataUnpublished(metadata)); } if (notifyByMail) { - java.util.Optional allGroupPrivsBefore = - sharingBefore.getPrivileges().stream().filter(p -> p.getGroup() == ReservedGroup.all.getId()).findFirst(); - - boolean publishedBefore = allGroupPrivsBefore.get().getOperations().get(ReservedOperation.view.name()); - java.util.Optional allGroupOpsAfter = privileges.stream().filter(p -> p.getGroup() == ReservedGroup.all.getId()).findFirst();