mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
. WCM UI
- Added Edit and Delete actions for AVM files and Delete action for AVM folders - Available on the Modified Items list for a user and also in the website sandbox browse screens - Edit is working using the inline editors for plain text and HTML files - XML form content editing to be integrated shortly! - Edit for non-inline editable files is working (i.e. download file), but no "Update" action available at present for saving updates - Delete will delete files/folders structures from the current sandbox, deleted files in a layer are shown in My Modified Files (see below) - User sandbox My Modified Files now shows deleted files as differences (as ghosted out rows) - Refactoring of the modified Create Content Wizard into a new wizard Create Web Content Wizard - responsible for creating content in the AVM store rather than usual SpacesStore - removed XML specific handling from Create Content Wizard (now only present in Create Web Content Wizard) - Create Content action added to sandbox view - NOTE: does not yet create content in the AVM world! - Added "jsp" filetype as plain text format mimetype (to allow inline-edit for JSP files as website content) - Open/closed state of My Modified Files panel is remembered between screen refreshes git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3864 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -42,205 +42,205 @@ import org.w3c.dom.Document;
|
||||
*/
|
||||
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";
|
||||
|
||||
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);
|
||||
final String result = PARENT_AVM_PATH + "/" + parentName;
|
||||
AVMService avmService = (AVMService)AVMContext.fgInstance.fAppContext.getBean("avmService");
|
||||
if (avmService.lookup(-1, result) != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
// avmService.createDirectory(PARENT_AVM_PATH, parentName);
|
||||
return PARENT_AVM_PATH;
|
||||
}
|
||||
}
|
||||
|
||||
public static void generate(NodeRef createdNode,
|
||||
Document xml,
|
||||
TemplateType tt,
|
||||
String fileName,
|
||||
NodeRef containerNodeRef,
|
||||
FileFolderService fileFolderService,
|
||||
ContentService contentService,
|
||||
NodeService nodeService)
|
||||
throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
// get the node ref of the node that will contain the content
|
||||
String generatedFileName = stripExtension(fileName) + ".shtml";
|
||||
FileInfo fileInfo =
|
||||
fileFolderService.create(containerNodeRef,
|
||||
generatedFileName,
|
||||
ContentModel.TYPE_CONTENT);
|
||||
NodeRef fileNodeRef = fileInfo.getNodeRef();
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("Created file node for file: " +
|
||||
generatedFileName);
|
||||
|
||||
// get a writer for the content and put the file
|
||||
ContentWriter writer = contentService.getWriter(fileNodeRef,
|
||||
ContentModel.PROP_CONTENT, true);
|
||||
// set the mimetype and encoding
|
||||
writer.setMimetype("text/html");
|
||||
writer.setEncoding("UTF-8");
|
||||
TemplateOutputMethod tom = tt.getOutputMethods().get(0);
|
||||
OutputStreamWriter out =
|
||||
new OutputStreamWriter(writer.getContentOutputStream());
|
||||
tom.generate(xml, tt, out);
|
||||
out.close();
|
||||
nodeService.setProperty(fileNodeRef,
|
||||
TemplatingService.TT_QNAME,
|
||||
tt.getName());
|
||||
|
||||
LOGGER.debug("generated " + generatedFileName + " using " + tom);
|
||||
|
||||
if (createdNode != null)
|
||||
{
|
||||
nodeService.setProperty(createdNode,
|
||||
TemplatingService.TT_GENERATED_OUTPUT_QNAME,
|
||||
fileNodeRef.toString());
|
||||
}
|
||||
|
||||
AVMService avmService = (AVMService)AVMContext.fgInstance.fAppContext.getBean("avmService");
|
||||
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
|
||||
{
|
||||
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, fileName));
|
||||
}
|
||||
catch (AVMExistsException e)
|
||||
{
|
||||
out = new OutputStreamWriter(avmService.getFileOutputStream(parentAVMPath + "/" + fileName));
|
||||
}
|
||||
LOGGER.debug("writing xml " + fileName + " to avm");
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
ts.writeXML(xml, out);
|
||||
out.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error(e);
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static void regenerate(final NodeRef nodeRef,
|
||||
final ContentService contentService,
|
||||
final NodeService nodeService)
|
||||
throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
final String templateTypeName = (String)
|
||||
nodeService.getProperty(nodeRef, TemplatingService.TT_QNAME);
|
||||
final TemplateType tt = ts.getTemplateType(templateTypeName);
|
||||
|
||||
final ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
|
||||
final Document xml = ts.parseXML(reader.getContentInputStream());
|
||||
String fileName = (String)
|
||||
nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
NodeRef generatedNodeRef =
|
||||
new NodeRef((String)
|
||||
nodeService.getProperty(nodeRef,
|
||||
TemplatingService.TT_GENERATED_OUTPUT_QNAME));
|
||||
String generatedFileName = (String)
|
||||
nodeService.getProperty(generatedNodeRef,
|
||||
ContentModel.PROP_NAME);
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("regenerating file node for : " + fileName + " (" +
|
||||
nodeRef.toString() + ") to " + generatedNodeRef.toString());
|
||||
|
||||
// get a writer for the content and put the file
|
||||
ContentWriter writer = contentService.getWriter(generatedNodeRef,
|
||||
ContentModel.PROP_CONTENT,
|
||||
true);
|
||||
// set the mimetype and encoding
|
||||
writer.setMimetype("text/html");
|
||||
writer.setEncoding("UTF-8");
|
||||
// put a loop to generate all output methods
|
||||
TemplateOutputMethod tom = tt.getOutputMethods().get(0);
|
||||
OutputStreamWriter out =
|
||||
new OutputStreamWriter(writer.getContentOutputStream());
|
||||
tom.generate(xml, tt, out);
|
||||
out.close();
|
||||
|
||||
LOGGER.debug("generated " + fileName + " using " + tom);
|
||||
|
||||
AVMService avmService = (AVMService)AVMContext.fgInstance.fAppContext.getBean("avmService");
|
||||
final String parentAVMPath = getAVMParentPath(nodeRef, 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, 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)
|
||||
{
|
||||
LOGGER.error(e);
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
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";
|
||||
|
||||
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);
|
||||
final String result = PARENT_AVM_PATH + "/" + parentName;
|
||||
AVMService avmService = (AVMService)AVMContext.fgInstance.fAppContext.getBean("avmService");
|
||||
if (avmService.lookup(-1, result) != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
// avmService.createDirectory(PARENT_AVM_PATH, parentName);
|
||||
return PARENT_AVM_PATH;
|
||||
}
|
||||
}
|
||||
|
||||
public static void generate(NodeRef createdNode,
|
||||
Document xml,
|
||||
TemplateType tt,
|
||||
String fileName,
|
||||
NodeRef containerNodeRef,
|
||||
FileFolderService fileFolderService,
|
||||
ContentService contentService,
|
||||
NodeService nodeService)
|
||||
throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
// get the node ref of the node that will contain the content
|
||||
String generatedFileName = stripExtension(fileName) + ".shtml";
|
||||
FileInfo fileInfo =
|
||||
fileFolderService.create(containerNodeRef,
|
||||
generatedFileName,
|
||||
ContentModel.TYPE_CONTENT);
|
||||
NodeRef fileNodeRef = fileInfo.getNodeRef();
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("Created file node for file: " +
|
||||
generatedFileName);
|
||||
|
||||
// get a writer for the content and put the file
|
||||
ContentWriter writer = contentService.getWriter(fileNodeRef,
|
||||
ContentModel.PROP_CONTENT, true);
|
||||
// set the mimetype and encoding
|
||||
writer.setMimetype("text/html");
|
||||
writer.setEncoding("UTF-8");
|
||||
TemplateOutputMethod tom = tt.getOutputMethods().get(0);
|
||||
OutputStreamWriter out =
|
||||
new OutputStreamWriter(writer.getContentOutputStream());
|
||||
tom.generate(xml, tt, out);
|
||||
out.close();
|
||||
nodeService.setProperty(fileNodeRef,
|
||||
TemplatingService.TT_QNAME,
|
||||
tt.getName());
|
||||
|
||||
LOGGER.debug("generated " + generatedFileName + " using " + tom);
|
||||
|
||||
if (createdNode != null)
|
||||
{
|
||||
nodeService.setProperty(createdNode,
|
||||
TemplatingService.TT_GENERATED_OUTPUT_QNAME,
|
||||
fileNodeRef.toString());
|
||||
}
|
||||
|
||||
AVMService avmService = (AVMService)AVMContext.fgInstance.fAppContext.getBean("avmService");
|
||||
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
|
||||
{
|
||||
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, fileName));
|
||||
}
|
||||
catch (AVMExistsException e)
|
||||
{
|
||||
out = new OutputStreamWriter(avmService.getFileOutputStream(parentAVMPath + "/" + fileName));
|
||||
}
|
||||
LOGGER.debug("writing xml " + fileName + " to avm");
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
ts.writeXML(xml, out);
|
||||
out.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error(e);
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static void regenerate(final NodeRef nodeRef,
|
||||
final ContentService contentService,
|
||||
final NodeService nodeService)
|
||||
throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
final String templateTypeName = (String)
|
||||
nodeService.getProperty(nodeRef, TemplatingService.TT_QNAME);
|
||||
final TemplateType tt = ts.getTemplateType(templateTypeName);
|
||||
|
||||
final ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
|
||||
final Document xml = ts.parseXML(reader.getContentInputStream());
|
||||
String fileName = (String)
|
||||
nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
NodeRef generatedNodeRef =
|
||||
new NodeRef((String)
|
||||
nodeService.getProperty(nodeRef,
|
||||
TemplatingService.TT_GENERATED_OUTPUT_QNAME));
|
||||
String generatedFileName = (String)
|
||||
nodeService.getProperty(generatedNodeRef,
|
||||
ContentModel.PROP_NAME);
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("regenerating file node for : " + fileName + " (" +
|
||||
nodeRef.toString() + ") to " + generatedNodeRef.toString());
|
||||
|
||||
// get a writer for the content and put the file
|
||||
ContentWriter writer = contentService.getWriter(generatedNodeRef,
|
||||
ContentModel.PROP_CONTENT,
|
||||
true);
|
||||
// set the mimetype and encoding
|
||||
writer.setMimetype("text/html");
|
||||
writer.setEncoding("UTF-8");
|
||||
// put a loop to generate all output methods
|
||||
TemplateOutputMethod tom = tt.getOutputMethods().get(0);
|
||||
OutputStreamWriter out =
|
||||
new OutputStreamWriter(writer.getContentOutputStream());
|
||||
tom.generate(xml, tt, out);
|
||||
out.close();
|
||||
|
||||
LOGGER.debug("generated " + fileName + " using " + tom);
|
||||
|
||||
AVMService avmService = (AVMService)AVMContext.fgInstance.fAppContext.getBean("avmService");
|
||||
final String parentAVMPath = getAVMParentPath(nodeRef, 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, 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)
|
||||
{
|
||||
LOGGER.error(e);
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user