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.commons; 029 030import org.opencms.jsp.CmsJspActionElement; 031import org.opencms.util.CmsStringUtil; 032import org.opencms.workplace.CmsReport; 033import org.opencms.workplace.CmsWorkplaceSettings; 034import org.opencms.workplace.threads.CmsSynchronizeThread; 035 036import javax.servlet.http.HttpServletRequest; 037import javax.servlet.http.HttpServletResponse; 038import javax.servlet.jsp.JspException; 039import javax.servlet.jsp.PageContext; 040 041/** 042 * Provides an output window for a CmsReport.<p> 043 * 044 * @since 6.0.0 045 */ 046public class CmsSynchronizeReport extends CmsReport { 047 048 /** The dialog type. */ 049 public static final String DIALOG_TYPE = "sync"; 050 051 /** 052 * Public constructor.<p> 053 * 054 * @param jsp an initialized JSP action element 055 */ 056 public CmsSynchronizeReport(CmsJspActionElement jsp) { 057 058 super(jsp); 059 } 060 061 /** 062 * Public constructor with JSP variables.<p> 063 * 064 * @param context the JSP page context 065 * @param req the JSP request 066 * @param res the JSP response 067 */ 068 public CmsSynchronizeReport(PageContext context, HttpServletRequest req, HttpServletResponse res) { 069 070 this(new CmsJspActionElement(context, req, res)); 071 } 072 073 /** 074 * Performs the move report, will be called by the JSP page.<p> 075 * 076 * @throws JspException if problems including sub-elements occur 077 */ 078 public void actionReport() throws JspException { 079 080 // save initialized instance of this class in request attribute for included sub-elements 081 getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this); 082 switch (getAction()) { 083 case ACTION_REPORT_UPDATE: 084 setParamAction(REPORT_UPDATE); 085 getJsp().include(FILE_REPORT_OUTPUT); 086 break; 087 case ACTION_REPORT_BEGIN: 088 case ACTION_CONFIRMED: 089 setParamRefreshWorkplace(CmsStringUtil.TRUE); 090 //$FALL-THROUGH$ 091 default: 092 CmsSynchronizeThread thread = new CmsSynchronizeThread(getCms()); 093 thread.start(); 094 setParamAction(REPORT_BEGIN); 095 setParamThread(thread.getUUID().toString()); 096 getJsp().include(FILE_REPORT_OUTPUT); 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 (REPORT_UPDATE.equals(getParamAction())) { 115 setAction(ACTION_REPORT_UPDATE); 116 } else if (REPORT_BEGIN.equals(getParamAction())) { 117 setAction(ACTION_REPORT_BEGIN); 118 } else if (REPORT_END.equals(getParamAction())) { 119 setAction(ACTION_REPORT_END); 120 } else if (DIALOG_CANCEL.equals(getParamAction())) { 121 setAction(ACTION_CANCEL); 122 } else { 123 setAction(ACTION_DEFAULT); 124 // add the title for the dialog 125 setParamTitle(key(Messages.GUI_SYNC_FOLDERS_AND_FILES_0)); 126 } 127 } 128}