001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software GmbH & Co. KG, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.workplace.tools.database;
029
030import org.opencms.jsp.CmsJspActionElement;
031import org.opencms.ui.apps.dbmanager.CmsStaticExportThread;
032import org.opencms.workplace.CmsReport;
033import org.opencms.workplace.CmsWorkplaceSettings;
034
035import javax.servlet.http.HttpServletRequest;
036import javax.servlet.http.HttpServletResponse;
037import javax.servlet.jsp.JspException;
038import javax.servlet.jsp.PageContext;
039
040/**
041 * Provides an output window for a CmsReport.<p>
042 *
043 * @since 6.0.0
044 */
045public class CmsStaticExportReport extends CmsReport {
046
047    /** The dialog type. */
048    public static final String DIALOG_TYPE = "sync";
049
050    /**
051     * Public constructor.<p>
052     *
053     * @param jsp an initialized JSP action element
054     */
055    public CmsStaticExportReport(CmsJspActionElement jsp) {
056
057        super(jsp);
058    }
059
060    /**
061     * Public constructor with JSP variables.<p>
062     *
063     * @param context the JSP page context
064     * @param req the JSP request
065     * @param res the JSP response
066     */
067    public CmsStaticExportReport(PageContext context, HttpServletRequest req, HttpServletResponse res) {
068
069        this(new CmsJspActionElement(context, req, res));
070    }
071
072    /**
073     * Performs the move report, will be called by the JSP page.<p>
074     *
075     * @throws JspException if problems including sub-elements occur
076     */
077    public void actionReport() throws JspException {
078
079        // save initialized instance of this class in request attribute for included sub-elements
080        getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
081        switch (getAction()) {
082            case ACTION_REPORT_UPDATE:
083                setParamAction(REPORT_UPDATE);
084                getJsp().include(FILE_REPORT_OUTPUT);
085                break;
086            case ACTION_REPORT_BEGIN:
087            case ACTION_CONFIRMED:
088            default:
089                CmsStaticExportThread thread = new CmsStaticExportThread(getCms());
090                thread.start();
091                setParamAction(REPORT_BEGIN);
092                setParamThread(thread.getUUID().toString());
093                getJsp().include(FILE_REPORT_OUTPUT);
094                break;
095        }
096    }
097
098    /**
099     * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
100     */
101    @Override
102    protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {
103
104        // fill the parameter values in the get/set methods
105        fillParamValues(request);
106        // set the dialog type
107        setParamDialogtype(DIALOG_TYPE);
108        // set the action for the JSP switch
109        if (DIALOG_CONFIRMED.equals(getParamAction())) {
110            setAction(ACTION_CONFIRMED);
111        } else if (REPORT_UPDATE.equals(getParamAction())) {
112            setAction(ACTION_REPORT_UPDATE);
113        } else if (REPORT_BEGIN.equals(getParamAction())) {
114            setAction(ACTION_REPORT_BEGIN);
115        } else if (REPORT_END.equals(getParamAction())) {
116            setAction(ACTION_REPORT_END);
117        } else if (DIALOG_CANCEL.equals(getParamAction())) {
118            setAction(ACTION_CANCEL);
119        } else {
120            setAction(ACTION_DEFAULT);
121            // add the title for the dialog
122            setParamTitle(Messages.get().getBundle(getLocale()).key(Messages.GUI_TITLE_STATICEXPORT_0));
123        }
124    }
125}