KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > action > core > backup > BackupAction


1 /*
2  * Copyright 2004 Blandware (http://www.blandware.com)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.blandware.atleap.webapp.action.core.backup;
17
18 import com.blandware.atleap.common.Constants;
19 import com.blandware.atleap.service.core.BackupManager;
20 import com.blandware.atleap.webapp.action.core.BaseAction;
21 import org.apache.struts.action.*;
22 import org.springframework.dao.DataAccessException;
23
24 import javax.servlet.http.HttpServletRequest JavaDoc;
25 import javax.servlet.http.HttpServletResponse JavaDoc;
26
27 /**
28  * <p>Action to backup database</p>
29  * <p/>
30  * <p><a HREF="BackupAction.java.htm"><i>View Source</i></a></p>
31  *
32  * @author Andrey Grebnev <a HREF="mailto:andrey.grebnev@blandware.com">&lt;andrey.grebnev@blandware.com&gt;</a>
33  * @version $Revision: 1.2 $ $Date: 2006/03/10 17:10:16 $
34  * @struts.action path="/core/backup/backup"
35  * validate="false"
36  * roles="core-backup-backup"
37  * @struts.action-forward name="listArchives"
38  * path="/core/backup/list.do"
39  * redirect="true"
40  * @struts.action-forward name="inputForward"
41  * path="/core/backup/list.do"
42  * @struts.action-forward name="unsatisfiable"
43  * path="/core/backup/list.do"
44  */

45 public class BackupAction extends BaseAction {
46
47     /**
48      * @param mapping The ActionMapping used to select this instance
49      * @param form The optional ActionForm bean for this request (if any)
50      * @param request The HTTP request we are proceeding
51      * @param response The HTTP response we are creating
52      * @return an ActionForward instance describing where and how
53      * control should be forwarded, or null if response
54      * has already been completed
55      */

56     public ActionForward execute(ActionMapping mapping, ActionForm form,
57                                  HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws Exception JavaDoc {
58
59         BackupManager backupManager = (BackupManager) getBean(Constants.BACKUP_MANAGER_BEAN);
60         try {
61             backupManager.backup();
62         } catch(DataAccessException ex) {
63             ActionMessages errors = new ActionMessages();
64             errors.add("cannotBackup", new ActionMessage("core.backup.errors.cannotBackup"));
65             saveErrors(request, errors);
66             return mapping.findForward("inputForward");
67         }
68
69         return mapping.findForward("listArchives");
70     }
71 }
72
Popular Tags