oodt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ross Laidlaw (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OODT-458) Allow XML namespaces to be defined in the RSS configuration file for the CAS REST service ('fmprod' webapp)
Date Tue, 15 May 2012 01:22:31 GMT



























<style>
/* Changing the layout to use less space for mobiles */
@media screen and (max-device-width: 480px), screen and (-webkit-min-device-pixel-ratio: 2)
{
    #email-body { min-width: 30em !important; }
    #email-page { padding: 8px !important; }
    #email-banner { padding: 8px 8px 0 8px !important; }
    #email-avatar { margin: 1px 8px 8px 0 !important; padding: 0 !important; }
    #email-fields { padding: 0 8px 8px 8px !important; }
    #email-gutter { width: 0 !important; }
}
</style>
<div id="email-body">
<table id="email-wrap" align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#f0f0f0;color:#000000;width:100%;">
    <tr valign="top">
        <td id="email-page" style="padding:16px !important;">
            <table align="center" border="0" cellpadding="0" cellspacing="0" style="background-color:#ffffff;border:1px
solid #bbbbbb;color:#000000;width:100%;">
                <tr valign="top">
                    <td bgcolor="#ffffff" style="background-color:#ffffff;color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;line-height:1;"><img
src="https://issues.apache.org/jira/s/en_UKy3do2c/731/4/_/images/asf_logo_wide.gif" alt=""
style="vertical-align:top;" /></td>
                </tr><tr valign="top">
    <td id="email-banner" style="padding:32px 32px 0 32px;">

                
        
        
            <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%"
style="width:100%;">
    <tr valign="top">
        <td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;padding:0;">
                                        <img id="email-avatar" src="https://issues.apache.org/jira/secure/useravatar?avatarId=10450"
alt="" height="48" width="48" border="0" align="left" style="padding:0;margin: 0 16px 16px
0;" />
                        <div id="email-action" style="padding: 0 0 8px 0;font-size:12px;line-height:18px;">
                                    <a class="user-hover" rel="rlaidlaw" id="email_rlaidlaw"
href="https://issues.apache.org/jira/secure/ViewProfile.jspa?name=rlaidlaw" style="color:#326ca6;">Ross
Laidlaw</a>
     commented on <img src="https://issues.apache.org/jira/images/icons/improvement.gif"
height="16" width="16" border="0" align="absmiddle" alt="Improvement"> <a style='color:#326ca6;text-decoration:none;'
href='https://issues.apache.org/jira/browse/OODT-458'>OODT-458</a>
            </div>
                        <div id="email-summary" style="font-size:16px;line-height:20px;padding:2px
0 16px 0;">
                <a style='color:#326ca6;text-decoration:none;' href='https://issues.apache.org/jira/browse/OODT-458'><strong>Allow
XML namespaces to be defined in the RSS configuration file for the CAS REST service (&#39;fmprod&#39;
webapp)</strong></a>
            </div>
                    </td>
    </tr>
</table>
    </td>
</tr>
<tr valign="top">
    <td id="email-fields" style="padding:0 32px 32px 32px;">
        <table border="0" cellpadding="0" cellspacing="0" style="padding:0;text-align:left;width:100%;"
width="100%">
            <tr valign="top">
                <td id="email-gutter" style="width:64px;white-space:nowrap;"></td>
                <td>
                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                        <tr valign="top">
    <td colspan="2" style="color:#000000;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:12px;padding:0
0 16px 0;width:100%;">
        <div class="comment-block" style="background-color:#edf5ff;border:1px solid #dddddd;color:#000000;padding:12px;"><p>(I
transferred this comment over from <a href="https://issues.apache.org/jira/browse/OODT-449"
title="Create a default GeoRSS configuration file for the fmprod web application">OODT-449</a>):</p>

<p>I've been experimenting with some ideas to implement Paul's suggestion for namespaces.
 I have a solution that appears to be working.  Here are the steps I took:</p>

