mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- fix error in namespaces in get company footer
- add a very demoware ready sample multi channel output, meaning generating a really ugly plain text version of the press release and adding a link to it from the html version. - removing the company footer xsl as it is no longer mandatory to have one - passing more parameters to the xsl process - rather ugly implementation - needs to be revisited git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4044 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,6 +18,8 @@ package org.alfresco.web.templating;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
@@ -71,7 +73,10 @@ public class OutputUtil
|
||||
LOGGER.debug("Created file node for file: " +
|
||||
fullAvmPath);
|
||||
final OutputStreamWriter out = new OutputStreamWriter(fileOut);
|
||||
tom.generate(xml, tt, sandBoxUrl, out);
|
||||
|
||||
final HashMap<String, String> parameters =
|
||||
getOutputMethodParameters(sandBoxUrl, fileName, generatedFileName);
|
||||
tom.generate(xml, tt, parameters, out);
|
||||
out.close();
|
||||
|
||||
NodeRef outputNodeRef = AVMNodeConverter.ToNodeRef(-1, fullAvmPath);
|
||||
@@ -136,7 +141,9 @@ public class OutputUtil
|
||||
}
|
||||
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(out);
|
||||
tom.generate(xml, tt, sandBoxUrl, writer);
|
||||
final HashMap<String, String> parameters =
|
||||
getOutputMethodParameters(sandBoxUrl, fileName, generatedFileName);
|
||||
tom.generate(xml, tt, parameters, writer);
|
||||
writer.close();
|
||||
LOGGER.debug("generated " + fileName + " using " + tom);
|
||||
}
|
||||
@@ -148,4 +155,15 @@ public class OutputUtil
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private static HashMap<String, String> getOutputMethodParameters(final String sandBoxUrl,
|
||||
final String fileName,
|
||||
final String generatedFileName)
|
||||
{
|
||||
final HashMap<String, String> parameters = new HashMap<String, String>();
|
||||
parameters.put("avm_store_url", sandBoxUrl);
|
||||
parameters.put("derived_from_file_name", fileName);
|
||||
parameters.put("generated_file_name", generatedFileName);
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ package org.alfresco.web.templating;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
@@ -37,7 +38,7 @@ public interface TemplateOutputMethod
|
||||
*/
|
||||
public void generate(final Document xmlContent,
|
||||
final TemplateType tt,
|
||||
final String sandBoxUrl,
|
||||
final Map<String, String> parameters,
|
||||
final Writer out)
|
||||
throws Exception;
|
||||
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package org.alfresco.web.templating.xforms;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Map;
|
||||
import org.alfresco.web.templating.*;
|
||||
import org.chiba.xml.util.DOMUtil;
|
||||
|
||||
@@ -33,7 +34,7 @@ public class FreeMarkerOutputMethod
|
||||
|
||||
public void generate(final Document xmlContent,
|
||||
final TemplateType tt,
|
||||
final String sandBoxUrl,
|
||||
final Map<String, String> parameters,
|
||||
final Writer out)
|
||||
{
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@ import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import java.util.Map;
|
||||
|
||||
public class XSLTOutputMethod
|
||||
implements TemplateOutputMethod
|
||||
@@ -62,7 +63,7 @@ public class XSLTOutputMethod
|
||||
|
||||
public void generate(final Document xmlContent,
|
||||
final TemplateType tt,
|
||||
final String sandBoxUrl,
|
||||
final Map<String, String> parameters,
|
||||
final Writer out)
|
||||
throws ParserConfigurationException,
|
||||
TransformerConfigurationException,
|
||||
@@ -70,6 +71,8 @@ public class XSLTOutputMethod
|
||||
SAXException,
|
||||
IOException
|
||||
{
|
||||
// XXXarielb - dirty - fix this
|
||||
final String sandBoxUrl = (String)parameters.get("avm_store_url");
|
||||
final TransformerFactory tf = TransformerFactory.newInstance();
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
final DOMSource source = new DOMSource(ts.parseXML(this.nodeRef));
|
||||
@@ -103,7 +106,12 @@ public class XSLTOutputMethod
|
||||
}
|
||||
}
|
||||
});
|
||||
t.setParameter("avm_store_url", sandBoxUrl);
|
||||
|
||||
for (Map.Entry<String, String> e : parameters.entrySet())
|
||||
{
|
||||
t.setParameter(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
LOGGER.debug("setting parameter avm_store_url=" + sandBoxUrl);
|
||||
final StreamResult result = new StreamResult(out);
|
||||
try
|
||||
|
Reference in New Issue
Block a user