diff options
author | Maria Odea B. Ching <oching@apache.org> | 2008-04-08 10:36:50 +0000 |
---|---|---|
committer | Maria Odea B. Ching <oching@apache.org> | 2008-04-08 10:36:50 +0000 |
commit | 66612a985f5fcea7e86af85dd163942cac5db5db (patch) | |
tree | fe5f30c4f8d9040611ab5e4e6a0474fbd40e8259 | |
parent | 919466bbd25449259800c25a41f19a2e5a27bb70 (diff) | |
download | archiva-66612a985f5fcea7e86af85dd163942cac5db5db.tar.gz archiva-66612a985f5fcea7e86af85dd163942cac5db5db.zip |
[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
-rw-r--r-- | archiva-jetty/src/main/conf/jetty.xml | 14 | ||||
-rw-r--r-- | archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/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 @@ </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"> 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<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 @@ 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; + } + } |