You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by jo...@apache.org on 2006/01/26 15:58:47 UTC
svn commit: r372534 - in /lenya/trunk/src:
java/org/apache/lenya/cms/cocoon/components/modules/input/
modules/opendocument/ modules/xhtml/ webapp/WEB-INF/
webapp/lenya/pubs/default/
Author: josias
Date: Thu Jan 26 06:58:36 2006
New Revision: 372534
URL: http://svn.apache.org/viewcvs?rev=372534&view=rev
Log:
added date-converter input module. it is used to set the correct last-modified http header.
Added:
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DateConverterModule.java (with props)
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java
lenya/trunk/src/modules/opendocument/sitemap.xmap
lenya/trunk/src/modules/xhtml/sitemap.xmap
lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
lenya/trunk/src/webapp/lenya/pubs/default/sitemap.xmap
Added: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DateConverterModule.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DateConverterModule.java?rev=372534&view=auto
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DateConverterModule.java (added)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DateConverterModule.java Thu Jan 26 06:58:36 2006
@@ -0,0 +1,63 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+package org.apache.lenya.cms.cocoon.components.modules.input;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.components.modules.input.AbstractInputModule;
+
+/**
+ * The DateConverterModule converts a date string from one format into
+ * another format.
+ * The conversion is defined by the nested elements <src-pattern/> and
+ * <pattern/> of the module declaration.
+ *
+ */
+public class DateConverterModule extends AbstractInputModule implements ThreadSafe {
+
+ public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+
+ String srcPattern = (String) this.settings.get("src-pattern");
+ String pattern = (String) this.settings.get("pattern");
+
+ if (modeConf != null) {
+ srcPattern = modeConf.getChild("src-pattern").getValue(srcPattern);
+ pattern = modeConf.getChild("pattern").getValue(pattern);
+ }
+
+ if (srcPattern==null) {
+ throw new ConfigurationException("Source date pattern not specified.");
+ }
+ if (pattern==null) {
+ throw new ConfigurationException("Date pattern not specified.");
+ }
+
+ try {
+ SimpleDateFormat srcFormat = new SimpleDateFormat(srcPattern);
+ SimpleDateFormat format = new SimpleDateFormat(pattern);
+ Date date = srcFormat.parse(name);
+ return format.format(date);
+ } catch (Exception e) {
+ throw new ConfigurationException("Could not convert date: "+name, e);
+ }
+ }
+}
Propchange: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DateConverterModule.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java?rev=372534&r1=372533&r2=372534&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java Thu Jan 26 06:58:36 2006
@@ -131,7 +131,7 @@
/**
* <code>DATE_FORMAT</code> The date format
*/
- public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
+ public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss Z";
/**
* @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
Modified: lenya/trunk/src/modules/opendocument/sitemap.xmap
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/opendocument/sitemap.xmap?rev=372534&r1=372533&r2=372534&view=diff
==============================================================================
--- lenya/trunk/src/modules/opendocument/sitemap.xmap (original)
+++ lenya/trunk/src/modules/opendocument/sitemap.xmap Thu Jan 26 06:58:36 2006
@@ -38,7 +38,7 @@
<!-- webdav GET matcher -->
<map:match pattern="davget.xml">
<map:act type="set-header">
- <map:parameter name="Last-Modified" value="{page-envelope:document-lastmodified}" />
+ <map:parameter name="Last-Modified" value="{date-iso8601-rfc822:{page-envelope:document-lastmodified}}" />
<map:read src="context://lenya/pubs/{page-envelope:publication-id}/content/{page-envelope:area}/{page-envelope:document-id}/index_{page-envelope:document-language}.odt" mime-type="application/vnd.oasis.opendocument.text"/>
</map:act>
</map:match>
Modified: lenya/trunk/src/modules/xhtml/sitemap.xmap
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/xhtml/sitemap.xmap?rev=372534&r1=372533&r2=372534&view=diff
==============================================================================
--- lenya/trunk/src/modules/xhtml/sitemap.xmap (original)
+++ lenya/trunk/src/modules/xhtml/sitemap.xmap Thu Jan 26 06:58:36 2006
@@ -53,7 +53,7 @@
<!-- webdav GET matcher -->
<map:match pattern="davget.xml">
<map:act type="set-header">
- <map:parameter name="Last-Modified" value="{page-envelope:document-lastmodified}" />
+ <map:parameter name="Last-Modified" value="{date-iso8601-rfc822:{page-envelope:document-lastmodified}}" />
<map:generate src="lenyadoc:/{page-envelope:document-language}/{page-envelope:document-id}"/>
<map:serialize type="xml-get"/>
</map:act>
Modified: lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl?rev=372534&r1=372533&r2=372534&view=diff
==============================================================================
--- lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl (original)
+++ lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl Thu Jan 26 06:58:36 2006
@@ -122,6 +122,11 @@
<format>yyyy-MM-dd HH:mm:ss Z</format>
</component-instance>
+ <component-instance name="date-iso8601-rfc822" logger="core.modules.input" class="org.apache.lenya.cms.cocoon.components.modules.input.DateConverterModule">
+ <src-pattern>yyyy-MM-dd HH:mm:ss Z</src-pattern>
+ <pattern>EEE, dd MMM yyyy HH:mm:ss Z</pattern>
+ </component-instance>
+
<component-instance name="proxy-url" logger="sitemap.modules.input.proxy-url"
class="org.apache.lenya.cms.cocoon.components.modules.input.ProxyUrlModule"/>
Modified: lenya/trunk/src/webapp/lenya/pubs/default/sitemap.xmap
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/sitemap.xmap?rev=372534&r1=372533&r2=372534&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/sitemap.xmap (original)
+++ lenya/trunk/src/webapp/lenya/pubs/default/sitemap.xmap Thu Jan 26 06:58:36 2006
@@ -165,7 +165,7 @@
<map:act type="language-exists">
<map:act type="set-header">
- <map:parameter name="Last-Modified" value="{page-envelope:document-lastmodified}" />
+ <map:parameter name="Last-Modified" value="{date-iso8601-rfc822:{page-envelope:document-lastmodified}}" />
<!-- HEAD request shouldn't have all the xslt overhead -->
<map:select type="request-method">
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org
Re: svn commit: r372534 - in /lenya/trunk/src: java/org/apache/lenya/cms/cocoon/components/modules/input/
modules/opendocument/ modules/xhtml/ webapp/WEB-INF/ webapp/lenya/pubs/default/
Posted by Doug Chestnut <dh...@virginia.edu>.
Sweet!! :)
Better caching support. I guess the next step is to be able to set
expire times for documents.
josias@apache.org wrote:
> Author: josias
> Date: Thu Jan 26 06:58:36 2006
> New Revision: 372534
>
> URL: http://svn.apache.org/viewcvs?rev=372534&view=rev
> Log:
> added date-converter input module. it is used to set the correct last-modified http header.
>
> Added:
> lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DateConverterModule.java (with props)
> Modified:
> lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java
> lenya/trunk/src/modules/opendocument/sitemap.xmap
> lenya/trunk/src/modules/xhtml/sitemap.xmap
> lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
> lenya/trunk/src/webapp/lenya/pubs/default/sitemap.xmap
>
> Added: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DateConverterModule.java
> URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DateConverterModule.java?rev=372534&view=auto
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DateConverterModule.java (added)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DateConverterModule.java Thu Jan 26 06:58:36 2006
> @@ -0,0 +1,63 @@
> +/*
> + * Copyright 1999-2004 The Apache Software Foundation.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * 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.
> + */
> +
> +package org.apache.lenya.cms.cocoon.components.modules.input;
> +
> +import java.text.SimpleDateFormat;
> +import java.util.Date;
> +import java.util.Map;
> +
> +import org.apache.avalon.framework.configuration.Configuration;
> +import org.apache.avalon.framework.configuration.ConfigurationException;
> +import org.apache.avalon.framework.thread.ThreadSafe;
> +import org.apache.cocoon.components.modules.input.AbstractInputModule;
> +
> +/**
> + * The DateConverterModule converts a date string from one format into
> + * another format.
> + * The conversion is defined by the nested elements <src-pattern/> and
> + * <pattern/> of the module declaration.
> + *
> + */
> +public class DateConverterModule extends AbstractInputModule implements ThreadSafe {
> +
> + public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
> +
> + String srcPattern = (String) this.settings.get("src-pattern");
> + String pattern = (String) this.settings.get("pattern");
> +
> + if (modeConf != null) {
> + srcPattern = modeConf.getChild("src-pattern").getValue(srcPattern);
> + pattern = modeConf.getChild("pattern").getValue(pattern);
> + }
> +
> + if (srcPattern==null) {
> + throw new ConfigurationException("Source date pattern not specified.");
> + }
> + if (pattern==null) {
> + throw new ConfigurationException("Date pattern not specified.");
> + }
> +
> + try {
> + SimpleDateFormat srcFormat = new SimpleDateFormat(srcPattern);
> + SimpleDateFormat format = new SimpleDateFormat(pattern);
> + Date date = srcFormat.parse(name);
> + return format.format(date);
> + } catch (Exception e) {
> + throw new ConfigurationException("Could not convert date: "+name, e);
> + }
> + }
> +}
>
> Propchange: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/DateConverterModule.java
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java
> URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java?rev=372534&r1=372533&r2=372534&view=diff
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java (original)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/PageEnvelopeModule.java Thu Jan 26 06:58:36 2006
> @@ -131,7 +131,7 @@
> /**
> * <code>DATE_FORMAT</code> The date format
> */
> - public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
> + public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss Z";
>
> /**
> * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
>
> Modified: lenya/trunk/src/modules/opendocument/sitemap.xmap
> URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/opendocument/sitemap.xmap?rev=372534&r1=372533&r2=372534&view=diff
> ==============================================================================
> --- lenya/trunk/src/modules/opendocument/sitemap.xmap (original)
> +++ lenya/trunk/src/modules/opendocument/sitemap.xmap Thu Jan 26 06:58:36 2006
> @@ -38,7 +38,7 @@
> <!-- webdav GET matcher -->
> <map:match pattern="davget.xml">
> <map:act type="set-header">
> - <map:parameter name="Last-Modified" value="{page-envelope:document-lastmodified}" />
> + <map:parameter name="Last-Modified" value="{date-iso8601-rfc822:{page-envelope:document-lastmodified}}" />
> <map:read src="context://lenya/pubs/{page-envelope:publication-id}/content/{page-envelope:area}/{page-envelope:document-id}/index_{page-envelope:document-language}.odt" mime-type="application/vnd.oasis.opendocument.text"/>
> </map:act>
> </map:match>
>
> Modified: lenya/trunk/src/modules/xhtml/sitemap.xmap
> URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/xhtml/sitemap.xmap?rev=372534&r1=372533&r2=372534&view=diff
> ==============================================================================
> --- lenya/trunk/src/modules/xhtml/sitemap.xmap (original)
> +++ lenya/trunk/src/modules/xhtml/sitemap.xmap Thu Jan 26 06:58:36 2006
> @@ -53,7 +53,7 @@
> <!-- webdav GET matcher -->
> <map:match pattern="davget.xml">
> <map:act type="set-header">
> - <map:parameter name="Last-Modified" value="{page-envelope:document-lastmodified}" />
> + <map:parameter name="Last-Modified" value="{date-iso8601-rfc822:{page-envelope:document-lastmodified}}" />
> <map:generate src="lenyadoc:/{page-envelope:document-language}/{page-envelope:document-id}"/>
> <map:serialize type="xml-get"/>
> </map:act>
>
> Modified: lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
> URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl?rev=372534&r1=372533&r2=372534&view=diff
> ==============================================================================
> --- lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl (original)
> +++ lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl Thu Jan 26 06:58:36 2006
> @@ -122,6 +122,11 @@
> <format>yyyy-MM-dd HH:mm:ss Z</format>
> </component-instance>
>
> + <component-instance name="date-iso8601-rfc822" logger="core.modules.input" class="org.apache.lenya.cms.cocoon.components.modules.input.DateConverterModule">
> + <src-pattern>yyyy-MM-dd HH:mm:ss Z</src-pattern>
> + <pattern>EEE, dd MMM yyyy HH:mm:ss Z</pattern>
> + </component-instance>
> +
> <component-instance name="proxy-url" logger="sitemap.modules.input.proxy-url"
> class="org.apache.lenya.cms.cocoon.components.modules.input.ProxyUrlModule"/>
>
>
> Modified: lenya/trunk/src/webapp/lenya/pubs/default/sitemap.xmap
> URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/sitemap.xmap?rev=372534&r1=372533&r2=372534&view=diff
> ==============================================================================
> --- lenya/trunk/src/webapp/lenya/pubs/default/sitemap.xmap (original)
> +++ lenya/trunk/src/webapp/lenya/pubs/default/sitemap.xmap Thu Jan 26 06:58:36 2006
> @@ -165,7 +165,7 @@
> <map:act type="language-exists">
>
> <map:act type="set-header">
> - <map:parameter name="Last-Modified" value="{page-envelope:document-lastmodified}" />
> + <map:parameter name="Last-Modified" value="{date-iso8601-rfc822:{page-envelope:document-lastmodified}}" />
>
> <!-- HEAD request shouldn't have all the xslt overhead -->
> <map:select type="request-method">
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
> For additional commands, e-mail: commits-help@lenya.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org