org.opencms.report.A_CmsReportThread Maven / Gradle / Ivy
Show all versions of opencms-test Show documentation
/*
* This library is part of OpenCms -
* the Open Source Content Management System
*
* Copyright (c) Alkacon Software GmbH & Co. KG (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 & Co. KG, 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.report;
import org.opencms.file.CmsObject;
import org.opencms.main.OpenCms;
import org.opencms.ui.A_CmsUI;
import org.opencms.util.CmsUUID;
import java.util.List;
import java.util.Locale;
/**
* Provides a common Thread class for the reports.
*
* @since 6.0.0
*/
public abstract class A_CmsReportThread extends Thread implements I_CmsReportThread {
/** The OpenCms request context to use. */
private CmsObject m_cms;
/** Indicates if the thread was already checked by the grim reaper. */
private boolean m_doomed;
/** The id of this report. */
private CmsUUID m_id;
/** The report that belongs to the thread. */
private I_CmsReport m_report;
/** The time this report is running. */
private long m_starttime;
/**
* Constructs a new report Thread with the given name.
*
* @param cms the current OpenCms context object
* @param name the name of the Thread
*/
protected A_CmsReportThread(CmsObject cms, String name) {
super(OpenCms.getThreadStore().getThreadGroup(), name);
// report Threads are never daemon Threads
setDaemon(false);
// the session in the cms context must not be updated when it is used in a report
m_cms = cms;
m_cms.getRequestContext().setUpdateSessionEnabled(false);
// generate the report Thread id
m_id = new CmsUUID();
setName(name + " [" + m_id + "]");
// new Threads are not doomed
m_doomed = false;
// set start time
m_starttime = System.currentTimeMillis();
// add this Thread to the main Thread store
OpenCms.getThreadStore().addThread(this);
}
/**
* Adds an error object to the list of errors that occurred during the report.
*
* @param obj the error object
*/
public void addError(Object obj) {
if (getReport() != null) {
getReport().addError(obj);
}
}
/**
* Returns the error exception in case there was an error during the execution of
* this Thread, null otherwise.
*
* @return the error exception in case there was an error, null otherwise
*/
public Throwable getError() {
return null;
}
/**
* Returns a list of all errors that occurred during the report.
*
* @return an error list that occurred during the report
*/
public List