diff --git a/source/java/org/alfresco/web/forms/AbstractRenderingEngine.java b/source/java/org/alfresco/web/forms/AbstractRenderingEngine.java index edb2ab20cf..b8c2cfcefc 100644 --- a/source/java/org/alfresco/web/forms/AbstractRenderingEngine.java +++ b/source/java/org/alfresco/web/forms/AbstractRenderingEngine.java @@ -23,6 +23,8 @@ import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.web.bean.wcm.AVMConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.jsf.FacesContextUtils; @@ -34,6 +36,8 @@ import org.springframework.web.jsf.FacesContextUtils; public abstract class AbstractRenderingEngine implements RenderingEngine { + private static final Log LOGGER = LogFactory.getLog(AbstractRenderingEngine.class); + protected static final String ALFRESCO_NS = "http://www.alfresco.org/alfresco"; protected static final String ALFRESCO_NS_PREFIX = "alfresco"; @@ -76,16 +80,25 @@ public abstract class AbstractRenderingEngine return new FormDataFunctions(AbstractRenderingEngine.getAVMRemote()); } - protected static String toAVMPath(String parentAVMPath, String path) + protected static String toAVMPath(final String parentAVMPath, final String path) { + String parent = parentAVMPath; if (path != null && path.length() != 0 && path.charAt(0) == '/') { - parentAVMPath = parentAVMPath.substring(0, - parentAVMPath.indexOf(':') + - ('/' + AVMConstants.DIR_APPBASE + - '/' + AVMConstants.DIR_WEBAPPS).length() + 1); + parent = parentAVMPath.substring(0, + parentAVMPath.indexOf(':') + + ('/' + AVMConstants.DIR_APPBASE + + '/' + AVMConstants.DIR_WEBAPPS).length() + 1); } - return parentAVMPath + (parentAVMPath.endsWith("/") ? path : '/' + path); + if (parent.endsWith("/")) + { + parent = parent.substring(0, parent.length() - 1); + } + final String result = parent + '/' + path; + LOGGER.debug("built full avmPath " + result + + " for parent " + parentAVMPath + + " and request path " + path); + return result; } } \ No newline at end of file diff --git a/source/test-resources/websites/alfresco/ROOT/WEB-INF/classes/org/alfresco/web/pr/CompanyFooterBean.java b/source/test-resources/websites/alfresco/ROOT/WEB-INF/classes/org/alfresco/web/pr/CompanyFooterBean.java index 67c9609f7f..64cc8d64f4 100644 --- a/source/test-resources/websites/alfresco/ROOT/WEB-INF/classes/org/alfresco/web/pr/CompanyFooterBean.java +++ b/source/test-resources/websites/alfresco/ROOT/WEB-INF/classes/org/alfresco/web/pr/CompanyFooterBean.java @@ -21,47 +21,72 @@ import javax.servlet.jsp.PageContext; import org.w3c.dom.*; import org.alfresco.web.forms.*; +/** + * Bean for getting data for company footers which are included within press release forms. + * It's used by /media/releases/get_company_footer_simple_type.jsp to aggregate all + * forms created by company-footer.xsd in /media/releases/content and generate an + * xsd simpleType enumeration which is used within the press release form (press-release.xsd). + * press-release.xsl then uses the selected company footers and loads the xml assets and + * includes their content within the generated press release renditions. + */ public class CompanyFooterBean { - public static List getCompanyFooters(final PageContext pageContext) - throws Exception - { - final FormDataFunctions ef = - new ServletContextFormDataFunctionsAdapter(pageContext.getServletContext()); + /** + * Loads all xml files generated by company-footer.xsd in /media/releases/content + * populates CompanyFooterBeans with their contents. This function is exposed to the + * jsp by /WEB-INF/pr.tld. + * + * @param pageContext the page context from the jsp, needed for accessing the + * servlet context for the ServletContextFormDataFunctionsAdapter class. + * + * @return a list of populated CompanyFooterBeans. + */ + public static List getCompanyFooters(final PageContext pageContext) + throws Exception + { + final FormDataFunctions ef = + new ServletContextFormDataFunctionsAdapter(pageContext.getServletContext()); - final Map entries = ef.getXMLDocuments("company-footer", - "/media/releases/content/company_footers"); - final List result = new ArrayList(entries.size()); - for (Map.Entry entry : entries.entrySet()) - { - final String fileName = entry.getKey(); - final Document d = entry.getValue(); - final Element n = (Element)d.getElementsByTagName("alfresco:name").item(0); - final String href = "/media/releases/content/company_footers/" + fileName; - result.add(new CompanyFooterBean(n.getFirstChild().getNodeValue(), - href)); - } - return result; - } + final Map entries = ef.getXMLDocuments("company-footer", + "/media/releases/content"); + final List result = new ArrayList(entries.size()); + for (Map.Entry entry : entries.entrySet()) + { + final String fileName = entry.getKey(); + final Document d = entry.getValue(); + final Element n = (Element)d.getElementsByTagName("alfresco:name").item(0); + result.add(new CompanyFooterBean(n.getFirstChild().getNodeValue(), + fileName)); + } + return result; + } - private final String name; - private final String href; + private final String name; + private final String fileName; - public CompanyFooterBean(final String name, - final String href) - { - this.name = name; - this.href = href; - } + public CompanyFooterBean(final String name, + final String fileName) + { + this.name = name; + this.fileName = fileName; + } - public String getName() - { - return this.name; - } + /** + * Returns the name of the company. + */ + public String getName() + { + return this.name; + } - public String getHref() - { - return this.href; - } + /** + * Returns the fileName of the xml file describing this company footer + * + * @return the fileName of the xml file. + */ + public String getFileName() + { + return this.fileName; + } } \ No newline at end of file diff --git a/source/test-resources/websites/alfresco/ROOT/WEB-INF/classes/org/alfresco/web/pr/PressReleaseBean.java b/source/test-resources/websites/alfresco/ROOT/WEB-INF/classes/org/alfresco/web/pr/PressReleaseBean.java index 588aed4f52..b811b80da6 100644 --- a/source/test-resources/websites/alfresco/ROOT/WEB-INF/classes/org/alfresco/web/pr/PressReleaseBean.java +++ b/source/test-resources/websites/alfresco/ROOT/WEB-INF/classes/org/alfresco/web/pr/PressReleaseBean.java @@ -22,8 +22,22 @@ import javax.servlet.jsp.PageContext; import org.w3c.dom.*; import org.alfresco.web.forms.*; +/** + * Bean for getting data for press releases. + * It's used by /media/releases/index.jsp to aggregate all forms created by press-release.xsd in + * /media/releases/content and generate an index page for them. + */ public class PressReleaseBean { + /** + * Loads all xml assets created by press-release.xsd in /media/releases/content and populates + * PressReleaseBeans with their contents. + * + * @param pageContext the page context from the jsp, needed for accessing the + * servlet context for the ServletContextFormDataFunctionsAdapter class. + * + * @return a list of populated PressReleaseBeans. + */ public static List getPressReleases(final PageContext pageContext) throws Exception { @@ -41,7 +55,7 @@ public class PressReleaseBean final Element dateEl = (Element)d.getElementsByTagName("alfresco:launch_date").item(0); final Date date = new SimpleDateFormat("yyyy-MM-dd").parse(dateEl.getFirstChild().getNodeValue()); String href = "/media/releases/content/" + fileName; - href = href.replaceAll(".xml$", ".shtml"); + href = href.replaceAll(".xml$", ".html"); result.add(new PressReleaseBean(t.getFirstChild().getNodeValue(), a.getFirstChild().getNodeValue(), date, @@ -66,23 +80,37 @@ public class PressReleaseBean this.href = href; } + /** + * The title of the press release as defined in the xml asset. + */ public String getTitle() { return this.title; } + /** + * The abstract of the press release as defined in the xml asset. + */ public String getAbstract() { return this.theAbstract; } + /** + * The launch date of the press release as defined in the xml asset. + */ public Date getLaunchDate() { return this.launchDate; } - public String getHref() - { - return this.href; - } + /** + * Returns the url within the webapp to the xml file describing this press release + * + * @return the url to the xml file which will be something like /media/releases/content/[filename].xml + */ + public String getHref() + { + return this.href; + } } \ No newline at end of file diff --git a/source/test-resources/websites/alfresco/ROOT/WEB-INF/web.xml b/source/test-resources/websites/alfresco/ROOT/WEB-INF/web.xml index 5307a911b8..712e01ee63 100644 --- a/source/test-resources/websites/alfresco/ROOT/WEB-INF/web.xml +++ b/source/test-resources/websites/alfresco/ROOT/WEB-INF/web.xml @@ -8,12 +8,42 @@ Alfresco Website Alfresco Website - + + + ssi + + org.apache.catalina.ssi.SSIFilter + + + contentType + text/.*html.* + + + debug + 1 + + + expires + 666 + + + isVirtualWebappRelative + 1 + + + + + ssi + /* + + + http://www.alfresco.org/pr /WEB-INF/pr.tld + index.jsp index.html diff --git a/source/test-resources/websites/alfresco/ROOT/about/navigation.html b/source/test-resources/websites/alfresco/ROOT/about/navigation.html new file mode 100644 index 0000000000..39d44ad7ed --- /dev/null +++ b/source/test-resources/websites/alfresco/ROOT/about/navigation.html @@ -0,0 +1,7 @@ +
+
+
+

Company  |  Contact  |  News  |  Events  |  People

+
+
+
diff --git a/source/test-resources/websites/alfresco/ROOT/assets/header.html b/source/test-resources/websites/alfresco/ROOT/assets/header.html deleted file mode 100644 index da814bb129..0000000000 --- a/source/test-resources/websites/alfresco/ROOT/assets/header.html +++ /dev/null @@ -1,40 +0,0 @@ -
- - - -
- -
-
-
-

Company  |  Contact  |  News  |  Events  |  People

-
-
-
diff --git a/source/test-resources/websites/alfresco/ROOT/assets/include_in_head.html b/source/test-resources/websites/alfresco/ROOT/assets/include_in_head.html new file mode 100644 index 0000000000..ca3cbfd9ca --- /dev/null +++ b/source/test-resources/websites/alfresco/ROOT/assets/include_in_head.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/source/test-resources/websites/alfresco/ROOT/assets/include_main_navigation.html b/source/test-resources/websites/alfresco/ROOT/assets/include_main_navigation.html new file mode 100644 index 0000000000..4e458c2851 --- /dev/null +++ b/source/test-resources/websites/alfresco/ROOT/assets/include_main_navigation.html @@ -0,0 +1,40 @@ +
+ + + +
+ +
+
+
+

Company  |  Contact  |  News  |  Events  |  People

+
+
+
diff --git a/source/test-resources/websites/alfresco/ROOT/media/releases/content/company_footers/Activiti.xml b/source/test-resources/websites/alfresco/ROOT/media/releases/content/company_footers/Activiti.xml deleted file mode 100644 index 9752890e64..0000000000 --- a/source/test-resources/websites/alfresco/ROOT/media/releases/content/company_footers/Activiti.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - Activiti - Alfresco used to be called Activiti. See About Alfresco. - diff --git a/source/test-resources/websites/alfresco/ROOT/media/releases/get_company_footer_simple_type.jsp b/source/test-resources/websites/alfresco/ROOT/media/releases/get_company_footer_simple_type.jsp index 95d96bc81f..5d7a30053a 100644 --- a/source/test-resources/websites/alfresco/ROOT/media/releases/get_company_footer_simple_type.jsp +++ b/source/test-resources/websites/alfresco/ROOT/media/releases/get_company_footer_simple_type.jsp @@ -1,7 +1,53 @@ +<%-- +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. +--%> +<%-- +Produces an xml schema simpleType definition which lists all company footers in /media/releases/content +as an enumerated type. This is intended to be included within a schema (such as press-release.xsd) +which wants to update the list of available company footers dynamically. + +The expected output is in the form: + + + + + + + Company Footer 1 Name + + + + + + + Company Footer 2 Name + + + + + + +--%> + xmlns:pr="http://www.alfresco.org/pr"> + <%-- xmlns:pr is mapped to /WEB-INF/pr.tld by web.xml --%> + <%-- call into CompanyFooterBean to retrieve all company footers --%> - + <%-- this is the file name of the company footer --%> + + <%-- this produces the label displayed in the combobox within the press release form --%> @@ -24,4 +73,4 @@ - \ No newline at end of file + diff --git a/source/test-resources/websites/alfresco/ROOT/media/releases/index.jsp b/source/test-resources/websites/alfresco/ROOT/media/releases/index.jsp index 5cbd49c126..bf807e0e3b 100644 --- a/source/test-resources/websites/alfresco/ROOT/media/releases/index.jsp +++ b/source/test-resources/websites/alfresco/ROOT/media/releases/index.jsp @@ -1,153 +1,100 @@ +<%-- +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. +--%> + +<%-- +Produces the index page for the press release page. +--%> + <%-- xmlns:pr is mapped to /WEB-INF/pr.tld by web.xml --%> - + - + - - Alfresco Press Releases - Open Source Content Management - - - - - - - - - -
-
- - - -
- -
-
-
-

Company&nbsp;&nbsp;|&nbsp;&nbsp;Contact&nbsp;&nbsp;|&nbsp;&nbsp;News&nbsp;&nbsp;|&nbsp;&nbsp;Events&nbsp;&nbsp;|&nbsp;&nbsp;People

-
-
-
-
- -
- - - -

Alfresco Press Releases

- - -

- - - - -

-

-

-
+ + <%-- include common navigation components using the jsp compile time include directive --%> + + Alfresco Press Releases - Open Source Content Management + + + + +
+ + +
 
+ +
+ + + +

Alfresco Press Releases

+ + <%-- load all PressReleaseBeans by using the function defined in /WEB-INF/pr.tld --%> + +

+ + + + +

+

+

+
- - -
- -
-
-

Press Release Archive

- -
-
-
 
-
- - - -
 
- - + + +
+ +
+
+

Press Release Archive

+ +
+
+
 
+
+ + +
diff --git a/source/test-resources/xforms/demos/press-release/press-release-plain-text.xsl b/source/test-resources/xforms/demos/press-release/press-release-plain-text.xsl index e27795dd1c..b1e31ef8c1 100644 --- a/source/test-resources/xforms/demos/press-release/press-release-plain-text.xsl +++ b/source/test-resources/xforms/demos/press-release/press-release-plain-text.xsl @@ -6,7 +6,6 @@ - --- --- diff --git a/source/test-resources/xforms/demos/press-release/press-release.xsl b/source/test-resources/xforms/demos/press-release/press-release.xsl index fa2fca239e..fdbf3e575b 100644 --- a/source/test-resources/xforms/demos/press-release/press-release.xsl +++ b/source/test-resources/xforms/demos/press-release/press-release.xsl @@ -1,3 +1,20 @@ + + - - - + + #include virtual="/assets/include_in_head.html" <xsl:value-of select="/alfresco:press-release/alfresco:title"/> - - - - -
-
- - - -
- -
-
-
-

Company  |  Contact  |  News  |  Events  |  People

-
-
-
+ #include virtual="/assets/include_main_navigation.html" + #include virtual="/about/navigation.html"
 
@@ -89,8 +62,10 @@ -

About

- + + +

About

+

@@ -110,42 +85,7 @@
 
- - -
 
- + #include virtual="/assets/footer.html"