mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -49,8 +49,7 @@ import org.alfresco.service.cmr.repository.ContentWriter;
|
|||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import org.alfresco.web.app.servlet.FacesHelper;
|
import org.alfresco.web.app.servlet.FacesHelper;
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.*;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.alfresco.repo.avm.*;
|
import org.alfresco.repo.avm.*;
|
||||||
|
|
||||||
@@ -63,13 +62,24 @@ public class OutputUtil
|
|||||||
{
|
{
|
||||||
private static final Log LOGGER = LogFactory.getLog(OutputUtil.class);
|
private static final Log LOGGER = LogFactory.getLog(OutputUtil.class);
|
||||||
private static final String PARENT_AVM_PATH =
|
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)
|
private static String stripExtension(String s)
|
||||||
{
|
{
|
||||||
return s.replaceAll("(.+)\\..*", "$1");
|
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,
|
public static void generate(NodeRef createdNode,
|
||||||
Document xml,
|
Document xml,
|
||||||
TemplateType tt,
|
TemplateType tt,
|
||||||
@@ -119,13 +129,14 @@ public class OutputUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
AVMService avmService = AVMContext.fgInstance.getAVMService();
|
AVMService avmService = AVMContext.fgInstance.getAVMService();
|
||||||
|
final String parentAVMPath = getAVMParentPath(createdNode, nodeService);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out = new OutputStreamWriter(avmService.createFile(PARENT_AVM_PATH, fileName));
|
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, fileName));
|
||||||
}
|
}
|
||||||
catch (AVMExistsException e)
|
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");
|
LOGGER.debug("generating " + fileName + " to avm");
|
||||||
tom.generate(xml, tt, out);
|
tom.generate(xml, tt, out);
|
||||||
@@ -139,7 +150,6 @@ public class OutputUtil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void regenerate(final NodeRef nodeRef,
|
public static void regenerate(final NodeRef nodeRef,
|
||||||
final ContentService contentService,
|
final ContentService contentService,
|
||||||
final NodeService nodeService)
|
final NodeService nodeService)
|
||||||
@@ -185,14 +195,14 @@ public class OutputUtil
|
|||||||
LOGGER.debug("generated " + fileName + " using " + tom);
|
LOGGER.debug("generated " + fileName + " using " + tom);
|
||||||
|
|
||||||
AVMService avmService = AVMContext.fgInstance.getAVMService();
|
AVMService avmService = AVMContext.fgInstance.getAVMService();
|
||||||
|
final String parentAVMPath = getAVMParentPath(nodeRef, nodeService);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
out = new OutputStreamWriter(avmService.createFile(PARENT_AVM_PATH, generatedFileName));
|
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, generatedFileName));
|
||||||
}
|
}
|
||||||
catch (AVMExistsException e)
|
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");
|
LOGGER.debug("generating " + generatedFileName + " to avm");
|
||||||
tom.generate(xml, tt, out);
|
tom.generate(xml, tt, out);
|
||||||
|
Reference in New Issue
Block a user