}
private Result execute(ToolsLogger logger, String applicationRootPath, String categories, String filterPropertiesFileName, Properties initProperties, String rootFolder, boolean importing) throws JetspeedException
{
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
SpringComponentManager scm = null;
PageSerializer.Result result = null;
try
{
JetspeedBeanDefinitionFilter filter = null;
if (filterPropertiesFileName != null)
{
filter = new JetspeedBeanDefinitionFilter("file:"+filterPropertiesFileName, categories);
}
else
{
filter = new JetspeedBeanDefinitionFilter(categories);
}
String assemblyRootPath = "file:"+applicationRootPath+"/WEB-INF/assembly";
String[] bootConfig = {assemblyRootPath+"/boot/*.xml"};
String[] appConfig = { assemblyRootPath+"/*.xml", assemblyRootPath+"/override/*.xml" };
ClassLoader extendedClassLoader = contextClassLoader;
File webInfClasses = new File(applicationRootPath, "WEB-INF/classes");
if (webInfClasses.exists())
{
extendedClassLoader = new URLClassLoader(new URL[]{webInfClasses.toURL()}, contextClassLoader);
}
Thread.currentThread().setContextClassLoader(extendedClassLoader);
if (initProperties == null)
{
initProperties = new Properties();
}
initProperties.put("page.manager.permissions.security", "false");
initProperties.put("page.manager.constraints.security", "false");
scm = new SpringComponentManager(filter, bootConfig, appConfig, applicationRootPath, initProperties, true);
scm.start();
PageSerializer serializer = (PageSerializer)scm.getComponent(PageSerializer.class.getName());
if (importing)
{
result = serializer.importPages(logger, rootFolder);
}
else
{
result = serializer.exportPages(logger, rootFolder);
}
}
catch (Exception e)
{
logger.error(e);
if (e instanceof JetspeedException)
{
throw (JetspeedException)e;
}
throw new JetspeedException(e);
}
finally
{
Thread.currentThread().setContextClassLoader(contextClassLoader);
if (scm != null)
{
scm.stop();
}
}
return result;
}