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.workplace; 029 030import org.opencms.jsp.CmsJspActionElement; 031import org.opencms.main.I_CmsEventListener; 032import org.opencms.main.OpenCms; 033import org.opencms.workplace.CmsDialog; 034import org.opencms.workplace.CmsWorkplaceSettings; 035 036import java.util.HashMap; 037 038import javax.servlet.http.HttpServletRequest; 039import javax.servlet.http.HttpServletResponse; 040import javax.servlet.jsp.JspException; 041import javax.servlet.jsp.PageContext; 042 043/** 044 * Provides an output window for re-initialization of the OpenCms Workplace.<p> 045 * 046 * @since 6.0.0 047 */ 048public class CmsReInitWorkplace extends CmsDialog { 049 050 /** The dialog type. */ 051 public static final String DIALOG_TYPE = "reinitworkplace"; 052 053 /** 054 * Public constructor.<p> 055 * 056 * @param jsp an initialized JSP action element 057 */ 058 public CmsReInitWorkplace(CmsJspActionElement jsp) { 059 060 super(jsp); 061 } 062 063 /** 064 * Public constructor with JSP variables.<p> 065 * 066 * @param context the JSP page context 067 * @param req the JSP request 068 * @param res the JSP response 069 */ 070 public CmsReInitWorkplace(PageContext context, HttpServletRequest req, HttpServletResponse res) { 071 072 this(new CmsJspActionElement(context, req, res)); 073 } 074 075 /** 076 * Performs the re-initialization report, will be called by the JSP page.<p> 077 * 078 * @throws JspException if including the error JSP element fails 079 */ 080 public void actionReport() throws JspException { 081 082 // save initialized instance of this class in request attribute for included sub-elements 083 getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this); 084 switch (getAction()) { 085 case ACTION_CONFIRMED: 086 default: 087 try { 088 // re-initialize the workplace 089 OpenCms.getWorkplaceManager().initialize(getCms()); 090 // fire "clear caches" event to reload all cached resource bundles 091 OpenCms.fireCmsEvent(I_CmsEventListener.EVENT_CLEAR_CACHES, new HashMap<String, Object>()); 092 actionCloseDialog(); 093 } catch (Throwable t) { 094 // create a new Exception with custom message 095 includeErrorpage(this, t); 096 } 097 break; 098 } 099 } 100 101 /** 102 * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest) 103 */ 104 @Override 105 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 106 107 // fill the parameter values in the get/set methods 108 fillParamValues(request); 109 // set the dialog type 110 setParamDialogtype(DIALOG_TYPE); 111 // set the action for the JSP switch 112 if (DIALOG_CONFIRMED.equals(getParamAction())) { 113 setAction(ACTION_CONFIRMED); 114 } else if (DIALOG_CANCEL.equals(getParamAction())) { 115 setAction(ACTION_CANCEL); 116 } else { 117 setAction(ACTION_DEFAULT); 118 // add the title for the dialog 119 setParamTitle(key(Messages.GUI_WORKPLACE_REINIT_NAME_0)); 120 } 121 } 122}