001/*
002 * This program is part of the Alkacon OpenCms Software library.
003 *
004 * This license applies to all programs, pages, Java classes, parts and
005 * modules of the Alkacon OpenCms Software library published by
006 * Alkacon Software GmbH & Co. KG, unless otherwise noted.
007 *
008 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
009 *
010 * This program is free software; you can redistribute it and/or modify
011 * it under the terms of the GNU General Public License as published by
012 * the Free Software Foundation; either version 2 of the License, or (at
013 * your option) any later version.
014 *
015 * This program is distributed in the hope that it will be useful, but
016 * WITHOUT ANY WARRANTY; without even the implied warranty of
017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
018 * General Public License for more details.
019 *
020 * You should have received a copy of the GNU General Public License
021 * along with this program; if not, write to the Free Software
022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
023 *
024 * For further information about Alkacon Software GmbH & Co. KG, please see the
025 * companys website: http://www.alkacon.com.
026 *
027 * For further information about OpenCms, please see the OpenCms project
028 * website: http://www.opencms.org.
029 *
030 * The names "Alkacon", "Alkacon Software GmbH & Co. KG" and "OpenCms" must not be used
031 * to endorse or promote products derived from this software without prior
032 * written permission. For written permission, please contact info@alkacon.com.
033 *
034 * Products derived from this software may not be called "Alkacon",
035 * "Alkacon Software GmbH & Co. KG" or "OpenCms", nor may "Alkacon", "Alkacon Software GmbH & Co. KG"
036 * or "OpenCms" appear in their name, without prior written permission of
037 * Alkacon Software GmbH & Co. KG.
038 *
039 * This program is also available under a commercial non-GPL license. For
040 * pricing and ordering information, please inquire at sales@alkacon.com.
041 */
042
043package org.opencms.workplace.tools.searchindex;
044
045import org.opencms.jsp.CmsJspActionElement;
046import org.opencms.ui.apps.searchindex.CmsIndexingReportThread;
047import org.opencms.workplace.CmsReport;
048import org.opencms.workplace.CmsWorkplaceSettings;
049
050import javax.servlet.http.HttpServletRequest;
051import javax.servlet.http.HttpServletResponse;
052import javax.servlet.jsp.JspException;
053import javax.servlet.jsp.PageContext;
054
055/**
056 * Implements methods for <code>CmsReport</code> to display the indexing progress.<p>
057 *
058 * @since 6.0.0
059 */
060public class CmsIndexingReport extends CmsReport {
061
062    /** Postfix for error.message dialog keys in the resource bundle.<p> */
063    public static final String DIALOG_TYPE = "indexing";
064
065    /**
066     * Public constructor.<p>
067     *
068     * @param jsp an initialized JSP action element
069     */
070    public CmsIndexingReport(CmsJspActionElement jsp) {
071
072        super(jsp);
073    }
074
075    /**
076     * Public constructor with JSP variables.<p>
077     *
078     * @param context the JSP page context
079     * @param req the JSP request
080     * @param res the JSP response
081     */
082    public CmsIndexingReport(PageContext context, HttpServletRequest req, HttpServletResponse res) {
083
084        this(new CmsJspActionElement(context, req, res));
085    }
086
087    /**
088     * Performs the report, will be called by the JSP page.<p>
089     *
090     * @throws JspException if problems including sub-elements occur
091     */
092    public void actionReport() throws JspException {
093
094        // save initialized instance of this class in request attribute for included sub-elements
095        getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
096        switch (getAction()) {
097            case ACTION_REPORT_UPDATE:
098                setParamAction(REPORT_UPDATE);
099                getJsp().include(FILE_REPORT_OUTPUT);
100                break;
101            case ACTION_REPORT_BEGIN:
102            case ACTION_CONFIRMED:
103            default:
104
105                CmsIndexingReportThread thread = new CmsIndexingReportThread(getCms(), null);
106                setParamAction(REPORT_BEGIN);
107                setParamThread(thread.getUUID().toString());
108                getJsp().include(FILE_REPORT_OUTPUT);
109                break;
110        }
111    }
112
113    /**
114     * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
115     */
116    @Override
117    protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {
118
119        // fill the parameter values in the get/set methods
120        fillParamValues(request);
121        // set the dialog type
122        setParamDialogtype(DIALOG_TYPE);
123        // set the action for the JSP switch
124        if (DIALOG_CONFIRMED.equals(getParamAction())) {
125            setAction(ACTION_CONFIRMED);
126        } else if (REPORT_UPDATE.equals(getParamAction())) {
127            setAction(ACTION_REPORT_UPDATE);
128        } else if (REPORT_BEGIN.equals(getParamAction())) {
129            setAction(ACTION_REPORT_BEGIN);
130        } else if (REPORT_END.equals(getParamAction())) {
131            setAction(ACTION_REPORT_END);
132        } else if (DIALOG_CANCEL.equals(getParamAction())) {
133            setAction(ACTION_CANCEL);
134        } else {
135            setAction(ACTION_DEFAULT);
136            // add the title for the dialog
137            setParamTitle(key("title." + getParamDialogtype()));
138        }
139    }
140
141}