KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > workplace > tools > database > CmsDatabaseImportFromHttp


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/database/CmsDatabaseImportFromHttp.java,v $
3  * Date : $Date: 2006/03/28 13:10:02 $
4  * Version: $Revision: 1.11 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.workplace.tools.database;
33
34 import org.opencms.jsp.CmsJspActionElement;
35 import org.opencms.main.CmsException;
36 import org.opencms.main.OpenCms;
37 import org.opencms.workplace.administration.A_CmsImportFromHttp;
38 import org.opencms.workplace.tools.CmsToolDialog;
39 import org.opencms.workplace.tools.CmsToolManager;
40
41 import java.io.IOException JavaDoc;
42 import java.util.HashMap JavaDoc;
43 import java.util.Map JavaDoc;
44
45 import javax.servlet.ServletException JavaDoc;
46 import javax.servlet.http.HttpServletRequest JavaDoc;
47 import javax.servlet.http.HttpServletResponse JavaDoc;
48 import javax.servlet.jsp.PageContext JavaDoc;
49
50 /**
51  * Class to upload a zip file containing VFS resources with HTTP upload.<p>
52  *
53  * @author Andreas Zahner
54  * @author Michael Emmerich
55  *
56  * @version $Revision: 1.11 $
57  *
58  * @since 6.0.0
59  */

60 public class CmsDatabaseImportFromHttp extends A_CmsImportFromHttp {
61
62     /** The dialog URI. */
63     public static final String JavaDoc DIALOG_URI = PATH_WORKPLACE + "admin/database/importhttp.jsp";
64
65     /**
66      * Public constructor with JSP action element.<p>
67      *
68      * @param jsp an initialized JSP action element
69      */

70     public CmsDatabaseImportFromHttp(CmsJspActionElement jsp) {
71
72         super(jsp);
73     }
74
75     /**
76      * Public constructor with JSP variables.<p>
77      *
78      * @param context the JSP page context
79      * @param req the JSP request
80      * @param res the JSP response
81      */

82     public CmsDatabaseImportFromHttp(PageContext JavaDoc context, HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res) {
83
84         this(new CmsJspActionElement(context, req, res));
85     }
86
87     /**
88      * @see org.opencms.workplace.administration.A_CmsImportFromHttp#actionCommit()
89      */

90     public void actionCommit() throws IOException JavaDoc, ServletException JavaDoc {
91
92         try {
93             copyFileToServer(OpenCms.getSystemInfo().getPackagesRfsPath());
94         } catch (CmsException e) {
95             // error copying the file to the OpenCms server
96
setException(e);
97             return;
98         }
99         Map JavaDoc params = new HashMap JavaDoc();
100         params.put(PARAM_FILE, getParamImportfile());
101         // set style to display report in correct layout
102
params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
103         // set close link to get back to overview after finishing the import
104
params.put(PARAM_CLOSELINK, CmsToolManager.linkForToolPath(getJsp(), "/database"));
105         // redirect to the report output JSP
106
getToolManager().jspForwardPage(this, CmsDatabaseImportFromServer.IMPORT_ACTION_REPORT, params);
107     }
108
109     /**
110      * @see org.opencms.workplace.administration.A_CmsImportFromHttp#getDialogReturnUri()
111      */

112     public String JavaDoc getDialogReturnUri() {
113
114         return DIALOG_URI;
115     }
116
117     /**
118      * @see org.opencms.workplace.administration.A_CmsImportFromHttp#getImportMessage()
119      */

120     public String JavaDoc getImportMessage() {
121
122         return key(Messages.GUI_DATABASE_IMPORT_FILE_0);
123     }
124
125     /**
126      * @see org.opencms.workplace.administration.A_CmsImportFromHttp#getStarttext()
127      */

128     public String JavaDoc getStarttext() {
129
130         return key(Messages.GUI_DATABASE_IMPORT_BLOCK_0);
131     }
132
133     /**
134      * @see org.opencms.workplace.CmsWorkplace#initMessages()
135      */

136     protected void initMessages() {
137
138         // add specific dialog resource bundle
139
addMessages(Messages.get().getBundleName());
140         // add default resource bundles
141
addMessages(org.opencms.workplace.Messages.get().getBundleName());
142         addMessages(org.opencms.workplace.tools.Messages.get().getBundleName());
143     }
144 }
Popular Tags