Skip to content

Commit

Permalink
Ingester / Remove initialisation of the GeoNetwork client (not used)
Browse files Browse the repository at this point in the history
  • Loading branch information
josegar74 committed Dec 5, 2023
1 parent c6759c5 commit 7364c3c
Showing 1 changed file with 0 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.geocat.ingester.dao.ingester.IngestJobRepo;
import com.geocat.ingester.dao.linkchecker.*;
import com.geocat.ingester.exception.GeoNetworkClientException;
import com.geocat.ingester.geonetwork.client.GeoNetworkClient;
import com.geocat.ingester.model.harvester.EndpointJob;
import com.geocat.ingester.model.harvester.HarvestJob;
import com.geocat.ingester.model.harvester.MetadataRecordXml;
Expand Down Expand Up @@ -49,9 +48,6 @@ public class IngesterService {
@Autowired
private CatalogueService catalogueService;

@Autowired
private GeoNetworkClient geoNetworkClient;

@Autowired
private IngestJobService ingestJobService;

Expand Down Expand Up @@ -201,13 +197,6 @@ public boolean run(String processId, String harvestJobId) throws Exception {
return false;
}

// Index added/updated records
// TODO: Test, commented to be indexed in GeoNetwork to avoid issues with GeoNetwork API and ECAS
List<String> metadataIdsToIndex = metadataIds.entrySet().stream().filter(a -> a.getValue().equals(Boolean.TRUE))
.map(Map.Entry::getKey)
.collect(Collectors.toList());
geoNetworkClient.init();

if (!continueProcessing(processId)) {
log.warn(harvestJobId + " is in USERABORT/ERROR state - aborting");
return false;
Expand Down Expand Up @@ -253,50 +242,6 @@ public boolean run(String processId, String harvestJobId) throws Exception {
return true;
}


/**
* Calls GeoNetwork index process for a set of metadata records.
*
* @param metadataIds
* @param processId
* @return true - completed, false - aborted
* @throws GeoNetworkClientException
*/
private boolean indexRecords(List<String> metadataIds, String processId) {
int batchSize = 50;

int totalPages = (int) Math.ceil(metadataIds.size() * 1.0 / batchSize * 1.0);

int total = 0;

for (int i = 0; i < totalPages; i++) {
try {
if (!continueProcessing(processId)) {
log.warn(processId + " is in USERABORT/ERROR state - aborting");
return false;
}

int from = i * batchSize;
int to = Math.min(((i + 1) * batchSize), metadataIds.size());

int toR = (i == totalPages - 1) ? metadataIds.size() : (to - 1);
log.info("Indexing harvested metadata records from " + Math.max(1, i * batchSize) + " to " + toR + " of " + metadataIds.size());

geoNetworkClient.index(metadataIds.subList(from, to));

total = total + (to - from);

ingestJobService.updateIngestJobStateInDBIndexedRecords(processId, total);

} catch (GeoNetworkClientException ex) {
// TODO: Handle exception
log.error(ex.getMessage(), ex);
return false;
}
}
return true;
}

/**
* Calls GeoNetwork delete process for a set of metadata records.
*
Expand Down

0 comments on commit 7364c3c

Please sign in to comment.