mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
first stab at the multi channel thing
- renamed create-xml-content-type wizard to create-form wizard and moved it into the wcm source tree - modified the create form wizard to accept 0 to n template output methods - changed terminology from presentation template to template output method - using associations to track output methods - added file extension as property of templateoutputmethod to parameterize what the name of the output file should be - auto adding .xml to file name in create web content if none specified. - making associating an output method with a template optional git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4043 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -238,7 +238,7 @@ remove_user=Remove User
|
||||
create_space=Create Space
|
||||
add_content=Add Content
|
||||
create_content=Create Content
|
||||
create_xml_content_type=Create Form
|
||||
create_form=Create Form
|
||||
add_multiple_files=Add Multiple Files
|
||||
import_directory=Import Directory
|
||||
advanced_space_wizard=Advanced Space Wizard
|
||||
@@ -641,17 +641,21 @@ content=Content
|
||||
text_content=Plain Text Content
|
||||
html_content=HTML Content
|
||||
xml_content=XML Content
|
||||
create_xml_content_type_title=Create Form Wizard
|
||||
create_xml_content_type_desc=Create Form
|
||||
create_xml_content_type_step1_title=Upload an XML Schema
|
||||
create_xml_content_type_step1_desc=Upload an XML Schema
|
||||
create_xml_content_type_step2_title=Edit the XML Schema
|
||||
create_xml_content_type_step2_desc=This is the generated XForm based on the schema provided.
|
||||
create_form_title=Create Form Wizard
|
||||
create_form_desc=Create Form
|
||||
create_form_step1_title=Upload an XML Schema
|
||||
create_form_step1_desc=Upload an XML Schema
|
||||
create_form_step2_title=Edit the XML Schema
|
||||
create_form_step2_desc=This is the generated XForm based on the schema provided.
|
||||
selected_templateoutputmethods=Selected Template Output Methods
|
||||
configure_output_methods_step1_desc=Upload template output method and specify the extension to use for it\'s generated assets.
|
||||
template_output_method_file=Template Output Method File
|
||||
extension_for_generated_assets=Extension For Generated Assets
|
||||
schema=Schema
|
||||
schema_root_tag_name=Root Tag
|
||||
edit_xml_schema=Edit XML Schema
|
||||
template_type=Template Type
|
||||
configure_presentation_templates=Configure Presentation Templates
|
||||
configure_template_output_methods=Configure Template Output Methods
|
||||
|
||||
# Rule and Action Wizard messages
|
||||
run_action_title=Run Action Wizard
|
||||
|
@@ -325,13 +325,13 @@
|
||||
</action>
|
||||
|
||||
<!-- Create XML content type -->
|
||||
<action id="create_xml_content_type">
|
||||
<action id="create_form">
|
||||
<permissions>
|
||||
<permission allow="true">CreateChildren</permission>
|
||||
</permissions>
|
||||
<label-id>create_xml_content_type</label-id>
|
||||
<label-id>create_form</label-id>
|
||||
<image>/images/icons/new_content.gif</image>
|
||||
<action>wizard:createXMLContentType</action>
|
||||
<action>wizard:createForm</action>
|
||||
</action>
|
||||
|
||||
<!-- Create space -->
|
||||
@@ -581,7 +581,7 @@
|
||||
<!-- Actions Menu for Create in Browse screen -->
|
||||
<action-group id="browse_create_menu">
|
||||
<action idref="create_content" />
|
||||
<action idref="create_xml_content_type" />
|
||||
<action idref="create_form" />
|
||||
<action idref="create_website_wizard" />
|
||||
<action idref="create_space" />
|
||||
<action idref="create_space_wizard" />
|
||||
|
@@ -226,29 +226,21 @@
|
||||
</wizard>
|
||||
|
||||
<!-- Definition of the Create XML Type wizard -->
|
||||
<wizard name="createXMLContentType" managed-bean="CreateXmlContentTypeWizard"
|
||||
title-id="create_xml_content_type_title" description-id="create_xml_content_type_desc"
|
||||
<wizard name="createForm" managed-bean="CreateXmlContentTypeWizard"
|
||||
title-id="create_form_title" description-id="create_form_desc"
|
||||
icon="/images/icons/new_content_large.gif">
|
||||
<step name="details" title-id="details" description-id="create_xml_content_type_step1_desc">
|
||||
<page path="/jsp/content/create-xml-content-type-wizard/details.jsp"
|
||||
title-id="create_xml_content_type_step1_title"
|
||||
description-id="create_xml_content_type_step1_desc"
|
||||
<step name="details" title-id="details" description-id="create_form_step1_desc">
|
||||
<page path="/jsp/wcm/create-form-wizard/details.jsp"
|
||||
title-id="create_form_step1_title"
|
||||
description-id="create_form_step1_desc"
|
||||
instruction-id="default_instruction" />
|
||||
</step>
|
||||
<!--
|
||||
<step name="edit_schema" title-id="edit_xml_schema" description-id="create_xml_content_type_step2_desc">
|
||||
<page path="/jsp/content/create-xml-content-type-wizard/edit.jsp"
|
||||
title-id="create_xml_content_type_step2_title"
|
||||
description-id="create_xml_content_type_step2_desc"
|
||||
instruction-id="default_instruction" />
|
||||
</step>
|
||||
-->
|
||||
<step name="configure_presentation_templates"
|
||||
title-id="configure_presentation_templates"
|
||||
description-id="create_xml_content_type_step2_desc">
|
||||
<page path="/jsp/content/create-xml-content-type-wizard/configure-presentation-templates.jsp"
|
||||
title-id="create_xml_content_type_step2_title"
|
||||
description-id="create_xml_content_type_step2_desc"
|
||||
title-id="configure_template_output_methods"
|
||||
description-id="create_form_step2_desc">
|
||||
<page path="/jsp/wcm/create-form-wizard/configure-template-output-methods.jsp"
|
||||
title-id="create_form_step2_title"
|
||||
description-id="create_form_step2_desc"
|
||||
instruction-id="default_instruction" />
|
||||
</step>
|
||||
<step name="summary" title-id="summary" description-id="summary_step_description">
|
||||
|
@@ -19,6 +19,10 @@ package org.alfresco.web.bean.content;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.faces.component.UIOutput;
|
||||
import javax.faces.event.ActionEvent;
|
||||
import javax.faces.model.DataModel;
|
||||
import javax.faces.model.ListDataModel;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ValueChangeEvent;
|
||||
import javax.faces.model.SelectItem;
|
||||
@@ -59,6 +63,50 @@ import org.xml.sax.SAXException;
|
||||
*/
|
||||
public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
{
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Simple wrapper class to represent a template output method
|
||||
*/
|
||||
public static class TemplateOutputMethodData
|
||||
{
|
||||
private final String fileName;
|
||||
private final File file;
|
||||
private final String fileExtension;
|
||||
|
||||
public TemplateOutputMethodData(final String fileName,
|
||||
final File file,
|
||||
final String fileExtension)
|
||||
{
|
||||
this.fileName = fileName;
|
||||
this.file = file;
|
||||
this.fileExtension = fileExtension;
|
||||
}
|
||||
|
||||
public String getFileExtension()
|
||||
{
|
||||
return this.fileExtension;
|
||||
}
|
||||
|
||||
public String getFileName()
|
||||
{
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
public File getFile()
|
||||
{
|
||||
return this.file;
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return this.getFileExtension().toUpperCase() + " (" + this.getFileName() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private final static Log LOGGER =
|
||||
LogFactory.getLog(CreateXmlContentTypeWizard.class);
|
||||
|
||||
@@ -66,7 +114,8 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
private String templateName;
|
||||
private String presentationTemplateType;
|
||||
protected ContentService contentService;
|
||||
|
||||
private DataModel templateOutputMethodsDataModel;
|
||||
private List<TemplateOutputMethodData> templateOutputMethods = null;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Wizard implementation
|
||||
@@ -102,14 +151,25 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(this.getSchemaFile());
|
||||
|
||||
// apply the titled aspect - title and description
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2, 1.0f);
|
||||
props.put(ContentModel.PROP_TITLE, this.getTemplateName());
|
||||
props.put(ContentModel.PROP_DESCRIPTION, "");
|
||||
this.nodeService.addAspect(schemaFileNodeRef, ContentModel.ASPECT_TITLED, props);
|
||||
|
||||
props = new HashMap<QName, Serializable>(1, 1.0f);
|
||||
props.put(WCMModel.PROP_SCHEMA_ROOT_TAG_NAME, this.getSchemaRootTagName());
|
||||
this.nodeService.addAspect(schemaFileNodeRef, WCMModel.ASPECT_TEMPLATE, props);
|
||||
|
||||
for (TemplateOutputMethodData tomd : this.templateOutputMethods)
|
||||
{
|
||||
fileInfo = this.fileFolderService.create(folderInfo.getNodeRef(),
|
||||
this.getPresentationTemplateFileName(),
|
||||
tomd.getFileName(),
|
||||
ContentModel.TYPE_CONTENT);
|
||||
final NodeRef presentationTemplateFileNodeRef = fileInfo.getNodeRef();
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("Created file node for file: " +
|
||||
this.getPresentationTemplateFileName());
|
||||
LOGGER.debug("Created file node for file: " + tomd.getFileName());
|
||||
|
||||
// get a writer for the content and put the file
|
||||
writer = this.contentService.getWriter(presentationTemplateFileNodeRef,
|
||||
@@ -118,24 +178,18 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
// set the mimetype and encoding
|
||||
writer.setMimetype("text/xml");
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(this.getPresentationTemplateFile());
|
||||
writer.putContent(tomd.getFile());
|
||||
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2, 1.0f);
|
||||
props.put(WCMModel.PROP_SCHEMA_ROOT_TAG_NAME, this.getSchemaRootTagName());
|
||||
props.put(WCMModel.ASSOC_TEMPLATE_OUTPUT_METHODS, presentationTemplateFileNodeRef);
|
||||
this.nodeService.addAspect(schemaFileNodeRef, WCMModel.ASPECT_TEMPLATE, props);
|
||||
this.nodeService.createAssociation(schemaFileNodeRef,
|
||||
presentationTemplateFileNodeRef,
|
||||
WCMModel.ASSOC_TEMPLATE_OUTPUT_METHODS);
|
||||
|
||||
// apply the titled aspect - title and description
|
||||
props = new HashMap<QName, Serializable>(2, 1.0f);
|
||||
props.put(ContentModel.PROP_TITLE, this.getTemplateName());
|
||||
props.put(ContentModel.PROP_DESCRIPTION, "");
|
||||
this.nodeService.addAspect(schemaFileNodeRef, ContentModel.ASPECT_TITLED, props);
|
||||
|
||||
props = new HashMap<QName, Serializable>(2, 1.0f);
|
||||
props.put(WCMModel.PROP_TEMPLATE_OUTPUT_METHOD_TYPE, this.getPresentationTemplateType());
|
||||
props = new HashMap<QName, Serializable>(3, 1.0f);
|
||||
props.put(WCMModel.PROP_TEMPLATE_OUTPUT_METHOD_TYPE, this.getTemplateOutputMethodType());
|
||||
props.put(WCMModel.PROP_TEMPLATE_SOURCE, schemaFileNodeRef);
|
||||
props.put(WCMModel.PROP_TEMPLATE_OUTPUT_METHOD_DERIVED_FILE_EXTENSION, tomd.getFileExtension());
|
||||
this.nodeService.addAspect(presentationTemplateFileNodeRef, WCMModel.ASPECT_TEMPLATE_OUTPUT_METHOD, props);
|
||||
|
||||
}
|
||||
// return the default outcome
|
||||
return outcome;
|
||||
}
|
||||
@@ -146,18 +200,19 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
super.init(parameters);
|
||||
|
||||
this.removeUploadedSchemaFile();
|
||||
this.removeUploadedPresentationTemplateFile();
|
||||
this.removeUploadedTemplateOutputMethodFile();
|
||||
this.schemaRootTagName = null;
|
||||
this.templateName = null;
|
||||
this.templateOutputMethods = new ArrayList<TemplateOutputMethodData>();
|
||||
clearUpload("schema");
|
||||
clearUpload("pt");
|
||||
clearUpload("template-output-method");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cancel()
|
||||
{
|
||||
this.removeUploadedSchemaFile();
|
||||
this.removeUploadedPresentationTemplateFile();
|
||||
this.removeUploadedTemplateOutputMethodFile();
|
||||
return super.cancel();
|
||||
}
|
||||
|
||||
@@ -183,6 +238,38 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
return disabled;
|
||||
}
|
||||
|
||||
public void addSelectedTemplateOutputMethod(ActionEvent event)
|
||||
{
|
||||
final UIOutput fileNameComponent = (UIOutput)
|
||||
event.getComponent().findComponent("template-output-method-file-name");
|
||||
final UIOutput fileExtensionComponent = (UIOutput)
|
||||
event.getComponent().findComponent("file-extension");
|
||||
final String fileName = (String)fileNameComponent.getValue();
|
||||
assert fileName != null;
|
||||
assert this.getTemplateOutputMethodFileName() != null;
|
||||
assert this.getTemplateOutputMethodFileName().equals(fileName);
|
||||
final TemplateOutputMethodData data =
|
||||
new TemplateOutputMethodData(fileName,
|
||||
this.getTemplateOutputMethodFile(),
|
||||
(String)fileExtensionComponent.getValue());
|
||||
this.templateOutputMethods.add(data);
|
||||
this.removeUploadedTemplateOutputMethodFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler called when the Remove button is pressed to remove a
|
||||
* template output method
|
||||
*/
|
||||
public void removeSelectedTemplateOutputMethod(ActionEvent event)
|
||||
{
|
||||
final TemplateOutputMethodData wrapper = (TemplateOutputMethodData)
|
||||
this.templateOutputMethodsDataModel.getRowData();
|
||||
if (wrapper != null)
|
||||
{
|
||||
this.templateOutputMethods.remove(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler called when the user wishes to remove an uploaded file
|
||||
*/
|
||||
@@ -197,9 +284,9 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
/**
|
||||
* Action handler called when the user wishes to remove an uploaded file
|
||||
*/
|
||||
public String removeUploadedPresentationTemplateFile()
|
||||
public String removeUploadedTemplateOutputMethodFile()
|
||||
{
|
||||
clearUpload("pt");
|
||||
clearUpload("template-output-method");
|
||||
|
||||
// refresh the current page
|
||||
return null;
|
||||
@@ -209,14 +296,31 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
/**
|
||||
* Returns the properties for current configured output methods JSF DataModel
|
||||
*
|
||||
* @return JSF DataModel representing the current configured output methods
|
||||
*/
|
||||
public DataModel getTemplateOutputMethodsDataModel()
|
||||
{
|
||||
if (this.templateOutputMethodsDataModel == null)
|
||||
{
|
||||
this.templateOutputMethodsDataModel = new ListDataModel();
|
||||
}
|
||||
|
||||
this.templateOutputMethodsDataModel.setWrappedData(this.templateOutputMethods);
|
||||
|
||||
return this.templateOutputMethodsDataModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the mime type currenty selected
|
||||
*/
|
||||
public String getPresentationTemplateType()
|
||||
public String getTemplateOutputMethodType()
|
||||
{
|
||||
if (this.getPresentationTemplateFileName() != null)
|
||||
if (this.getTemplateOutputMethodFileName() != null)
|
||||
{
|
||||
// String s = this.getPresentationTemplateFileName();
|
||||
// String s = this.getTemplateOutputMethodFileName();
|
||||
// String extension =
|
||||
this.presentationTemplateType = "XSL";
|
||||
}
|
||||
@@ -226,7 +330,7 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
/**
|
||||
* @param presentationTemplateType Sets the currently selected mime type
|
||||
*/
|
||||
public void setPresentationTemplateType(String presentationTemplateType)
|
||||
public void setTemplateOutputMethodType(String presentationTemplateType)
|
||||
{
|
||||
this.presentationTemplateType = presentationTemplateType;
|
||||
}
|
||||
@@ -281,17 +385,17 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
/**
|
||||
* @return Returns the schema file or <tt>null</tt>
|
||||
*/
|
||||
public String getPresentationTemplateFileName()
|
||||
public String getTemplateOutputMethodFileName()
|
||||
{
|
||||
return this.getFileName("pt");
|
||||
return this.getFileName("template-output-method");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the presentationTemplate file or <tt>null</tt>
|
||||
*/
|
||||
public File getPresentationTemplateFile()
|
||||
public File getTemplateOutputMethodFile()
|
||||
{
|
||||
return this.getFile("pt");
|
||||
return this.getFile("template-output-method");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,7 +437,7 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
/**
|
||||
* @return Returns a list of mime types to allow the user to select from
|
||||
*/
|
||||
public List<SelectItem> getCreatePresentationTemplateTypes()
|
||||
public List<SelectItem> getCreateTemplateOutputMethodTypes()
|
||||
{
|
||||
return (List<SelectItem>)Arrays.asList(new SelectItem[] {
|
||||
new SelectItem("freemarker", "FreeMarker"),
|
||||
@@ -346,19 +450,21 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
*/
|
||||
public String getSummary()
|
||||
{
|
||||
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
|
||||
final ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
|
||||
final String[] labels = new String[2 + this.templateOutputMethods.size()];
|
||||
final String[] values = new String[2 + this.templateOutputMethods.size()];
|
||||
labels[0] = "Schema File";
|
||||
values[0] = this.getSchemaFileName();
|
||||
labels[1] = "Template output method type";
|
||||
values[1] = this.getTemplateOutputMethodType();
|
||||
for (int i = 0; i < this.templateOutputMethods.size(); i++)
|
||||
{
|
||||
final TemplateOutputMethodData tomd = this.templateOutputMethods.get(i);
|
||||
labels[2 + i] = "Template output method for " + tomd.getFileExtension();
|
||||
values[2 + i] = tomd.getFileName();
|
||||
}
|
||||
|
||||
// TODO: show first few lines of content here?
|
||||
return buildSummary(new String[] {
|
||||
"Schema File",
|
||||
"Presentation Template Type",
|
||||
"Presentation Template"
|
||||
},
|
||||
new String[] {
|
||||
this.getSchemaFileName(),
|
||||
this.getPresentationTemplateType(),
|
||||
this.getPresentationTemplateFileName()
|
||||
});
|
||||
return this.buildSummary(labels, values);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -313,7 +313,8 @@ public class AVMEditBean
|
||||
{
|
||||
OutputUtil.regenerate(avmRef,
|
||||
this.contentService,
|
||||
this.nodeService);
|
||||
this.nodeService,
|
||||
this.avmService);
|
||||
}
|
||||
|
||||
resetState();
|
||||
|
@@ -190,6 +190,16 @@ public class CreateWebContentWizard extends BaseContentWizard
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
/**
|
||||
* @param fileName The name of the file
|
||||
*/
|
||||
public void setFileName(String fileName)
|
||||
{
|
||||
super.setFileName(fileName != null && fileName.indexOf('.') == -1
|
||||
? fileName + ".xml"
|
||||
: fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the content from the edited form.
|
||||
*/
|
||||
|
@@ -21,6 +21,7 @@ import java.io.OutputStreamWriter;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
@@ -56,23 +57,20 @@ public class OutputUtil
|
||||
throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
for (TemplateOutputMethod tom : tt.getOutputMethods())
|
||||
{
|
||||
// get the node ref of the node that will contain the content
|
||||
String generatedFileName = stripExtension(fileName) + ".shtml";
|
||||
|
||||
OutputStream fileOut = avmService.createFile(parentPath, generatedFileName);
|
||||
|
||||
String fullAvmPath = parentPath + '/' + generatedFileName;
|
||||
|
||||
String avmStore = parentPath.substring(0, parentPath.indexOf(":/"));
|
||||
String sandBoxUrl = AVMConstants.buildAVMStoreUrl(avmStore);
|
||||
final String generatedFileName = stripExtension(fileName) + "." + tom.getFileExtension();
|
||||
final OutputStream fileOut = avmService.createFile(parentPath, generatedFileName);
|
||||
final String fullAvmPath = parentPath + '/' + generatedFileName;
|
||||
final String avmStore = parentPath.substring(0, parentPath.indexOf(":/"));
|
||||
final String sandBoxUrl = AVMConstants.buildAVMStoreUrl(avmStore);
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("Created file node for file: " +
|
||||
fullAvmPath);
|
||||
|
||||
TemplateOutputMethod tom = tt.getOutputMethods().get(0);
|
||||
OutputStreamWriter out = new OutputStreamWriter(fileOut);
|
||||
final OutputStreamWriter out = new OutputStreamWriter(fileOut);
|
||||
tom.generate(xml, tt, sandBoxUrl, out);
|
||||
out.close();
|
||||
|
||||
@@ -88,6 +86,7 @@ public class OutputUtil
|
||||
TemplatingService.TT_GENERATED_OUTPUT_QNAME,
|
||||
outputNodeRef.toString());
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error(e);
|
||||
@@ -98,7 +97,8 @@ public class OutputUtil
|
||||
|
||||
public static void regenerate(final NodeRef nodeRef,
|
||||
final ContentService contentService,
|
||||
final NodeService nodeService)
|
||||
final NodeService nodeService,
|
||||
final AVMService avmService)
|
||||
throws Exception
|
||||
{
|
||||
try
|
||||
@@ -110,38 +110,37 @@ public class OutputUtil
|
||||
|
||||
final ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
|
||||
final Document xml = ts.parseXML(reader.getContentInputStream());
|
||||
String fileName = (String)
|
||||
final 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);
|
||||
String avmPath = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond();
|
||||
String avmStore = avmPath.substring(0, avmPath.indexOf(":/"));
|
||||
String sandBoxUrl = AVMConstants.buildAVMStoreUrl(avmStore);
|
||||
final String avmPath = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond();
|
||||
final String avmStore = avmPath.substring(0, avmPath.indexOf(":/"));
|
||||
final String sandBoxUrl = AVMConstants.buildAVMStoreUrl(avmStore);
|
||||
final String parentPath = AVMNodeConverter.SplitBase(avmPath)[0];
|
||||
for (TemplateOutputMethod tom : tt.getOutputMethods())
|
||||
{
|
||||
final String generatedFileName = stripExtension(fileName) + "." + tom.getFileExtension();
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("regenerating file node for : " + fileName + " (" +
|
||||
nodeRef.toString() + ") to " + generatedNodeRef.toString());
|
||||
nodeRef.toString() + ") to " + parentPath + "/" + generatedFileName);
|
||||
|
||||
// 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, sandBoxUrl, out);
|
||||
out.close();
|
||||
OutputStream out = null;
|
||||
try
|
||||
{
|
||||
out = avmService.getFileOutputStream(parentPath + "/" + generatedFileName);
|
||||
}
|
||||
catch (AVMNotFoundException e)
|
||||
{
|
||||
out = avmService.createFile(parentPath, generatedFileName);
|
||||
}
|
||||
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(out);
|
||||
tom.generate(xml, tt, sandBoxUrl, writer);
|
||||
writer.close();
|
||||
LOGGER.debug("generated " + fileName + " using " + tom);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error(e);
|
||||
|
@@ -40,4 +40,13 @@ public interface TemplateOutputMethod
|
||||
final String sandBoxUrl,
|
||||
final Writer out)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* Returns the file extension to use when generating content for this
|
||||
* output method.
|
||||
*
|
||||
* @return the file extension to use when generating content for this
|
||||
* output method, such as html, rss, pdf.
|
||||
*/
|
||||
public String getFileExtension();
|
||||
}
|
||||
|
@@ -40,6 +40,7 @@ import org.alfresco.model.WCMModel;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.search.*;
|
||||
import org.alfresco.service.cmr.model.*;
|
||||
@@ -196,11 +197,15 @@ public final class TemplatingService implements Serializable
|
||||
final String schemaRootTagName = (String)
|
||||
this.nodeService.getProperty(schemaNodeRef, WCMModel.PROP_SCHEMA_ROOT_TAG_NAME);
|
||||
LOGGER.debug("root tag name is " + schemaRootTagName);
|
||||
TemplateType tt = new TemplateTypeImpl(title, schemaNodeRef, schemaRootTagName);
|
||||
final NodeRef xslNodeRef = (NodeRef)
|
||||
this.nodeService.getProperty(schemaNodeRef, WCMModel.ASSOC_TEMPLATE_OUTPUT_METHODS);
|
||||
LOGGER.debug("xsl noderef is " + xslNodeRef);
|
||||
tt.addOutputMethod(new XSLTOutputMethod(xslNodeRef));
|
||||
final TemplateType tt = new TemplateTypeImpl(title, schemaNodeRef, schemaRootTagName);
|
||||
for (AssociationRef assoc : this.nodeService.getTargetAssocs(schemaNodeRef,
|
||||
WCMModel.ASSOC_TEMPLATE_OUTPUT_METHODS))
|
||||
{
|
||||
final NodeRef xslNodeRef = assoc.getTargetRef();
|
||||
final TemplateOutputMethod tom = new XSLTOutputMethod(xslNodeRef, this.nodeService);
|
||||
LOGGER.debug("loaded template output method " + tom.getFileExtension() + ", " + xslNodeRef);
|
||||
tt.addOutputMethod(tom);
|
||||
}
|
||||
return tt;
|
||||
}
|
||||
|
||||
|
@@ -37,4 +37,9 @@ public class FreeMarkerOutputMethod
|
||||
final Writer out)
|
||||
{
|
||||
}
|
||||
|
||||
public String getFileExtension()
|
||||
{
|
||||
return "unimpleemnted";
|
||||
}
|
||||
}
|
||||
|
@@ -2251,8 +2251,8 @@ public class SchemaFormBuilder
|
||||
" (owningElementName=" + owningElementName + ")");
|
||||
|
||||
if (owner != null)
|
||||
LOGGER.debug("*************** owner is " + owner.getClass() +
|
||||
" name is " + owner.getName() + " ****************");
|
||||
LOGGER.debug("owner is " + owner.getClass() +
|
||||
", name is " + owner.getName());
|
||||
// create the <xforms:bind> element and add it to the model.
|
||||
Element bindElement = xForm.createElementNS(XFORMS_NS,
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "bind");
|
||||
|
@@ -36,6 +36,8 @@ import javax.xml.transform.stream.StreamSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.alfresco.model.WCMModel;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
@@ -49,10 +51,13 @@ public class XSLTOutputMethod
|
||||
private static final Log LOGGER = LogFactory.getLog(XSLTOutputMethod.class);
|
||||
|
||||
private final NodeRef nodeRef;
|
||||
private final NodeService nodeService;
|
||||
|
||||
public XSLTOutputMethod(final NodeRef nodeRef)
|
||||
public XSLTOutputMethod(final NodeRef nodeRef,
|
||||
final NodeService nodeService)
|
||||
{
|
||||
this.nodeRef = nodeRef;
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void generate(final Document xmlContent,
|
||||
@@ -65,9 +70,9 @@ public class XSLTOutputMethod
|
||||
SAXException,
|
||||
IOException
|
||||
{
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
final TransformerFactory tf = TransformerFactory.newInstance();
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
DOMSource source = new DOMSource(ts.parseXML(this.nodeRef));
|
||||
final DOMSource source = new DOMSource(ts.parseXML(this.nodeRef));
|
||||
final Templates templates = tf.newTemplates(source);
|
||||
final Transformer t = templates.newTransformer();
|
||||
t.setURIResolver(new URIResolver()
|
||||
@@ -111,4 +116,11 @@ public class XSLTOutputMethod
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public String getFileExtension()
|
||||
{
|
||||
return (String)
|
||||
this.nodeService.getProperty(this.nodeRef,
|
||||
WCMModel.PROP_TEMPLATE_OUTPUT_METHOD_DERIVED_FILE_EXTENSION);
|
||||
}
|
||||
}
|
||||
|
@@ -1,87 +0,0 @@
|
||||
<%--
|
||||
Copyright (C) 2005 Alfresco, Inc.
|
||||
|
||||
Licensed under the Mozilla Public License version 1.1
|
||||
with a permitted attribution clause. You may obtain a
|
||||
copy of the License at
|
||||
|
||||
http://www.alfresco.org/legal/license.txt
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
either express or implied. See the License for the specific
|
||||
language governing permissions and limitations under the
|
||||
License.
|
||||
--%>
|
||||
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
|
||||
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
|
||||
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
|
||||
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
|
||||
<%@ page import="java.io.*" %>
|
||||
<%@ page import="org.alfresco.web.bean.FileUploadBean" %>
|
||||
|
||||
<f:verbatim>
|
||||
<script type="text/javascript">
|
||||
function upload_file(el)
|
||||
{
|
||||
el.form.method = "post";
|
||||
el.form.enctype = "multipart/form-data";
|
||||
el.form.action = "<%= request.getContextPath() %>/uploadFileServlet";
|
||||
el.form.submit();
|
||||
}
|
||||
</script>
|
||||
</f:verbatim>
|
||||
|
||||
<h:panelGrid columns="1" cellpadding="2" style="padding-top: 4px; padding-bottom: 4px;"
|
||||
width="100%" rowClasses="wizardSectionHeading">
|
||||
<h:outputText value=" #{msg.general_properties}" escape="false" />
|
||||
</h:panelGrid>
|
||||
|
||||
<h:panelGrid id="panel_grid_3"
|
||||
columns="3" cellpadding="3" cellspacing="3" border="0"
|
||||
width="100%">
|
||||
<%--
|
||||
<h:graphicImage value="/images/icons/required_field.gif" alt="Required Field" />
|
||||
<h:outputText id="panel_grid_3_output_text_1"
|
||||
value="Presentation Template Type:" escape="false" />
|
||||
<h:selectOneRadio value="#{WizardManager.bean.presentationTemplateType}">
|
||||
<f:selectItems value="#{WizardManager.bean.createPresentationTemplateTypes}"/>
|
||||
</h:selectOneRadio>
|
||||
--%>
|
||||
|
||||
<h:graphicImage id="required_image_pt"
|
||||
value="/images/icons/required_field.gif" alt="Required Field" />
|
||||
<h:outputText id="output_text_pt"
|
||||
value="Presentation Template:"/>
|
||||
<h:column id="column_pt">
|
||||
<%
|
||||
FileUploadBean upload = (FileUploadBean)session.getAttribute(FileUploadBean.getKey("pt"));
|
||||
if (upload == null || upload.getFile() == null)
|
||||
{
|
||||
%>
|
||||
<f:verbatim>
|
||||
<input type="hidden" name="upload-id" value="pt"/>
|
||||
<input type="hidden" name="return-page" value="<%= request.getContextPath() %>/faces<%= request.getServletPath() %>"/>
|
||||
<input id="wizard:wizard-body:file-input" type="file" size="35" name="alfFileInput" onchange="javascript:upload_file(this)"/>
|
||||
</f:verbatim>
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
<h:outputText id="output_text_schema_name"
|
||||
value="#{WizardManager.bean.presentationTemplateFileName}"/>
|
||||
<h:outputText id="output_text_schema_space"
|
||||
value=" "
|
||||
escape="false"/>
|
||||
<a:actionLink id="action_link_remove_schema"
|
||||
image="/images/icons/delete.gif"
|
||||
value="#{msg.remove}"
|
||||
action="#{WizardManager.bean.removeUploadedPresentationTemplateFile}"
|
||||
showLink="false"
|
||||
target="top"/>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</h:column>
|
||||
|
||||
</h:panelGrid>
|
@@ -0,0 +1,126 @@
|
||||
<%--
|
||||
Copyright (C) 2005 Alfresco, Inc.
|
||||
|
||||
Licensed under the Mozilla Public License version 1.1
|
||||
with a permitted attribution clause. You may obtain a
|
||||
copy of the License at
|
||||
|
||||
http://www.alfresco.org/legal/license.txt
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
either express or implied. See the License for the specific
|
||||
language governing permissions and limitations under the
|
||||
License.
|
||||
--%>
|
||||
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
|
||||
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
|
||||
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
|
||||
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
|
||||
|
||||
<jsp:directive.page import="java.io.*"/>
|
||||
<jsp:directive.page import="org.alfresco.web.bean.FileUploadBean"/>
|
||||
<jsp:directive.page buffer="32kb" contentType="text/html;charset=UTF-8"/>
|
||||
<jsp:directive.page isELIgnored="false"/>
|
||||
|
||||
<f:verbatim>
|
||||
<script type="text/javascript">
|
||||
function upload_file(el)
|
||||
{
|
||||
el.form.method = "post";
|
||||
el.form.enctype = "multipart/form-data";
|
||||
el.form.action = "<%= request.getContextPath() %>/uploadFileServlet";
|
||||
el.form.submit();
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</f:verbatim>
|
||||
|
||||
<h:panelGrid id="general-properties-panel-grid"
|
||||
columns="1" cellpadding="2" style="padding-top: 4px; padding-bottom: 4px;"
|
||||
width="100%">
|
||||
<h:outputText id="step-1-text" value="1. #{msg.configure_output_methods_step1_desc}" escape="false" />
|
||||
<h:panelGrid id="panel_grid_3"
|
||||
columns="3" cellpadding="3" cellspacing="3" border="0"
|
||||
width="100%">
|
||||
<%--
|
||||
<h:graphicImage id="required-image-type" value="/images/icons/required_field.gif" alt="Required Field" />
|
||||
<h:outputText id="panel_grid_3_output_text_1"
|
||||
value="Presentation Template Type:" escape="false" />
|
||||
<h:selectOneRadio value="#{WizardManager.bean.templateOutputMethodType}">
|
||||
<f:selectItems value="#{WizardManager.bean.createTemplateOutputMethodTypes}"/>
|
||||
</h:selectOneRadio>
|
||||
--%>
|
||||
|
||||
<h:graphicImage id="required_image_pt"
|
||||
value="/images/icons/required_field.gif" alt="Required Field" />
|
||||
<h:outputText id="output_text_pt"
|
||||
value="#{msg.template_output_method_file}:"/>
|
||||
<%
|
||||
FileUploadBean upload = (FileUploadBean)
|
||||
session.getAttribute(FileUploadBean.getKey("template-output-method"));
|
||||
if (upload == null || upload.getFile() == null)
|
||||
{
|
||||
%>
|
||||
<h:column id="column_pt">
|
||||
<f:verbatim>
|
||||
<input type="hidden" name="upload-id" value="template-output-method"/>
|
||||
<input type="hidden" name="return-page" value="<%= request.getContextPath() %>/faces<%= request.getServletPath() %>"/>
|
||||
<input id="wizard:wizard-body:file-input" type="file" size="35" name="alfFileInput" onchange="javascript:upload_file(this)"/>
|
||||
</f:verbatim>
|
||||
</h:column>
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
<h:outputText id="template-output-method-file-name"
|
||||
value="#{WizardManager.bean.templateOutputMethodFileName}"/>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<h:graphicImage id="required_image_file_extension"
|
||||
value="/images/icons/required_field.gif" alt="Required Field" />
|
||||
<h:outputText id="file_extension_output_text"
|
||||
value="#{msg.extension_for_generated_assets}:"/>
|
||||
<h:inputText id="file-extension" value=""
|
||||
maxlength="10" size="10"/>
|
||||
</h:panelGrid>
|
||||
|
||||
<h:panelGroup id="step-2-panel-group" styleClass="mainSubText">
|
||||
<h:outputText id="step-2-output-text" value="2." />
|
||||
<h:commandButton id="add-to-list-button"
|
||||
value="#{msg.add_to_list_button}"
|
||||
actionListener="#{CreateXmlContentTypeWizard.addSelectedTemplateOutputMethod}"
|
||||
styleClass="wizardButton" />
|
||||
</h:panelGroup>
|
||||
<h:outputText id="selected_template_output_methods_output_text"
|
||||
styleClass="mainSubText" value="#{msg.selected_templateoutputmethods}" />
|
||||
<h:panelGroup id="data-table-panel-group">
|
||||
<h:dataTable id="template_output_method_data_table"
|
||||
value="#{CreateXmlContentTypeWizard.templateOutputMethodsDataModel}" var="row"
|
||||
rowClasses="selectedItemsRow,selectedItemsRowAlt"
|
||||
styleClass="selectedItems" headerClass="selectedItemsHeader"
|
||||
cellspacing="0" cellpadding="4"
|
||||
rendered="#{CreateXmlContentTypeWizard.templateOutputMethodsDataModel.rowCount != 0}">
|
||||
<h:column id="data-table-column-1">
|
||||
<f:facet name="header">
|
||||
<h:outputText id="data-table-name" value="#{msg.name}" />
|
||||
</f:facet>
|
||||
<h:outputText id="data-table-value" value="#{row.label}" />
|
||||
</h:column>
|
||||
<h:column id="data-table-column-2">
|
||||
<a:actionLink id="remove-select-template-output-method-action-link"
|
||||
actionListener="#{CreateXmlContentTypeWizard.removeSelectedTemplateOutputMethod}"
|
||||
image="/images/icons/delete.gif"
|
||||
value="#{msg.remove}" showLink="false" style="padding-left:6px" />
|
||||
</h:column>
|
||||
</h:dataTable>
|
||||
|
||||
<a:panel id="no-items" rendered="#{CreateXmlContentTypeWizard.templateOutputMethodsDataModel.rowCount == 0}">
|
||||
<h:panelGrid id="no-items-panel-grid" columns="1" cellpadding="2" styleClass="selectedItems" rowClasses="selectedItemsHeader,selectedItemsRow">
|
||||
<h:outputText styleClass="selectedItemsHeader" id="no-items-name" value="#{msg.name}" />
|
||||
<h:outputText styleClass="selectedItemsRow" id="no-items-msg" value="#{msg.no_selected_items}" />
|
||||
</h:panelGrid>
|
||||
</a:panel>
|
||||
</h:panelGroup>
|
||||
</h:panelGrid>
|
Reference in New Issue
Block a user