Skip to content
Snippets Groups Projects
Commit ff8d8be0 authored by srosse's avatar srosse
Browse files

no-jira: backport some changes for weblogic compatibility

parent 712a5e4a
No related branches found
No related tags found
No related merge requests found
......@@ -129,6 +129,9 @@ public class StaticServlet extends HttpServlet {
expiration &= false;
} else {
staticAbsPath = WebappHelper.getContextRealPath(STATIC_DIR_NAME);
if(staticAbsPath == null) {
staticAbsPath = WebappHelper.getContextRoot() + STATIC_DIR_NAME;
}
expiration &= true;
}
......
......@@ -263,10 +263,16 @@ public class WebappHelper implements Initializable, Destroyable, ServletContextA
try {
String resource = "/serviceconfig/olat.properties";
Resource res = new ClassPathResource(resource);
String path = res.getFile().getParentFile().getParentFile().getAbsolutePath();
return path;
String protocol = res.getURL().getProtocol();
if("file".equals(protocol)) {
String path = res.getFile().getParentFile().getParentFile().getAbsolutePath();
return path;
} else {
return null;
}
} catch (IOException e) {
throw new StartupException("could not find classpath resource: 'serviceconfig/olat.properties'", e);
log.error("Path to build output is not accessible", e);
return null;
}
}
......
......@@ -1775,27 +1775,31 @@ public class I18nManager extends BasicManager {
} else {
// Fall back to compiled classes
srcPath = WebappHelper.getBuildOutputFolderRoot();
}
I18nDirectoriesVisitor srcVisitor = new I18nDirectoriesVisitor(srcPath);
FileUtils.visitRecursively(new File(srcPath), srcVisitor);
foundBundles = srcVisitor.getBundlesContainingI18nFiles();
// 3) For jUnit tests, add also the I18n test dir
if (Settings.isJUnitTest()) {
Resource testres = new ClassPathResource("olat.local.properties");
String jUnitSrcPath = null;
try {
jUnitSrcPath = testres.getFile().getAbsolutePath();
} catch (IOException e) {
throw new StartupException("Could not find classpath resource for: test-classes/olat.local.property ", e);
}
I18nDirectoriesVisitor juniSrcVisitor = new I18nDirectoriesVisitor(jUnitSrcPath);
FileUtils.visitRecursively(new File(jUnitSrcPath), juniSrcVisitor);
foundBundles.addAll(juniSrcVisitor.getBundlesContainingI18nFiles());
}
// Sort alphabetically
Collections.sort(foundBundles);
if(StringHelper.containsNonWhitespace(srcPath)) {
I18nDirectoriesVisitor srcVisitor = new I18nDirectoriesVisitor(srcPath);
FileUtils.visitRecursively(new File(srcPath), srcVisitor);
foundBundles = srcVisitor.getBundlesContainingI18nFiles();
// 3) For jUnit tests, add also the I18n test dir
if (Settings.isJUnitTest()) {
Resource testres = new ClassPathResource("olat.local.properties");
String jUnitSrcPath = null;
try {
jUnitSrcPath = testres.getFile().getAbsolutePath();
} catch (IOException e) {
throw new StartupException("Could not find classpath resource for: test-classes/olat.local.property ", e);
}
I18nDirectoriesVisitor juniSrcVisitor = new I18nDirectoriesVisitor(jUnitSrcPath);
FileUtils.visitRecursively(new File(jUnitSrcPath), juniSrcVisitor);
foundBundles.addAll(juniSrcVisitor.getBundlesContainingI18nFiles());
}
// Sort alphabetically
Collections.sort(foundBundles);
} else {
foundBundles = new ArrayList<String>();
}
return foundBundles;
}
......
......@@ -300,17 +300,35 @@ public class I18nModule extends AbstractOLATModule implements Destroyable {
}
}
File libDir = new File(WebappHelper.getBuildOutputFolderRoot());
for (String languageCode : i18nMgr.searchForAvailableLanguages(libDir)) {
if (availableLanguages.contains(languageCode)) {
logDebug("Skipping duplicate or previously loaded language::" + languageCode + " found in " + libDir.getAbsolutePath(), null);
continue;
String folderRoot = WebappHelper.getBuildOutputFolderRoot();
if(StringHelper.containsNonWhitespace(folderRoot)) {
//started from WEB-INF/classes
File libDir = new File(WebappHelper.getBuildOutputFolderRoot());
for (String languageCode : i18nMgr.searchForAvailableLanguages(libDir)) {
if (availableLanguages.contains(languageCode)) {
logDebug("Skipping duplicate or previously loaded language::" + languageCode + " found in " + libDir.getAbsolutePath(), null);
continue;
}
logDebug("Detected non-translatable language " + languageCode + " in " + libDir.getAbsolutePath(), null);
availableLanguages.add(languageCode);
// don't add to translatable languages nor to source lookup maps - those
// langs are read only
}
} else {
//started from jar (like weblogic does) -> load from the configuration
String enabledLanguagesConfig = getStringPropertyValue(CONFIG_LANGUAGES_ENABLED, false);
String[] enabledLanguages = enabledLanguagesConfig.split(",");
for (String languageCode : enabledLanguages) {
if (availableLanguages.contains(languageCode)) {
logWarn("Skipping duplicate or previously loaded language::" + languageCode + " found in "
+ LANG_PACKS_DIRECTORY.getAbsolutePath(), null);
continue;
}
logDebug("Force non-translatable language " + languageCode + " defined from enabledLanguages.", null);
availableLanguages.add(languageCode);
}
logDebug("Detected non-translatable language " + languageCode + " in " + libDir.getAbsolutePath(), null);
availableLanguages.add(languageCode);
// don't add to translatable languages nor to source lookup maps - those
// langs are read only
}
// 4) Add languages from the customizing lang packs
for (String languageCode : i18nMgr.searchForAvailableLanguages(LANG_PACKS_DIRECTORY)) {
if (availableLanguages.contains(languageCode)) {
......
......@@ -4,7 +4,7 @@
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="I18nManager" class="org.olat.core.util.i18n.I18nManager" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment