Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

svn commit: r289423 - in /lenya/trunk/src: java/org/apache/lenya/cms/cocoon: msg#00037

cms.lenya.cvs

Subject: svn commit: r289423 - in /lenya/trunk/src: java/org/apache/lenya/cms/cocoon/components/modules/input/CustomMetaDataModule.java webapp/WEB-INF/cocoon-xconf.xsl

Author: andreas
Date: Fri Sep 16 01:06:02 2005
New Revision: 289423

URL: http://svn.apache.org/viewcvs?rev=289423&view=rev
Log:
Added CustomMetaDataModule to retrieve custom meta data. This fixes bug #36668.
Thanks to Felix Roethenbacher (and sorry that I forgot to mention you in my
last commit ...)

Added:

lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/CustomMetaDataModule.java
Modified:
lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl

Added:
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/CustomMetaDataModule.java
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/CustomMetaDataModule.java?rev=289423&view=auto
==============================================================================
---
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/CustomMetaDataModule.java
(added)
+++
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/CustomMetaDataModule.java
Fri Sep 16 01:06:02 2005
@@ -0,0 +1,111 @@
+/*
+ * Copyright 1999-2005 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.
+ *
+ */
+
+/* $Id: DublinCoreModule.java 169299 2005-05-09 12:00:43Z jwkaltz $ */
+
+package org.apache.lenya.cms.cocoon.components.modules.input;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.lenya.cms.metadata.MetaData;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentException;
+
+/**
+ * Input module to access custom meta data values.
+ */
+public class CustomMetaDataModule extends AbstractPageEnvelopeModule {
+
+ final static String NS_PREFIX = "lenya:";
+
+ /**
+ * @see
org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
+ * org.apache.avalon.framework.configuration.Configuration,
java.util.Map)
+ */
+ public Object getAttribute(String name, Configuration modeConf, Map
objectModel)
+ throws ConfigurationException {
+ Object value;
+
+ MetaData metaData = getCustomMetaData(objectModel);
+
+ if (!metaData.isValidAttribute(NS_PREFIX + name)) {
+ throw new ConfigurationException("The attribute [" + name + "] is
not supported!");
+ }
+
+ try {
+ value = metaData.getFirstValue(NS_PREFIX + name);
+ } catch (DocumentException e) {
+ throw new ConfigurationException("Obtaining custom meta data value
for [" + name
+ + "] failed: ", e);
+ }
+
+ return value;
+ }
+
+ /**
+ * @see
org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
+ * java.util.Map)
+ */
+ public Iterator getAttributeNames(Configuration modeConf, Map objectModel)
+ throws ConfigurationException {
+
+ // No pre-defined attributes. Return empty iterator.
+ return new ArrayList().iterator();
+ }
+
+ /**
+ * @see
org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
+ * org.apache.avalon.framework.configuration.Configuration,
java.util.Map)
+ */
+ public Object[] getAttributeValues(String name, Configuration modeConf,
Map objectModel)
+ throws ConfigurationException {
+ Object[] values;
+ MetaData metaData = getCustomMetaData(objectModel);
+
+ if (!metaData.isValidAttribute(NS_PREFIX + name)) {
+ throw new ConfigurationException("The attribute [" + name + "] is
not supported!");
+ }
+
+ try {
+ values = metaData.getValues(NS_PREFIX + name);
+ } catch (DocumentException e) {
+ throw new ConfigurationException("Obtaining custom meta data value
for [" + name
+ + "] failed: ", e);
+ }
+
+ return values;
+ }
+
+ protected MetaData getCustomMetaData(Map objectModel) throws
ConfigurationException {
+ // FIXME: There seems to be no reason to pass the attribute name to
get the page envelope.
+ Document document = getEnvelope(objectModel, "").getDocument();
+ if (document == null) {
+ throw new ConfigurationException("There is no document for this
page envelope!");
+ }
+ MetaData metaData = null;
+ try {
+ metaData = document.getMetaDataManager().getCustomMetaData();
+ } catch (DocumentException e) {
+ throw new ConfigurationException("Obtaining custom meta data value
for ["
+ + document.getSourceURI() + "] failed: ", e);
+ }
+ return metaData;
+ }
+}

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=289423&r1=289422&r2=289423&view=diff
==============================================================================
--- lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl (original)
+++ lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl Fri Sep 16 01:06:02 2005
@@ -90,6 +90,9 @@
<component-instance logger="sitemap.modules.input.dublincore"
name="dublincore"

class="org.apache.lenya.cms.cocoon.components.modules.input.DublinCoreModule"/>

+ <component-instance logger="sitemap.modules.input.custom-metadata"
name="custom-metadata"
+
class="org.apache.lenya.cms.cocoon.components.modules.input.CustomMetaDataModule"/>
+
<component-instance logger="core.modules.input.access-control"
name="access-control"

class="org.apache.lenya.cms.cocoon.components.modules.input.AccessControlModule"/>


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qplus.devel/200...    network.jabber....    debian.qa-packa...    encryption.gpg....    python.dabo.dev...    uclinux.devel/2...    science.mathema...    recreation.pesc...    kernel.ck/2004-...    mozilla.devel.e...    tex.latex.prosp...    ietf.multi6/200...    bbc.cvs/2002-11...    xfree86.newbie/...    jakarta.taglibs...    altlinux.hardwa...    comedi/2002-05/...    horde.bugs/2004...    games.diplomacy...    finance.e-gold....    web.dom.test-su...    lang.ruby.rails...    os.netbsd.devel...    video.gstreamer...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation