Skip to content

Commit

Permalink
[DS-509] SOLR returns ArrayIndexOutOfBounds with non-existent country…
Browse files Browse the repository at this point in the history
… 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
peterdietz committed May 13, 2010
1 parent 88994cf commit 845c23b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions dspace-api/src/main/resources/Messages.properties
Expand Up @@ -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.
Expand Down
14 changes: 9 additions & 5 deletions dspace-stats/src/main/java/org/dspace/statistics/Dataset.java
Expand Up @@ -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) {
Expand Down
Expand Up @@ -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,
Expand Down Expand Up @@ -799,13 +800,21 @@ public class LocationUtils {
{"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){
Expand Down
1 change: 1 addition & 0 deletions dspace/CHANGES
Expand Up @@ -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)
Expand Down

0 comments on commit 845c23b

Please sign in to comment.