1 31 32 package org.opencms.workplace.threads; 33 34 import org.opencms.db.CmsPublishList; 35 import org.opencms.file.CmsObject; 36 import org.opencms.main.CmsLog; 37 import org.opencms.report.A_CmsReportThread; 38 import org.opencms.workplace.CmsWorkplaceSettings; 39 40 import org.apache.commons.logging.Log; 41 42 49 public class CmsXmlDocumentLinkValidatorThread extends A_CmsReportThread { 50 51 52 private static final Log LOG = CmsLog.getLog(CmsXmlDocumentLinkValidatorThread.class); 53 54 55 private CmsPublishList m_publishList; 56 57 58 private boolean m_savePublishList; 59 60 61 private CmsWorkplaceSettings m_settings; 62 63 77 public CmsXmlDocumentLinkValidatorThread(CmsObject cms) { 78 79 super(cms, Messages.get().getBundle().key( 80 Messages.GUI_HTML_LINK_VALIDATOR_THREAD_NAME_1, 81 new Object [] {cms.getRequestContext().currentProject().getName()})); 82 83 m_publishList = null; 84 m_savePublishList = false; 85 m_settings = null; 86 87 initHtmlReport(cms.getRequestContext().getLocale()); 88 start(); 89 } 90 91 108 public CmsXmlDocumentLinkValidatorThread(CmsObject cms, CmsPublishList publishList, CmsWorkplaceSettings settings) { 109 110 super(cms, Messages.get().getBundle().key( 111 Messages.GUI_HTML_LINK_VALIDATOR_THREAD_NAME_1, 112 new Object [] {cms.getRequestContext().currentProject().getName()})); 113 m_publishList = publishList; 114 m_savePublishList = true; 115 m_settings = settings; 116 117 initHtmlReport(cms.getRequestContext().getLocale()); 118 start(); 119 } 120 121 124 public String getReportUpdate() { 125 126 return getReport().getReportUpdate(); 127 } 128 129 132 public void run() { 133 134 CmsPublishList publishList = null; 135 136 try { 137 if (m_publishList == null) { 139 publishList = getCms().getPublishList(); 140 } else { 141 publishList = m_publishList; 142 } 143 144 getCms().validateHtmlLinks(publishList, getReport()); 146 147 if (m_savePublishList && m_settings != null) { 148 m_settings.setPublishList(publishList); 150 } 151 } catch (Exception e) { 152 if (m_savePublishList && m_settings != null) { 153 m_settings.setPublishList(null); 155 } 156 157 getReport().println(e); 158 LOG.error(Messages.get().getBundle().key(Messages.ERR_LINK_VALIDATION_0), e); 159 } 160 } 161 } | Popular Tags |