<p>1) Added Paul's namespace tags to the georss-config.xml file, as follows:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">&lt;namespace prefix=<span class="code-quote">"geo"</span>
uri=<span class="code-quote">"http:<span class="code-comment">//www.w3.org/2003/01/geo/wgs84_pos#"</span>
/&gt;
</span>&lt;namespace prefix=<span class="code-quote">"georss"</span>
uri=<span class="code-quote">"http:<span class="code-comment">//www.georss.org/georss"</span>
/&gt;
</span>&lt;namespace prefix=<span class="code-quote">"gml"</span> uri=<span
class="code-quote">"http:<span class="code-comment">//www.opengis.net/gml"</span>
/&gt;</span></pre>
</div></div>


<p>2) Created a new RSSNamespace class, which is very similar to the RSSTag class:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-keyword">package</span> org.apache.oodt.cas.product.rss;

<span class="code-keyword">public</span> class RSSNamespace 
{
  <span class="code-keyword">private</span> <span class="code-object">String</span>
prefix;
  <span class="code-keyword">private</span> <span class="code-object">String</span>
uri;

  <span class="code-keyword">public</span> RSSNamespace() { }

  <span class="code-keyword">public</span> <span class="code-object">String</span>
getPrefix() { <span class="code-keyword">return</span> prefix; }
  <span class="code-keyword">public</span> void setPrefix(<span class="code-object">String</span>
prefix) { <span class="code-keyword">this</span>.prefix = prefix;}

  <span class="code-keyword">public</span> <span class="code-object">String</span>
getUri() { <span class="code-keyword">return</span> uri; }
  <span class="code-keyword">public</span> void setUri(<span class="code-object">String</span>
uri) { <span class="code-keyword">this</span>.uri = uri; }
}</pre>
</div></div>


<p>3) Modified the RSSConfig class to add a list to store namespaces:</p>

<ul>
	<li>added new instance variable namespaces:</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-keyword">private</span> List&lt;RSSNamespace&gt;
namespaces;</pre>
</div></div>


<ul>
	<li>added assignment to the constructor:</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-keyword">this</span>.namespaces
= <span class="code-keyword">new</span> Vector&lt;RSSNamespace&gt;();</pre>
</div></div>


<ul>
	<li>added getter and setter methods for the namespaces instance variable:</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-keyword">public</span> List&lt;RSSNamespace&gt;
getNamespaces() { <span class="code-keyword">return</span> namespaces; }
<span class="code-keyword">public</span> void setNamespaces(List&lt;RSSNamespace&gt;
namespaces) { <span class="code-keyword">this</span>.namespaces = namespaces;
}</pre>
</div></div>


<p>4) Added new constants to the RSSConfigReaderMetKeys interface:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-keyword">public</span> <span
class="code-keyword">static</span> <span class="code-keyword">final</span>
<span class="code-object">String</span> NAMESPACE_TAG = <span class="code-quote">"namespace"</span>;
<span class="code-keyword">public</span> <span class="code-keyword">static</span>
<span class="code-keyword">final</span> <span class="code-object">String</span>
NAMESPACE_ATTR_PREFIX = <span class="code-quote">"prefix"</span>;
<span class="code-keyword">public</span> <span class="code-keyword">static</span>
<span class="code-keyword">final</span> <span class="code-object">String</span>
NAMESPACE_ATTR_URI = <span class="code-quote">"uri"</span>;</pre>
</div></div>


<p>5) Updated the RSSConfigReader class to read in the namespace tags:</p>

<ul>
	<li>added readNamespaces() method to RSSConfigReader</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-keyword">protected</span> <span
