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:
@@ -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";
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user