VIVO-73 Check for null Set from ServletContext.getResourcePaths()
This commit is contained in:
parent
91277a1715
commit
b86a34b611
1 changed files with 11 additions and 7 deletions
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.i18n.selection;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
|
@ -40,13 +41,16 @@ public class LocaleSelectorUtilities {
|
||||||
String imageDirPath = "/" + themeDir + "i18n/images/";
|
String imageDirPath = "/" + themeDir + "i18n/images/";
|
||||||
|
|
||||||
ServletContext ctx = vreq.getSession().getServletContext();
|
ServletContext ctx = vreq.getSession().getServletContext();
|
||||||
for (Object o : ctx.getResourcePaths(imageDirPath)) {
|
@SuppressWarnings("unchecked")
|
||||||
String resourcePath = (String) o;
|
Set<String> resourcePaths = ctx.getResourcePaths(imageDirPath);
|
||||||
if (resourcePath.contains(filename)) {
|
if (resourcePaths != null) {
|
||||||
String fullPath = vreq.getContextPath() + resourcePath;
|
for (String resourcePath : resourcePaths) {
|
||||||
log.debug("Found image for " + locale + " at '" + fullPath
|
if (resourcePath.contains(filename)) {
|
||||||
+ "'");
|
String fullPath = vreq.getContextPath() + resourcePath;
|
||||||
return fullPath;
|
log.debug("Found image for " + locale + " at '" + fullPath
|
||||||
|
+ "'");
|
||||||
|
return fullPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new FileNotFoundException("Can't find an image for " + locale);
|
throw new FileNotFoundException("Can't find an image for " + locale);
|
||||||
|
|
Loading…
Add table
Reference in a new issue