Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginSaveAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginSaveAction.java,v
diff -u -r1.9 -r1.10
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginSaveAction.java 23 Apr 2007 06:42:04 -0000 1.9
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginSaveAction.java 15 Nov 2012 23:23:38 -0000 1.10
@@ -71,18 +71,13 @@
*/
public class LoginSaveAction extends LamsDispatchAction {
- private static final String LOGO_TAG = "";
-
- private static final String ALPHABET = "ABCDEFGHIJKLMOPQRSTUWVXYZabcdefghijklmnopqrstuvwxyz_1234567890";
-
private static final String IMAGE_FOLDER_SUFFIX = File.separatorChar
+ "lams-www.war" + File.separatorChar + "images";
- private static final String LOGIN_PAGE_PATH_SUFFIX = File.separatorChar
- + "lams-central.war" + File.separatorChar + "login.jsp";
-
private static final String NEWS_PAGE_PATH_SUFFIX = File.separatorChar
+ "lams-www.war" + File.separatorChar + "news.html";
+
+ private static final String LOGO_FILENAME = "lams_login.gif";
public ActionForward save(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
@@ -100,9 +95,8 @@
}
if (errors.isEmpty()) {
if ((file != null) && (file.getFileSize() != 0)) {
- String fileName = fixBuggyFileName(file.getFileName());
- createImageFile(file, fileName);
- updateLoginPage(buildURL(fileName));
+ updateImageFile(file, LOGO_FILENAME);
+
}
updateNewsPage(loginMaintainForm.getString("news"));
} else {
@@ -112,28 +106,6 @@
return mapping.findForward("sysadmin");
}
- private String fixBuggyFileName(String fileName) {
- fileName = generateRandomFileName() + fileName.substring(fileName.lastIndexOf('.'));
- int i=0;
- while(new File(Configuration.get(ConfigurationKeys.LAMS_EAR_DIR)
- + IMAGE_FOLDER_SUFFIX + File.separatorChar + fileName).exists()){
- fileName = fileName.replace(".", new Integer(i).toString());
- i++;
- }
- log.debug("generated filename " + fileName);
- return fileName;
- }
-
- private String generateRandomFileName() {
- StringBuilder name = new StringBuilder();
- int length = 1 + new Random().nextInt(ALPHABET.length());
- for (int i = 0; i < length; i++) {
- name.append(ALPHABET.charAt(new Random().nextInt(ALPHABET.length())));
- }
- log.debug("generated random name " + name);
- return name.toString();
- }
-
private void updateNewsPage(String news) throws IOException {
BufferedWriter bWriter = null;
try {
@@ -149,42 +121,8 @@
}
}
- private void updateLoginPage(String url) throws IOException {
- BufferedReader bReader = null;
- BufferedWriter bWriter = null;
- try {
- bReader = new BufferedReader(new FileReader(
- Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + LOGIN_PAGE_PATH_SUFFIX));
- StringBuilder source = new StringBuilder();
- String line = bReader.readLine();
- while (line != null) {
- source.append(line).append('\n');
- line = bReader.readLine();
- }
- int index = source.indexOf(LOGO_TAG);
- if (index != -1) {
- int startIndex = index + LOGO_TAG.length();
- int endIndex = source.indexOf("\"", startIndex);
- source.replace(startIndex, endIndex, url);
- bWriter = new BufferedWriter(new FileWriter(
- Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + LOGIN_PAGE_PATH_SUFFIX));
- bWriter.write(source.toString());
- bWriter.flush();
- }
- } finally {
- if (bReader != null)
- bReader.close();
- if(bWriter != null)
- bWriter.close();
- }
- }
- private static String buildURL(String fileName)
- throws UnsupportedEncodingException {
- return "/www/images/" + fileName;
- }
-
- private void createImageFile(FormFile file, String fileName)
+ private void updateImageFile(FormFile file, String fileName)
throws IOException {
File imagesFolder = new File(
Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + IMAGE_FOLDER_SUFFIX);
Index: lams_central/web/login.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_central/web/login.jsp,v
diff -u -r1.49 -r1.50
--- lams_central/web/login.jsp 15 Aug 2012 10:59:18 -0000 1.49
+++ lams_central/web/login.jsp 15 Nov 2012 23:33:09 -0000 1.50
@@ -75,7 +75,7 @@