Permalink
Browse files

[DS-509] SOLR returns ArrayIndexOutOfBounds with non-existent country…

… code OR when there is no view/download data. Added to trunk. contains i18n keys for country and continent, and performs check that they exist before trying to display. Also fixes a similar ArrayIOOB by adding a check.

Issue #DS-509 - Retrieving country names in SOLR can return ArrayIndexOutOfBounds when country code is unchecked

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@4924 9c30dcfa-912a-0410-8fc2-9e0234be79fd
  • Loading branch information...
1 parent 88994cf commit 845c23be75161da3824dd6be38e76377499fae9f @peterdietz peterdietz committed May 13, 2010
@@ -1412,6 +1412,8 @@ org.dspace.eperson.Subscribe.authors
org.dspace.eperson.Subscribe.id = ID:
org.dspace.eperson.Subscribe.new-items = New Items:
org.dspace.eperson.Subscribe.title = Title:
+org.dspace.statistics.util.LocationUtils.unknown-continent = Unknown Continent
+org.dspace.statistics.util.LocationUtils.unknown-country = Unknown Country
org.dspace.workflow.WorkflowManager.step1 = It requires reviewing.
org.dspace.workflow.WorkflowManager.step2 = The submission must be checked before inclusion in the archive.
org.dspace.workflow.WorkflowManager.step3 = The metadata needs to be checked to ensure compliance with the collection's standards, and edited if necessary.
@@ -168,13 +168,17 @@ public void setFormat(String format) {
public String[][] getMatrixFormatted(){
DecimalFormat decimalFormat = new DecimalFormat(format);
- String [][]strMatrix = new String[matrix.length][matrix[0].length];
- for (int i = 0; i < matrix.length; i++) {
- for (int j = 0; j < matrix[i].length; j++) {
- strMatrix[i][j] = decimalFormat.format(matrix[i][j]);
+ if (matrix.length == 0) {
+ return new String[0][0];
+ } else {
+ String[][] strMatrix = new String[matrix.length][matrix[0].length];
+ for (int i = 0; i < matrix.length; i++) {
+ for (int j = 0; j < matrix[i].length; j++) {
+ strMatrix[i][j] = decimalFormat.format(matrix[i][j]);
+ }
}
+ return strMatrix;
}
- return strMatrix;
}
public void addValueToMatrix(int row, int coll, float value) {
@@ -15,6 +15,7 @@
import java.util.Arrays;
import java.util.List;
import java.lang.reflect.Array;
+import org.dspace.core.I18nUtil;
/**
* Mapping between Country codes, English Country names,
@@ -799,13 +800,21 @@
{"OC", "Oceania"}};
public static String getCountryName(String countryCode){
- int index = countryCodeList.indexOf(countryCode);
- return countryNameList.get(index).toString();
+ if (countryCode.length() > 0 && countryCodeList.contains(countryCode)) {
+ int index = countryCodeList.indexOf(countryCode);
+ return countryNameList.get(index).toString();
+ } else {
+ return I18nUtil.getMessage("org.dspace.statistics.util.LocationUtils.unknown-country");
+ }
}
public static String getContinentCode(String countryCode){
- int index = countryCodeList.indexOf(countryCode);
- return continentCodeList.get(index).toString();
+ if(countryCode.length() > 0 && countryCodeList.contains(countryCode)) {
+ int index = countryCodeList.indexOf(countryCode);
+ return continentCodeList.get(index).toString();
+ } else {
+ return I18nUtil.getMessage("org.dspace.statistics.util.LocationUtils.unknown-continent");
+ }
}
public static String getContinentName(String continentCode){
View
@@ -15,6 +15,7 @@
- [DS-537] Malformed Japanese option values in the authority lookup window
(Peter Dietz)
+- [DS-509] SOLR returns ArrayIndexOutOfBounds with non-existent country code OR when there is no view/download data
- [DS-542] verbose output for stats-log-importer displays spurious city/country from previous committed entry
(Kim Shepherd)

0 comments on commit 845c23b

Please sign in to comment.