class="code-keyword">static</span> void readNamespaces(Element root, RSSConfig conf)
{
  NodeList namespaceList = root.getElementsByTagName(NAMESPACE_TAG);
  <span class="code-keyword">if</span> (namespaceList != <span class="code-keyword">null</span>
&amp;&amp; namespaceList.getLength() &gt; 0) {
    <span class="code-keyword">for</span> (<span class="code-object">int</span>
i = 0; i &lt; namespaceList.getLength(); i++) {
      Element namespaceElem = (Element) namespaceList.item(i);
      RSSNamespace namespace = <span class="code-keyword">new</span> RSSNamespace();
      namespace.setPrefix(namespaceElem.getAttribute(NAMESPACE_ATTR_PREFIX));
      namespace.setUri(namespaceElem.getAttribute(NAMESPACE_ATTR_URI));
      conf.getNamespaces().add(namespace);
    }
  }
}</pre>
</div></div>


<ul>
	<li>added call to readNamespaces before the call to readTags in the readConfig method</li>
</ul>


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-keyword">public</span> <span
class="code-keyword">static</span> RSSConfig readConfig(File file) <span class="code-keyword">throws</span>
FileNotFoundException {
  ...
  readNamespaces(rootElem, conf);
  readTags(rootElem, conf);
  ...
}</pre>
</div></div>


<p>6) Updated the doIt() method in the RSSProductServlet class to process the list of
namespace tags and add any namespaces to the rss tag of the output:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-keyword">public</span> void doIt(HttpServletRequest
req, HttpServletResponse resp) 
  <span class="code-keyword">throws</span> ServletException, java.io.IOException

{
  ...

  <span class="code-keyword">if</span> (products != <span class="code-keyword">null</span>
&amp;&amp; products.size() &gt; 0) 
  {
    ...
    <span class="code-keyword">try</span> 
    {
      ...
      Element rss = XMLUtils.addNode(doc, doc, <span class="code-quote">"rss"</span>);
      XMLUtils.addAttribute(doc, rss, <span class="code-quote">"version"</span>,
<span class="code-quote">"2.0"</span>);
      XMLUtils.addAttribute(doc, rss, <span class="code-quote">"xmlns:cas"</span>,
(<span class="code-object">String</span>) NS_MAP.get(<span class="code-quote">"cas"</span>));
        
      <span class="code-keyword">for</span> (RSSNamespace namespace : <span
class="code-keyword">this</span>.conf.getNamespaces()) 
      {
        XMLUtils.addAttribute(doc, rss, <span class="code-quote">"xmlns:"</span>
+ namespace.getPrefix(), namespace.getUri());
      }
      ...
    }
  }
}</pre>
</div></div>


<p>7) Tested the output:</p>

<p>The results showed that the namespaces defined in georss-config.xml are now being
added to the 'rss' tag of the output, as follows:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">&lt;rss xmlns:cas=<span class="code-quote">"http:<span
class="code-comment">//oodt.jpl.nasa.gov/1.0/cas"</span> 
</span>     xmlns:geo=<span class="code-quote">"http:<span class="code-comment">//www.w3.org/2003/01/geo/wgs84_pos#"</span>

</span>     xmlns:georss=<span class="code-quote">"http:<span class="code-comment">//www.georss.org/georss"</span>

</span>     xmlns:gml=<span class="code-quote">"http:<span class="code-comment">//www.opengis.net/gml"</span>
version=<span class="code-quote">"2.0"</span>&gt;</span></pre>
</div></div></div>
        <div style="color:#505050;padding:4px 0 0 0;">                </div>
    </td>
</tr>
                    </table>
                </td>
            </tr>
        </table>
    </td>
</tr>













            </table>
        </td><!-- End #email-page -->
    </tr>
    <tr valign="top">
        <td style="color:#505050;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:10px;line-height:14px;padding:
0 16px 16px 16px;text-align:center;">
            This message is automatically generated by JIRA.<br />
            If you think it was sent incorrectly, please contact your <a style='color:#326ca6;'
href='https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa'>JIRA administrators</a>.<br
/>
            For more information on JIRA, see: <a style='color:#326ca6;' href='http://www.atlassian.com/software/jira'>http://www.atlassian.com/software/jira</a>
        </td>
    </tr>
</table><!-- End #email-wrap -->
</div><!-- End #email-body -->

Mime
View raw message