updates to put output in particualr directories and emit the captured xml as well as generated output to the avm

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3746 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2006-09-09 23:26:34 +00:00
parent 61394bda4e
commit 01d5ed2576

View File

@@ -85,7 +85,7 @@ public class OutputUtil
} }
catch (AVMNotFoundException notFound) catch (AVMNotFoundException notFound)
{ {
avmService.createDirectory(PARENT_AVM_PATH, parentName); // avmService.createDirectory(PARENT_AVM_PATH, parentName);
return PARENT_AVM_PATH; return PARENT_AVM_PATH;
} }
} }
@@ -103,16 +103,16 @@ public class OutputUtil
try try
{ {
// get the node ref of the node that will contain the content // get the node ref of the node that will contain the content
fileName = stripExtension(fileName) + ".html"; String generatedFileName = stripExtension(fileName) + ".shtml";
FileInfo fileInfo = FileInfo fileInfo =
fileFolderService.create(containerNodeRef, fileFolderService.create(containerNodeRef,
fileName, generatedFileName,
ContentModel.TYPE_CONTENT); ContentModel.TYPE_CONTENT);
NodeRef fileNodeRef = fileInfo.getNodeRef(); NodeRef fileNodeRef = fileInfo.getNodeRef();
if (LOGGER.isDebugEnabled()) if (LOGGER.isDebugEnabled())
LOGGER.debug("Created file node for file: " + LOGGER.debug("Created file node for file: " +
fileName); generatedFileName);
// get a writer for the content and put the file // get a writer for the content and put the file
ContentWriter writer = contentService.getWriter(fileNodeRef, ContentWriter writer = contentService.getWriter(fileNodeRef,
@@ -129,7 +129,7 @@ public class OutputUtil
TemplatingService.TT_QNAME, TemplatingService.TT_QNAME,
tt.getName()); tt.getName());
LOGGER.debug("generated " + fileName + " using " + tom); LOGGER.debug("generated " + generatedFileName + " using " + tom);
if (createdNode != null) if (createdNode != null)
{ {
@@ -140,6 +140,29 @@ public class OutputUtil
AVMService avmService = (AVMService)AVMContext.fgInstance.fAppContext.getBean("avmService"); AVMService avmService = (AVMService)AVMContext.fgInstance.fAppContext.getBean("avmService");
final String parentAVMPath = getAVMParentPath(createdNode, nodeService); final String parentAVMPath = getAVMParentPath(createdNode, nodeService);
try
{
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, generatedFileName));
}
catch (AVMExistsException e)
{
out = new OutputStreamWriter(avmService.getFileOutputStream(parentAVMPath + "/" + generatedFileName));
}
LOGGER.debug("generating " + generatedFileName + " to avm");
tom.generate(xml, tt, out);
out.close();
try
{
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, generatedFileName));
}
catch (AVMExistsException e)
{
out = new OutputStreamWriter(avmService.getFileOutputStream(parentAVMPath + "/" + generatedFileName));
}
LOGGER.debug("generating " + generatedFileName + " to avm");
tom.generate(xml, tt, out);
out.close();
try try
{ {
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, fileName)); out = new OutputStreamWriter(avmService.createFile(parentAVMPath, fileName));
@@ -148,8 +171,9 @@ public class OutputUtil
{ {
out = new OutputStreamWriter(avmService.getFileOutputStream(parentAVMPath + "/" + fileName)); out = new OutputStreamWriter(avmService.getFileOutputStream(parentAVMPath + "/" + fileName));
} }
LOGGER.debug("generating " + fileName + " to avm"); LOGGER.debug("writing xml " + fileName + " to avm");
tom.generate(xml, tt, out); final TemplatingService ts = TemplatingService.getInstance();
ts.writeXML(xml, out);
out.close(); out.close();
} }
catch (Exception e) catch (Exception e)
@@ -217,6 +241,18 @@ public class OutputUtil
LOGGER.debug("generating " + generatedFileName + " to avm"); LOGGER.debug("generating " + generatedFileName + " to avm");
tom.generate(xml, tt, out); tom.generate(xml, tt, out);
out.close(); out.close();
try
{
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, fileName));
}
catch (AVMExistsException e)
{
out = new OutputStreamWriter(avmService.getFileOutputStream(parentAVMPath + "/" + fileName));
}
LOGGER.debug("writing xml " + fileName + " to avm");
ts.writeXML(xml, out);
out.close();
} }
catch (Exception e) catch (Exception e)
{ {