1 6 7 package org.contineo.actions.setup; 8 9 import javax.servlet.http.HttpServletRequest ; 10 import javax.servlet.http.HttpServletResponse ; 11 import org.apache.log4j.Level; 12 import org.apache.log4j.Logger; 13 import org.apache.struts.action.Action; 14 import org.apache.struts.action.ActionForm; 15 import org.apache.struts.action.ActionForward; 16 import org.apache.struts.action.ActionMapping; 17 import org.contineo.core.FileBean; 18 import org.contineo.core.LoggingManager; 19 import org.contineo.core.config.BackupConfigurator; 20 import org.contineo.forms.BackupForm; 21 26 public class SaveBackupAction extends Action { 27 28 32 private Logger logger; 33 34 35 36 public SaveBackupAction() { 37 logger = LoggingManager.getLogger(this.getClass()); 38 } 39 40 public ActionForward execute(ActionMapping mapping, 41 ActionForm form, HttpServletRequest request, 42 HttpServletResponse response) { 43 ActionForward actionForward = new ActionForward(); 44 try { 45 BackupForm backupForm = (BackupForm)form; 46 BackupConfigurator conf = new BackupConfigurator(); 47 conf.setEnabled(backupForm.isEnable()); 48 conf.setLocation(backupForm.getPath()); 49 conf.write(); 50 if (backupForm.isEnable()) 51 FileBean.createDir(backupForm.getPath()); 52 actionForward = mapping.findForward("choosedblevel"); 53 } catch (Exception e) { 54 if (logger.isEnabledFor(Level.ERROR)) 55 logger.error(e.getMessage()); 56 actionForward = mapping.findForward("error"); 57 } 58 return actionForward; 59 } 60 } 61 | Popular Tags |