From c539dc15169db131b27e44f089cc0516c72dbd54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Garc=C3=ADa?= Date: Tue, 15 Oct 2024 17:10:44 +0200 Subject: [PATCH] Database batch edit (Save mode): - Avoid double indexing of the updated metadata. - Return the XML document after saving it in the database, applying update-fixed-info process. --- .../api/processing/DatabaseProcessUtils.java | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/services/src/main/java/org/fao/geonet/api/processing/DatabaseProcessUtils.java b/services/src/main/java/org/fao/geonet/api/processing/DatabaseProcessUtils.java index 1387a2c8e87..7c256bc277a 100644 --- a/services/src/main/java/org/fao/geonet/api/processing/DatabaseProcessUtils.java +++ b/services/src/main/java/org/fao/geonet/api/processing/DatabaseProcessUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2016 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) * @@ -26,24 +26,17 @@ import jeeves.server.context.ServiceContext; import org.apache.commons.lang.StringUtils; import org.fao.geonet.api.processing.report.MetadataReplacementProcessingReport; -import org.fao.geonet.api.processing.report.XsltMetadataProcessingReport; import org.fao.geonet.domain.AbstractMetadata; import org.fao.geonet.domain.ISODate; import org.fao.geonet.kernel.AccessManager; import org.fao.geonet.kernel.DataManager; -import org.fao.geonet.kernel.SchemaManager; -import org.fao.geonet.kernel.datamanager.IMetadataManager; -import org.fao.geonet.kernel.datamanager.IMetadataSchemaUtils; import org.fao.geonet.kernel.datamanager.IMetadataUtils; import org.fao.geonet.kernel.search.IndexingMode; -import org.fao.geonet.kernel.setting.SettingManager; import org.fao.geonet.lib.Lib; import org.fao.geonet.repository.MetadataRepository; -import org.fao.geonet.repository.MetadataValidationRepository; import org.fao.geonet.utils.Xml; import org.jdom.Element; -import java.util.Map; public class DatabaseProcessUtils { /** @@ -72,7 +65,7 @@ public static Element process(ServiceContext context, String id, return null; } - int iId = Integer.valueOf(id); + int iId = Integer.parseInt(id); AbstractMetadata info = metadataUtils.findOne(id); @@ -108,16 +101,12 @@ public static Element process(ServiceContext context, String id, boolean ufo = true; String language = context.getLanguage(); - dataMan.updateMetadata(context, id, wellFormedXml, validate, ufo, language, new ISODate().toString(), + AbstractMetadata metadata = dataMan.updateMetadata(context, id, wellFormedXml, validate, ufo, language, new ISODate().toString(), updateDateStamp, index ? IndexingMode.full : IndexingMode.none); - if (index) { - dataMan.indexMetadata(id, true); - } + wellFormedXml = Xml.loadString(metadata.getData(), false); } } - - report.addMetadataId(iId); // TODO : it could be relevant to list at least // if there was any change in the record or not.