From 66612a985f5fcea7e86af85dd163942cac5db5db Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Tue, 8 Apr 2008 10:36:50 +0000 Subject: [PATCH] [MRM-123] -configure host and port of the links in the rss feeds git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@645833 13f79535-47bb-0310-9956-ffa450edef68 --- archiva-jetty/src/main/conf/jetty.xml | 14 ++++-- .../NewArtifactsRssFeedProcessor.java | 48 ++++++++++++++++--- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/archiva-jetty/src/main/conf/jetty.xml b/archiva-jetty/src/main/conf/jetty.xml index 6e1f4577c..439d808c3 100644 --- a/archiva-jetty/src/main/conf/jetty.xml +++ b/archiva-jetty/src/main/conf/jetty.xml @@ -51,6 +51,15 @@ + + jetty.port + 8080 + + + + jetty.host + localhost + @@ -64,7 +73,7 @@ - + 30000 2 @@ -268,8 +277,7 @@ True False - - + diff --git a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java index 7b556f07a..675731386 100644 --- a/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java +++ b/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java @@ -22,9 +22,11 @@ package org.apache.archiva.rss.processor; 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 @@ public class NewArtifactsRssFeedProcessor 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 @@ public class NewArtifactsRssFeedProcessor { 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 @@ public class NewArtifactsRssFeedProcessor 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 @@ public class NewArtifactsRssFeedProcessor 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 @@ public class NewArtifactsRssFeedProcessor List entries = new ArrayList(); 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 @@ public class NewArtifactsRssFeedProcessor 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 @@ public class NewArtifactsRssFeedProcessor { this.generator = generator; } - + + private String getBaseUrl() + { + String baseUrl = "http://" + host; + + if( port != null && !"".equals( port ) ) + { + baseUrl = baseUrl + ":" + port; + } + + return baseUrl; + } + } -- 2.39.5