001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://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: https://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: https://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.convertxml; 029 030import org.opencms.db.CmsResourceState; 031import org.opencms.file.CmsFile; 032import org.opencms.file.CmsObject; 033import org.opencms.file.CmsProject; 034import org.opencms.file.CmsPropertyDefinition; 035import org.opencms.file.CmsResource; 036import org.opencms.file.CmsResourceFilter; 037import org.opencms.i18n.CmsEncoder; 038import org.opencms.lock.CmsLock; 039import org.opencms.main.CmsException; 040import org.opencms.main.CmsLog; 041import org.opencms.main.OpenCms; 042import org.opencms.publish.CmsPublishManager; 043import org.opencms.report.A_CmsReportThread; 044import org.opencms.report.I_CmsReport; 045import org.opencms.util.CmsStringUtil; 046import org.opencms.util.CmsUUID; 047import org.opencms.util.CmsXsltUtil; 048import org.opencms.xml.CmsXmlException; 049import org.opencms.xml.content.CmsXmlContent; 050import org.opencms.xml.content.CmsXmlContentFactory; 051 052import java.util.Iterator; 053import java.util.List; 054 055import org.apache.commons.logging.Log; 056 057/** 058 * Converting xml contents according to new schema. 059 * <p> 060 * 061 * @since 7.0.5 062 */ 063public class CmsConvertXmlThread extends A_CmsReportThread { 064 065 /** The log object for this class. */ 066 private static final Log LOG = CmsLog.getLog(CmsConvertXmlThread.class); 067 068 /** Number of files transformed already. */ 069 private int m_alreadyTransformed; 070 071 /** Current CmsObject. */ 072 private CmsObject m_cmsObject; 073 074 /** Number of errors while transforming. */ 075 private int m_errorTransform; 076 077 /** Number of locked files during of transformation. */ 078 private int m_lockedFiles; 079 080 /** Number of files where encoding type could not become get. */ 081 private int m_missingEncodingType; 082 083 /** Settings. */ 084 private CmsConvertXmlSettings m_settings; 085 086 /** 087 * Creates a replace html tag Thread.<p> 088 * 089 * @param cms the current cms context. 090 * 091 * @param settings the settings needed to perform the operation. 092 */ 093 public CmsConvertXmlThread(CmsObject cms, CmsConvertXmlSettings settings) { 094 095 super(cms, Messages.get().getBundle().key(Messages.GUI_CONVERTXML_THREAD_NAME_0)); 096 initHtmlReport(cms.getRequestContext().getLocale()); 097 m_cmsObject = cms; 098 m_settings = settings; 099 } 100 101 /** 102 * @see org.opencms.report.A_CmsReportThread#getReportUpdate() 103 */ 104 @Override 105 public String getReportUpdate() { 106 107 return getReport().getReportUpdate(); 108 } 109 110 /** 111 * @see java.lang.Runnable#run() 112 */ 113 @Override 114 public void run() { 115 116 I_CmsReport report = getReport(); 117 report.println( 118 Messages.get().container(Messages.RPT_CONVERTXML_BEGIN_TRANSFORM_THREAD_0), 119 I_CmsReport.FORMAT_HEADLINE); 120 try { 121 // convert xml contents 122 mainTransform( 123 report, 124 m_settings.getResourceType(), 125 m_settings.getVfsFolder(), 126 m_settings.getIncludeSubFolders(), 127 m_settings.getXslFile(), 128 m_cmsObject, 129 m_settings.getOnlyCountFiles()); 130 } catch (Throwable f) { 131 m_errorTransform += 1; 132 report.println(Messages.get().container(Messages.RPT_CONVERTXML_TRANSFORMATION_ERROR_0)); 133 if (LOG.isErrorEnabled()) { 134 LOG.error(f.toString()); 135 } 136 } 137 138 // append runtime statistics to report 139 getReport().print(org.opencms.report.Messages.get().container(org.opencms.report.Messages.RPT_STAT_0)); 140 getReport().println( 141 org.opencms.report.Messages.get().container( 142 org.opencms.report.Messages.RPT_STAT_DURATION_1, 143 getReport().formatRuntime())); 144 getReport().println( 145 Messages.get().container(Messages.RPT_CONVERTXML_THREAD_END_0), 146 I_CmsReport.FORMAT_HEADLINE); 147 } 148 149 /** 150 * Locks the current resource.<p> 151 * 152 * @param cms the current CmsObject 153 * @param cmsProject the current project 154 * @param cmsResource the resourcfe to lock 155 * @param report the report 156 * 157 * @throws CmsException if some goes wrong 158 */ 159 private boolean lockResource(CmsObject cms, CmsProject cmsProject, CmsResource cmsResource, I_CmsReport report) 160 throws CmsException { 161 162 cms.getRequestContext().setCurrentProject(cmsProject); 163 CmsLock lock = cms.getLock(getCms().getSitePath(cmsResource)); 164 // check the lock 165 if ((lock != null) 166 && lock.isOwnedBy(getCms().getRequestContext().getCurrentUser()) 167 && lock.isOwnedInProjectBy(getCms().getRequestContext().getCurrentUser(), cmsProject)) { 168 // prove is current lock from current user in current project 169 return true; 170 } else if ((lock != null) 171 && !lock.isUnlocked() 172 && !lock.isOwnedBy(getCms().getRequestContext().getCurrentUser())) { 173 // the resource is not locked by the current user, so can not lock it 174 m_lockedFiles += 1; 175 return false; 176 } else if ((lock != null) 177 && !lock.isUnlocked() 178 && lock.isOwnedBy(getCms().getRequestContext().getCurrentUser()) 179 && !lock.isOwnedInProjectBy(getCms().getRequestContext().getCurrentUser(), cmsProject)) { 180 // prove is current lock from current user but not in current project 181 // file is locked by current user but not in current project 182 // change the lock 183 cms.changeLock(getCms().getSitePath(cmsResource)); 184 } else if ((lock != null) && lock.isUnlocked()) { 185 // lock resource from current user in current project 186 cms.lockResource(getCms().getSitePath(cmsResource)); 187 } 188 lock = cms.getLock(getCms().getSitePath(cmsResource)); 189 if ((lock != null) 190 && lock.isOwnedBy(getCms().getRequestContext().getCurrentUser()) 191 && !lock.isOwnedInProjectBy(getCms().getRequestContext().getCurrentUser(), cmsProject)) { 192 // resource could not be locked 193 m_lockedFiles += 1; 194 195 return false; 196 } 197 // resource is locked successfully 198 return true; 199 } 200 201 /** 202 * Main method to transforms xml contents from files of one format because 203 * of new xsd file.<p> 204 * 205 * @param report I_CmsReport 206 * @param fileFormat File format of xml contents to transform 207 * @param resourcePath Path where to transform xml contents 208 * @param inclSubFolder True, if also transform xml contents in sub folders 209 * @param xsltFile XLST file which includes logic for transforming 210 * @param cmsObject Current CmsObject 211 * @param countFilesToTransformOnly Only count files to transform 212 * 213 * @return True if transformation of all xml contents was successful 214 */ 215 @SuppressWarnings("unchecked") 216 private boolean mainTransform( 217 I_CmsReport report, 218 int fileFormat, 219 String resourcePath, 220 boolean inclSubFolder, 221 String xsltFile, 222 CmsObject cmsObject, 223 boolean countFilesToTransformOnly) { 224 225 boolean transformSuccess = true; 226 boolean transformConditions = true; 227 // write parameters to report 228 report.println(Messages.get().container(Messages.RPT_CONVERTXML_BEGIN_TRANSFORM_0), I_CmsReport.FORMAT_NOTE); 229 report.println(Messages.get().container(Messages.RPT_CONVERTXML_PARAMETERS_0), I_CmsReport.FORMAT_NOTE); 230 report.println( 231 Messages.get().container(Messages.RPT_CONVERTXML_PARAMETERS_RESOURCE_PATH_1, resourcePath), 232 I_CmsReport.FORMAT_NOTE); 233 report.println( 234 Messages.get().container( 235 Messages.RPT_CONVERTXML_PARAMETERS_INC_SUBFOLDERS_1, 236 Boolean.valueOf(inclSubFolder).toString()), 237 I_CmsReport.FORMAT_NOTE); 238 report.println( 239 Messages.get().container(Messages.RPT_CONVERTXML_PARAMETERS_XSLT_FILE_1, xsltFile), 240 I_CmsReport.FORMAT_NOTE); 241 report.println( 242 Messages.get().container( 243 Messages.RPT_CONVERTXML_PARAMETERS_ONLY_COUNT_1, 244 Boolean.valueOf(countFilesToTransformOnly).toString()), 245 I_CmsReport.FORMAT_NOTE); 246 // check if xslt file is available 247 if (CmsStringUtil.isEmpty(xsltFile)) { 248 report.println(Messages.get().container(Messages.RPT_CONVERTXML_NO_XSLT_FILE_0), I_CmsReport.FORMAT_ERROR); 249 transformConditions = false; 250 } 251 // check if new xsd main file is available 252 String newXsdMainFile = ""; 253 String xsltString = ""; 254 try { 255 xsltString = new String(cmsObject.readFile(xsltFile).getContents()); 256 } catch (CmsException e) { 257 if (LOG.isErrorEnabled()) { 258 LOG.error(e.getMessageContainer(), e); 259 } 260 } 261 // get main xsd file string in xml content in format: xsi:noNamespaceSchemaLocation="opencms://system/modules/org.opencms.frontend.templatetwo.demo/schemas/article.xsd" 262 int posMainFileBegin = xsltString.indexOf("xsi:noNamespaceSchemaLocation=\""); 263 if (posMainFileBegin > 0) { 264 String fileName = xsltString.substring(posMainFileBegin + "xsi:noNamespaceSchemaLocation=\"".length()); 265 int posMainFileEnd = fileName.indexOf("\""); 266 if (posMainFileEnd > 0) { 267 newXsdMainFile = fileName.substring(0, posMainFileEnd); 268 } 269 } 270 // check file 271 int fileLength = newXsdMainFile.length(); 272 if ((fileLength < 5) || !newXsdMainFile.substring(fileLength - 4, fileLength).toUpperCase().equals(".XSD")) { 273 newXsdMainFile = ""; 274 } 275 if (CmsStringUtil.isEmpty(newXsdMainFile)) { 276 report.println(Messages.get().container(Messages.RPT_CONVERTXML_NO_XSD_FILE_0), I_CmsReport.FORMAT_ERROR); 277 transformConditions = false; 278 } else { 279 report.println( 280 Messages.get().container(Messages.RPT_CONVERTXML_PARAMETERS_NEW_XSD_MAINFILE_1, newXsdMainFile), 281 I_CmsReport.FORMAT_NOTE); 282 } 283 // check if vfs folder is set 284 if (CmsStringUtil.isEmpty(resourcePath)) { 285 report.println(Messages.get().container(Messages.RPT_CONVERTXML_NO_VFS_FOLDER_0), I_CmsReport.FORMAT_ERROR); 286 transformConditions = false; 287 } 288 // only start actions if all conditions are okay 289 if (!transformConditions) { 290 return false; 291 } 292 // read all files to transform 293 report.println(Messages.get().container(Messages.RPT_CONVERTXML_START_SEARCHING_0), I_CmsReport.FORMAT_NOTE); 294 List<CmsResource> files2Transform = null; 295 try { 296 files2Transform = cmsObject.readResources( 297 resourcePath, 298 CmsResourceFilter.requireType(fileFormat), 299 inclSubFolder); 300 } catch (CmsException e) { 301 m_errorTransform += 1; 302 report.println(Messages.get().container(Messages.RPT_CONVERTXML_SEARCH_ERROR_0), I_CmsReport.FORMAT_ERROR); 303 if (LOG.isErrorEnabled()) { 304 LOG.error(e.getMessageContainer(), e); 305 } 306 report.println(Messages.get().container(Messages.RPT_CONVERTXML_TRANSFORM_END_0), I_CmsReport.FORMAT_NOTE); 307 return false; 308 } 309 int file2Transform = 0; 310 if (files2Transform != null) { 311 file2Transform = files2Transform.size(); 312 report.println( 313 Messages.get().container( 314 Messages.RPT_CONVERTXML_FOUND_FILES_1, 315 Integer.valueOf(file2Transform).toString()), 316 I_CmsReport.FORMAT_OK); 317 } else { 318 report.println(Messages.get().container(Messages.RPT_CONVERTXML_NO_FILES_FOUND_0), I_CmsReport.FORMAT_OK); 319 return false; 320 } 321 if (countFilesToTransformOnly || (file2Transform < 1)) { 322 report.println(Messages.get().container(Messages.RPT_CONVERTXML_NO_FILES_FOUND_0), I_CmsReport.FORMAT_OK); 323 return false; 324 } 325 // transform and write files 326 CmsObject cmsObject2Publish = transformAndWriteFiles( 327 files2Transform, 328 xsltFile, 329 cmsObject, 330 newXsdMainFile, 331 report); 332 // publish files in project 333 report.println(Messages.get().container(Messages.RPT_CONVERTXML_PUBLISHING_FILES_0), I_CmsReport.FORMAT_NOTE); 334 CmsPublishManager cmsPublishManager = OpenCms.getPublishManager(); 335 try { 336 cmsPublishManager.publishProject(cmsObject2Publish); 337 } catch (Exception e) { 338 m_errorTransform += 1; 339 report.println( 340 Messages.get().container(Messages.RPT_CONVERTXML_TRANSFORMATION_ERROR_0), 341 I_CmsReport.FORMAT_ERROR); 342 if (LOG.isErrorEnabled()) { 343 LOG.error(e.toString()); 344 } 345 } 346 // output from the results 347 report.println(Messages.get().container(Messages.RPT_CONVERTXML_RESULT_0), I_CmsReport.FORMAT_NOTE); 348 report.println( 349 Messages.get().container(Messages.RPT_CONVERTXML_FOUND_FILES_1, Integer.valueOf(file2Transform).toString()), 350 I_CmsReport.FORMAT_NOTE); 351 report.println( 352 Messages.get().container( 353 Messages.RPT_CONVERTXML_FILES_ALREADY_TRANSFORMED_1, 354 Integer.valueOf(m_alreadyTransformed).toString()), 355 I_CmsReport.FORMAT_NOTE); 356 report.println( 357 Messages.get().container( 358 Messages.RPT_CONVERTXML_TRANSFORM_NUMBER_ERRORS_1, 359 Integer.valueOf(m_errorTransform).toString()), 360 I_CmsReport.FORMAT_NOTE); 361 report.println( 362 Messages.get().container(Messages.RPT_CONVERTXML_LOCKED_FILES_1, Integer.valueOf(m_lockedFiles).toString()), 363 I_CmsReport.FORMAT_NOTE); 364 if ((m_lockedFiles > 0) || (m_errorTransform > 0)) { 365 report.println( 366 Messages.get().container(Messages.RPT_CONVERTXML_TRANSFORMING_FAILED_0), 367 I_CmsReport.FORMAT_ERROR); 368 } else { 369 report.println( 370 Messages.get().container(Messages.RPT_CONVERTXML_TRANSFORMING_SUCCESS_0), 371 I_CmsReport.FORMAT_OK); 372 } 373 374 report.println(Messages.get().container(Messages.RPT_CONVERTXML_TRANSFORM_END_0), I_CmsReport.FORMAT_NOTE); 375 return transformSuccess; 376 } 377 378 /** 379 * Gets file xml content.<p> 380 * 381 * @param cmsResource current resource CmsResource 382 * @param cmsFile current CmsFile 383 * @param cmsObject current CmsObject 384 * @param xmlContent xml content to write 385 * @param encodingType encoding type 386 * @param report I_CmsReport 387 */ 388 private void setXmlContentFromFile( 389 CmsResource cmsResource, 390 CmsFile cmsFile, 391 CmsObject cmsObject, 392 String xmlContent, 393 String encodingType, 394 I_CmsReport report) { 395 396 try { 397 byte[] fileContent = xmlContent.getBytes(encodingType); 398 cmsFile.setContents(fileContent); 399 // write into file 400 cmsObject.writeFile(cmsFile); 401 // unlock resource 402 try { 403 cmsObject.unlockResource(cmsObject.getSitePath(cmsResource)); 404 } catch (CmsException e) { 405 m_errorTransform += 1; 406 report.println( 407 Messages.get().container(Messages.RPT_CONVERTXML_UNLOCK_FILE_1, cmsObject.getSitePath(cmsResource)), 408 I_CmsReport.FORMAT_ERROR); 409 if (LOG.isErrorEnabled()) { 410 LOG.error(e.getMessageContainer(), e); 411 } 412 } 413 } catch (Exception e) { 414 m_errorTransform += 1; 415 String reportContent = "<br/>"; 416 reportContent = reportContent + CmsEncoder.escapeXml(xmlContent); 417 reportContent = reportContent.replaceAll("\r\n", "<br/>"); 418 report.println( 419 Messages.get().container(Messages.RPT_CONVERTXML_WRITE_ERROR_1, reportContent), 420 I_CmsReport.FORMAT_ERROR); 421 if (LOG.isErrorEnabled()) { 422 LOG.error(e.toString()); 423 } 424 } 425 } 426 427 /** 428 * Transforms and write files.<p> 429 * 430 * @param files2Transform Files to transform 431 * @param xsltFile XLST file which includes logic for transforming 432 * @param cmsObject Current CmsObject 433 * @param newXsdMainFile New xsd main file 434 * @param report I_CmsReport 435 * 436 * @return Project with files to publish 437 * 438 * @throws CmsException Can become thrown while creating temporary OpenCms Projects 439 */ 440 private CmsObject transformAndWriteFiles( 441 List<CmsResource> files2Transform, 442 String xsltFile, 443 CmsObject cmsObject, 444 String newXsdMainFile, 445 I_CmsReport report) { 446 447 // the CmsObject to publish resources 448 CmsObject cms1 = null; 449 // the CmsObject to handle resources which are not to publish 450 CmsObject cms2 = null; 451 // the publish project 452 CmsProject project2Publish = null; 453 // initialize the CmsObjects and the publish project 454 try { 455 cms1 = OpenCms.initCmsObject(cmsObject); 456 cms2 = OpenCms.initCmsObject(cmsObject); 457 cms1.copyResourceToProject("/"); 458 project2Publish = cms1.createTempfileProject(); // init new 459 cms1.getRequestContext().setCurrentProject(project2Publish); 460 } catch (CmsException e) { 461 report.println(Messages.get().container(Messages.RPT_CONVERTXML_INITIALIZE_CMS_ERROR_0)); 462 if (LOG.isErrorEnabled()) { 463 LOG.error(e.toString()); 464 } 465 return cms1; 466 } 467 468 // iterate over all the resources to transform 469 Iterator<CmsResource> iter = files2Transform.iterator(); 470 while (iter.hasNext()) { 471 // get the next resource to transform 472 CmsResource cmsResource = iter.next(); 473 // check if the resource has to be published after transforming 474 boolean resource2Publish = false; 475 // get info if resource shall become published 476 CmsResourceState cmsResourceState = cmsResource.getState(); 477 if (!(cmsResourceState.equals(CmsResourceState.STATE_CHANGED) 478 || cmsResourceState.equals(CmsResourceState.STATE_NEW))) { 479 // resource is not touched or is not new 480 resource2Publish = true; 481 } 482 483 // get current lock from file 484 if (resource2Publish) { 485 // lock the resource in the publish project 486 try { 487 // try to lock the resource 488 if (!lockResource(cms1, project2Publish, cmsResource, report)) { 489 report.println( 490 Messages.get().container( 491 Messages.RPT_CONVERTXML_LOCKED_FILE_1, 492 cmsObject.getSitePath(cmsResource)), 493 I_CmsReport.FORMAT_ERROR); 494 continue; 495 } 496 } catch (CmsException e) { 497 report.println( 498 Messages.get().container( 499 Messages.RPT_CONVERTXML_LOCKED_FILE_1, 500 cmsObject.getSitePath(cmsResource)), 501 I_CmsReport.FORMAT_ERROR); 502 if (LOG.isErrorEnabled()) { 503 LOG.error(e.getMessageContainer(), e); 504 } 505 continue; 506 } 507 } else { 508 // lock the resource in the project where the resource was last modified in 509 try { 510 // get the project id from the project where the resource is last modified in 511 CmsUUID pid = cmsResource.getProjectLastModified(); 512 CmsProject fileProject = cms2.readProject(pid); 513 cms2.getRequestContext().setCurrentProject(fileProject); 514 // try to lock the resource 515 if (!lockResource(cms2, fileProject, cmsResource, report)) { 516 report.println( 517 Messages.get().container( 518 Messages.RPT_CONVERTXML_LOCKED_FILE_1, 519 cmsObject.getSitePath(cmsResource)), 520 I_CmsReport.FORMAT_ERROR); 521 continue; 522 } 523 } catch (CmsException e) { 524 report.println( 525 Messages.get().container( 526 Messages.RPT_CONVERTXML_LOCKED_FILE_1, 527 cmsObject.getSitePath(cmsResource)), 528 I_CmsReport.FORMAT_ERROR); 529 if (LOG.isErrorEnabled()) { 530 LOG.error(e.getMessageContainer(), e); 531 } 532 continue; 533 } 534 } 535 536 // get CmsFile object and the xml content 537 CmsFile cmsFile = null; 538 String fileXmlContent = ""; 539 try { 540 cmsFile = cmsObject.readFile(cmsResource); 541 CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(getCms(), cmsFile); 542 fileXmlContent = xmlContent.toString(); 543 } catch (CmsException e) { 544 m_errorTransform += 1; 545 report.println( 546 Messages.get().container(Messages.RPT_CONVERTXML_TRANSFORMATION_ERROR_0), 547 I_CmsReport.FORMAT_ERROR); 548 if (LOG.isErrorEnabled()) { 549 LOG.error(e.getMessageContainer(), e); 550 } 551 continue; 552 } 553 554 // get encoding per resource 555 String encodingType = ""; 556 try { 557 encodingType = cmsObject.readPropertyObject( 558 cmsResource.getRootPath(), 559 CmsPropertyDefinition.PROPERTY_CONTENT_ENCODING, 560 true).getValue(OpenCms.getSystemInfo().getDefaultEncoding()); 561 } catch (CmsException e) { 562 encodingType = OpenCms.getSystemInfo().getDefaultEncoding(); 563 } 564 565 // check transform conditions per resource 566 // encoding type given? 567 if (CmsStringUtil.isEmpty(encodingType)) { 568 m_missingEncodingType += 1; 569 report.println( 570 Messages.get().container( 571 Messages.RPT_CONVERTXML_MISSION_ENCODING_TYPE_1, 572 cmsResource.getRootPath()), 573 I_CmsReport.FORMAT_ERROR); 574 continue; 575 } 576 // already transformed? 577 if (fileXmlContent.toUpperCase().contains(newXsdMainFile.toUpperCase())) { 578 m_alreadyTransformed += 1; 579 report.println( 580 Messages.get().container( 581 Messages.RPT_CONVERTXML_FILE_ALREADY_TRANSFORMED_1, 582 cmsResource.getRootPath()), 583 I_CmsReport.FORMAT_OK); 584 continue; 585 } 586 587 // create and write the changed xml content 588 try { 589 String transformedXmlContent = CmsXsltUtil.transformXmlContent(cmsObject, xsltFile, fileXmlContent); 590 transformedXmlContent = "<?xml version=\"1.0\" encoding=\"".concat(encodingType).concat("\"?>").concat( 591 transformedXmlContent); 592 // write file xml content 593 if (resource2Publish) { 594 report.println( 595 Messages.get().container( 596 Messages.RPT_CONVERTXML_TRANSFORM_CURRENT_FILE_NAME2_2, 597 cmsResource.getRootPath(), 598 encodingType), 599 I_CmsReport.FORMAT_OK); 600 cms1.getRequestContext().setCurrentProject(project2Publish); 601 setXmlContentFromFile(cmsResource, cmsFile, cms1, transformedXmlContent, encodingType, report); 602 } else { 603 report.println( 604 Messages.get().container( 605 Messages.RPT_CONVERTXML_TRANSFORM_CURRENT_FILE_NAME_2, 606 cmsResource.getRootPath(), 607 encodingType), 608 I_CmsReport.FORMAT_OK); 609 setXmlContentFromFile(cmsResource, cmsFile, cms2, transformedXmlContent, encodingType, report); 610 } 611 } catch (CmsXmlException e) { 612 m_errorTransform += 1; 613 report.println( 614 Messages.get().container(Messages.RPT_CONVERTXML_TRANSFORMATION_ERROR_0), 615 I_CmsReport.FORMAT_ERROR); 616 if (LOG.isErrorEnabled()) { 617 LOG.error(e.getMessageContainer(), e); 618 } 619 } catch (CmsException e) { 620 m_errorTransform += 1; 621 report.println( 622 Messages.get().container(Messages.RPT_CONVERTXML_TRANSFORMATION_ERROR_0), 623 I_CmsReport.FORMAT_ERROR); 624 if (LOG.isErrorEnabled()) { 625 LOG.error(e.getMessageContainer(), e); 626 } 627 } 628 629 } 630 return cms1; 631 } 632}