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.configuration; 029 030import org.opencms.db.CmsUserExportSettings; 031import org.opencms.importexport.CmsExtendedHtmlImportDefault; 032import org.opencms.importexport.CmsImportExportManager; 033import org.opencms.importexport.CmsImportExportManager.TimestampMode; 034import org.opencms.importexport.I_CmsImport; 035import org.opencms.importexport.I_CmsImportExportHandler; 036import org.opencms.main.CmsLog; 037import org.opencms.repository.CmsRepositoryFilter; 038import org.opencms.repository.CmsRepositoryManager; 039import org.opencms.repository.I_CmsRepository; 040import org.opencms.security.I_CmsPrincipal; 041import org.opencms.staticexport.CmsStaticExportExportRule; 042import org.opencms.staticexport.CmsStaticExportManager; 043import org.opencms.staticexport.CmsStaticExportRfsRule; 044import org.opencms.util.CmsStringUtil; 045 046import java.io.File; 047import java.util.Iterator; 048import java.util.List; 049import java.util.Map; 050import java.util.Map.Entry; 051import java.util.regex.Pattern; 052 053import org.apache.commons.digester3.Digester; 054 055import org.dom4j.Element; 056 057/** 058 * Import / export master configuration class.<p> 059 * 060 * @since 6.0.0 061 */ 062public class CmsImportExportConfiguration extends A_CmsXmlConfiguration { 063 064 /** The name of the DTD for this configuration. */ 065 public static final String CONFIGURATION_DTD_NAME = "opencms-importexport.dtd"; 066 067 /** The name of the default XML file for this configuration. */ 068 public static final String DEFAULT_XML_FILE_NAME = "opencms-importexport.xml"; 069 070 /** The node name of the column node. */ 071 public static final String N_PROTECTED_EXPORT = "protectedexport"; 072 073 /** The node name of the column node. */ 074 public static final String N_COLUMN = "column"; 075 076 /** The node name of the columns node. */ 077 public static final String N_COLUMNS = "columns"; 078 079 /** Node that indicates page conversion. */ 080 public static final String N_CONVERT = "convert"; 081 082 /** The main configuration node for the extended html import. */ 083 public static final String N_EXTHTMLIMPORT = "extendedhtmlimport"; 084 085 /** The node name of the html import destination node. */ 086 public static final String N_EXTHTMLIMPORT_DESTINATION = "destination"; 087 088 /** The node name of the html import download gallery node. */ 089 public static final String N_EXTHTMLIMPORT_DOWNLOAD = "download"; 090 091 /** The node name of the html import template node. */ 092 public static final String N_EXTHTMLIMPORT_ELEMENT = "element"; 093 094 /** The node name of the html import encoding node. */ 095 public static final String N_EXTHTMLIMPORT_ENCODING = "encoding"; 096 097 /** The node name of the html import image gallery node. */ 098 public static final String N_EXTHTMLIMPORT_EXTERNALLINK = "externallink"; 099 100 /** The node name of the html import galleries node. */ 101 public static final String N_EXTHTMLIMPORT_GALLERIES = "galleries"; 102 103 /** The node name of the html import image gallery node. */ 104 public static final String N_EXTHTMLIMPORT_IMAGE = "image"; 105 106 /** The node name of the html import input node. */ 107 public static final String N_EXTHTMLIMPORT_INPUT = "input"; 108 109 /** The node name of the html import overwritefiles node. */ 110 public static final String N_EXTHTMLIMPORT_KEEPBROKENLINKS = "keepbrokenlinks"; 111 112 /** The node name of the html import locale node. */ 113 public static final String N_EXTHTMLIMPORT_LOCALE = "locale"; 114 115 /** The node name of the html import overwritefiles node. */ 116 public static final String N_EXTHTMLIMPORT_OVERWRITE = "overwritefiles"; 117 118 /** The node name of the html import pattern node. */ 119 public static final String N_EXTHTMLIMPORT_PATTERN = "pattern"; 120 121 /** The node name of the html import end pattern node. */ 122 public static final String N_EXTHTMLIMPORT_PATTERN_END = "end"; 123 124 /** The node name of the html import start pattern node. */ 125 public static final String N_EXTHTMLIMPORT_PATTERN_START = "start"; 126 127 /** The node name of the html import settings node. */ 128 public static final String N_EXTHTMLIMPORT_SETTINGS = "settings"; 129 130 /** The node name of the html import template node. */ 131 public static final String N_EXTHTMLIMPORT_TEMPLATE = "template"; 132 133 /** The node name of the repository filter node. */ 134 public static final String N_FILTER = "filter"; 135 136 /** Node that contains a list of properties ignored during import. */ 137 public static final String N_IGNOREDPROPERTIES = "ignoredproperties"; 138 139 /** The import immutable resources node. */ 140 public static final String N_IMMUTABLES = "immutables"; 141 142 /** The node name of the import sub-configuration. */ 143 public static final String N_IMPORT = "import"; 144 145 /** The node name of the export sub-configuration. */ 146 public static final String N_EXPORT = "export"; 147 148 /** The node name of the defaultexporttimestamps sub-configuration. */ 149 public static final String N_EXPORT_DEFAULTTIMESTAMPMODES = "defaulttimestampmodes"; 150 151 /** The node name of the timestamp sub-configuration. */ 152 public static final String N_EXPORT_TIMESTAMPMODE = "timestampmode"; 153 154 /** The node name of the resourcetype sub-configuration. */ 155 public static final String N_EXPORT_RESOURCETYPENAME = "resourcetypename"; 156 157 /** The main configuration node name. */ 158 public static final String N_IMPORTEXPORT = "importexport"; 159 160 /** The node name of an individual import/export handler. */ 161 public static final String N_IMPORTEXPORTHANDLER = "importexporthandler"; 162 163 /** Master node for import/export handlers. */ 164 public static final String N_IMPORTEXPORTHANDLERS = "importexporthandlers"; 165 166 /** The node name of an individual import version class. */ 167 public static final String N_IMPORTVERSION = "importversion"; 168 169 /** Master node for import version class names. */ 170 public static final String N_IMPORTVERSIONS = "importversions"; 171 172 /** The node name of the static export handler node. */ 173 public static final String N_LINKSUBSTITUTION_HANDLER = "linksubstitutionhandler"; 174 175 /** Node the contains an optional URL of old web application. */ 176 public static final String N_OLDWEBAPPURL = "oldwebappurl"; 177 178 /** The import overwrite node name. */ 179 public static final String N_OVERWRITE = "overwrite"; 180 181 /** The node name of the repository params node. */ 182 public static final String N_PARAMS = "params"; 183 184 /** An individual principal translation node. */ 185 public static final String N_PRINCIPALTRANSLATION = "principaltranslation"; 186 187 /** The principal translation node. */ 188 public static final String N_PRINCIPALTRANSLATIONS = "principaltranslations"; 189 190 /** The node name of the repository filter regex node. */ 191 public static final String N_REGEX = "regex"; 192 193 /** The node name of the repositories node. */ 194 public static final String N_REPOSITORIES = "repositories"; 195 196 /** The node name of the repository node. */ 197 public static final String N_REPOSITORY = "repository"; 198 199 /** The node name of the separator node. */ 200 public static final String N_SEPARATOR = "separator"; 201 202 /** The main configuration node for static export name. */ 203 public static final String N_STATICEXPORT = "staticexport"; 204 205 /** The node name of the static export acceptcharset node. */ 206 public static final String N_STATICEXPORT_ACCEPTCHARSET = "acceptcharset"; 207 208 /** The node name of the static export acceptlanguage node. */ 209 public static final String N_STATICEXPORT_ACCEPTLANGUAGE = "acceptlanguage"; 210 211 /** The node name of the static export default node. */ 212 public static final String N_STATICEXPORT_DEFAULT = "defaultpropertyvalue"; 213 214 /** The node name of the static export defualtsuffix node. */ 215 public static final String N_STATICEXPORT_DEFAULTSUFFIXES = "defaultsuffixes"; 216 217 /** The node name of the static export rule description nodes. */ 218 public static final String N_STATICEXPORT_DESCRIPTION = "description"; 219 220 /** The node name of the static export export-rule export node. */ 221 public static final String N_STATICEXPORT_EXPORT = "export-resources"; 222 223 /** The node name of the static export exportbackups node. */ 224 public static final String N_STATICEXPORT_EXPORTBACKUPS = "exportbackups"; 225 226 /** The node name of the static export exportheaders node. */ 227 public static final String N_STATICEXPORT_EXPORTHEADERS = "exportheaders"; 228 229 /** The node name of the static export exportpath node. */ 230 public static final String N_STATICEXPORT_EXPORTPATH = "exportpath"; 231 232 /** The node name of the static export export-rule node. */ 233 public static final String N_STATICEXPORT_EXPORTRULE = "export-rule"; 234 235 /** The node name of the static export export-rules node. */ 236 public static final String N_STATICEXPORT_EXPORTRULES = "export-rules"; 237 238 /** The node name of the static export exporturl node. */ 239 public static final String N_STATICEXPORT_EXPORTURL = "exporturl"; 240 241 /** The node name of the static export exportworkpath node. */ 242 public static final String N_STATICEXPORT_EXPORTWORKPATH = "exportworkpath"; 243 244 /** The node name of the static export handler node. */ 245 public static final String N_STATICEXPORT_HANDLER = "staticexporthandler"; 246 247 /** The node name of the static export header node. */ 248 public static final String N_STATICEXPORT_HEADER = "header"; 249 250 /** The node name of the static export export-rule modified node. */ 251 public static final String N_STATICEXPORT_MODIFIED = "modified-resources"; 252 253 /** The node name of the static export rule name nodes. */ 254 public static final String N_STATICEXPORT_NAME = "name"; 255 256 /** The node name of the static export plainoptimization node. */ 257 public static final String N_STATICEXPORT_PLAINOPTIMIZATION = "plainoptimization"; 258 259 /** The node name of the static export regex node. */ 260 public static final String N_STATICEXPORT_REGEX = "regex"; 261 262 /** The node name of the static export related-system-res node. */ 263 public static final String N_STATICEXPORT_RELATED_SYSTEM_RES = "related-system-res"; 264 265 /** The node name of the static export relativelinks node. */ 266 public static final String N_STATICEXPORT_RELATIVELINKS = "userelativelinks"; 267 268 /** The node name of the static export remoteaddr node. */ 269 public static final String N_STATICEXPORT_REMOTEADDR = "remoteaddr"; 270 271 /** The node name of the static export rendersettings node. */ 272 public static final String N_STATICEXPORT_RENDERSETTINGS = "rendersettings"; 273 274 /** The node name of the static export requestheaders node. */ 275 public static final String N_STATICEXPORT_REQUESTHEADERS = "requestheaders"; 276 277 /** The node name of the static export resourcestorender node. */ 278 public static final String N_STATICEXPORT_RESOURCESTORENDER = "resourcestorender"; 279 280 /** The node name of the static export rfx-prefix node. */ 281 public static final String N_STATICEXPORT_RFS_PREFIX = "rfs-prefix"; 282 283 /** The node name of the static export rfx-rule node. */ 284 public static final String N_STATICEXPORT_RFS_RULE = "rfs-rule"; 285 286 /** The node name of the static export rfx-rules node. */ 287 public static final String N_STATICEXPORT_RFS_RULES = "rfs-rules"; 288 289 /** The node name of the static export rfx-rule source node. */ 290 public static final String N_STATICEXPORT_SOURCE = "source"; 291 292 /** The node name of the static export suffix node. */ 293 public static final String N_STATICEXPORT_SUFFIX = "suffix"; 294 295 /** The node name of the static export testresource node. */ 296 public static final String N_STATICEXPORT_TESTRESOURCE = "testresource"; 297 298 /** The node name of the static export export-rule export uri node. */ 299 public static final String N_STATICEXPORT_URI = "uri"; 300 301 /** The node name of the static export vfx-prefix node. */ 302 public static final String N_STATICEXPORT_VFS_PREFIX = "vfs-prefix"; 303 304 /** The temporary export point path node. */ 305 public static final String N_TEMP_EXPORTPONT_PATH = "temp-exportpoint-path"; 306 307 /** The node name of the user csv export node. */ 308 public static final String N_USERCSVEXPORT = "usercsvexport"; 309 310 /** The configured import/export manager. */ 311 private CmsImportExportManager m_importExportManager; 312 313 /** The configured repository manager. */ 314 private CmsRepositoryManager m_repositoryManager; 315 316 /** The configured static export manager. */ 317 private CmsStaticExportManager m_staticExportManager; 318 319 /** 320 * Adds an protected export point.<p> 321 * 322 * @param uri the source URI 323 * @param destination the export destination 324 */ 325 public void addProtectedExportPoint(String uri, String destination) { 326 327 m_staticExportManager.addProtectedExportPoint(uri, destination); 328 } 329 330 /** 331 * @see org.opencms.configuration.I_CmsXmlConfiguration#addXmlDigesterRules(org.apache.commons.digester3.Digester) 332 */ 333 public void addXmlDigesterRules(Digester digester) { 334 335 // add finish rule 336 digester.addCallMethod("*/" + N_IMPORTEXPORT, "initializeFinished"); 337 338 // creation of the import/export manager 339 digester.addObjectCreate("*/" + N_IMPORTEXPORT, CmsImportExportManager.class); 340 // import/export manager finished 341 digester.addSetNext("*/" + N_IMPORTEXPORT, "setImportExportManager"); 342 343 // add rules for import/export handlers 344 digester.addObjectCreate( 345 "*/" + N_IMPORTEXPORT + "/" + N_IMPORTEXPORTHANDLERS + "/" + N_IMPORTEXPORTHANDLER, 346 CmsConfigurationException.class.getName(), 347 A_CLASS); 348 digester.addSetNext( 349 "*/" + N_IMPORTEXPORT + "/" + N_IMPORTEXPORTHANDLERS + "/" + N_IMPORTEXPORTHANDLER, 350 "addImportExportHandler"); 351 352 // overwrite rule 353 digester.addCallMethod( 354 "*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_OVERWRITE, 355 "setOverwriteCollidingResources", 356 0); 357 358 // convert rule 359 digester.addCallMethod("*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_CONVERT, "setConvertToXmlPage", 0); 360 361 // old webapp rule 362 digester.addCallMethod("*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_OLDWEBAPPURL, "setOldWebAppUrl", 0); 363 364 // add rules for the import versions 365 digester.addObjectCreate( 366 "*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_IMPORTVERSIONS + "/" + N_IMPORTVERSION, 367 CmsConfigurationException.class.getName(), 368 A_CLASS); 369 digester.addSetNext( 370 "*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_IMPORTVERSIONS + "/" + N_IMPORTVERSION, 371 "addImportVersionClass"); 372 373 // add rules for the import immutables 374 digester.addCallMethod( 375 "*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_IMMUTABLES + "/" + N_RESOURCE, 376 "addImmutableResource", 377 1); 378 digester.addCallParam("*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_IMMUTABLES + "/" + N_RESOURCE, 0, A_URI); 379 380 // add rules for the import principal translations 381 digester.addCallMethod( 382 "*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_PRINCIPALTRANSLATIONS + "/" + N_PRINCIPALTRANSLATION, 383 "addImportPrincipalTranslation", 384 3); 385 digester.addCallParam( 386 "*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_PRINCIPALTRANSLATIONS + "/" + N_PRINCIPALTRANSLATION, 387 0, 388 A_TYPE); 389 digester.addCallParam( 390 "*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_PRINCIPALTRANSLATIONS + "/" + N_PRINCIPALTRANSLATION, 391 1, 392 A_FROM); 393 digester.addCallParam( 394 "*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_PRINCIPALTRANSLATIONS + "/" + N_PRINCIPALTRANSLATION, 395 2, 396 A_TO); 397 398 // add rules for the ignored properties 399 digester.addCallMethod( 400 "*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_IGNOREDPROPERTIES + "/" + N_PROPERTY, 401 "addIgnoredProperty", 402 1); 403 digester.addCallParam( 404 "*/" + N_IMPORTEXPORT + "/" + N_IMPORT + "/" + N_IGNOREDPROPERTIES + "/" + N_PROPERTY, 405 0, 406 A_NAME); 407 408 // add rules for export settings 409 digester.addCallMethod( 410 "*/" 411 + N_IMPORTEXPORT 412 + "/" 413 + N_EXPORT 414 + "/" 415 + N_EXPORT_DEFAULTTIMESTAMPMODES 416 + "/" 417 + N_EXPORT_TIMESTAMPMODE, 418 "addDefaultTimestampMode", 419 1); 420 421 digester.addCallParam( 422 "*/" 423 + N_IMPORTEXPORT 424 + "/" 425 + N_EXPORT 426 + "/" 427 + N_EXPORT_DEFAULTTIMESTAMPMODES 428 + "/" 429 + N_EXPORT_TIMESTAMPMODE, 430 0, 431 A_MODE); 432 433 digester.addCallMethod( 434 "*/" 435 + N_IMPORTEXPORT 436 + "/" 437 + N_EXPORT 438 + "/" 439 + N_EXPORT_DEFAULTTIMESTAMPMODES 440 + "/" 441 + N_EXPORT_TIMESTAMPMODE 442 + "/" 443 + N_EXPORT_RESOURCETYPENAME, 444 "addResourceTypeForDefaultTimestampMode", 445 1); 446 447 digester.addCallParam( 448 "*/" 449 + N_IMPORTEXPORT 450 + "/" 451 + N_EXPORT 452 + "/" 453 + N_EXPORT_DEFAULTTIMESTAMPMODES 454 + "/" 455 + N_EXPORT_TIMESTAMPMODE 456 + "/" 457 + N_EXPORT_RESOURCETYPENAME, 458 0); 459 460 digester.addCallMethod("*/" + N_IMPORTEXPORT + "/" + N_TEMP_EXPORTPONT_PATH, "addTempExportpointPath", 1); 461 digester.addCallParam("*/" + N_IMPORTEXPORT + "/" + N_TEMP_EXPORTPONT_PATH, 0); 462 463 // creation of the static export manager 464 digester.addObjectCreate("*/" + N_STATICEXPORT, CmsStaticExportManager.class); 465 // static export manager finished 466 digester.addSetNext("*/" + N_STATICEXPORT, "setStaticExportManager"); 467 // export enabled role 468 digester.addCallMethod("*/" + N_STATICEXPORT, "setExportEnabled", 1); 469 digester.addCallParam("*/" + N_STATICEXPORT, 0, A_ENABLED); 470 // export handler rule 471 digester.addCallMethod("*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_HANDLER, "setHandler", 0); 472 // link substitution handler rule 473 digester.addCallMethod( 474 "*/" + N_STATICEXPORT + "/" + N_LINKSUBSTITUTION_HANDLER, 475 "setLinkSubstitutionHandler", 476 0); 477 // exportpath rule 478 digester.addCallMethod("*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_EXPORTPATH, "setExportPath", 0); 479 // exportworkpath rule 480 digester.addCallMethod("*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_EXPORTWORKPATH, "setExportWorkPath", 0); 481 // exportbackups rule 482 digester.addCallMethod("*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_EXPORTBACKUPS, "setExportBackups", 0); 483 // default property rule 484 digester.addCallMethod("*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_DEFAULT, "setDefault", 0); 485 // export suffix rule 486 digester.addCallMethod( 487 "*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_DEFAULTSUFFIXES + "/" + N_STATICEXPORT_SUFFIX, 488 "setExportSuffix", 489 1); 490 digester.addCallParam( 491 "*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_DEFAULTSUFFIXES + "/" + N_STATICEXPORT_SUFFIX, 492 0, 493 A_KEY); 494 // header rule 495 digester.addCallMethod( 496 "*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_EXPORTHEADERS + "/" + N_STATICEXPORT_HEADER, 497 "setExportHeader", 498 0); 499 // accept-language rule 500 digester.addCallMethod( 501 "*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_REQUESTHEADERS + "/" + N_STATICEXPORT_ACCEPTLANGUAGE, 502 "setAcceptLanguageHeader", 503 0); 504 // accept-charset rule 505 digester.addCallMethod( 506 "*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_REQUESTHEADERS + "/" + N_STATICEXPORT_ACCEPTCHARSET, 507 "setAcceptCharsetHeader", 508 0); 509 // accept-charset rule 510 digester.addCallMethod( 511 "*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_REQUESTHEADERS + "/" + N_STATICEXPORT_REMOTEADDR, 512 "setRemoteAddr", 513 0); 514 // rfs-prefix rule 515 digester.addCallMethod( 516 "*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_RENDERSETTINGS + "/" + N_STATICEXPORT_RFS_PREFIX, 517 "setRfsPrefix", 518 0); 519 // vfs-prefix rule 520 digester.addCallMethod( 521 "*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_RENDERSETTINGS + "/" + N_STATICEXPORT_VFS_PREFIX, 522 "setVfsPrefix", 523 0); 524 // relative links rule 525 digester.addCallMethod( 526 "*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_RENDERSETTINGS + "/" + N_STATICEXPORT_RELATIVELINKS, 527 "setRelativeLinks", 528 0); 529 // exporturl rule 530 digester.addCallMethod( 531 "*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_RENDERSETTINGS + "/" + N_STATICEXPORT_EXPORTURL, 532 "setExportUrl", 533 0); 534 // plain export optimization rule 535 digester.addCallMethod( 536 "*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_RENDERSETTINGS + "/" + N_STATICEXPORT_PLAINOPTIMIZATION, 537 "setPlainExportOptimization", 538 0); 539 // test resource rule 540 digester.addCallMethod( 541 "*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_RENDERSETTINGS + "/" + N_STATICEXPORT_TESTRESOURCE, 542 "setTestResource", 543 1); 544 digester.addCallParam( 545 "*/" + N_STATICEXPORT + "/" + N_STATICEXPORT_RENDERSETTINGS + "/" + N_STATICEXPORT_TESTRESOURCE, 546 0, 547 A_URI); 548 // resources to export rule 549 digester.addCallMethod( 550 "*/" 551 + N_STATICEXPORT 552 + "/" 553 + N_STATICEXPORT_RENDERSETTINGS 554 + "/" 555 + N_STATICEXPORT_RESOURCESTORENDER 556 + "/" 557 + N_STATICEXPORT_REGEX, 558 "setExportFolderPattern", 559 0); 560 561 // export-rules configuration 562 String exportRulePath = "*/" 563 + N_STATICEXPORT 564 + "/" 565 + N_STATICEXPORT_RENDERSETTINGS 566 + "/" 567 + N_STATICEXPORT_RESOURCESTORENDER 568 + "/" 569 + N_STATICEXPORT_EXPORTRULES 570 + "/" 571 + N_STATICEXPORT_EXPORTRULE; 572 digester.addCallMethod(exportRulePath, "addExportRule", 2); 573 digester.addCallParam(exportRulePath + "/" + N_STATICEXPORT_NAME, 0); 574 digester.addCallParam(exportRulePath + "/" + N_STATICEXPORT_DESCRIPTION, 1); 575 digester.addCallMethod( 576 exportRulePath + "/" + N_STATICEXPORT_MODIFIED + "/" + N_STATICEXPORT_REGEX, 577 "addExportRuleRegex", 578 1); 579 digester.addCallParam(exportRulePath + "/" + N_STATICEXPORT_MODIFIED + "/" + N_STATICEXPORT_REGEX, 0); 580 digester.addCallMethod( 581 exportRulePath + "/" + N_STATICEXPORT_EXPORT + "/" + N_STATICEXPORT_URI, 582 "addExportRuleUri", 583 1); 584 digester.addCallParam(exportRulePath + "/" + N_STATICEXPORT_EXPORT + "/" + N_STATICEXPORT_URI, 0); 585 586 // rfs-rules configuration 587 String rfsRulePath = "*/" 588 + N_STATICEXPORT 589 + "/" 590 + N_STATICEXPORT_RENDERSETTINGS 591 + "/" 592 + N_STATICEXPORT_RFS_RULES 593 + "/" 594 + N_STATICEXPORT_RFS_RULE; 595 digester.addCallMethod(rfsRulePath, "addRfsRule", 8); 596 digester.addCallParam(rfsRulePath + "/" + N_STATICEXPORT_NAME, 0); 597 digester.addCallParam(rfsRulePath + "/" + N_STATICEXPORT_DESCRIPTION, 1); 598 digester.addCallParam(rfsRulePath + "/" + N_STATICEXPORT_SOURCE, 2); 599 digester.addCallParam(rfsRulePath + "/" + N_STATICEXPORT_RFS_PREFIX, 3); 600 digester.addCallParam(rfsRulePath + "/" + N_STATICEXPORT_EXPORTPATH, 4); 601 digester.addCallParam(rfsRulePath + "/" + N_STATICEXPORT_EXPORTWORKPATH, 5); 602 digester.addCallParam(rfsRulePath + "/" + N_STATICEXPORT_EXPORTBACKUPS, 6); 603 digester.addCallParam(rfsRulePath + "/" + N_STATICEXPORT_RELATIVELINKS, 7); 604 // rfs-rule related system resources 605 digester.addCallMethod( 606 rfsRulePath + "/" + N_STATICEXPORT_RELATED_SYSTEM_RES + "/" + N_STATICEXPORT_REGEX, 607 "addRfsRuleSystemRes", 608 1); 609 digester.addCallParam(rfsRulePath + "/" + N_STATICEXPORT_RELATED_SYSTEM_RES + "/" + N_STATICEXPORT_REGEX, 0); 610 611 // adds protected export rules 612 digester.addCallMethod( 613 "*/" + N_PROTECTED_EXPORT + "/" + N_STATICEXPORT_EXPORTPATH, 614 "setProtectedExportPath", 615 1); 616 digester.addCallParam("*/" + N_PROTECTED_EXPORT + "/" + N_STATICEXPORT_EXPORTPATH, 0); 617 // add rules for the protected export points 618 digester.addCallMethod( 619 "*/" 620 + N_PROTECTED_EXPORT 621 + "/" 622 + I_CmsXmlConfiguration.N_EXPORTPOINTS 623 + "/" 624 + I_CmsXmlConfiguration.N_EXPORTPOINT, 625 "addProtectedExportPoint", 626 2); 627 digester.addCallParam( 628 "*/" 629 + N_PROTECTED_EXPORT 630 + "/" 631 + I_CmsXmlConfiguration.N_EXPORTPOINTS 632 + "/" 633 + I_CmsXmlConfiguration.N_EXPORTPOINT, 634 0, 635 I_CmsXmlConfiguration.A_URI); 636 digester.addCallParam( 637 "*/" 638 + N_PROTECTED_EXPORT 639 + "/" 640 + I_CmsXmlConfiguration.N_EXPORTPOINTS 641 + "/" 642 + I_CmsXmlConfiguration.N_EXPORTPOINT, 643 1, 644 I_CmsXmlConfiguration.A_DESTINATION); 645 646 // add rules for the user data export 647 digester.addObjectCreate("*/" + N_USERCSVEXPORT, CmsUserExportSettings.class); 648 digester.addCallMethod("*/" + N_USERCSVEXPORT + "/" + N_SEPARATOR, "setSeparator", 0); 649 digester.addCallMethod("*/" + N_USERCSVEXPORT + "/" + N_COLUMNS + "/" + N_COLUMN, "addColumn", 0); 650 digester.addSetNext("*/" + N_USERCSVEXPORT, "setUserExportSettings"); 651 652 // creation of the static repository manager 653 digester.addObjectCreate("*/" + N_REPOSITORIES, CmsRepositoryManager.class); 654 digester.addCallMethod("*/" + N_REPOSITORIES, I_CmsConfigurationParameterHandler.INIT_CONFIGURATION_METHOD); 655 digester.addSetNext("*/" + N_REPOSITORIES, "setRepositoryManager"); 656 657 // repository 658 digester.addObjectCreate( 659 "*/" + N_REPOSITORIES + "/" + N_REPOSITORY, 660 CmsConfigurationException.class.getName(), 661 A_CLASS); 662 663 // repository name 664 digester.addCallMethod("*/" + N_REPOSITORIES + "/" + N_REPOSITORY, "setName", 1); 665 digester.addCallParam("*/" + N_REPOSITORIES + "/" + N_REPOSITORY, 0, A_NAME); 666 667 // repository params 668 digester.addCallMethod( 669 "*/" + N_REPOSITORIES + "/" + N_REPOSITORY + "/" + N_PARAMS + "/" + N_PARAM, 670 I_CmsConfigurationParameterHandler.ADD_PARAMETER_METHOD, 671 2); 672 digester.addCallParam( 673 "*/" + N_REPOSITORIES + "/" + N_REPOSITORY + "/" + N_PARAMS + "/" + N_PARAM, 674 0, 675 I_CmsXmlConfiguration.A_NAME); 676 digester.addCallParam("*/" + N_REPOSITORIES + "/" + N_REPOSITORY + "/" + N_PARAMS + "/" + N_PARAM, 1); 677 678 // repository filter 679 digester.addObjectCreate( 680 "*/" + N_REPOSITORIES + "/" + N_REPOSITORY + "/" + N_FILTER, 681 CmsRepositoryFilter.class); 682 683 // repository filter type 684 digester.addCallMethod("*/" + N_REPOSITORIES + "/" + N_REPOSITORY + "/" + N_FILTER, "setType", 1); 685 digester.addCallParam("*/" + N_REPOSITORIES + "/" + N_REPOSITORY + "/" + N_FILTER, 0, A_TYPE); 686 687 // repository filter rules 688 digester.addCallMethod( 689 "*/" + N_REPOSITORIES + "/" + N_REPOSITORY + "/" + N_FILTER + "/" + N_REGEX, 690 "addFilterRule", 691 1); 692 digester.addCallParam("*/" + N_REPOSITORIES + "/" + N_REPOSITORY + "/" + N_FILTER + "/" + N_REGEX, 0); 693 694 digester.addSetNext("*/" + N_REPOSITORIES + "/" + N_REPOSITORY + "/" + N_FILTER, "setFilter"); 695 696 digester.addSetNext("*/" + N_REPOSITORIES + "/" + N_REPOSITORY, "addRepositoryClass"); 697 698 // create at least a repository manager though no repositories are configured 699 if (m_repositoryManager == null) { 700 m_repositoryManager = new CmsRepositoryManager(false); 701 } 702 // creation of the extended HTML importer 703 digester.addObjectCreate("*/" + N_EXTHTMLIMPORT, CmsExtendedHtmlImportDefault.class); 704 // extended HTML importer finished 705 digester.addSetNext("*/" + N_EXTHTMLIMPORT, "setExtendedHtmlImportManager"); 706 digester.addCallMethod("*/" + N_EXTHTMLIMPORT + "/" + N_EXTHTMLIMPORT_DESTINATION, "setDestinationDir", 0); 707 digester.addCallMethod("*/" + N_EXTHTMLIMPORT + "/" + N_EXTHTMLIMPORT_INPUT, "setInputDir", 0); 708 digester.addCallMethod( 709 "*/" + N_EXTHTMLIMPORT + "/" + N_EXTHTMLIMPORT_GALLERIES + "/" + N_EXTHTMLIMPORT_DOWNLOAD, 710 "setDownloadGallery", 711 0); 712 digester.addCallMethod( 713 "*/" + N_EXTHTMLIMPORT + "/" + N_EXTHTMLIMPORT_GALLERIES + "/" + N_EXTHTMLIMPORT_IMAGE, 714 "setImageGallery", 715 0); 716 digester.addCallMethod( 717 "*/" + N_EXTHTMLIMPORT + "/" + N_EXTHTMLIMPORT_GALLERIES + "/" + N_EXTHTMLIMPORT_EXTERNALLINK, 718 "setLinkGallery", 719 0); 720 digester.addCallMethod( 721 "*/" + N_EXTHTMLIMPORT + "/" + N_EXTHTMLIMPORT_SETTINGS + "/" + N_EXTHTMLIMPORT_TEMPLATE, 722 "setTemplate", 723 0); 724 digester.addCallMethod( 725 "*/" + N_EXTHTMLIMPORT + "/" + N_EXTHTMLIMPORT_SETTINGS + "/" + N_EXTHTMLIMPORT_ELEMENT, 726 "setElement", 727 0); 728 digester.addCallMethod( 729 "*/" + N_EXTHTMLIMPORT + "/" + N_EXTHTMLIMPORT_SETTINGS + "/" + N_EXTHTMLIMPORT_LOCALE, 730 "setLocale", 731 0); 732 digester.addCallMethod( 733 "*/" + N_EXTHTMLIMPORT + "/" + N_EXTHTMLIMPORT_SETTINGS + "/" + N_EXTHTMLIMPORT_ENCODING, 734 "setEncoding", 735 0); 736 digester.addCallMethod( 737 "*/" 738 + N_EXTHTMLIMPORT 739 + "/" 740 + N_EXTHTMLIMPORT_SETTINGS 741 + "/" 742 + N_EXTHTMLIMPORT_PATTERN 743 + "/" 744 + N_EXTHTMLIMPORT_PATTERN_START, 745 "setStartPattern", 746 0); 747 digester.addCallMethod( 748 "*/" 749 + N_EXTHTMLIMPORT 750 + "/" 751 + N_EXTHTMLIMPORT_SETTINGS 752 + "/" 753 + N_EXTHTMLIMPORT_PATTERN 754 + "/" 755 + N_EXTHTMLIMPORT_PATTERN_END, 756 "setEndPattern", 757 0); 758 digester.addCallMethod( 759 "*/" + N_EXTHTMLIMPORT + "/" + N_EXTHTMLIMPORT_SETTINGS + "/" + N_EXTHTMLIMPORT_OVERWRITE, 760 "setOverwrite", 761 0); 762 digester.addCallMethod( 763 "*/" + N_EXTHTMLIMPORT + "/" + N_EXTHTMLIMPORT_SETTINGS + "/" + N_EXTHTMLIMPORT_KEEPBROKENLINKS, 764 "setKeepBrokenLinks", 765 0); 766 } 767 768 /** 769 * @see org.opencms.configuration.I_CmsXmlConfiguration#generateXml(org.dom4j.Element) 770 */ 771 public Element generateXml(Element parent) { 772 773 // generate import/export node and subnodes 774 Element importexportElement = parent.addElement(N_IMPORTEXPORT); 775 776 Element resourceloadersElement = importexportElement.addElement(N_IMPORTEXPORTHANDLERS); 777 List<I_CmsImportExportHandler> handlers = m_importExportManager.getImportExportHandlers(); 778 Iterator<I_CmsImportExportHandler> handlerIt = handlers.iterator(); 779 while (handlerIt.hasNext()) { 780 I_CmsImportExportHandler handler = handlerIt.next(); 781 // add the handler node 782 Element loaderNode = resourceloadersElement.addElement(N_IMPORTEXPORTHANDLER); 783 loaderNode.addAttribute(A_CLASS, handler.getClass().getName()); 784 } 785 786 Element importElement = importexportElement.addElement(N_IMPORT); 787 788 // <overwrite> node 789 importElement.addElement(N_OVERWRITE).setText( 790 String.valueOf(m_importExportManager.overwriteCollidingResources())); 791 792 // <convert> node 793 importElement.addElement(N_CONVERT).setText(String.valueOf(m_importExportManager.convertToXmlPage())); 794 795 // <oldwebappurl> node 796 if (m_importExportManager.getOldWebAppUrl() != null) { 797 importElement.addElement(N_OLDWEBAPPURL).setText(m_importExportManager.getOldWebAppUrl()); 798 } 799 800 // <importversions> node 801 Element resourcetypesElement = importElement.addElement(N_IMPORTVERSIONS); 802 Iterator<I_CmsImport> importVersions = m_importExportManager.getImportVersionClasses().iterator(); 803 while (importVersions.hasNext()) { 804 resourcetypesElement.addElement(N_IMPORTVERSION).addAttribute( 805 A_CLASS, 806 importVersions.next().getClass().getName()); 807 } 808 809 // <immutables> node 810 Element immutablesElement = importElement.addElement(N_IMMUTABLES); 811 Iterator<String> immutables = m_importExportManager.getImmutableResources().iterator(); 812 while (immutables.hasNext()) { 813 String uri = immutables.next(); 814 immutablesElement.addElement(N_RESOURCE).addAttribute(A_URI, uri); 815 } 816 817 // <principaltranslations> node 818 Element principalsElement = importElement.addElement(N_PRINCIPALTRANSLATIONS); 819 Iterator<String> userTranslationKeys = m_importExportManager.getImportUserTranslations().keySet().iterator(); 820 while (userTranslationKeys.hasNext()) { 821 String from = userTranslationKeys.next(); 822 String to = m_importExportManager.getImportUserTranslations().get(from); 823 principalsElement.addElement(N_PRINCIPALTRANSLATION).addAttribute( 824 A_TYPE, 825 I_CmsPrincipal.PRINCIPAL_USER).addAttribute(A_FROM, from).addAttribute(A_TO, to); 826 } 827 Iterator<String> groupTranslationKeys = m_importExportManager.getImportGroupTranslations().keySet().iterator(); 828 while (groupTranslationKeys.hasNext()) { 829 String from = groupTranslationKeys.next(); 830 String to = m_importExportManager.getImportGroupTranslations().get(from); 831 principalsElement.addElement(N_PRINCIPALTRANSLATION).addAttribute( 832 A_TYPE, 833 I_CmsPrincipal.PRINCIPAL_GROUP).addAttribute(A_FROM, from).addAttribute(A_TO, to); 834 } 835 836 // <ignoredproperties> node 837 Element propertiesElement = importElement.addElement(N_IGNOREDPROPERTIES); 838 Iterator<String> ignoredProperties = m_importExportManager.getIgnoredProperties().iterator(); 839 while (ignoredProperties.hasNext()) { 840 String property = ignoredProperties.next(); 841 propertiesElement.addElement(N_PROPERTY).addAttribute(A_NAME, property); 842 } 843 844 // <export> node 845 Element exportElement = importexportElement.addElement(N_EXPORT); 846 Map<TimestampMode, List<String>> defaultTimestampModes = m_importExportManager.getDefaultTimestampModes(); 847 if (!defaultTimestampModes.isEmpty()) { 848 849 // <defaulttimestampmodes> 850 Element defaultTimestampModesElement = exportElement.addElement(N_EXPORT_DEFAULTTIMESTAMPMODES); 851 for (TimestampMode mode : defaultTimestampModes.keySet()) { 852 853 // <timestampmode> 854 Element timestampModeElement = defaultTimestampModesElement.addElement(N_EXPORT_TIMESTAMPMODE); 855 timestampModeElement.addAttribute(A_MODE, mode.toString().toLowerCase()); 856 for (String resourcetypeName : defaultTimestampModes.get(mode)) { 857 858 // <resourcetypename> 859 Element resourcetypeElement = timestampModeElement.addElement(N_EXPORT_RESOURCETYPENAME); 860 resourcetypeElement.addText(resourcetypeName); 861 } 862 } 863 } 864 865 List<String> tempExportpointPaths = m_importExportManager.getTempExportPointPaths(); 866 for (String path : tempExportpointPaths) { 867 importexportElement.addElement(N_TEMP_EXPORTPONT_PATH).addText(path); 868 } 869 870 // <staticexport> node 871 Element staticexportElement = parent.addElement(N_STATICEXPORT); 872 staticexportElement.addAttribute(A_ENABLED, m_staticExportManager.getExportEnabled()); 873 874 // <staticexporthandler> node 875 staticexportElement.addElement(N_STATICEXPORT_HANDLER).addText( 876 m_staticExportManager.getHandler().getClass().getName()); 877 878 // <linksubstitutionhandler> node 879 staticexportElement.addElement(N_LINKSUBSTITUTION_HANDLER).addText( 880 m_staticExportManager.getLinkSubstitutionHandler().getClass().getName()); 881 882 // <exportpath> node 883 String exportPathUnmodified = m_staticExportManager.getExportPathForConfiguration(); 884 // cut path seperator 885 if (exportPathUnmodified.endsWith(File.separator)) { 886 exportPathUnmodified = exportPathUnmodified.substring(0, exportPathUnmodified.length() - 1); 887 } 888 staticexportElement.addElement(N_STATICEXPORT_EXPORTPATH).addText(exportPathUnmodified); 889 890 // <exportworkpath> node 891 String exportWorkPathUnmodified = m_staticExportManager.getExportWorkPathForConfiguration(); 892 if (exportWorkPathUnmodified != null) { 893 // cut path seperator 894 if (exportWorkPathUnmodified.endsWith(File.separator)) { 895 exportWorkPathUnmodified = exportWorkPathUnmodified.substring(0, exportWorkPathUnmodified.length() - 1); 896 } 897 staticexportElement.addElement(N_STATICEXPORT_EXPORTWORKPATH).addText(exportWorkPathUnmodified); 898 } 899 900 // <exportbackups> node 901 if (m_staticExportManager.getExportBackups() != null) { 902 String exportBackupsUnmodified = String.valueOf(m_staticExportManager.getExportBackups()); 903 staticexportElement.addElement(N_STATICEXPORT_EXPORTBACKUPS).addText(exportBackupsUnmodified); 904 } 905 906 // <defaultpropertyvalue> node 907 staticexportElement.addElement(N_STATICEXPORT_DEFAULT).addText(m_staticExportManager.getDefault()); 908 909 // <defaultsuffixes> node and its <suffix> sub nodes 910 Element defaultsuffixesElement = staticexportElement.addElement(N_STATICEXPORT_DEFAULTSUFFIXES); 911 912 Iterator<String> exportSuffixes = m_staticExportManager.getExportSuffixes().iterator(); 913 while (exportSuffixes.hasNext()) { 914 String suffix = exportSuffixes.next(); 915 Element suffixElement = defaultsuffixesElement.addElement(N_STATICEXPORT_SUFFIX); 916 suffixElement.addAttribute(A_KEY, suffix); 917 } 918 919 // <exportheaders> node and its <header> sub nodes 920 Iterator<String> exportHandlers = m_staticExportManager.getExportHeaders().iterator(); 921 if (exportHandlers.hasNext()) { 922 Element exportheadersElement = staticexportElement.addElement(N_STATICEXPORT_EXPORTHEADERS); 923 while (exportHandlers.hasNext()) { 924 String header = exportHandlers.next(); 925 exportheadersElement.addElement(N_STATICEXPORT_HEADER).addText(header); 926 } 927 } 928 // <requestheaders> node and the <acceptlanguage> and <acceptcharset> node 929 String acceptlanguage = m_staticExportManager.getAcceptLanguageHeader(); 930 String acceptcharset = m_staticExportManager.getAcceptCharsetHeader(); 931 String remoteaddr = m_staticExportManager.getRemoteAddr(); 932 if ((acceptlanguage != null) || (acceptcharset != null) || (remoteaddr != null)) { 933 Element requestheadersElement = staticexportElement.addElement(N_STATICEXPORT_REQUESTHEADERS); 934 if (acceptlanguage != null) { 935 requestheadersElement.addElement(N_STATICEXPORT_ACCEPTLANGUAGE).addText(acceptlanguage); 936 } 937 if (acceptcharset != null) { 938 requestheadersElement.addElement(N_STATICEXPORT_ACCEPTCHARSET).addText(acceptcharset); 939 } 940 if (remoteaddr != null) { 941 requestheadersElement.addElement(N_STATICEXPORT_REMOTEADDR).addText(remoteaddr); 942 } 943 } 944 945 // <rendersettings> node 946 Element rendersettingsElement = staticexportElement.addElement(N_STATICEXPORT_RENDERSETTINGS); 947 948 // <rfsPrefix> node 949 rendersettingsElement.addElement(N_STATICEXPORT_RFS_PREFIX).addText( 950 m_staticExportManager.getRfsPrefixForConfiguration()); 951 952 // <vfsPrefix> node 953 rendersettingsElement.addElement(N_STATICEXPORT_VFS_PREFIX).addText( 954 m_staticExportManager.getVfsPrefixForConfiguration()); 955 956 // <userelativelinks> node 957 rendersettingsElement.addElement(N_STATICEXPORT_RELATIVELINKS).addText( 958 m_staticExportManager.getRelativeLinks()); 959 960 // <exporturl> node 961 rendersettingsElement.addElement(N_STATICEXPORT_EXPORTURL).addText( 962 m_staticExportManager.getExportUrlForConfiguration()); 963 964 // <plainoptimization> node 965 rendersettingsElement.addElement(N_STATICEXPORT_PLAINOPTIMIZATION).addText( 966 m_staticExportManager.getPlainExportOptimization()); 967 968 // <testresource> node 969 Element testresourceElement = rendersettingsElement.addElement(N_STATICEXPORT_TESTRESOURCE); 970 testresourceElement.addAttribute(A_URI, m_staticExportManager.getTestResource()); 971 972 // <resourcestorender> node and <regx> subnodes 973 Element resourcetorenderElement = rendersettingsElement.addElement(N_STATICEXPORT_RESOURCESTORENDER); 974 975 Iterator<String> exportFolderPatterns = m_staticExportManager.getExportFolderPatterns().iterator(); 976 while (exportFolderPatterns.hasNext()) { 977 String pattern = exportFolderPatterns.next(); 978 resourcetorenderElement.addElement(N_STATICEXPORT_REGEX).addText(pattern); 979 } 980 981 if (!m_staticExportManager.getExportRules().isEmpty()) { 982 // <export-rules> node 983 Element exportRulesElement = resourcetorenderElement.addElement(N_STATICEXPORT_EXPORTRULES); 984 985 Iterator<CmsStaticExportExportRule> exportRules = m_staticExportManager.getExportRules().iterator(); 986 while (exportRules.hasNext()) { 987 CmsStaticExportExportRule rule = exportRules.next(); 988 // <export-rule> node 989 Element exportRuleElement = exportRulesElement.addElement(N_STATICEXPORT_EXPORTRULE); 990 exportRuleElement.addElement(N_STATICEXPORT_NAME).addText(rule.getName()); 991 exportRuleElement.addElement(N_STATICEXPORT_DESCRIPTION).addText(rule.getDescription()); 992 // <modified-resources> node and <regex> subnodes 993 Element modifiedElement = exportRuleElement.addElement(N_STATICEXPORT_MODIFIED); 994 Iterator<Pattern> itMods = rule.getModifiedResources().iterator(); 995 while (itMods.hasNext()) { 996 Pattern regex = itMods.next(); 997 modifiedElement.addElement(N_STATICEXPORT_REGEX).addText(regex.pattern()); 998 } 999 // <export-resources> node and <uri> subnodes 1000 Element exportResourcesElement = exportRuleElement.addElement(N_STATICEXPORT_EXPORT); 1001 Iterator<String> itExps = rule.getExportResourcePatterns().iterator(); 1002 while (itExps.hasNext()) { 1003 String uri = itExps.next(); 1004 exportResourcesElement.addElement(N_STATICEXPORT_URI).addText(uri); 1005 } 1006 } 1007 } 1008 1009 if (!m_staticExportManager.getRfsRules().isEmpty()) { 1010 // <rfs-rules> node 1011 Element rfsRulesElement = rendersettingsElement.addElement(N_STATICEXPORT_RFS_RULES); 1012 1013 Iterator<CmsStaticExportRfsRule> rfsRules = m_staticExportManager.getRfsRules().iterator(); 1014 while (rfsRules.hasNext()) { 1015 CmsStaticExportRfsRule rule = rfsRules.next(); 1016 // <rfs-rule> node and subnodes 1017 Element rfsRuleElement = rfsRulesElement.addElement(N_STATICEXPORT_RFS_RULE); 1018 rfsRuleElement.addElement(N_STATICEXPORT_NAME).addText(rule.getName()); 1019 rfsRuleElement.addElement(N_STATICEXPORT_DESCRIPTION).addText(rule.getDescription()); 1020 rfsRuleElement.addElement(N_STATICEXPORT_SOURCE).addText(rule.getSource().pattern()); 1021 rfsRuleElement.addElement(N_STATICEXPORT_RFS_PREFIX).addText(rule.getRfsPrefixConfigured()); 1022 rfsRuleElement.addElement(N_STATICEXPORT_EXPORTPATH).addText(rule.getExportPathConfigured()); 1023 if (rule.getExportWorkPathConfigured() != null) { 1024 rfsRuleElement.addElement(N_STATICEXPORT_EXPORTWORKPATH).addText( 1025 rule.getExportWorkPathConfigured()); 1026 } 1027 if (rule.getExportBackups() != null) { 1028 rfsRuleElement.addElement(N_STATICEXPORT_EXPORTBACKUPS).addText( 1029 String.valueOf(rule.getExportBackups())); 1030 } 1031 if (rule.getUseRelativeLinks() != null) { 1032 rfsRuleElement.addElement(N_STATICEXPORT_RELATIVELINKS).addText( 1033 rule.getUseRelativeLinks().toString()); 1034 } 1035 Element relatedSystemRes = rfsRuleElement.addElement(N_STATICEXPORT_RELATED_SYSTEM_RES); 1036 Iterator<Pattern> itSystemRes = rule.getRelatedSystemResources().iterator(); 1037 while (itSystemRes.hasNext()) { 1038 Pattern sysRes = itSystemRes.next(); 1039 relatedSystemRes.addElement(N_STATICEXPORT_REGEX).addText(sysRes.pattern()); 1040 } 1041 } 1042 1043 } 1044 1045 if (m_staticExportManager.getProtectedExportPath() != null) { 1046 Element streamingEl = parent.addElement(N_PROTECTED_EXPORT); 1047 streamingEl.addElement(N_STATICEXPORT_EXPORTPATH).setText(m_staticExportManager.getProtectedExportPath()); 1048 Element exportpoints = streamingEl.addElement(I_CmsXmlConfiguration.N_EXPORTPOINTS); 1049 for (Entry<String, String> entry : m_staticExportManager.getProtectedExportPoints().entrySet()) { 1050 Element point = exportpoints.addElement(I_CmsXmlConfiguration.N_EXPORTPOINT); 1051 point.addAttribute(I_CmsXmlConfiguration.A_URI, entry.getKey()); 1052 point.addAttribute(I_CmsXmlConfiguration.A_DESTINATION, entry.getValue()); 1053 } 1054 } 1055 1056 if (m_importExportManager.getUserExportSettings() != null) { 1057 // <usercsvexport> 1058 Element userExportElement = parent.addElement(N_USERCSVEXPORT); 1059 1060 userExportElement.addElement(N_SEPARATOR).setText( 1061 m_importExportManager.getUserExportSettings().getSeparator()); 1062 Element exportColumns = userExportElement.addElement(N_COLUMNS); 1063 List<String> exportColumnList = m_importExportManager.getUserExportSettings().getColumns(); 1064 Iterator<String> itExportColumnList = exportColumnList.iterator(); 1065 while (itExportColumnList.hasNext()) { 1066 exportColumns.addElement(N_COLUMN).setText(itExportColumnList.next()); 1067 } 1068 // </usercsvexport> 1069 } 1070 1071 if (m_repositoryManager.isConfigured()) { 1072 List<I_CmsRepository> repositories = m_repositoryManager.getRepositories(); 1073 if (repositories != null) { 1074 1075 // <repositories> node 1076 Element repositoriesElement = parent.addElement(N_REPOSITORIES); 1077 1078 Iterator<I_CmsRepository> repositoriesIt = repositories.iterator(); 1079 while (repositoriesIt.hasNext()) { 1080 1081 // <repository> node 1082 I_CmsRepository repository = repositoriesIt.next(); 1083 Element repositoryElement = repositoriesElement.addElement(N_REPOSITORY); 1084 repositoryElement.addAttribute(A_NAME, repository.getName()); 1085 repositoryElement.addAttribute(A_CLASS, repository.getClass().getName()); 1086 1087 // <params> node 1088 CmsParameterConfiguration config = repository.getConfiguration(); 1089 if ((config != null) && (config.size() > 0)) { 1090 Element paramsElement = repositoryElement.addElement(N_PARAMS); 1091 config.appendToXml(paramsElement); 1092 } 1093 1094 // <filter> node 1095 CmsRepositoryFilter filter = repository.getFilter(); 1096 if (filter != null) { 1097 List<Pattern> rules = filter.getFilterRules(); 1098 if (rules.size() > 0) { 1099 Element filterElement = repositoryElement.addElement(N_FILTER); 1100 filterElement.addAttribute(A_TYPE, filter.getType()); 1101 1102 // <regex> nodes 1103 Iterator<Pattern> it = rules.iterator(); 1104 while (it.hasNext()) { 1105 Pattern rule = it.next(); 1106 filterElement.addElement(N_REGEX).addText(rule.pattern()); 1107 } 1108 } 1109 } 1110 } 1111 } 1112 } 1113 CmsExtendedHtmlImportDefault htmlimport = m_importExportManager.getExtendedHtmlImportDefault(true); 1114 if (htmlimport != null) { 1115 // <extendedhtmlimport> 1116 Element htmlImportElement = parent.addElement(N_EXTHTMLIMPORT); 1117 // <destination> node 1118 if (!CmsStringUtil.isEmptyOrWhitespaceOnly(htmlimport.getDestinationDir())) { 1119 htmlImportElement.addElement(N_EXTHTMLIMPORT_DESTINATION).setText(htmlimport.getDestinationDir()); 1120 } 1121 // <input> node 1122 if (!CmsStringUtil.isEmptyOrWhitespaceOnly(htmlimport.getInputDir())) { 1123 htmlImportElement.addElement(N_EXTHTMLIMPORT_INPUT).setText(htmlimport.getInputDir()); 1124 } 1125 1126 // <galleries> node 1127 Element galleryElement = htmlImportElement.addElement(N_EXTHTMLIMPORT_GALLERIES); 1128 // <download> node 1129 if (!CmsStringUtil.isEmptyOrWhitespaceOnly(htmlimport.getDownloadGallery())) { 1130 galleryElement.addElement(N_EXTHTMLIMPORT_DOWNLOAD).setText(htmlimport.getDownloadGallery()); 1131 } 1132 // <image> node 1133 if (!CmsStringUtil.isEmptyOrWhitespaceOnly(htmlimport.getImageGallery())) { 1134 galleryElement.addElement(N_EXTHTMLIMPORT_IMAGE).setText(htmlimport.getImageGallery()); 1135 } 1136 // <externallink> node 1137 if (!CmsStringUtil.isEmptyOrWhitespaceOnly(htmlimport.getLinkGallery())) { 1138 galleryElement.addElement(N_EXTHTMLIMPORT_EXTERNALLINK).setText(htmlimport.getLinkGallery()); 1139 } 1140 1141 // <settings> node 1142 Element settingElement = htmlImportElement.addElement(N_EXTHTMLIMPORT_SETTINGS); 1143 // <template> node 1144 settingElement.addElement(N_EXTHTMLIMPORT_TEMPLATE).setText(htmlimport.getTemplate()); 1145 // <element> node 1146 settingElement.addElement(N_EXTHTMLIMPORT_ELEMENT).setText(htmlimport.getElement()); 1147 // <locale> node 1148 settingElement.addElement(N_EXTHTMLIMPORT_LOCALE).setText(htmlimport.getLocale()); 1149 // <encoding> node 1150 settingElement.addElement(N_EXTHTMLIMPORT_ENCODING).setText(htmlimport.getEncoding()); 1151 1152 // <pattern> node 1153 Element patternElement = settingElement.addElement(N_EXTHTMLIMPORT_PATTERN); 1154 // <start> node 1155 if (!CmsStringUtil.isEmptyOrWhitespaceOnly(htmlimport.getStartPattern())) { 1156 patternElement.addElement(N_EXTHTMLIMPORT_PATTERN_START).setText(htmlimport.getStartPattern()); 1157 } 1158 // <end> node 1159 if (!CmsStringUtil.isEmptyOrWhitespaceOnly(htmlimport.getEndPattern())) { 1160 patternElement.addElement(N_EXTHTMLIMPORT_PATTERN_END).setText(htmlimport.getEndPattern()); 1161 } 1162 1163 // <overwrite> node 1164 settingElement.addElement(N_EXTHTMLIMPORT_OVERWRITE).setText(htmlimport.getOverwrite()); 1165 // <keepbrokenlinks> node 1166 settingElement.addElement(N_EXTHTMLIMPORT_KEEPBROKENLINKS).setText(htmlimport.getKeepBrokenLinks()); 1167 // </extendedhtmlimport> 1168 } 1169 1170 // return the configured node 1171 return importexportElement; 1172 } 1173 1174 /** 1175 * @see org.opencms.configuration.I_CmsXmlConfiguration#getDtdFilename() 1176 */ 1177 public String getDtdFilename() { 1178 1179 return CONFIGURATION_DTD_NAME; 1180 } 1181 1182 /** 1183 * Returns the initialized import/export manager.<p> 1184 * 1185 * @return the initialized import/export manager 1186 */ 1187 public CmsImportExportManager getImportExportManager() { 1188 1189 return m_importExportManager; 1190 } 1191 1192 /** 1193 * Returns the initialized repository manager.<p> 1194 * 1195 * @return the initialized repository manager 1196 */ 1197 public CmsRepositoryManager getRepositoryManager() { 1198 1199 return m_repositoryManager; 1200 } 1201 1202 /** 1203 * Returns the initialized static export manager.<p> 1204 * 1205 * @return the initialized static export manager 1206 */ 1207 public CmsStaticExportManager getStaticExportManager() { 1208 1209 return m_staticExportManager; 1210 } 1211 1212 /** 1213 * Will be called when configuration of this object is finished.<p> 1214 */ 1215 public void initializeFinished() { 1216 1217 if (CmsLog.INIT.isInfoEnabled()) { 1218 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_IMPORT_CONFIG_FINISHED_0)); 1219 } 1220 } 1221 1222 /** 1223 * Sets the extendedHtmlImportManager.<p> 1224 * 1225 * @param extendedHtmlImportManager the extendedHtmlImportManager to set 1226 */ 1227 public void setExtendedHtmlImportManager(CmsExtendedHtmlImportDefault extendedHtmlImportManager) { 1228 1229 m_importExportManager.setExtendedHtmlImportDefault(extendedHtmlImportManager); 1230 } 1231 1232 /** 1233 * Sets the generated import/export manager.<p> 1234 * 1235 * @param manager the import/export manager to set 1236 */ 1237 public void setImportExportManager(CmsImportExportManager manager) { 1238 1239 m_importExportManager = manager; 1240 if (CmsLog.INIT.isInfoEnabled()) { 1241 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_IMPORT_MANAGER_0)); 1242 } 1243 } 1244 1245 /** 1246 * Sets the protected export path.<p> 1247 * 1248 * @param exportPath the export path to set 1249 */ 1250 public void setProtectedExportPath(String exportPath) { 1251 1252 m_staticExportManager.setProtectedExportPath(exportPath); 1253 } 1254 1255 /** 1256 * Sets the generated repository manager.<p> 1257 * 1258 * @param manager the repository manager to set 1259 */ 1260 public void setRepositoryManager(CmsRepositoryManager manager) { 1261 1262 m_repositoryManager = manager; 1263 } 1264 1265 /** 1266 * Sets the generated static export manager.<p> 1267 * 1268 * @param manager the static export manager to set 1269 */ 1270 public void setStaticExportManager(CmsStaticExportManager manager) { 1271 1272 m_staticExportManager = manager; 1273 if (CmsLog.INIT.isInfoEnabled()) { 1274 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_STATEXP_MANAGER_0)); 1275 } 1276 } 1277 1278 /** 1279 * Sets the user settings for export and import.<p> 1280 * 1281 * @param userExportSettings the user settings for export and import 1282 */ 1283 public void setUserExportSettings(CmsUserExportSettings userExportSettings) { 1284 1285 m_importExportManager.setUserExportSettings(userExportSettings); 1286 } 1287 1288 /** 1289 * @see org.opencms.configuration.A_CmsXmlConfiguration#initMembers() 1290 */ 1291 @Override 1292 protected void initMembers() { 1293 1294 setXmlFileName(DEFAULT_XML_FILE_NAME); 1295 if (CmsLog.INIT.isInfoEnabled()) { 1296 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_IMPORT_CONFIG_INIT_0)); 1297 } 1298 } 1299 1300}