oodt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rlaid...@apache.org
Subject svn commit: r1365200 - in /oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss: RSSConfig.java RSSConfigReader.java RSSConfigReaderMetKeys.java RSSNamespace.java RSSProductServlet.java
Date Tue, 24 Jul 2012 18:14:38 GMT
Author: rlaidlaw
Date: Tue Jul 24 18:14:37 2012
New Revision: 1365200

URL: http://svn.apache.org/viewvc?rev=1365200&view=rev
Log:
OODT-469: removed hard-coded namespaces from RSSProductServlet and enabled configurable namespaces
via RSS config

Added:
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSNamespace.java
  (with props)
Modified:
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfig.java
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfigReader.java
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfigReaderMetKeys.java
    oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSProductServlet.java

Modified: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfig.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfig.java?rev=1365200&r1=1365199&r2=1365200&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfig.java
(original)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfig.java
Tue Jul 24 18:14:37 2012
@@ -34,6 +34,7 @@ import java.util.Vector;
 public class RSSConfig {
 
   private List<RSSTag> tags;
+  private List<RSSNamespace> namespaces;
   
   private String channelLink;
 
@@ -43,6 +44,7 @@ public class RSSConfig {
   public RSSConfig() {
     this.channelLink = null;
     this.tags = new Vector<RSSTag>();
+    this.namespaces = new Vector<RSSNamespace>();
   }
 
   /**
@@ -59,6 +61,21 @@ public class RSSConfig {
   public void setTags(List<RSSTag> tags) {
     this.tags = tags;
   }
+  
+  /**
+   * @return the namespaces
+   */
+  public List<RSSNamespace> getNamespaces() { 
+    return namespaces; 
+  }
+  
+  /**
+   * @param namespaces
+   *          the namespaces to set
+   */
+  public void setNamespaces(List<RSSNamespace> namespaces) { 
+    this.namespaces = namespaces; 
+  }
 
   /**
    * @return the channelLink

Modified: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfigReader.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfigReader.java?rev=1365200&r1=1365199&r2=1365200&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfigReader.java
(original)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfigReader.java
Tue Jul 24 18:14:37 2012
@@ -56,9 +56,23 @@ public class RSSConfigReader implements 
     Element rootElem = doc.getDocumentElement();
     conf.setChannelLink(rootElem.getAttribute(CHANNEL_LINK_ATTR));
 
+    readNamespaces(rootElem, conf);
     readTags(rootElem, conf);
     return conf;
   }
+  
+  protected static void readNamespaces(Element root, RSSConfig conf) {
+    NodeList namespaceList = root.getElementsByTagName(NAMESPACE_TAG);
+    if (namespaceList != null && namespaceList.getLength() > 0) {
+      for (int i = 0; i < namespaceList.getLength(); i++) {
+        Element namespaceElem = (Element) namespaceList.item(i);
+        RSSNamespace namespace = new RSSNamespace();
+        namespace.setPrefix(namespaceElem.getAttribute(NAMESPACE_ATTR_PREFIX));
+        namespace.setUri(namespaceElem.getAttribute(NAMESPACE_ATTR_URI));
+        conf.getNamespaces().add(namespace);
+      }
+    }
+  }
 
   protected static void readTags(Element root, RSSConfig conf) {
     NodeList tagList = root.getElementsByTagName(TAG_TAG);

Modified: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfigReaderMetKeys.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfigReaderMetKeys.java?rev=1365200&r1=1365199&r2=1365200&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfigReaderMetKeys.java
(original)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSConfigReaderMetKeys.java
Tue Jul 24 18:14:37 2012
@@ -29,6 +29,12 @@ package org.apache.oodt.cas.product.rss;
 public interface RSSConfigReaderMetKeys {
   
   public static final String CHANNEL_LINK_ATTR = "channelLink";
+  
+  public static final String NAMESPACE_TAG = "namespace";
+  
+  public static final String NAMESPACE_ATTR_PREFIX = "prefix";
+  
+  public static final String NAMESPACE_ATTR_URI = "uri";
 
   public static final String TAG_TAG = "tag";
 

Added: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSNamespace.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSNamespace.java?rev=1365200&view=auto
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSNamespace.java
(added)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSNamespace.java
Tue Jul 24 18:14:37 2012
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.oodt.cas.product.rss;
+
+/**
+ * 
+ * RSS namespace definition to include in an RSS feed as defined by the
+ * {@link RSSProductServlet}'s {@link RSSConfig}.
+ * 
+ * @author rlaidlaw
+ * @version $Revision$
+ */
+public class RSSNamespace 
+{
+  private String prefix;
+  private String uri;
+
+  /**
+   * Default constructor.
+   */
+  public RSSNamespace() { }
+
+  /**
+   * @return the prefix
+   */
+  public String getPrefix() { return prefix; }
+
+  /**
+   * @param prefix
+   *          the prefix to set
+   */
+  public void setPrefix(String prefix) { this.prefix = prefix;}
+
+  /**
+   * @return the uri
+   */
+  public String getUri() { return uri; }
+
+  /**
+   * @param uri
+   *          the uri to set
+   */
+  public void setUri(String uri) { this.uri = uri; }
+}
\ No newline at end of file

Propchange: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSNamespace.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSProductServlet.java
URL: http://svn.apache.org/viewvc/oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSProductServlet.java?rev=1365200&r1=1365199&r2=1365200&view=diff
==============================================================================
--- oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSProductServlet.java
(original)
+++ oodt/trunk/webapp/fmprod/src/main/java/org/apache/oodt/cas/product/rss/RSSProductServlet.java
Tue Jul 24 18:14:37 2012
@@ -83,8 +83,6 @@ public class RSSProductServlet extends H
   /* our log stream */
   private Logger LOG = Logger.getLogger(RSSProductServlet.class.getName());
 
-  private static final Map NS_MAP = new HashMap();
-
   public static final String COPYRIGHT_BOILER_PLATE = "Copyright 2010: Apache Software Foundation";
 
   public static final String RSS_FORMAT_STR = "E, dd MMM yyyy HH:mm:ss z";
@@ -92,10 +90,6 @@ public class RSSProductServlet extends H
   public static final SimpleDateFormat dateFormatter = new SimpleDateFormat(
       RSS_FORMAT_STR);
 
-  static {
-    NS_MAP.put("cas", "http://oodt.jpl.nasa.gov/1.0/cas");
-  }
-
   /**
    * Default constructor.
    */
@@ -206,8 +200,13 @@ public class RSSProductServlet extends H
 
         Element rss = XMLUtils.addNode(doc, doc, "rss");
         XMLUtils.addAttribute(doc, rss, "version", "2.0");
-        XMLUtils
-            .addAttribute(doc, rss, "xmlns:cas", (String) NS_MAP.get("cas"));
+        
+        // add namespace attributes from config file to rss tag
+        for (RSSNamespace namespace : this.conf.getNamespaces()) 
+        {
+          XMLUtils.addAttribute(doc, rss, "xmlns:" + namespace.getPrefix(), namespace.getUri());
+        }
+        
         Element channel = XMLUtils.addNode(doc, rss, "channel");
 
         XMLUtils.addNode(doc, channel, "title", productTypeName);



Mime
View raw message