diff --git a/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/database/DatabaseHarvesterAligner.java b/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/database/DatabaseHarvesterAligner.java index d6fe5cba40b..677983d0d61 100644 --- a/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/database/DatabaseHarvesterAligner.java +++ b/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/database/DatabaseHarvesterAligner.java @@ -59,6 +59,7 @@ class DatabaseHarvesterAligner extends BaseAligner impl private IMetadataUtils metadataUtils; private IMetadataIndexer metadataIndexer; private IMetadataSchemaUtils metadataSchemaUtils; + private MetadataRepository metadataRepository; private HarvestResult result; private CategoryMapper localCateg; private GroupMapper localGroups; @@ -91,6 +92,7 @@ public DatabaseHarvesterAligner(AtomicBoolean cancelMonitor, Logger log, Service metadataSchemaUtils = gc.getBean(IMetadataSchemaUtils.class); metadataUtils = gc.getBean(IMetadataUtils.class); metadataIndexer = gc.getBean(IMetadataIndexer.class); + metadataRepository = gc.getBean(MetadataRepository.class); } @Override @@ -110,7 +112,7 @@ public HarvestResult harvest(Logger log) throws Exception { //--- retrieve harvested uuids for given harvesting node localCateg = new CategoryMapper(context); localGroups = new GroupMapper(context); - localUuids = new UUIDMapper(context.getBean(IMetadataUtils.class), params.getUuid()); + localUuids = new UUIDMapper(metadataUtils, params.getUuid()); Pair> filter = HarvesterUtil.parseXSLFilter(params.getXslfilter()); processName = filter.one(); @@ -165,7 +167,7 @@ public void align(String metadata) { private void deleteLocalMetadataNotInDatabase(List idsForHarvestingResult) throws Exception { Set idsResultHs = Sets.newHashSet(idsForHarvestingResult); - List existingMetadata = context.getBean(MetadataRepository.class).findIdsBy(MetadataSpecs.hasHarvesterUuid(params.getUuid())); + List existingMetadata = metadataRepository.findIdsBy(MetadataSpecs.hasHarvesterUuid(params.getUuid())); for (Integer existingId : existingMetadata) { if (cancelMonitor.get()) { return;