From 86a62b1b9ed0ec302156b3c023d51a7195f71cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Garc=C3=ADa?= Date: Sun, 19 May 2024 10:31:48 +0200 Subject: [PATCH 1/2] CSW Harvester / Avoid increment 2 metrics for a single metadata in certain conditions. Retrieve metadata method increments metrics under certain conditions and returns null. Methods calling the retrieve metadata method increments additionally the unretrievable metric if null is returned. Sonarlint fixeas are already applied. Fixes #8039 --- .../kernel/harvest/harvester/csw/Aligner.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/csw/Aligner.java b/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/csw/Aligner.java index 7a224fa1345..ba2962d9769 100644 --- a/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/csw/Aligner.java +++ b/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/csw/Aligner.java @@ -1,5 +1,5 @@ //============================================================================= -//=== Copyright (C) 2001-2007 Food and Agriculture Organization of the +//=== Copyright (C) 2001-2024 Food and Agriculture Organization of the //=== United Nations (FAO-UN), United Nations World Food Programme (WFP) //=== and United Nations Environment Programme (UNEP) //=== @@ -232,7 +232,7 @@ private void insertOrUpdate(Collection records, Collection Date: Thu, 5 Sep 2024 15:11:23 +0200 Subject: [PATCH 2/2] CSW Harvester / Use primitive boolean for 'force' parameter --- .../geonet/kernel/harvest/harvester/csw/Aligner.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/csw/Aligner.java b/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/csw/Aligner.java index ba2962d9769..fa363b5735f 100644 --- a/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/csw/Aligner.java +++ b/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/csw/Aligner.java @@ -418,13 +418,13 @@ public static void applyBatchEdits( } } } - private void updateMetadata(RecordInfo ri, String id, Boolean force) throws Exception { + private void updateMetadata(RecordInfo ri, String id, boolean force) throws Exception { String date = localUuids.getChangeDate(ri.uuid); if (date == null && !force) { log.debug(" - Skipped metadata managed by another harvesting node. uuid:" + ri.uuid + ", name:" + params.getName()); } else { - if (Boolean.TRUE.equals(!force) && !ri.isMoreRecentThan(date)) { + if (!force && !ri.isMoreRecentThan(date)) { log.debug(" - Metadata XML not changed for uuid:" + ri.uuid); result.unchangedMetadata++; } else { @@ -437,7 +437,7 @@ private void updateMetadata(RecordInfo ri, String id, Boolean force) throws Exce } } @Transactional(value = TxType.REQUIRES_NEW) - boolean updatingLocalMetadata(RecordInfo ri, String id, Boolean force) throws Exception { + boolean updatingLocalMetadata(RecordInfo ri, String id, boolean force) throws Exception { Element md = retrieveMetadata(ri.uuid); if (md == null) { @@ -472,8 +472,8 @@ boolean updatingLocalMetadata(RecordInfo ri, String id, Boolean force) throws Ex String language = context.getLanguage(); final AbstractMetadata metadata = metadataManager.updateMetadata(context, id, md, validate, ufo, language, ri.changeDate, true, IndexingMode.none); - if (Boolean.TRUE.equals(force) || updateSchema) { - if (Boolean.TRUE.equals(force)) { + if (force || updateSchema) { + if (force) { //change ownership of metadata to new harvester metadata.getHarvestInfo().setUuid(params.getUuid()); metadata.getSourceInfo().setSourceId(params.getUuid());