[DS-246] Fix configurable browse parameter encoding (XMLUI)

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@4488 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Kim Shepherd
2009-10-29 00:43:43 +00:00
parent a5bfb45ab2
commit 953ffdb74a
2 changed files with 34 additions and 17 deletions

View File

@@ -364,17 +364,21 @@ public class ConfigurableBrowse extends AbstractDSpaceTransformer implements
String type = info.getBrowseIndex().getName(); String type = info.getBrowseIndex().getName();
// Prepare a Map of query parameters required for all links // Prepare a Map of query parameters required for all links
Map<String, String> queryParams = new HashMap<String, String>(); Map<String, String> queryParamsGET = new HashMap<String, String>();
queryParams.putAll(params.getCommonParameters()); queryParamsGET.putAll(params.getCommonParametersEncoded());
queryParams.putAll(params.getControlParameters()); queryParamsGET.putAll(params.getControlParameters());
Map<String, String> queryParamsPOST = new HashMap<String, String>();
queryParamsPOST.putAll(params.getCommonParameters());
queryParamsPOST.putAll(params.getControlParameters());
// Navigation aid (really this is a poor version of pagination) // Navigation aid (really this is a poor version of pagination)
Division jump = div.addInteractiveDivision("browse-navigation", BROWSE_URL_BASE, Division jump = div.addInteractiveDivision("browse-navigation", BROWSE_URL_BASE,
Division.METHOD_POST, "secondary navigation"); Division.METHOD_POST, "secondary navigation");
// Add all the query parameters as hidden fields on the form // Add all the query parameters as hidden fields on the form
for (String key : queryParams.keySet()) for (String key : queryParamsPOST.keySet())
jump.addHidden(key).setValue(queryParams.get(key)); jump.addHidden(key).setValue(queryParamsPOST.get(key));
// If this is a date based browse, render the date navigation // If this is a date based browse, render the date navigation
if (isSortedByDate(info)) if (isSortedByDate(info))
@@ -426,13 +430,13 @@ public class ConfigurableBrowse extends AbstractDSpaceTransformer implements
// Create a clickable list of the alphabet // Create a clickable list of the alphabet
List jumpList = jump.addList("jump-list", List.TYPE_SIMPLE, "alphabet"); List jumpList = jump.addList("jump-list", List.TYPE_SIMPLE, "alphabet");
Map<String, String> zeroQuery = new HashMap<String, String>(queryParams); Map<String, String> zeroQuery = new HashMap<String, String>(queryParamsGET);
zeroQuery.put(BrowseParams.STARTS_WITH, "0"); zeroQuery.put(BrowseParams.STARTS_WITH, "0");
jumpList.addItemXref(super.generateURL(BROWSE_URL_BASE, zeroQuery), "0-9"); jumpList.addItemXref(super.generateURL(BROWSE_URL_BASE, zeroQuery), "0-9");
for (char c = 'A'; c <= 'Z'; c++) for (char c = 'A'; c <= 'Z'; c++)
{ {
Map<String, String> cQuery = new HashMap<String, String>(queryParams); Map<String, String> cQuery = new HashMap<String, String>(queryParamsGET);
cQuery.put(BrowseParams.STARTS_WITH, Character.toString(c)); cQuery.put(BrowseParams.STARTS_WITH, Character.toString(c));
jumpList.addItemXref(super.generateURL(BROWSE_URL_BASE, cQuery), Character jumpList.addItemXref(super.generateURL(BROWSE_URL_BASE, cQuery), Character
.toString(c)); .toString(c));
@@ -552,7 +556,7 @@ public class ConfigurableBrowse extends AbstractDSpaceTransformer implements
return null; return null;
Map<String, String> parameters = new HashMap<String, String>(); Map<String, String> parameters = new HashMap<String, String>();
parameters.putAll(params.getCommonParameters()); parameters.putAll(params.getCommonParametersEncoded());
parameters.putAll(params.getControlParameters()); parameters.putAll(params.getControlParameters());
if (info.hasPrevPage()) if (info.hasPrevPage())
@@ -578,7 +582,7 @@ public class ConfigurableBrowse extends AbstractDSpaceTransformer implements
return null; return null;
Map<String, String> parameters = new HashMap<String, String>(); Map<String, String> parameters = new HashMap<String, String>();
parameters.putAll(params.getCommonParameters()); parameters.putAll(params.getCommonParametersEncoded());
parameters.putAll(params.getControlParameters()); parameters.putAll(params.getControlParameters());
if (info.hasNextPage()) if (info.hasNextPage())
@@ -946,26 +950,36 @@ class BrowseParams
{ {
Map<String, String> paramMap = new HashMap<String, String>(); Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put(BrowseParams.TYPE, AbstractDSpaceTransformer.URLEncode( paramMap.put(BrowseParams.TYPE, scope.getBrowseIndex().getName());
scope.getBrowseIndex().getName()));
if (scope.getFilterValue() != null) if (scope.getFilterValue() != null)
{ {
paramMap.put(scope.getAuthorityValue() != null? paramMap.put(scope.getAuthorityValue() != null?
BrowseParams.FILTER_VALUE[1]:BrowseParams.FILTER_VALUE[0], BrowseParams.FILTER_VALUE[1]:BrowseParams.FILTER_VALUE[0], scope.getFilterValue());
AbstractDSpaceTransformer.URLEncode(
scope.getFilterValue()));
} }
if (scope.getFilterValueLang() != null) if (scope.getFilterValueLang() != null)
{ {
paramMap.put(BrowseParams.FILTER_VALUE_LANG, AbstractDSpaceTransformer.URLEncode( paramMap.put(BrowseParams.FILTER_VALUE_LANG, scope.getFilterValueLang());
scope.getFilterValueLang()));
} }
return paramMap; return paramMap;
} }
Map<String, String> getCommonParametersEncoded() throws UIException
{
Map<String, String> paramMap = getCommonParameters();
Map<String, String> encodedParamMap = new HashMap<String, String>();
for (String key: paramMap.keySet())
{
encodedParamMap.put(key, AbstractDSpaceTransformer.URLEncode(paramMap.get(key)));
}
return encodedParamMap;
}
/* /*
* Creates a Map of the browse control options (sort by / ordering / results * Creates a Map of the browse control options (sort by / ordering / results
* per page / authors per item) * per page / authors per item)

View File

@@ -139,6 +139,9 @@
(Toni Prieto) (Toni Prieto)
- [DS-356] Antispam for suggest item feature - [DS-356] Antispam for suggest item feature
(Flavio Botelho)
- [DS-246] Fix configurable browse parameter encoding (XMLUI)
1.5.2 final 1.5.2 final
=========== ===========