final ClientPropertiesKey clientkey, final String prefix, final String subDir, final String name,
final String suffix, final boolean reverseOrder, final boolean single, final boolean returnKey, final String key,
final boolean returnStrings, boolean ignoreMissing) {
final List matches = new ArrayList();
final String contentType = clientkey.getContentType();
final Theme theme = clientkey.getTheme();
final UserAgent browser = clientkey.getUserAgent();
final List<String> locales = LocaleUtils.getLocaleSuffixList(clientkey.getLocale());
// check first the local web application directory
for (final String localeSuffix : locales) {
if (production) {
boolean found = checkPath(prefix, reverseOrder, returnKey, returnStrings, matches,
name, MINIMIZE_SUFFIX, localeSuffix, suffix, key);
if (found && (single || !returnStrings)) {
return matches;
}
if (!found) {
found = checkPath(prefix, reverseOrder, returnKey, returnStrings, matches,
name, null, localeSuffix, suffix, key);
if (found && (single || !returnStrings)) {
return matches;
}
}
} else {
final boolean found = checkPath(prefix, reverseOrder, returnKey, returnStrings, matches,
name, null, localeSuffix, suffix, key);
if (found && (single || !returnStrings)) {
return matches;
}
}
}
// after that check the whole resources tree
// e.g. 1. application, 2. library or renderkit
for (final Theme currentTheme : theme.getFallbackList()) {// theme loop
for (final String resourceDirectory : tobagoConfig.getResourceDirs()) {
for (final String browserType : browser.getFallbackList()) { // browser loop
for (final String localeSuffix : locales) { // locale loop
if (production) {
boolean found = checkPath(prefix, reverseOrder, returnKey, returnStrings, matches,
resourceDirectory, contentType, currentTheme, browserType, subDir, name, MINIMIZE_SUFFIX,
localeSuffix, suffix, key);
if (found && (single || !returnStrings)) {
return matches;
}
if (!found) {
found = checkPath(prefix, reverseOrder, returnKey, returnStrings, matches,
resourceDirectory, contentType, currentTheme, browserType, subDir, name, null,
localeSuffix, suffix, key);
if (found && (single || !returnStrings)) {
return matches;
}
}
} else {
final boolean found = checkPath(prefix, reverseOrder, returnKey, returnStrings, matches,
resourceDirectory, contentType, currentTheme, browserType, subDir, name, null,
localeSuffix, suffix, key);
if (found && (single || !returnStrings)) {
return matches;
}
}
}
}
}
}
if (matches.isEmpty()) {
// XXX hack for Tobago 2.0.x backward compatibility: renaming of style.css to tobago.css
// XXX style.css should be collected, but missing should be ignored
if ("style/style".equals(name) && ".css".equals(suffix)) {
ignoreMissing = true;
}
if (!ignoreMissing) {
LOG.error("Path not found, and no fallback. Using empty string.\n"
+ "resourceDirs = '" + tobagoConfig.getResourceDirs()
+ "' contentType = '" + contentType
+ "' theme = '" + theme.getName()
+ "' browser = '" + browser
+ "' subDir = '" + subDir
+ "' name = '" + name
+ "' suffix = '" + suffix
+ "' key = '" + key