VIVO-73 Check for null Set from ServletContext.getResourcePaths()

This commit is contained in:
j2blake 2013-06-06 18:09:13 -04:00
parent 91277a1715
commit b86a34b611

View file

@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.i18n.selection;
import java.io.FileNotFoundException;
import java.util.Locale;
import java.util.Set;
import javax.servlet.ServletContext;
@ -40,8 +41,10 @@ public class LocaleSelectorUtilities {
String imageDirPath = "/" + themeDir + "i18n/images/";
ServletContext ctx = vreq.getSession().getServletContext();
for (Object o : ctx.getResourcePaths(imageDirPath)) {
String resourcePath = (String) o;
@SuppressWarnings("unchecked")
Set<String> resourcePaths = ctx.getResourcePaths(imageDirPath);
if (resourcePaths != null) {
for (String resourcePath : resourcePaths) {
if (resourcePath.contains(filename)) {
String fullPath = vreq.getContextPath() + resourcePath;
log.debug("Found image for " + locale + " at '" + fullPath
@ -49,6 +52,7 @@ public class LocaleSelectorUtilities {
return fullPath;
}
}
}
throw new FileNotFoundException("Can't find an image for " + locale);
}
}