Skip to content

Script update-metrics using service wos-person throws org.json.JSONException #509

@jorgeltd

Description

@jorgeltd

Describe the bug
DSpace-CRIS version: 2024.02.00

Running the script update-metrics using the service wos-person throws the next error:

2025-04-12 17:18:28.675 INFO update-metrics - 214 @ The script has started
2025-04-12 17:18:28.701 INFO update-metrics - 214 @ Update start
2025-04-12 17:18:30.525 ERROR update-metrics - 214 @ null
2025-04-12 17:18:30.528 ERROR update-metrics - 214 @ org.json.JSONException: JSONObject["silo_tc"] is not a JSONObject (class org.json.JSONArray).
	at org.json.JSONObject.wrongValueFormatException(JSONObject.java:2906)
	at org.json.JSONObject.getJSONObject(JSONObject.java:782)
	at org.dspace.metrics.wos.WOSPersonRestConnector.sumMetricCounts(WOSPersonRestConnector.java:114)
	at org.dspace.metrics.wos.WOSPersonRestConnector.sendRequestToWOS(WOSPersonRestConnector.java:94)
	at org.dspace.metrics.wos.UpdateWOSPersonMetrics.updateMetric(UpdateWOSPersonMetrics.java:49)
	at org.dspace.metrics.UpdateCrisMetricsWithExternalSource.performUpdateWithSingleFetches(UpdateCrisMetricsWithExternalSource.java:207)
	at org.dspace.metrics.UpdateCrisMetricsWithExternalSource.performUpdate(UpdateCrisMetricsWithExternalSource.java:132)
	at org.dspace.metrics.UpdateCrisMetricsWithExternalSource.internalRun(UpdateCrisMetricsWithExternalSource.java:109)
	at org.dspace.scripts.DSpaceRunnable.run(DSpaceRunnable.java:162)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)

To Reproduce
Steps to reproduce the behavior:

  1. Add person with the metadata person.identifier.orcid of a real person that has cited documents on Web Of Science.
  2. Execute the script update-metrics --service wos-person

Expected behavior
Metrics of persons with a ORCID that has cited documents on WoS should be added to the system.

More info
Seems like there is a problem on line 110 of WOSPersonRestConnector.java

private int sumMetricCounts(JSONArray records) {
int total = 0;
if (Objects.nonNull(records)) {
for (int i = 0; i < records.length(); i++) {
Integer count = records.getJSONObject(i)
.getJSONObject("dynamic_data")
.getJSONObject("citation_related")
.getJSONObject("tc_list")
.getJSONObject("silo_tc")
.getInt("local_count");
if (Objects.nonNull(count)) {
total += count.intValue();
}
}
}
return total;

It tries to read a int value on local_count inside silo_tc, but silo_tc contains a list of JSON object with the format:

{
"coll_id: string //collection code
"local_count": int  //number of citations
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions