Skip to content

Commit b22dbf7

Browse files
committed
Consistently log info messages when harvester UUID collision occurs
1 parent 9a883cd commit b22dbf7

File tree

8 files changed

+32
-18
lines changed

8 files changed

+32
-18
lines changed

harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/csw/Aligner.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,23 +197,25 @@ private void insertOrUpdate(Collection<RecordInfo> records, Collection<HarvestEr
197197
} else if (localUuids.getID(ri.uuid) == null) {
198198
//Record does not belong to this harvester
199199
result.datasetUuidExist++;
200+
log.info(String.format("UUID collision detected for record with uuid '%s'. Record already exists in the catalogue but does not belong to this harvester (%s).",
201+
ri.uuid, params.getName()));
200202

201203
switch (params.getOverrideUuid()) {
202204
case OVERRIDE:
203205
updateMetadata(ri, Integer.toString(metadataUtils.findOneByUuid(ri.uuid).getId()), true);
204-
log.debug("Overriding record with uuid " + ri.uuid);
206+
log.info("Overriding record with uuid " + ri.uuid);
205207

206208
if (params.isIfRecordExistAppendPrivileges()) {
207209
addPrivileges(id, params.getPrivileges(), localGroups, context);
208210
result.privilegesAppendedOnExistingRecord++;
209211
}
210212
break;
211213
case RANDOM:
212-
log.debug("Generating random uuid for remote record with uuid " + ri.uuid);
214+
log.info("Generating random uuid for remote record with uuid " + ri.uuid);
213215
addMetadata(ri, UUID.randomUUID().toString());
214216
break;
215217
case SKIP:
216-
log.debug("Skipping record with uuid " + ri.uuid);
218+
log.info("Skipping record with uuid " + ri.uuid);
217219
result.uuidSkipped++;
218220
break;
219221
default:

harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/database/DatabaseHarvesterAligner.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,21 @@ private String processMetadata(Element metadataElement) throws Exception {
233233
} else if (localUuids.getID(uuid) == null) {
234234
//Record does not belong to this harvester
235235
result.datasetUuidExist++;
236+
log.info(String.format("UUID collision detected for record with uuid '%s'. Record already exists in the catalogue but does not belong to this harvester (%s).",
237+
uuid, params.getName()));
236238

237239
switch (params.getOverrideUuid()) {
238240
case OVERRIDE:
239241
updateMetadata(metadataElement, metadataUtils.findOneByUuid(uuid), true);
240-
log.debug(String.format("Overriding record with uuid %s", uuid));
242+
log.info(String.format("Overriding record with uuid %s", uuid));
241243
result.updatedMetadata++;
242244
break;
243245
case RANDOM:
244-
log.debug(String.format("Generating random uuid for remote record with uuid %s", uuid));
246+
log.info(String.format("Generating random uuid for remote record with uuid %s", uuid));
245247
addMetadata(metadataElement, UUID.randomUUID().toString(), schema);
246248
break;
247249
case SKIP:
248-
log.debug(String.format("Skipping record with uuid %s", uuid));
250+
log.info(String.format("Skipping record with uuid %s", uuid));
249251
result.uuidSkipped++;
250252
break;
251253
default:

harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/geonet/BaseGeoNetworkAligner.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ public HarvestResult align(SortedSet<RecordInfo> records, List<HarvestError> err
237237
} else if (localUuids.getID(ri.uuid) == null) {
238238
//record doesn't belong to this harvester but exists
239239
result.datasetUuidExist++;
240+
log.info(String.format("UUID collision detected for record with uuid '%s'. Record already exists in the catalogue but does not belong to this harvester (%s).",
241+
ri.uuid, params.getName()));
240242

241243
switch (params.getOverrideUuid()) {
242244
case OVERRIDE:
@@ -258,7 +260,7 @@ public HarvestResult align(SortedSet<RecordInfo> records, List<HarvestError> err
258260
addMetadata(ri, localRating.equals(RatingsSetting.BASIC), UUID.randomUUID().toString());
259261
break;
260262
case SKIP:
261-
log.debug("Skipping record with uuid " + ri.uuid);
263+
log.info("Skipping record with uuid " + ri.uuid);
262264
result.uuidSkipped++;
263265
break;
264266
default:

harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/localfilesystem/LocalFsHarvesterFileVisitor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,19 +305,21 @@ private void processXmlData(Path file, Element rawXml) throws Exception {
305305
final AbstractMetadata metadata = repo.findOne(id);
306306
if (!params.getUuid().equals(metadata.getHarvestInfo().getUuid())) {
307307
// Metadata exists and belongs to another source (local node or other harvester)
308+
harvester.getLogger().info(String.format("UUID collision detected for record with uuid '%s' from path '%s'. Record already exists in the catalogue but does not belong to this harvester (%s).",
309+
metadata.getUuid(), filePath, params.getName()));
308310
switch (params.getOverrideUuid()) {
309311
case OVERRIDE:
310312
updateMetadata(file, filePath, xml, schema, id, metadata, true);
311313
break;
312314
case RANDOM:
313-
harvester.getLogger().debug("Generating random uuid for remote record with uuid " + metadata.getUuid());
315+
harvester.getLogger().info("Generating random uuid for remote record with uuid " + metadata.getUuid());
314316
String createDate = getCreateDate(file, xml, schema, uuid);
315317
String newUuid = UUID.randomUUID().toString();
316318
id = addMetadata(xml, schema, newUuid, createDate);
317319

318320
break;
319321
case SKIP:
320-
harvester.getLogger().debug("Skipping record with uuid " + metadata.getUuid());
322+
harvester.getLogger().info("Skipping record with uuid " + metadata.getUuid());
321323
result.uuidSkipped++;
322324
result.unchangedMetadata++;
323325

harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/oaipmh/Harvester.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ private void align(XmlRequest t, Set<RecordInfo> records) throws Exception {
310310
} else if (localUuids.getID(ri.id) == null) {
311311
// Record with such uuid already exists in the database but doesn't belong to this harvester
312312
result.datasetUuidExist++;
313+
log.info(String.format("UUID collision detected for record with uuid '%s'. Record already exists in the catalogue but does not belong to this harvester (%s).",
314+
ri.id, params.getName()));
313315

314316
switch (params.getOverrideUuid()) {
315317
case OVERRIDE:
@@ -319,15 +321,13 @@ private void align(XmlRequest t, Set<RecordInfo> records) throws Exception {
319321
result.updatedMetadata++;
320322
break;
321323
case RANDOM:
322-
if (log.isDebugEnabled()) {
323-
log.debug(String.format("Generating random uuid for remote record with uuid %s", ri.id));
324-
}
324+
log.info(String.format("Generating random uuid for remote record with uuid %s", ri.id));
325325
String newRandomUuid = UUID.randomUUID().toString();
326326
processParams.put("mdChangeDate", ri.changeDate);
327327
addMetadata(t, ri, processName, processParams, newRandomUuid);
328328
break;
329329
case SKIP:
330-
log.debug("Skipping record with uuid " + ri.id);
330+
log.info("Skipping record with uuid " + ri.id);
331331
result.uuidSkipped++;
332332
break;
333333
default:

harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/sftp/Aligner.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,21 @@ private void insertOrUpdate(RecordInfo ri, Element md, Collection<HarvestError>
201201
} else if (localUuids.getID(ri.uuid) == null) {
202202
//Record does not belong to this harvester
203203
result.datasetUuidExist++;
204+
log.info(String.format("UUID collision detected for record with uuid '%s'. Record already exists in the catalogue but does not belong to this harvester (%s).",
205+
ri.uuid, params.getName()));
204206

205207
switch (params.getOverrideUuid()) {
206208
case OVERRIDE:
207209
updateMetadata(ri, Integer.toString(metadataUtils.findOneByUuid(ri.uuid).getId()), md, true);
208-
log.debug("Overriding record with uuid " + ri.uuid);
210+
log.info("Overriding record with uuid " + ri.uuid);
209211

210212
if (params.isIfRecordExistAppendPrivileges()) {
211213
addPrivileges(id, params.getPrivileges(), localGroups, context);
212214
result.privilegesAppendedOnExistingRecord++;
213215
}
214216
break;
215217
case RANDOM:
216-
log.debug("Generating random uuid for remote record with uuid " + ri.uuid);
218+
log.info("Generating random uuid for remote record with uuid " + ri.uuid);
217219
addMetadata(ri, md, UUID.randomUUID().toString());
218220
break;
219221
case SKIP:

harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/simpleurl/Aligner.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,21 @@ private void insertOrUpdate(Map<String, Element> records, Collection<HarvestErro
127127
} else if (localUuids.getID(e.getKey()) == null) {
128128
//Record does not belong to this harvester
129129
result.datasetUuidExist++;
130+
log.info(String.format("UUID collision detected for record with uuid '%s'. Record already exists in the catalogue but does not belong to this harvester (%s).",
131+
e.getKey(), params.getName()));
130132

131133
switch (params.getOverrideUuid()) {
132134
case OVERRIDE:
133135
updateMetadata(e, Integer.toString(metadataUtils.findOneByUuid(e.getKey()).getId()), true);
134-
log.debug("Overriding record with uuid " + e.getKey());
136+
log.info("Overriding record with uuid " + e.getKey());
135137
result.updatedMetadata++;
136138
break;
137139
case RANDOM:
138-
log.debug("Generating random uuid for remote record with uuid " + e.getKey());
140+
log.info("Generating random uuid for remote record with uuid " + e.getKey());
139141
addMetadata(e, UUID.randomUUID().toString());
140142
break;
141143
case SKIP:
142-
log.debug("Skipping record with uuid " + e.getKey());
144+
log.info("Skipping record with uuid " + e.getKey());
143145
result.uuidSkipped++;
144146
break;
145147
default:

harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/webdav/Harvester.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ private void addMetadata(RemoteFile rf) throws Exception {
234234
// random one
235235
if (dataMan.existsMetadataUuid(uuid)) {
236236
result.datasetUuidExist++;
237+
log.info(String.format("UUID collision detected for record with uuid '%s' from path '%s'. Record already exists in the catalogue and does not belong to this harvester.",
238+
uuid, rf.getPath()));
237239
switch(params.getOverrideUuid()){
238240
case OVERRIDE:
239241
Metadata existingMetadata = metadataRepository.findOneByUuid(uuid);

0 commit comments

Comments
 (0)