mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Merge pull request #1453 from tuub/DS-3256
DS-3256: Load webui.itemdisplay.default correctly.
This commit is contained in:
@@ -25,6 +25,7 @@ import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.JspWriter;
|
||||
import javax.servlet.jsp.jstl.fmt.LocaleSupport;
|
||||
import javax.servlet.jsp.tagext.TagSupport;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
|
||||
import org.apache.commons.lang.time.DateFormatUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
@@ -430,11 +431,11 @@ public class ItemTag extends TagSupport
|
||||
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
|
||||
Context context = UIUtil.obtainContext(request);
|
||||
Locale sessionLocale = UIUtil.getSessionLocale(request);
|
||||
String configLine = styleSelection.getConfigurationForStyle(style);
|
||||
String[] metadataFields = styleSelection.getConfigurationForStyle(style);
|
||||
|
||||
if (configLine == null)
|
||||
if (ArrayUtils.isEmpty(metadataFields))
|
||||
{
|
||||
configLine = defaultFields;
|
||||
metadataFields = defaultFields.split(",");
|
||||
}
|
||||
|
||||
out.println("<table class=\"table itemDisplayTable\">");
|
||||
@@ -446,11 +447,9 @@ public class ItemTag extends TagSupport
|
||||
* to a more efficient intermediate class, but then it would become more
|
||||
* difficult to reload the configuration "on the fly".
|
||||
*/
|
||||
StringTokenizer st = new StringTokenizer(configLine, ",");
|
||||
|
||||
while (st.hasMoreTokens())
|
||||
for (String field : metadataFields)
|
||||
{
|
||||
String field = st.nextToken().trim();
|
||||
field = field.trim();
|
||||
boolean isDate = false;
|
||||
boolean isLink = false;
|
||||
boolean isResolver = false;
|
||||
|
@@ -7,7 +7,8 @@
|
||||
*/
|
||||
package org.dspace.app.webui.util;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* Simple abstract class that provide utility method for get/check style configuration from dspace.cfg file
|
||||
* @author Andrea Bollini
|
||||
@@ -16,13 +17,15 @@ import org.dspace.core.ConfigurationManager;
|
||||
*/
|
||||
public abstract class AKeyBasedStyleSelection implements StyleSelection
|
||||
{
|
||||
public String getConfigurationForStyle(String style)
|
||||
public String[] getConfigurationForStyle(String style)
|
||||
{
|
||||
return ConfigurationManager.getProperty("webui.itemdisplay." + style);
|
||||
return DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||
.getArrayProperty("webui.itemdisplay." + style);
|
||||
}
|
||||
|
||||
protected boolean isConfigurationDefinedForStyle(String style)
|
||||
{
|
||||
return ConfigurationManager.getProperty("webui.itemdisplay." + style) == null;
|
||||
return DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||
.getProperty("webui.itemdisplay." + style) != null;
|
||||
}
|
||||
}
|
||||
|
@@ -106,7 +106,7 @@ public class CollectionStyleSelection extends AKeyBasedStyleSelection
|
||||
}
|
||||
|
||||
// Specific style specified. Check style exists
|
||||
if (isConfigurationDefinedForStyle(styleName))
|
||||
if (!isConfigurationDefinedForStyle(styleName))
|
||||
{
|
||||
log.warn("dspace.cfg specifies undefined item display style '"
|
||||
+ styleName + "' for collection handle " + handle + ". Using default");
|
||||
|
@@ -59,7 +59,7 @@ public class MetadataStyleSelection extends AKeyBasedStyleSelection
|
||||
|
||||
|
||||
// Specific style specified. Check style exists
|
||||
if (isConfigurationDefinedForStyle(styleName))
|
||||
if (!isConfigurationDefinedForStyle(styleName))
|
||||
{
|
||||
log.warn("metadata '" + metadata + "' specify undefined item display style '"
|
||||
+ styleName + "'. Using default");
|
||||
|
@@ -32,6 +32,7 @@ public interface StyleSelection
|
||||
* The configuration has the following syntax: <code>schema.element[.qualifier|.*][(display-option)]</code>
|
||||
*
|
||||
* @param style
|
||||
* @return An array of Strings each containing a metadata field and if given a display option.
|
||||
*/
|
||||
public String getConfigurationForStyle(String style);
|
||||
public String[] getConfigurationForStyle(String style);
|
||||
}
|
||||
|
Reference in New Issue
Block a user