modification to get generated output to save to a directory in the avm based on the current working directory in the webapp

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3738 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2006-09-08 22:15:56 +00:00
parent 215daea304
commit 99dc9c9128

View File

@@ -49,8 +49,7 @@ import org.alfresco.service.cmr.repository.ContentWriter;
import java.io.OutputStreamWriter;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.*;
import org.w3c.dom.Document;
import org.alfresco.repo.avm.*;
@@ -63,13 +62,24 @@ public class OutputUtil
{
private static final Log LOGGER = LogFactory.getLog(OutputUtil.class);
private static final String PARENT_AVM_PATH =
"repo-1:/repo-1/alice/appBase/avm_webapps/ROOT/home-insurance";
"repo-1:/repo-1/alice/appBase/avm_webapps/ROOT";
private static String stripExtension(String s)
{
return s.replaceAll("(.+)\\..*", "$1");
}
private static String getAVMParentPath(NodeRef nodeRef,
NodeService nodeService)
throws Exception
{
ChildAssociationRef caf = nodeService.getPrimaryParent(nodeRef);
final String parentName = (String)
nodeService.getProperty(caf.getParentRef(), ContentModel.PROP_NAME);
LOGGER.debug("computed avm path " + PARENT_AVM_PATH + "/" + parentName);
return PARENT_AVM_PATH + "/" + parentName;
}
public static void generate(NodeRef createdNode,
Document xml,
TemplateType tt,
@@ -119,13 +129,14 @@ public class OutputUtil
}
AVMService avmService = AVMContext.fgInstance.getAVMService();
final String parentAVMPath = getAVMParentPath(createdNode, nodeService);
try
{
out = new OutputStreamWriter(avmService.createFile(PARENT_AVM_PATH, fileName));
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, fileName));
}
catch (AVMExistsException e)
{
out = new OutputStreamWriter(avmService.getFileOutputStream(PARENT_AVM_PATH + "/" + fileName));
out = new OutputStreamWriter(avmService.getFileOutputStream(parentAVMPath + "/" + fileName));
}
LOGGER.debug("generating " + fileName + " to avm");
tom.generate(xml, tt, out);
@@ -139,7 +150,6 @@ public class OutputUtil
}
}
public static void regenerate(final NodeRef nodeRef,
final ContentService contentService,
final NodeService nodeService)
@@ -185,14 +195,14 @@ public class OutputUtil
LOGGER.debug("generated " + fileName + " using " + tom);
AVMService avmService = AVMContext.fgInstance.getAVMService();
final String parentAVMPath = getAVMParentPath(nodeRef, nodeService);
try
{
out = new OutputStreamWriter(avmService.createFile(PARENT_AVM_PATH, generatedFileName));
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, generatedFileName));
}
catch (AVMExistsException e)
{
out = new OutputStreamWriter(avmService.getFileOutputStream(PARENT_AVM_PATH + "/" + generatedFileName));
out = new OutputStreamWriter(avmService.getFileOutputStream(parentAVMPath + "/" + generatedFileName));
}
LOGGER.debug("generating " + generatedFileName + " to avm");
tom.generate(xml, tt, out);