1 31 32 package org.opencms.workplace.tools.content.check; 33 34 import org.opencms.file.CmsFile; 35 import org.opencms.file.CmsObject; 36 import org.opencms.file.CmsResource; 37 import org.opencms.main.CmsException; 38 import org.opencms.xml.content.CmsXmlContent; 39 import org.opencms.xml.content.CmsXmlContentFactory; 40 41 import java.util.ArrayList ; 42 import java.util.List ; 43 44 55 public class CmsContentCheckResource { 56 57 58 private byte[] m_content; 59 60 61 private List m_errors; 62 63 64 private CmsResource m_resource; 65 66 67 private List m_warnings; 68 69 70 private CmsXmlContent m_xmlcontent; 71 72 77 public CmsContentCheckResource(CmsResource res) { 78 79 m_resource = res; 80 m_content = null; 81 m_xmlcontent = null; 82 m_errors = new ArrayList (); 83 m_warnings = new ArrayList (); 84 } 85 86 90 public void addError(String error) { 91 92 m_errors.add(error); 93 } 94 95 99 public void addErrors(List errors) { 100 101 m_errors.addAll(errors); 102 } 103 104 108 public void addWarning(String warning) { 109 110 m_warnings.add(warning); 111 } 112 113 117 public void addWarnings(List warnings) { 118 119 m_warnings.addAll(warnings); 120 } 121 122 127 public byte[] getContent() { 128 129 return m_content; 130 } 131 132 136 public List getErrors() { 137 138 return m_errors; 139 } 140 141 146 public CmsResource getResource() { 147 148 return m_resource; 149 } 150 151 156 public String getResourceName() { 157 158 return m_resource.getRootPath(); 159 } 160 161 165 public List getWarnings() { 166 167 return m_warnings; 168 } 169 170 175 public CmsXmlContent getXmlContent() { 176 177 return m_xmlcontent; 178 } 179 180 188 public void upgradeContent(CmsObject cms) throws CmsException { 189 190 if (m_content == null) { 191 m_content = CmsFile.upgrade(m_resource, cms).getContents(); 192 } 193 } 194 195 203 public void upgradeXmlContent(CmsObject cms) throws CmsException { 204 205 if (m_xmlcontent == null) { 206 CmsFile file = CmsFile.upgrade(m_resource, cms); 207 m_xmlcontent = CmsXmlContentFactory.unmarshal(cms, file); 208 } 209 } 210 } 211 | Popular Tags |