Version repository200509 = factory.createVersion("repository 2005/09");
Version repository200512 = factory.createVersion("repository 2005/12");
Version repository200602 = factory.createVersion("repository 2006/02");
ResourceMigratorBuilder builder =
factory.createResourceMigratorBuilder(reporter);
// ====================================================================
// Repository Migration
// ====================================================================
// Set the target version for the next type (YEUCH).
// todo: add this inside the type, and validate to make sure that it is set properly.
builder.setTarget(repository200602);
builder.startType("repository");
builder.setRegexpPathRecogniser(".*\\.(mthm|mimg|mlyt|mtxt|mlnk|" +
"mrlv|mscr|mdyv|mcht|mbtn|mauc|mgrp)");
// --------------------------------------------------------------------
// Repository Versions
// --------------------------------------------------------------------
builder.addRegexpContentRecogniser(lpdm30,
PolicySchemas.MARLIN_LPDM_V3_0.getNamespaceURL());
builder.addRegexpContentRecogniser(rpdm27to30,
"</remotePolicySetResponse>|</remotePolicyResponse>");
// todo the namespace URLs may contain characters that have a special
// todo meaning in a RE and they should really be quoted.
builder.addRegexpContentRecogniser(repository200509,
PolicySchemas.MARLIN_LPDM_2005_09.getNamespaceURL() + "|" +
PolicySchemas.MARLIN_RPDM_2005_09.getNamespaceURL());
builder.addRegexpContentRecogniser(repository200512,
PolicySchemas.MARLIN_LPDM_2005_12.getNamespaceURL() + "|" +
PolicySchemas.MARLIN_RPDM_2005_12.getNamespaceURL());
builder.addRegexpContentRecogniser(repository200602,
PolicySchemas.MARLIN_LPDM_2006_02.getNamespaceURL() + "|" +
PolicySchemas.MARLIN_RPDM_2006_02.getNamespaceURL());
XSLStreamMigratorBuilder xslBuilder;
// --------------------------------------------------------------------
// Step: LPDM 3.0 -> 2005/09
// --------------------------------------------------------------------
xslBuilder = builder.createXSLStreamMigratorBuilder();
xslBuilder.setXSL(
"/com/volantis/mcs/migrate/impl/config/lpdm/xsl/lpdm-v30-to-200509.xsl");
xslBuilder.setStrictMode(strictMode);
// Add the 3.0 LPDM schemas for input validation.
xslBuilder.addInputSchema(PolicySchemas.MARLIN_LPDM_V3_0);
// Add the 2005/09 LPDM schemas for output validation.
xslBuilder.addOutputSchemata(PolicySchemas.REPOSITORY_2005_09);
builder.addStep(lpdm30, repository200509, xslBuilder.getCompletedMigrator());
// --------------------------------------------------------------------
// Step: RPDM 2.7-3.0 -> 2005/09
// --------------------------------------------------------------------
xslBuilder = builder.createXSLStreamMigratorBuilder();
xslBuilder.setXSL(
"/com/volantis/mcs/migrate/impl/config/lpdm/xsl/rpdm-v30-to-200509.xsl");
// Input DTDs are handled via the repository resolver.
// TODO: handle rpdm DTDs explicitly.
xslBuilder.addEntityResolver(createRepositoryEntityResolver());
// Turn of strict mode because previous version of MCS allowed
// garbage to de entered.
xslBuilder.setStrictMode(false);
// Add the 2005/12 RPDM schemas for output validation.
xslBuilder.addOutputSchemata(PolicySchemas.REPOSITORY_2005_09);
builder.addStep(rpdm27to30, repository200509, xslBuilder.getCompletedMigrator());
// --------------------------------------------------------------------
// Step: 2005/09 -> 2005/12
// --------------------------------------------------------------------
xslBuilder = builder.createXSLStreamMigratorBuilder();
xslBuilder.setXSL(
"/com/volantis/mcs/migrate/impl/config/lpdm/xsl/rpdm-200509-to-200512.xsl");
xslBuilder.setStrictMode(strictMode);
// Add schema for 2005/09
xslBuilder.addInputSchemata(PolicySchemas.REPOSITORY_2005_09);
// Add schema for 2005/12
xslBuilder.addOutputSchemata(PolicySchemas.REPOSITORY_2005_12);
builder.addStep(repository200509, repository200512,
xslBuilder.getCompletedMigrator());
// --------------------------------------------------------------------
// Step: 2005/12 -> 2006/02
// --------------------------------------------------------------------
xslBuilder = builder.createXSLStreamMigratorBuilder();
xslBuilder.setXSL(
"/com/volantis/mcs/migrate/impl/config/lpdm/xsl/rpdm-200512-to-200602.xsl");
xslBuilder.setStrictMode(strictMode);
// Add schema for 2005/12
xslBuilder.addInputSchemata(PolicySchemas.REPOSITORY_2005_12);
// Add schema for 2006/02
xslBuilder.addOutputSchemata(PolicySchemas.REPOSITORY_2006_02);
builder.addStep(repository200512, repository200602,
xslBuilder.getCompletedMigrator());
builder.endType();
return builder.getCompletedResourceMigrator();
}