Index: lams_admin/conf/language/lams/ApplicationResources.properties
===================================================================
RCS file: /usr/local/cvsroot/lams_admin/conf/language/lams/ApplicationResources.properties,v
diff -u -r1.2 -r1.3
--- lams_admin/conf/language/lams/ApplicationResources.properties 20 Feb 2007 03:16:20 -0000 1.2
+++ lams_admin/conf/language/lams/ApplicationResources.properties 30 Mar 2007 03:41:00 -0000 1.3
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_admin/conf/language/lams/ApplicationResources_en_AU.properties,v
diff -u -r1.2 -r1.3
--- lams_admin/conf/language/lams/ApplicationResources_en_AU.properties 20 Feb 2007 03:16:20 -0000 1.2
+++ lams_admin/conf/language/lams/ApplicationResources_en_AU.properties 30 Mar 2007 03:41:00 -0000 1.3
@@ -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
===================================================================
RCS file: /usr/local/cvsroot/lams_admin/conf/xdoclet/struts-forms.xml,v
diff -u -r1.24 -r1.25
--- lams_admin/conf/xdoclet/struts-forms.xml 20 Dec 2006 04:53:07 -0000 1.24
+++ lams_admin/conf/xdoclet/struts-forms.xml 30 Mar 2007 03:41:00 -0000 1.25
@@ -107,4 +107,8 @@
+
+
+
+
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CleanupTempFilesAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CleanupTempFilesAction.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CleanupTempFilesAction.java 30 Mar 2007 03:41:00 -0000 1.1
@@ -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: CleanupTempFilesAction.java,v 1.1 2007/03/30 03:41:00 jliew Exp $ */
+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" %>
+
+