Retrieving country names in SOLR can return ArrayIndexOutOfBounds when country 
code is unchecked
------------------------------------------------------------------------------------------------

                 Key: DS-509
                 URL: http://jira.dspace.org/jira/browse/DS-509
             Project: DSpace 1.x
          Issue Type: Bug
          Components: Solr
    Affects Versions: 1.6.0
            Reporter: Peter Dietz
            Priority: Minor


When viewing SOLR statistics about an item/collection/community the section 
that displays the list of countries with the most visits can choke out when it 
encounters an invalid country code. It will just leave a blank section for 
countries when displaying the stats page.

It is unknown why invalid/blank country codes make it in to SOLR statistics, 
but errors can be prevented when querying. Perhaps some additional checks on 
the ingest of SOLR data would also be useful.

== Error as discovered in dspace.log ==
2010-03-09 13:04:32,703 ERROR 
org.dspace.app.xmlui.aspect.statistics.StatisticsTransformer @ Error occured 
while creating statistics for dso with ID: 993 and type 2 and handle: 1811/706
java.lang.ArrayIndexOutOfBoundsException: -1
        at java.util.Arrays$ArrayList.get(Arrays.java:3381)
        at 
org.dspace.statistics.util.LocationUtils.getCountryName(LocationUtils.java:803)
        at 
org.dspace.statistics.content.StatisticsDataVisits.getResultName(StatisticsDataVisits.java:403)
        at 
org.dspace.statistics.content.StatisticsDataVisits.createDataset(StatisticsDataVisits.java:295)
        at 
org.dspace.statistics.content.StatisticsDisplay.getDataset(StatisticsDisplay.java:91)
...


http://scm.dspace.org/svn/repo/dspace/trunk/dspace-stats/src/main/java/org/dspace/statistics/util/LocationUtils.java

Original Code
public static String getCountryName(String countryCode){
        int index = countryCodeList.indexOf(countryCode);
        return countryNameList.get(index).toString();           
    }

Revised Code
public static String getCountryName(String countryCode){
        if(countryCodeList.contains(countryCode)) {
            int index = countryCodeList.indexOf(countryCode);
            return countryNameList.get(index).toString();           
        } else {
            return "Unknown Country";
        }
    }


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.dspace.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Dspace-devel mailing list
Dspace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to