[opencms-dev] usage of com.opencms.util.LinkSubstitution
Thomas Joseph Olaes
thomas.olaes at gmail.com
Wed Aug 4 21:51:02 CEST 2004
Good afternoon list,
I am trying to implement an instance of the LinkSubstitution class in
OpenCMS 5.0.1. I've been looking through the code trying to figure out
how to use this to turn <edittemplate /> stuff in the "/system/bodies"
component of a "Page" resource into the piece that goes into <TEMPLATE
/> of the same file.
I have a file in the VFS called /TestProject/test.html, which has some
HTML pasted inside the <![CDATA[ ... ]]> tag in source edit mode. This
HTML has some absolute links in the form "/path/to/file.html" in <a
href="" /> tags
Here's my test JSP page:
<%@ page session="false"
import="com.opencms.core.*,
com.opencms.file.*,
com.opencms.flex.cache.CmsFlexController,
com.opencms.util.LinkSubstitution,
java.util.*,
java.sql.*,
java.util.regex.Pattern,
java.util.regex.Matcher"
%>
<%
CmsObject cmsobject = CmsFlexController.getCmsObject(request);
String sFileContents = new
String(cmsobject.readFile("/system/bodies/TestProject/test.html").getContents());
Pattern p = Pattern.compile("<edittemplate>(.*)</edittemplate>",
Pattern.DOTALL); // greedy
Matcher m = p.matcher(sFileContents);
String sEditTemplateContents = "";
if(m.find()){
sEditTemplateContents = m.group(1);
}
out.println(sEditTemplateContents);
out.println("----------------------------------");
LinkSubstitution ls = new LinkSubstitution();
String sScrubbedContents = ls.substituteEditorContent(cmsobject,
sEditTemplateContents);
out.println(sScrubbedContents);
out.println((sScrubbedContents == null)?"yes":"no");
out.println(request.getContextPath() + request.getServletPath());
out.println(request.getHeader("content-type"));
%>
Important part is the line "LinkSubstitution ls = new
LinkSubstitution();" and the line immediately following it. As it runs
now, I sScrubbedContents seems to be an empty string when I try to run
this JSP from within OpenCMS.
Any help is appreciated, thanks in advance for any time and assistance
provided to me.
-TJ
More information about the opencms-dev
mailing list