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.tools.content.check; 029 030import java.util.ArrayList; 031import java.util.HashMap; 032import java.util.List; 033import java.util.Map; 034 035/** 036 * This class holds the results of the content tests and provides methods to access the collected 037 * errors and warnings.<p> 038 * 039 * 040 * @since 6.1.2 041 */ 042public class CmsContentCheckResult { 043 044 /** List of all CmsContentCheckResource with collected warnings or errors. */ 045 private List m_allCheckResources; 046 047 /** List of all resources with collected warnings or errors. */ 048 private List m_allResources; 049 050 /** List of all CmsContentCheckResource with collected errors. */ 051 private List m_errorCheckResources; 052 053 /** List containing all recouces that collected errors. */ 054 private List m_errorResources; 055 056 /** 057 * Map containing all all collected errors. Resourcenames are used as keys, 058 * lists are used as values. 059 */ 060 private Map m_errors; 061 062 /** List of all CmsContentCheckResource with collected warnings. */ 063 private List m_warningCheckResources; 064 065 /** List containing all recouces that collected warnings. */ 066 private List m_warningResources; 067 068 /** 069 * Map containing all all collected warnings. Resourcenames are used as keys, 070 * lists are used as values. 071 */ 072 private Map m_warnings; 073 074 /** 075 * Constructor, creates an empty CmsContentCheckResult.<p> 076 */ 077 public CmsContentCheckResult() { 078 079 m_errors = new HashMap(); 080 m_warnings = new HashMap(); 081 m_errorResources = new ArrayList(); 082 m_warningResources = new ArrayList(); 083 m_allResources = new ArrayList(); 084 m_errorCheckResources = new ArrayList(); 085 m_warningCheckResources = new ArrayList(); 086 m_allCheckResources = new ArrayList(); 087 } 088 089 /** 090 * Adds the testing results of a CmsContentCheckResource to the result lists.<p> 091 * @param testResource the CmsContentCheckResource to add the results from 092 */ 093 public void addResult(CmsContentCheckResource testResource) { 094 095 List warnings = testResource.getWarnings(); 096 List errors = testResource.getErrors(); 097 // add the warnings if there were any 098 if ((warnings != null) && (warnings.size() > 0)) { 099 m_warnings.put(testResource.getResourceName(), warnings); 100 m_warningResources.add(testResource.getResource()); 101 m_warningCheckResources.add(testResource); 102 } 103 // add the errors if there were any 104 if ((errors != null) && (errors.size() > 0)) { 105 m_errors.put(testResource.getResourceName(), errors); 106 m_errorResources.add(testResource.getResource()); 107 m_errorCheckResources.add(testResource); 108 } 109 m_allResources.add(testResource.getResource()); 110 m_allCheckResources.add(testResource); 111 } 112 113 /** 114 * Gets a list of all CmsContentCheckResource that colleced an error or a warning during the content check.<p> 115 * @return List of CmsContentCheckResource which collected an error or a warning. 116 */ 117 public List getAllCheckResources() { 118 119 return m_allCheckResources; 120 } 121 122 /** 123 * Gets a list of all resources that colleced an error or a warning during the content check.<p> 124 * @return List of CmsResources which collected an error or a warning. 125 */ 126 public List getAllResources() { 127 128 return m_allResources; 129 } 130 131 /** 132 * Gets a list of all CmsContentCheckResource that colleced an error during the content check.<p> 133 * @return List of CmsContentCheckResource which collected an error. 134 */ 135 public List getErrorCheckResources() { 136 137 return m_errorCheckResources; 138 } 139 140 /** 141 * Gets a list of all resources that colleced an error during the content check.<p> 142 * @return List of CmsResources which collected an error. 143 */ 144 public List getErrorResources() { 145 146 return m_errorResources; 147 } 148 149 /** 150 * Gets a map of all error collected during the content check. <p> 151 * 152 * The map contains the complete resource root path as keys and a list of errors 153 * as values. 154 * @return map of collected warnings 155 */ 156 public Map getErrors() { 157 158 return m_errors; 159 } 160 161 /** 162 * Gets a list of errors collected during the content check for a given 163 * resource.<p> 164 * 165 * @param resourceName the complete root path of the resource to get the list from 166 * @return list of error messages or null if no warnings are found 167 */ 168 public List getErrors(String resourceName) { 169 170 return (List)m_errors.get(resourceName); 171 } 172 173 /** 174 * Gets a list of all CmsContentCheckResource that colleced a warning during the content check.<p> 175 * @return List of CmsContentCheckResource which collected a warning. 176 */ 177 public List getWarningCheckResources() { 178 179 return m_warningCheckResources; 180 } 181 182 /** 183 * Gets a list of all resources that colleced a warning during the content check.<p> 184 * @return List of CmsResources which collected a warning. 185 */ 186 public List getWarningResources() { 187 188 return m_warningResources; 189 } 190 191 /** 192 * Gets a map of all warnings collected during the content check. <p> 193 * 194 * The map contains the complete resource root path as keys and a list of warnings 195 * as values. 196 * @return map of collected warnings 197 */ 198 public Map getWarnings() { 199 200 return m_warnings; 201 } 202 203 /** 204 * Gets a list of warnings collected during the content check for a given 205 * resource.<p> 206 * 207 * @param resourceName the complete root path of the resource to get the list from 208 * @return list of warning messages or null if no warnings are found 209 */ 210 public List getWarnings(String resourceName) { 211 212 return (List)m_warnings.get(resourceName); 213 } 214 215}