Merge pull request #1453 from tuub/DS-3256

DS-3256: Load webui.itemdisplay.default correctly.
This commit is contained in:
Pascal-Nicolas Becker
2016-07-13 17:30:57 +02:00
committed by GitHub
5 changed files with 17 additions and 14 deletions

View File

@@ -25,6 +25,7 @@ import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.jstl.fmt.LocaleSupport; import javax.servlet.jsp.jstl.fmt.LocaleSupport;
import javax.servlet.jsp.tagext.TagSupport; import javax.servlet.jsp.tagext.TagSupport;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.time.DateFormatUtils; import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@@ -430,11 +431,11 @@ public class ItemTag extends TagSupport
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
Context context = UIUtil.obtainContext(request); Context context = UIUtil.obtainContext(request);
Locale sessionLocale = UIUtil.getSessionLocale(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\">"); 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 * to a more efficient intermediate class, but then it would become more
* difficult to reload the configuration "on the fly". * difficult to reload the configuration "on the fly".
*/ */
StringTokenizer st = new StringTokenizer(configLine, ","); for (String field : metadataFields)
while (st.hasMoreTokens())
{ {
String field = st.nextToken().trim(); field = field.trim();
boolean isDate = false; boolean isDate = false;
boolean isLink = false; boolean isLink = false;
boolean isResolver = false; boolean isResolver = false;

View File

@@ -7,7 +7,8 @@
*/ */
package org.dspace.app.webui.util; 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 * Simple abstract class that provide utility method for get/check style configuration from dspace.cfg file
* @author Andrea Bollini * @author Andrea Bollini
@@ -16,13 +17,15 @@ import org.dspace.core.ConfigurationManager;
*/ */
public abstract class AKeyBasedStyleSelection implements StyleSelection 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) protected boolean isConfigurationDefinedForStyle(String style)
{ {
return ConfigurationManager.getProperty("webui.itemdisplay." + style) == null; return DSpaceServicesFactory.getInstance().getConfigurationService()
.getProperty("webui.itemdisplay." + style) != null;
} }
} }

View File

@@ -106,7 +106,7 @@ public class CollectionStyleSelection extends AKeyBasedStyleSelection
} }
// Specific style specified. Check style exists // Specific style specified. Check style exists
if (isConfigurationDefinedForStyle(styleName)) if (!isConfigurationDefinedForStyle(styleName))
{ {
log.warn("dspace.cfg specifies undefined item display style '" log.warn("dspace.cfg specifies undefined item display style '"
+ styleName + "' for collection handle " + handle + ". Using default"); + styleName + "' for collection handle " + handle + ". Using default");

View File

@@ -59,7 +59,7 @@ public class MetadataStyleSelection extends AKeyBasedStyleSelection
// Specific style specified. Check style exists // Specific style specified. Check style exists
if (isConfigurationDefinedForStyle(styleName)) if (!isConfigurationDefinedForStyle(styleName))
{ {
log.warn("metadata '" + metadata + "' specify undefined item display style '" log.warn("metadata '" + metadata + "' specify undefined item display style '"
+ styleName + "'. Using default"); + styleName + "'. Using default");

View File

@@ -32,6 +32,7 @@ public interface StyleSelection
* The configuration has the following syntax: <code>schema.element[.qualifier|.*][(display-option)]</code> * The configuration has the following syntax: <code>schema.element[.qualifier|.*][(display-option)]</code>
* *
* @param style * @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);
} }