📄 cmsmergepages.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/workplace/tools/content/CmsMergePages.java,v $
* Date : $Date: 2006/03/31 13:59:16 $
* Version: $Revision: 1.15 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about Alkacon Software GmbH, please see the
* company website: http://www.alkacon.com
*
* For further information about OpenCms, please see the
* project website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.opencms.workplace.tools.content;
import org.opencms.file.CmsFile;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.file.types.CmsResourceTypeXmlPage;
import org.opencms.i18n.CmsLocaleManager;
import org.opencms.i18n.CmsMessages;
import org.opencms.jsp.CmsJspActionElement;
import org.opencms.main.CmsException;
import org.opencms.report.I_CmsReport;
import org.opencms.util.CmsStringUtil;
import org.opencms.workplace.CmsReport;
import org.opencms.workplace.CmsWorkplaceSettings;
import org.opencms.xml.page.CmsXmlPage;
import org.opencms.xml.page.CmsXmlPageFactory;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
/**
* Provides methods for the merge pages dialog.<p>
*
* @author Michael Emmerich
*
* @version $Revision: 1.15 $
*
* @since 6.0.0
*/
public class CmsMergePages extends CmsReport {
/** A constant representing the select option all templates. */
public static final String ALL = "ALL";
/** Key for pages found in folder 1 exclusivly. */
public static final int FOLDER1_EXCLUSIVE = 0;
/** Key for pages found in folder 2 exclusivly. */
public static final int FOLDER2_EXCLUSIVE = 1;
/** Key for pages found in both folders but as different types. */
public static final int FOLDERS_DIFFERENTTYPES = 4;
/** Key for pages found in both folders as individual resources. */
public static final int FOLDERS_EQUALNAMES = 3;
/** Key for pages found in both folders as siblings. */
public static final int FOLDERS_SIBLING = 2;
/** The dialog type. */
public static final String DIALOG_TYPE = "mergepages";
/** Request parameter name for the first folder to merge. */
public static final String PARAM_FOLDER1 = "folder1";
/** Request parameter name for the second folder to merge. */
public static final String PARAM_FOLDER2 = "folder2";
/** the cms object. */
private CmsObject m_cms;
/** the error message. */
private String m_errorMessage;
/** List of pages found in folder 1 exclusivly. */
private List m_folder1Exclusive;
/** List of pages found in folder 2 exclusivly. */
private List m_folder2Exclusive;
/** List of pages found in both folders but as different types. */
private List m_foldersDifferenttypes;
/** List of pages found in both folders as individual resources. */
private List m_foldersEqualnames;
/** List of pages found in both folders as siblings. */
private List m_foldersSibling;
/** The first folder to merge. */
private String m_paramFolder1;
/** The second folder to merge. */
private String m_paramFolder2;
/** the report for the output. */
private I_CmsReport m_report;
/**
* Public constructor with JSP action element.<p>
*
* @param jsp an initialized JSP action element
*/
public CmsMergePages(CmsJspActionElement jsp) {
super(jsp);
m_folder1Exclusive = new ArrayList();
m_folder2Exclusive = new ArrayList();
m_foldersSibling = new ArrayList();
m_foldersEqualnames = new ArrayList();
m_foldersDifferenttypes = new ArrayList();
}
/**
* Public constructor with JSP variables.<p>
*
* @param cms the current CmsObject
* @param context the JSP page context
* @param req the JSP request
* @param res the JSP response
*/
public CmsMergePages(CmsObject cms, PageContext context, HttpServletRequest req, HttpServletResponse res) {
this(new CmsJspActionElement(context, req, res));
m_cms = cms;
}
/**
* Merges the specified resources.<p>
*
* @param report the cms report
*/
public void actionMerge(I_CmsReport report) {
m_report = report;
m_report.println(Messages.get().container(Messages.RPT_MERGE_PAGES_BEGIN_0), I_CmsReport.FORMAT_HEADLINE);
try {
// collect all pages and sort them depending on their state
collectResources();
// merge all pages that can be merged
mergePages();
// cleanup
cleanup();
} catch (CmsException e) {
m_report.println(e);
}
}
/**
* Performs the move report, will be called by the JSP page.<p>
*
* @throws JspException if problems including sub-elements occur
*/
public void actionReport() throws JspException {
// save initialized instance of this class in request attribute for included sub-elements
getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
switch (getAction()) {
case ACTION_REPORT_END:
actionCloseDialog();
break;
case ACTION_REPORT_UPDATE:
setParamAction(REPORT_UPDATE);
getJsp().include(FILE_REPORT_OUTPUT);
break;
case ACTION_REPORT_BEGIN:
case ACTION_CONFIRMED:
default:
CmsMergePagesThread thread = new CmsMergePagesThread(getCms(), this);
setParamAction(REPORT_BEGIN);
setParamThread(thread.getUUID().toString());
getJsp().include(FILE_REPORT_OUTPUT);
break;
}
}
/**
* @see org.opencms.workplace.CmsWorkplace#getCms()
*/
public CmsObject getCms() {
if (m_cms == null) {
return super.getCms();
}
return m_cms;
}
/**
* Returns the errorMessage.<p>
*
* @return the errorMessage
*/
public String getErrorMessage() {
if (CmsStringUtil.isEmpty(m_errorMessage)) {
return "";
}
return m_errorMessage;
}
/**
* Returns the first folder.<p>
*
* @return the folder
*/
public String getParamFolder1() {
return m_paramFolder1;
}
/**
* Returns the second folder.<p>
*
* @return the folder
*/
public String getParamFolder2() {
return m_paramFolder2;
}
/**
* Sets the errorMessage.<p>
*
* @param errorMessage the errorMessage to set
*/
public void setErrorMessage(String errorMessage) {
m_errorMessage = errorMessage;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -