Author: oching
Date: Tue Apr  8 03:36:50 2008
New Revision: 645833

URL: http://svn.apache.org/viewvc?rev=645833&view=rev
Log:
[MRM-123]
-configure host and port of the links in the rss feeds

Modified:
    archiva/trunk/archiva-jetty/src/main/conf/jetty.xml
    
archiva/trunk/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java

Modified: archiva/trunk/archiva-jetty/src/main/conf/jetty.xml
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-jetty/src/main/conf/jetty.xml?rev=645833&r1=645832&r2=645833&view=diff
==============================================================================
--- archiva/trunk/archiva-jetty/src/main/conf/jetty.xml (original)
+++ archiva/trunk/archiva-jetty/src/main/conf/jetty.xml Tue Apr  8 03:36:50 2008
@@ -51,6 +51,15 @@
     </Set>
 
 
+    <Call class="java.lang.System" name="setProperty">
+      <Arg>jetty.port</Arg>
+      <Arg>8080</Arg>
+    </Call>
+
+    <Call class="java.lang.System" name="setProperty">
+      <Arg>jetty.host</Arg>
+      <Arg>localhost</Arg>
+    </Call>
 
     <!-- =========================================================== -->
     <!-- Set connectors                                              -->
@@ -64,7 +73,7 @@
     <Call name="addConnector">
       <Arg>
           <New class="org.mortbay.jetty.nio.SelectChannelConnector">
-            <Set name="host"><SystemProperty name="jetty.host" /></Set>
+            <Set name="host"><SystemProperty name="jetty.host"/></Set>
             <Set name="port"><SystemProperty name="jetty.port" 
default="8080"/></Set>
             <Set name="maxIdleTime">30000</Set>
             <Set name="Acceptors">2</Set>
@@ -268,8 +277,7 @@
     <Arg type="boolean">True</Arg>
     <Arg type="boolean">False</Arg>
   </Call>
-  
-  
+
   <!-- ARCHIVA CONFIG -->
        
   <New id="validation_mail" class="org.mortbay.jetty.plus.naming.Resource">

Modified: 
archiva/trunk/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java?rev=645833&r1=645832&r2=645833&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java
 Tue Apr  8 03:36:50 2008
@@ -22,9 +22,11 @@
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collections;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
 import org.apache.archiva.rss.RssFeedEntry;
 import org.apache.archiva.rss.RssFeedGenerator;
@@ -53,7 +55,17 @@
     private RssFeedGenerator generator;
 
     private Logger log = LoggerFactory.getLogger( 
NewArtifactsRssFeedProcessor.class );
-
+    
+    /**
+     * The hostname that will be used in the urls for the feed links.
+     */
+    private String host = "localhost";
+    
+    /**
+     * The port that will be used in the urls for the feed links.
+     */
+    private String port = "8080";
+    
     /**
      * Process the newly discovered artifacts in the repository. Generate 
feeds for new artifacts in the repository and
      * new versions of artifact.
@@ -62,6 +74,16 @@
     {
         log.debug( "Process new artifacts into rss feeds." );
         
+        if ( System.getProperty( "jetty.host" ) != null )
+        {
+            host = System.getProperty( "jetty.host" );
+        }
+        
+        if ( System.getProperty( "jetty.port" ) != null )
+        {
+            port = System.getProperty( "jetty.port" );
+        }
+        
         processNewArtifactsInRepo( data );
         processNewVersionsOfArtifact( data );
     }
@@ -73,7 +95,7 @@
 
         RssFeedEntry entry =
             new RssFeedEntry( NEW_ARTIFACTS_IN_REPO + "\'" + repoId + "\'" + " 
as of " +
-                Calendar.getInstance().getTime(), 
"http://localhost:8080/archiva/rss/new_artifacts_"; + repoId + ".xml" );
+                Calendar.getInstance().getTime(), getBaseUrl() + 
"/archiva/rss/new_artifacts_" + repoId + ".xml" );
         String description = "These are the new artifacts found in repository 
" + "\'" + repoId + "\'" + ": \n";
 
         for ( ArchivaArtifact artifact : data )
@@ -84,7 +106,7 @@
         entries.add( entry );
 
         generateFeed( "new_artifacts_" + repoId + ".xml", 
NEW_ARTIFACTS_IN_REPO + "\'" + repoId + "\'",
-                      
"http://localhost:8080/archiva/repository/rss/new_artifacts_"; + repoId + ".xml",
+                      getBaseUrl() + "/archiva/repository/rss/new_artifacts_" 
+ repoId + ".xml",
                       "New artifacts found in repository " + "\'" + repoId + 
"\'" + " during repository scan.", entries );
     }
 
@@ -108,7 +130,7 @@
             List<RssFeedEntry> entries = new ArrayList<RssFeedEntry>();
             RssFeedEntry entry =
                 new RssFeedEntry( NEW_VERSIONS_OF_ARTIFACT + "\'" + key + "\'" 
+ " as of " +
-                    Calendar.getInstance().getTime(), 
"http://localhost:8080/archiva/rss/new_versions_"; + key + ".xml" );
+                    Calendar.getInstance().getTime(), getBaseUrl() + 
"/archiva/rss/new_versions_" + key + ".xml" );
 
             String description =
                 "These are the new versions of artifact " + "\'" + key + "\'" 
+ " in the repository: \n" +
@@ -116,9 +138,9 @@
 
             entry.setDescription( description );
             entries.add( entry );
-
+            
             generateFeed( "new_versions_" + key + ".xml", 
NEW_VERSIONS_OF_ARTIFACT + "\'" + key + "\'",
-                          "http://localhost:8080/archiva/rss/new_versions_"; + 
key + ".xml",
+                          getBaseUrl() + "/archiva/rss/new_versions_" + key + 
".xml",
                           "New versions of artifact " + "\'" + key + "\' found 
in repository " + "\'" + repoId + "\'" +
                               " during repository scan.", entries );
         }
@@ -173,5 +195,17 @@
     {
         this.generator = generator;
     }
-
+    
+    private String getBaseUrl()
+    {
+        String baseUrl = "http://"; + host;
+        
+        if( port != null && !"".equals( port ) )
+        {
+            baseUrl = baseUrl + ":" + port;
+        }
+        
+        return baseUrl;
+    }
+    
 }


Reply via email to