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:
Ariel Backenroth
2006-10-06 02:26:38 +00:00
parent fe50122847
commit d26fe8cbb5
16 changed files with 521 additions and 339 deletions

View File

@@ -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

View File

@@ -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" />

View File

@@ -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">

View File

@@ -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,8 +114,9 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
private String templateName;
private String presentationTemplateType;
protected ContentService contentService;
private DataModel templateOutputMethodsDataModel;
private List<TemplateOutputMethodData> templateOutputMethods = null;
// ------------------------------------------------------------------------------
// Wizard implementation
@@ -101,41 +150,46 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
writer.setMimetype("text/xml");
writer.setEncoding("UTF-8");
writer.putContent(this.getSchemaFile());
fileInfo = this.fileFolderService.create(folderInfo.getNodeRef(),
this.getPresentationTemplateFileName(),
ContentModel.TYPE_CONTENT);
final NodeRef presentationTemplateFileNodeRef = fileInfo.getNodeRef();
if (LOGGER.isDebugEnabled())
LOGGER.debug("Created file node for file: " +
this.getPresentationTemplateFileName());
// get a writer for the content and put the file
writer = this.contentService.getWriter(presentationTemplateFileNodeRef,
ContentModel.PROP_CONTENT,
true);
// set the mimetype and encoding
writer.setMimetype("text/xml");
writer.setEncoding("UTF-8");
writer.putContent(this.getPresentationTemplateFile());
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);
// apply the titled aspect - title and description
props = new HashMap<QName, Serializable>(2, 1.0f);
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(),
tomd.getFileName(),
ContentModel.TYPE_CONTENT);
final NodeRef presentationTemplateFileNodeRef = fileInfo.getNodeRef();
props = new HashMap<QName, Serializable>(2, 1.0f);
props.put(WCMModel.PROP_TEMPLATE_OUTPUT_METHOD_TYPE, this.getPresentationTemplateType());
props.put(WCMModel.PROP_TEMPLATE_SOURCE, schemaFileNodeRef);
this.nodeService.addAspect(presentationTemplateFileNodeRef, WCMModel.ASPECT_TEMPLATE_OUTPUT_METHOD, props);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Created file node for file: " + tomd.getFileName());
// get a writer for the content and put the file
writer = this.contentService.getWriter(presentationTemplateFileNodeRef,
ContentModel.PROP_CONTENT,
true);
// set the mimetype and encoding
writer.setMimetype("text/xml");
writer.setEncoding("UTF-8");
writer.putContent(tomd.getFile());
this.nodeService.createAssociation(schemaFileNodeRef,
presentationTemplateFileNodeRef,
WCMModel.ASSOC_TEMPLATE_OUTPUT_METHODS);
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();
}
@@ -182,6 +237,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;
@@ -208,15 +295,32 @@ 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());
// 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()
});
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();
}
return this.buildSummary(labels, values);
}

View File

@@ -312,8 +312,9 @@ public class AVMEditBean
if (nodeService.getProperty(avmRef, TemplatingService.TT_QNAME) != null)
{
OutputUtil.regenerate(avmRef,
this.contentService,
this.nodeService);
this.contentService,
this.nodeService,
this.avmService);
}
resetState();

View File

@@ -189,6 +189,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.

View File

