Skip to content

Commit

Permalink
SAK-29334 WebDAV instructions page throws NPE except if your language is
Browse files Browse the repository at this point in the history
English
  • Loading branch information
Gao-Jun committed Oct 8, 2015
1 parent 4238764 commit a8980f1
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5688,15 +5688,24 @@ else if(parts.length >= 3)
int extIndex = webdav_instructions.indexOf(".html");
String webdav_doc = webdav_instructions.substring(0,extIndex).trim();
String locale = new ResourceLoader().getLocale().getLanguage();
String country = new ResourceLoader().getLocale().getCountry();

if ((locale == null) || locale.equalsIgnoreCase("en") || (locale.trim().length()==0)){
webdav_instructions = ServerConfigurationService.getString("webdav.instructions.url");
}else{
String locale_webdav_instructions = webdav_doc + "_" + locale + ".html";
String filePath = getServletConfig().getServletContext().getRealPath( ".."+locale_webdav_instructions );
File localeFile = new File( filePath );
if ( localeFile.exists() )
webdav_instructions = locale_webdav_instructions;
String locale_country_webdav_instructions = String.format("%s_%s_%s.html", webdav_doc, locale, country);
File contentRoot = new File(getServletContext().getRealPath("/"));
File localeFile;
localeFile = new File(contentRoot.getParent(), locale_country_webdav_instructions);
if (localeFile.exists()){
webdav_instructions = locale_country_webdav_instructions;
} else {
String locale_webdav_instructions = String.format("%s_%s.html", webdav_doc, locale);
localeFile = new File(contentRoot.getParent(), locale_webdav_instructions);
if ( localeFile.exists() ) {
webdav_instructions = locale_webdav_instructions;
}
}
}

context.put("webdav_instructions" ,webdav_instructions);
Expand Down

0 comments on commit a8980f1

Please sign in to comment.