Index: lams_admin/conf/language/lams/ApplicationResources.properties
===================================================================
diff -u -rb28804be5bf441fda8792c5d1a3ce27cbe43e2b3 -r558aecb906b5902a2bfa566c2e68abf2f97352a9
--- lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision b28804be5bf441fda8792c5d1a3ce27cbe43e2b3)
+++ lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 558aecb906b5902a2bfa566c2e68abf2f97352a9)
@@ -230,5 +230,13 @@
msg.importv1.created =Created {0} users and {1} groups.
msg.importv1.already.exist =The following logins already exist
msg.importv1.5 = Note that the passwords of the imported users will be reset, since LAMS 2 does not accept md5 passwords. They will be reset to the user's login.
+msg.cleanup.files.deleted = {0} files were deleted.
+msg.cleanup.warning = Warning: calculating the size of LAMS' temporary files may incur a performance hit on your server if it hasn't been cleaned out for a while.
+label.exported.learning.designs = exported learning designs
+label.imported.learning.designs = imported learning designs
+label.unknown = unknown
+msg.cleanup.actual.space = Depending on your server's file system, the actual space occupied may differ from the above.
+msg.cleanup.recommended = It's recommended to leave at least 1 day of temporary files in order not to remove anything that's currently in use.
+label.cleanup.delete = Delete temporary files older than this number of days
#======= End labels: Exported 224 labels for en AU =====
Index: lams_admin/conf/language/lams/ApplicationResources_en_AU.properties
===================================================================
diff -u -rb28804be5bf441fda8792c5d1a3ce27cbe43e2b3 -r558aecb906b5902a2bfa566c2e68abf2f97352a9
--- lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision b28804be5bf441fda8792c5d1a3ce27cbe43e2b3)
+++ lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 558aecb906b5902a2bfa566c2e68abf2f97352a9)
@@ -166,7 +166,7 @@
sysadmin.login.text =Update the text under the logo on the login page:
sysadmin.headline =System Administration
sysadmin.config.settings.edit =Edit Configuration Settings
-sysadmin.batch.temp.file.delete =Delete old temporary files
+sysadmin.batch.temp.file.delete =Delete Temporary Files
sysadmin.job.list =Job List
sysadmin.list.job =List scheduled jobs in Quartz queue
sysadmin.register.server =Register Server
@@ -230,5 +230,13 @@
msg.importv1.created =Created {0} users and {1} groups.
msg.importv1.already.exist =The following logins already exist
msg.importv1.5 = Note that the passwords of the imported users will be reset, since LAMS 2 does not accept md5 passwords. They will be reset to the user's login.
+msg.cleanup.files.deleted = {0} files were deleted.
+msg.cleanup.warning = Warning: calculating the size of LAMS' temporary files may incur a performance hit on your server if it hasn't been cleaned out for a while.
+label.exported.learning.designs = exported learning designs
+label.imported.learning.designs = imported learning designs
+label.unknown = unknown
+msg.cleanup.actual.space = Depending on your server's file system, the actual space occupied may differ from the above.
+msg.cleanup.recommended = It's recommended to leave at least 1 day of temporary files in order not to remove anything that's currently in use.
+label.cleanup.delete = Delete temporary files older than this number of days
#======= End labels: Exported 224 labels for en AU =====
Index: lams_admin/conf/xdoclet/struts-forms.xml
===================================================================
diff -u -r570bcc3eaf789d638c08cb96e0fec3e4a9ba6167 -r558aecb906b5902a2bfa566c2e68abf2f97352a9
--- lams_admin/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision 570bcc3eaf789d638c08cb96e0fec3e4a9ba6167)
+++ lams_admin/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision 558aecb906b5902a2bfa566c2e68abf2f97352a9)
@@ -107,4 +107,8 @@
+
+
+
+
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CleanupTempFilesAction.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CleanupTempFilesAction.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CleanupTempFilesAction.java (revision 558aecb906b5902a2bfa566c2e68abf2f97352a9)
@@ -0,0 +1,140 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+/* $Id$ */
+package org.lamsfoundation.lams.admin.web.action;
+
+import java.io.File;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.apache.struts.action.DynaActionForm;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+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;
+
+/**
+ * @author jliew
+ *
+ * @struts:action path="/cleanup"
+ * name="CleanupForm"
+ * scope="request"
+ * validate="false"
+ *
+ * @struts:action-forward name="cleanup" path=".cleanup"
+ * @struts:action-forward name="sysadmin" path=".sysadmin"
+ */
+public class CleanupTempFilesAction extends Action {
+
+ private static Logger log = Logger.getLogger(CleanupTempFilesAction.class);
+
+ public ActionForward execute(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ // check user is sysadmin
+ if (!(request.isUserInRole(Role.SYSADMIN))) {
+ request.setAttribute("errorName","CleanupTempFilesAction");
+ request.setAttribute("errorMessage",AdminServiceProxy
+ .getMessageService(getServlet().getServletContext())
+ .getMessage("error.need.sysadmin"));
+ return mapping.findForward("error");
+ }
+
+ if (isCancelled(request)) {
+ return mapping.findForward("sysadmin");
+ }
+
+ // 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(mapping, form, request, response);
+ }
+
+ ActionMessages errors = new ActionMessages();
+ DynaActionForm dynaForm = (DynaActionForm)form;
+ Integer numDays = (Integer)dynaForm.get("numDays");
+
+ // delete directories if form has been submitted
+ if (numDays != null) {
+ if (numDays >= 0) {
+ int filesDeleted = FileUtil.cleanupOldFiles(FileUtil.getOldTempFiles(numDays));
+ MessageService messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ String args[] = new String[1];
+ args[0] = new Integer(filesDeleted).toString();
+ request.setAttribute("filesDeleted", messageService.getMessage("msg.cleanup.files.deleted", args));
+ } else {
+ errors.add("numDays", new ActionMessage("error.non.negative.number.required"));
+ }
+ } else {
+ // recommended number of days to leave temp files
+ dynaForm.set("numDays", new Integer(1));
+ }
+
+ return mapping.findForward("cleanup");
+ }
+
+ public ActionForward refresh(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) 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
+<%@ page import="org.lamsfoundation.lams.util.FileUtil" %>
+<%@ page import="org.lamsfoundation.lams.util.TempDirectoryFilter" %>
+
+