001: /*
002: * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/database/CmsDatabaseImportFromHttp.java,v $
003: * Date : $Date: 2008-02-27 12:05:51 $
004: * Version: $Revision: 1.14 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.workplace.tools.database;
033:
034: import org.opencms.jsp.CmsJspActionElement;
035: import org.opencms.main.CmsException;
036: import org.opencms.main.OpenCms;
037: import org.opencms.workplace.administration.A_CmsImportFromHttp;
038: import org.opencms.workplace.tools.CmsToolDialog;
039: import org.opencms.workplace.tools.CmsToolManager;
040:
041: import java.io.IOException;
042: import java.util.HashMap;
043: import java.util.Map;
044:
045: import javax.servlet.ServletException;
046: import javax.servlet.http.HttpServletRequest;
047: import javax.servlet.http.HttpServletResponse;
048: import javax.servlet.jsp.PageContext;
049:
050: /**
051: * Class to upload a zip file containing VFS resources with HTTP upload.<p>
052: *
053: * @author Andreas Zahner
054: * @author Michael Emmerich
055: *
056: * @version $Revision: 1.14 $
057: *
058: * @since 6.0.0
059: */
060: public class CmsDatabaseImportFromHttp extends A_CmsImportFromHttp {
061:
062: /** The dialog URI. */
063: public static final String DIALOG_URI = PATH_WORKPLACE
064: + "admin/database/importhttp.jsp";
065:
066: /** Keep permissions request parameter name. */
067: public static final String PARAM_KEEPPERMISSIONS = "keepPermissions";
068:
069: /** The keep permissions flag stored by the check box widget. */
070: private String m_keepPermissions;
071:
072: /**
073: * Public constructor with JSP action element.<p>
074: *
075: * @param jsp an initialized JSP action element
076: */
077: public CmsDatabaseImportFromHttp(CmsJspActionElement jsp) {
078:
079: super (jsp);
080: }
081:
082: /**
083: * Public constructor with JSP variables.<p>
084: *
085: * @param context the JSP page context
086: * @param req the JSP request
087: * @param res the JSP response
088: */
089: public CmsDatabaseImportFromHttp(PageContext context,
090: HttpServletRequest req, HttpServletResponse res) {
091:
092: this (new CmsJspActionElement(context, req, res));
093: }
094:
095: /**
096: * @see org.opencms.workplace.administration.A_CmsImportFromHttp#actionCommit()
097: */
098: public void actionCommit() throws IOException, ServletException {
099:
100: try {
101: copyFileToServer(OpenCms.getSystemInfo()
102: .getPackagesRfsPath());
103: } catch (CmsException e) {
104: // error copying the file to the OpenCms server
105: setException(e);
106: return;
107: }
108: Map params = new HashMap();
109: params.put(PARAM_FILE, getParamImportfile());
110: params.put(PARAM_KEEPPERMISSIONS, getParamKeeppermissions());
111: // set style to display report in correct layout
112: params.put(PARAM_STYLE, CmsToolDialog.STYLE_NEW);
113: // set close link to get back to overview after finishing the import
114: params.put(PARAM_CLOSELINK, CmsToolManager.linkForToolPath(
115: getJsp(), "/database"));
116: // redirect to the report output JSP
117: getToolManager().jspForwardPage(this ,
118: CmsDatabaseImportFromServer.IMPORT_ACTION_REPORT,
119: params);
120: }
121:
122: /**
123: * @see org.opencms.workplace.administration.A_CmsImportFromHttp#getDialogReturnUri()
124: */
125: public String getDialogReturnUri() {
126:
127: return DIALOG_URI;
128: }
129:
130: /**
131: * @see org.opencms.workplace.administration.A_CmsImportFromHttp#getImportMessage()
132: */
133: public String getImportMessage() {
134:
135: return key(Messages.GUI_DATABASE_IMPORT_FILE_0);
136: }
137:
138: /**
139: * Returns the keepPermissions parameter.<p>
140: *
141: * @return the keepPermissions parameter
142: */
143: public String getParamKeeppermissions() {
144:
145: return m_keepPermissions;
146: }
147:
148: /**
149: * @see org.opencms.workplace.administration.A_CmsImportFromHttp#getStarttext()
150: */
151: public String getStarttext() {
152:
153: return key(Messages.GUI_DATABASE_IMPORT_BLOCK_0);
154: }
155:
156: /**
157: * Sets the keepPermissions parameter.<p>
158: *
159: * @param keepPermissions the keepPermissions parameter
160: */
161: public void setParamKeeppermissions(String keepPermissions) {
162:
163: m_keepPermissions = keepPermissions;
164: }
165:
166: /**
167: * @see org.opencms.workplace.CmsWorkplace#initMessages()
168: */
169: protected void initMessages() {
170:
171: // add specific dialog resource bundle
172: addMessages(Messages.get().getBundleName());
173: // add default resource bundles
174: addMessages(org.opencms.workplace.Messages.get()
175: .getBundleName());
176: addMessages(org.opencms.workplace.tools.Messages.get()
177: .getBundleName());
178: }
179: }
|