forked from lsmyrnaios/UrlsController
- Add error-handling for the case when no payloads could be associated with a specific url which should have been in the hashMultiMap in "addUrlReportsByMatchingRecordsFromBacklog".
- Fix not cloning the payload, before changing it and adding it in the "prefilledPayloads"-list; instead, an object-reference was used.
This commit is contained in:
parent
1048463ca0
commit
e20c5d2146
|
@ -68,6 +68,14 @@ public class Payload {
|
|||
this.datasourceId = datasourceId;
|
||||
}
|
||||
|
||||
|
||||
public Payload clone()
|
||||
{
|
||||
// Return a new object with the same values. Clone whatever objects are not immutable.!
|
||||
return new Payload(this.id, this.original_url, this.actual_url, (Timestamp) this.timestamp_acquired.clone(), this.mime_type, this.size, this.hash,
|
||||
this.location, this.provenance, this.datasourceId);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -804,6 +804,10 @@ public class FileUtils {
|
|||
return; // Move to the next payload.
|
||||
}
|
||||
Set<Payload> foundPayloads = urlToPayloadsMultimap.get(original_url);
|
||||
if ( foundPayloads == null ) {
|
||||
logger.error("No payloads associated with \"original_url\" = \"" + original_url + "\"!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Select a random "foundPayload" to use its data to fill the "prefilledPayload" (in a "Set" the first element is pseudo-random).
|
||||
Optional<Payload> optPayload = foundPayloads.stream().findFirst();
|
||||
|
@ -811,7 +815,7 @@ public class FileUtils {
|
|||
logger.error("Could not retrieve any payload for the \"original_url\": " + original_url);
|
||||
return; // Move to the next payload.
|
||||
}
|
||||
Payload prefilledPayload = optPayload.get(); // We change just the id and the original_url.
|
||||
Payload prefilledPayload = optPayload.get().clone(); // We take a clone of the original payload and change just the id and the original_url.
|
||||
prefilledPayload.setId(id);
|
||||
prefilledPayload.setOriginal_url(original_url);
|
||||
prefilledPayloads.add(prefilledPayload);
|
||||
|
|
Loading…
Reference in New Issue