001/* 002 * File : 003 * Date : 004 * Version: 005 * 006 * This library is part of OpenCms - 007 * the Open Source Content Management System 008 * 009 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 010 * 011 * This library is free software; you can redistribute it and/or 012 * modify it under the terms of the GNU Lesser General Public 013 * License as published by the Free Software Foundation; either 014 * version 2.1 of the License, or (at your option) any later version. 015 * 016 * This library is distributed in the hope that it will be useful, 017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 019 * Lesser General Public License for more details. 020 * 021 * For further information about Alkacon Software GmbH & Co. KG, please see the 022 * company website: http://www.alkacon.com 023 * 024 * For further information about OpenCms, please see the 025 * project website: http://www.opencms.org 026 * 027 * You should have received a copy of the GNU Lesser General Public 028 * License along with this library; if not, write to the Free Software 029 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 030 */ 031 032package org.opencms.workplace.threads; 033 034import org.opencms.file.CmsObject; 035import org.opencms.main.CmsLog; 036import org.opencms.relations.CmsExternalLinksValidator; 037import org.opencms.report.A_CmsReportThread; 038import org.opencms.workplace.threads.Messages; 039 040import org.apache.commons.logging.Log; 041 042/** 043 * Thread for extern link validation. <p> 044 * 045 * @since 6.0.0 046 */ 047public class CmsExternalLinksValidatorThread extends A_CmsReportThread { 048 049 /** The log object for this class. */ 050 private static final Log LOG = CmsLog.getLog(CmsExternalLinksValidatorThread.class); 051 052 /** the CmsObject to use. */ 053 private CmsObject m_cms; 054 055 /** reference to the HtmlImport. */ 056 private CmsExternalLinksValidator m_externLinkValidator; 057 058 /** 059 * Constructor, creates a new CmsExternLinkValidationThread.<p> 060 * 061 * @param cms the current CmsObject 062 */ 063 public CmsExternalLinksValidatorThread(CmsObject cms) { 064 065 super(cms, Messages.get().getBundle().key(Messages.GUI_POINTER_VALIDATION_THREAD_NAME_0)); 066 initHtmlReport(cms.getRequestContext().getLocale()); 067 m_cms = cms; 068 m_cms.getRequestContext().setUpdateSessionEnabled(false); 069 m_externLinkValidator = new CmsExternalLinksValidator(); 070 m_externLinkValidator.setReport(getReport()); 071 } 072 073 /** 074 * @see org.opencms.report.A_CmsReportThread#getReportUpdate() 075 */ 076 @Override 077 public String getReportUpdate() { 078 079 return getReport().getReportUpdate(); 080 } 081 082 /** 083 * The run method which starts the import process.<p> 084 */ 085 @Override 086 public void run() { 087 088 try { 089 // do the validation 090 m_externLinkValidator.validateLinks(m_cms); 091 } catch (Throwable e) { 092 getReport().println(e); 093 if (LOG.isErrorEnabled()) { 094 LOG.error(e.getLocalizedMessage()); 095 } 096 } 097 } 098}