@@ -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;
@@ -47,46 +48,44 @@ public class OutputUtil
}
public static void generate(String parentPath,
Document xml,
TemplateType tt,
String fileName,
ContentService contentService,
NodeService nodeService,
AVMService avmService)
Document xml,
TemplateType tt,
String fileName,
ContentService contentService,
NodeService nodeService,
AVMService avmService)
throws Exception
{
try
{
// get the node ref of the node that will contain the content
String generatedFileName = stripExtension(fileName) + ".shtml";
for (TemplateOutputMethod tom : tt.getOutputMethods())
{
// get the node ref of the node that will contain the content
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);
OutputStream fileOut = avmService.createFile(parentPath, generatedFileName);
String fullAvmPath = parentPath + '/' + generatedFileName;
String avmStore = parentPath.substring(0, parentPath.indexOf(":/"));
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);
tom.generate(xml, tt, sandBoxUrl, out);
out.close();
NodeRef outputNodeRef = AVMNodeConverter.ToNodeRef(-1, fullAvmPath);
nodeService.setProperty(outputNodeRef,
TemplatingService.TT_QNAME,
tt.getName());
LOGGER.debug("generated " + generatedFileName + " using " + tom);
NodeRef createdNodeRef = AVMNodeConverter.ToNodeRef(-1, parentPath + '/' + fileName);
nodeService.setProperty(createdNodeRef,
TemplatingService.TT_GENERATED_OUTPUT_QNAME,
outputNodeRef.toString());
if (LOGGER.isDebugEnabled())
LOGGER.debug("Created file node for file: " +
fullAvmPath);
final OutputStreamWriter out = new OutputStreamWriter(fileOut);
tom.generate(xml, tt, sandBoxUrl, out);
out.close();
NodeRef outputNodeRef = AVMNodeConverter.ToNodeRef(-1, fullAvmPath);
nodeService.setProperty(outputNodeRef,
TemplatingService.TT_QNAME,
tt.getName());
LOGGER.debug("generated " + generatedFileName + " using " + tom);
NodeRef createdNodeRef = AVMNodeConverter.ToNodeRef(-1, parentPath + '/' + fileName);
nodeService.setProperty(createdNodeRef,
TemplatingService.TT_GENERATED_OUTPUT_QNAME,
outputNodeRef.toString());
}
}
catch (Exception e)
{
@@ -97,50 +96,50 @@ public class OutputUtil
}
public static void regenerate(final NodeRef nodeRef,
final ContentService contentService,
final NodeService nodeService)
final ContentService contentService,
final NodeService nodeService,
final AVMService avmService)
throws Exception
{
try
{
final TemplatingService ts = TemplatingService.getInstance();
final String templateTypeName = (String)
nodeService.getProperty(nodeRef, TemplatingService.TT_QNAME);
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);
String avmPath = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond();
String avmStore = avmPath.substring(0, avmPath.indexOf(":/"));
String sandBoxUrl = AVMConstants.buildAVMStoreUrl(avmStore);
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, sandBoxUrl, out);
out.close();
LOGGER.debug("generated " + fileName + " using " + tom);
final String fileName = (String)
nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
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 " + parentPath + "/" + generatedFileName);
// get a writer for the content and put the file
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)
{

View File

@@ -24,20 +24,29 @@ import org.w3c.dom.Document;
* Serializes the xml data to a writer.
*/
public interface TemplateOutputMethod
extends Serializable
extends Serializable
{
/**
* Serializes the xml data in to a presentation format.
*
* @param xmlContent the xml content to serialize
* @param tt the template type that collected the xml content.
* @param sandBoxUrl the url of the current sandbox
* @param out the writer to serialize to.
*/
public void generate(final Document xmlContent,
final TemplateType tt,
final String sandBoxUrl,
final Writer out)
throws Exception;
/**
* Serializes the xml data in to a presentation format.
*
* @param xmlContent the xml content to serialize
* @param tt the template type that collected the xml content.
* @param sandBoxUrl the url of the current sandbox
* @param out the writer to serialize to.
*/
public void generate(final Document xmlContent,
final TemplateType tt,
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();
}

View File

@@ -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;
}

View File

@@ -24,17 +24,22 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
public class FreeMarkerOutputMethod
implements TemplateOutputMethod
implements TemplateOutputMethod
{
public FreeMarkerOutputMethod()
{
}
public FreeMarkerOutputMethod()
{
}
public void generate(final Document xmlContent,
final TemplateType tt,
final String sandBoxUrl,
final Writer out)
{
}
public void generate(final Document xmlContent,
final TemplateType tt,
final String sandBoxUrl,
final Writer out)
{
}
public String getFileExtension()
{
return "unimpleemnted";
}
}

View File

@@ -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");

View File

@@ -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;
@@ -46,69 +48,79 @@ public class XSLTOutputMethod
implements TemplateOutputMethod
{
private static final Log LOGGER = LogFactory.getLog(XSLTOutputMethod.class);
private static final Log LOGGER = LogFactory.getLog(XSLTOutputMethod.class);
private final NodeRef nodeRef;
private final NodeService nodeService;
private final NodeRef nodeRef;
public XSLTOutputMethod(final NodeRef nodeRef,
final NodeService nodeService)
{
this.nodeRef = nodeRef;
this.nodeService = nodeService;
}
public XSLTOutputMethod(final NodeRef nodeRef)
{
this.nodeRef = nodeRef;
}
public void generate(final Document xmlContent,
final TemplateType tt,
final String sandBoxUrl,
final Writer out)
throws ParserConfigurationException,
TransformerConfigurationException,
TransformerException,
SAXException,
IOException
{
final TransformerFactory tf = TransformerFactory.newInstance();
final TemplatingService ts = TemplatingService.getInstance();
final DOMSource source = new DOMSource(ts.parseXML(this.nodeRef));
final Templates templates = tf.newTemplates(source);
final Transformer t = templates.newTransformer();
t.setURIResolver(new URIResolver()
{
public Source resolve(final String href, final String base)
throws TransformerException
{
URI uri = null;
try
{
uri = new URI(sandBoxUrl + href);
}
catch (URISyntaxException e)
{
throw new TransformerException("unable to create uri " + sandBoxUrl + href, e);
}
try
{
LOGGER.debug("loading " + uri);
final Document d = ts.parseXML(uri.toURL().openStream());
LOGGER.debug("loaded " + ts.writeXMLToString(d));
return new DOMSource(d);
}
catch (Exception e)
{
LOGGER.warn(e);
throw new TransformerException("unable to load " + uri, e);
}
}
});
t.setParameter("avm_store_url", sandBoxUrl);
LOGGER.debug("setting parameter avm_store_url=" + sandBoxUrl);
final StreamResult result = new StreamResult(out);
try
{
t.transform(new DOMSource(xmlContent), result);
}
catch (TransformerException e)
{
LOGGER.error(e.getMessageAndLocation());
throw e;
}
}
public void generate(final Document xmlContent,
final TemplateType tt,
final String sandBoxUrl,
final Writer out)
throws ParserConfigurationException,
TransformerConfigurationException,
TransformerException,
SAXException,
IOException
{
TransformerFactory tf = TransformerFactory.newInstance();
final TemplatingService ts = TemplatingService.getInstance();
DOMSource source = new DOMSource(ts.parseXML(this.nodeRef));
final Templates templates = tf.newTemplates(source);
final Transformer t = templates.newTransformer();
t.setURIResolver(new URIResolver()
{
public Source resolve(final String href, final String base)
throws TransformerException
{
URI uri = null;
try
{
uri = new URI(sandBoxUrl + href);
}
catch (URISyntaxException e)
{
throw new TransformerException("unable to create uri " + sandBoxUrl + href, e);
}
try
{
LOGGER.debug("loading " + uri);
final Document d = ts.parseXML(uri.toURL().openStream());
LOGGER.debug("loaded " + ts.writeXMLToString(d));
return new DOMSource(d);
}
catch (Exception e)
{
LOGGER.warn(e);
throw new TransformerException("unable to load " + uri, e);
}
}
});
t.setParameter("avm_store_url", sandBoxUrl);
LOGGER.debug("setting parameter avm_store_url=" + sandBoxUrl);
final StreamResult result = new StreamResult(out);
try
{
t.transform(new DOMSource(xmlContent), result);
}
catch (TransformerException e)
{
LOGGER.error(e.getMessageAndLocation());
throw e;
}
}
public String getFileExtension()
{
return (String)
this.nodeService.getProperty(this.nodeRef,
WCMModel.PROP_TEMPLATE_OUTPUT_METHOD_DERIVED_FILE_EXTENSION);
}
}

View File

@@ -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="&nbsp;#{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="&nbsp;"
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>

View File

@@ -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>