Index: lams_admin/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r3f3f34c22194aeaf302e1fd332925dffd35019aa -r4d39e9dca40fc4b974cb775f27284fbd582c3615 --- lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 3f3f34c22194aeaf302e1fd332925dffd35019aa) +++ lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 4d39e9dca40fc4b974cb775f27284fbd582c3615) @@ -688,3 +688,9 @@ user.import.password.change.email.content.footer = LAMS label.import.email = Email users account activation emails msg.password.generated = for user name "{0}" the following password was created: {1} +sysadmin.cleanup = Clean up cache and files +sysadmin.cache.clear = Clear Hibernate cache +sysadmin.clear = Clear +sysadmin.cache.cleared = Cache cleared +sysadmin.garbage.clear = Run Garbage Collector +sysadmin.garbage.cleared = Garbage Collector triggered Index: lams_admin/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r3f3f34c22194aeaf302e1fd332925dffd35019aa -r4d39e9dca40fc4b974cb775f27284fbd582c3615 --- lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 3f3f34c22194aeaf302e1fd332925dffd35019aa) +++ lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 4d39e9dca40fc4b974cb775f27284fbd582c3615) @@ -685,3 +685,9 @@ user.import.password.change.email.content.footer = LAMS label.import.email = Email users account activation emails msg.password.generated = for user name "{0}" the following password was created: {1} +sysadmin.cleanup = Clean up cache and files +sysadmin.cache.clear = Clear Hibernate cache +sysadmin.clear = Clear +sysadmin.cache.cleared = Cache cleared +sysadmin.garbage.clear = Run Garbage Collector +sysadmin.garbage.cleared = Garbage Collector triggered Index: lams_admin/conf/language/lams/ApplicationResources_es_ES.properties =================================================================== diff -u -r3f3f34c22194aeaf302e1fd332925dffd35019aa -r4d39e9dca40fc4b974cb775f27284fbd582c3615 --- lams_admin/conf/language/lams/ApplicationResources_es_ES.properties (.../ApplicationResources_es_ES.properties) (revision 3f3f34c22194aeaf302e1fd332925dffd35019aa) +++ lams_admin/conf/language/lams/ApplicationResources_es_ES.properties (.../ApplicationResources_es_ES.properties) (revision 4d39e9dca40fc4b974cb775f27284fbd582c3615) @@ -685,3 +685,9 @@ user.import.password.change.email.content.footer = LAMS label.import.email = Enviar a los usuarios correos electrónicos de activación de cuentas msg.password.generated = para el nombre de usuario "{0}" se creó la siguiente contraseña: {1} +sysadmin.cleanup = Limpiar caché y archivos +sysadmin.cache.clear = Borrar caché de Hibernate +sysadmin.clear = Borrar +sysadmin.cache.cleared = Caché borrado +sysadmin.garbage.clear = Ejecutar JVM Garbage Collector +sysadmin.garbage.cleared = Se ha ejecutado Garbage Collection Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/AppAdminStartController.java =================================================================== diff -u -rdd60c645ebe32ff15180cff47caa583cb41b7ee1 -r4d39e9dca40fc4b974cb775f27284fbd582c3615 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/AppAdminStartController.java (.../AppAdminStartController.java) (revision dd60c645ebe32ff15180cff47caa583cb41b7ee1) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/AppAdminStartController.java (.../AppAdminStartController.java) (revision 4d39e9dca40fc4b974cb775f27284fbd582c3615) @@ -79,7 +79,7 @@ links = new ArrayList<>(); links.add(new LinkBean("logevent/start.do", "label.event.log")); - links.add(new LinkBean("cleanup/start.do", "appadmin.batch.temp.file.delete")); + links.add(new LinkBean("cleanup/start.do", "sysadmin.cleanup")); links.add(new LinkBean("cleanupPreviewLessons/start.do", "appadmin.batch.preview.lesson.delete")); links.add(new LinkBean("statistics/start.do", "admin.statistics.title")); groupedLinks.add(new Object[] { AdminConstants.START_MONITOR_LINKS, links }); Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CleanupController.java =================================================================== diff -u --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CleanupController.java (revision 0) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CleanupController.java (revision 4d39e9dca40fc4b974cb775f27284fbd582c3615) @@ -0,0 +1,151 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.admin.web.controller; + +import java.io.File; + +import javax.management.MalformedObjectNameException; +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.admin.web.form.CleanupForm; +import org.lamsfoundation.lams.usermanagement.Role; +import org.lamsfoundation.lams.util.FileUtil; +import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.util.TempDirectoryFilter; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.util.hibernate.HibernateSessionManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * @author jliew + */ +@Controller +@RequestMapping("/cleanup") +public class CleanupController { + private static Logger log = Logger.getLogger(CleanupController.class); + + @Autowired + @Qualifier("adminMessageService") + private MessageService messageService; + + @RequestMapping(path = "/start") + public String start(@ModelAttribute CleanupForm cleanupForm, HttpServletRequest request) throws Exception { + // check user is sysadmin + if (!(request.isUserInRole(Role.APPADMIN))) { + request.setAttribute("errorName", "CleanupAction"); + request.setAttribute("errorMessage", messageService.getMessage("error.need.sysadmin")); + return "error"; + } + + // check if url contains request for refresh folder sizes only + String action = WebUtil.readStrParam(request, "action", true); + if (action != null && StringUtils.equals(action, "refresh")) { + return refresh(cleanupForm, request); + } + return "cleanup"; + } + + @RequestMapping(path = "/files", method = RequestMethod.POST) + public String cleanUpFiles(@ModelAttribute CleanupForm cleanupForm, HttpServletRequest request) throws Exception { + // check user is sysadmin + if (!(request.isUserInRole(Role.APPADMIN))) { + request.setAttribute("errorName", "CleanupTempFilesAction"); + request.setAttribute("errorMessage", messageService.getMessage("error.need.sysadmin")); + return "error"; + } + + MultiValueMap errorMap = new LinkedMultiValueMap<>(); + Integer numDays = cleanupForm.getNumDays(); + + // delete directories if form has been submitted + if (numDays != null) { + if (numDays >= 0) { + int filesDeleted = FileUtil.cleanupOldFiles(FileUtil.getOldTempFiles(numDays)); + request.setAttribute("filesDeleted", + messageService.getMessage("msg.cleanup.files.deleted", new Integer[] { filesDeleted })); + } else { + errorMap.add("numDays", messageService.getMessage("error.non.negative.number.required")); + } + } + request.setAttribute("errorMap", errorMap); + return "cleanup"; + } + + @RequestMapping(path = "/cache", method = RequestMethod.POST) + public String cleanUpCache(HttpServletRequest request) throws MalformedObjectNameException { + // check user is sysadmin + if (!(request.isUserInRole(Role.APPADMIN))) { + request.setAttribute("errorName", "CleanupCacheAction"); + request.setAttribute("errorMessage", messageService.getMessage("error.need.sysadmin")); + return "error"; + } + + boolean cacheCleared = HibernateSessionManager.clearCache(); + return "redirect:start.do?cacheCleared=" + cacheCleared; + } + + @RequestMapping(path = "/garbage", method = RequestMethod.POST) + public String cleanUpGarbage(HttpServletRequest request) throws MalformedObjectNameException { + // check user is sysadmin + if (!(request.isUserInRole(Role.APPADMIN))) { + request.setAttribute("errorName", "CleanupGarbageAction"); + request.setAttribute("errorMessage", messageService.getMessage("error.need.sysadmin")); + return "error"; + } + + System.gc(); + return "redirect:start.do?garbageCollectorRun=true"; + } + + @RequestMapping("/refresh") + public String refresh(@ModelAttribute CleanupForm cleanupForm, HttpServletRequest request) throws Exception { + + // display temp files info + File oldFiles[] = FileUtil.getOldTempFiles(0); + long zipTotal = 0; + long tmpTotal = 0; + if (oldFiles != null) { + for (int i = 0; i < oldFiles.length; i++) { + if (oldFiles[i].getName().startsWith(TempDirectoryFilter.zip_prefix)) { + zipTotal += FileUtil.calculateFileSize(oldFiles[i]); + } else if (oldFiles[i].getName().startsWith(TempDirectoryFilter.tmp_prefix)) { + tmpTotal += FileUtil.calculateFileSize(oldFiles[i]); + } + } + } + request.setAttribute("zipTotal", zipTotal / 1024); + request.setAttribute("tmpTotal", tmpTotal / 1024); + + return "cleanup"; + } + +} Index: lams_admin/web/cleanup.jsp =================================================================== diff -u -r5b9f590b301c276f8df06b30c26981b0eb634e69 -r4d39e9dca40fc4b974cb775f27284fbd582c3615 --- lams_admin/web/cleanup.jsp (.../cleanup.jsp) (revision 5b9f590b301c276f8df06b30c26981b0eb634e69) +++ lams_admin/web/cleanup.jsp (.../cleanup.jsp) (revision 4d39e9dca40fc4b974cb775f27284fbd582c3615) @@ -6,7 +6,7 @@ - + ${title} @@ -17,45 +17,90 @@ - +

- - +
+
+ + + +
+ +
+ - -
-
- - - -

-
- - + +
+
+ + + +

+
+ + + +
    +
  • * : KB +
  • * : KB +
+ -
    -
  • * : KB -
  • * : KB -
- -

- -

- -

- - - -

: -

+

+ +

-
- - " /> + + + +

: +

+ +
+ " /> +
+
+
- +
+
+ + + +
+ +
+ + + + " /> + + + + +
+
+ +
+
+ + + +
+ +
+ + + + " /> + + + + +
+
Index: lams_gradebook/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r4fb0517551dd30568c65666806d235ad472be8bd -r4d39e9dca40fc4b974cb775f27284fbd582c3615 --- lams_gradebook/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 4fb0517551dd30568c65666806d235ad472be8bd) +++ lams_gradebook/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 4d39e9dca40fc4b974cb775f27284fbd582c3615) @@ -52,7 +52,6 @@ gradebook.exportcourse.lessonFeedback = Lesson feedback gradebook.exportcourse.mark = Mark gradebook.exportcourse.lesson = Lesson: {0} -gradebook.exportcourse.subcourse = Subcourse: {0} gradebook.exportcourse.progress = Progress gradebook.exportcourse.learner.name = Name gradebook.exportcourse.ok = Completed @@ -134,3 +133,4 @@ gradebook.monitor.releasemarks.email.content.thanks = Thank you gradebook.monitor.releasemarks.email.content.footer = LAMS gradebook.monitor.releasemarks.toggle.panel = Show marks release +gradebook.exportcourse.subcourse = Subcourse: {0} Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java =================================================================== diff -u -r5b9f590b301c276f8df06b30c26981b0eb634e69 -r4d39e9dca40fc4b974cb775f27284fbd582c3615 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 5b9f590b301c276f8df06b30c26981b0eb634e69) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 4d39e9dca40fc4b974cb775f27284fbd582c3615) @@ -26,7 +26,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -740,8 +739,6 @@ throw new ForumException("FileNotFoundException occured while trying to upload File" + e.getMessage()); } catch (RepositoryCheckedException e) { throw new ForumException("FileNotFoundException occured while trying to upload File" + e.getMessage()); - } catch (IOException e) { - throw new ForumException("FileNotFoundException occured while trying to upload File" + e.getMessage()); } } return node;