You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by oc...@apache.org on 2008/04/08 12:37:22 UTC

svn commit: r645833 - in /archiva/trunk: archiva-jetty/src/main/conf/jetty.xml archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java

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;
+    }
+    
 }



Re: svn commit: r645833 - in /archiva/trunk: archiva-jetty/src/main/conf/jetty.xml archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java

Posted by Maria Odea Ching <oc...@apache.org>.
On Wed, Apr 9, 2008 at 8:46 PM, Brett Porter <br...@apache.org> wrote:

>
> On 09/04/2008, at 4:10 PM, Maria Odea Ching wrote:
>
>  Is it persisted to disk so it is still correct after a restart?
> > >
> >
> >
> > Yep, it's being written into the disk with different filenames and is
> > updated everytime new artifacts are discovered in the repo. Now that
> > you've
> > mentioned this, I think I should also put a check or limit as to how
> > many
> > entries in the feeds should be kept so as to prevent the size of the
> > files
> > from bloating.
> >
>
> yep, I agree - and the size should be kept small so that it's quick to
> download. You also need to make sure that the when the client requests the
> RSS, it gets the right headers to not try and update it if it hasn't changed
> for performance.
>
>
> > Hmm, by 'request' do you mean when a user clicks the rss feed icon to
> > subscribe to a feed? If it is, my only concern here is for the new feed
> > entries. Since a user only subscribes to a feed once, if we have new
> > feed
> > entries (e.g. new artifacts discovered after another repo scan) then the
> > rss
> > would only be generated or updated if another user subscribes to the
> > feed
> > :-)
> >
>
> I don't think anything happens when they subscribe to the feed - the same
> request is made every time the feed reader checks for an update. The URLs
> given inside the feed do need to remain consistent, so passing them through
> the request for the RSS makes the most sense.


Yeah, I agree it makes more sense to do this. I'll see what i can do here.
I'll open a separate jira for this and for the file size control above.


>
>
> How is the RSS accessed at the moment? I haven't checked the code -is
> there a ww action for it, or is it served as the flat file?


It's being served as a flat file so there's no ww action for it..


>
>
> - Brett
>
> --
> Brett Porter
> brett@apache.org
> http://blogs.exist.com/bporter/
>
>
Thanks,
Deng

Re: svn commit: r645833 - in /archiva/trunk: archiva-jetty/src/main/conf/jetty.xml archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java

Posted by Brett Porter <br...@apache.org>.
On 09/04/2008, at 4:10 PM, Maria Odea Ching wrote:

>> Is it persisted to disk so it is still correct after a restart?
>
>
> Yep, it's being written into the disk with different filenames and is
> updated everytime new artifacts are discovered in the repo. Now that  
> you've
> mentioned this, I think I should also put a check or limit as to how  
> many
> entries in the feeds should be kept so as to prevent the size of the  
> files
> from bloating.

yep, I agree - and the size should be kept small so that it's quick to  
download. You also need to make sure that the when the client requests  
the RSS, it gets the right headers to not try and update it if it  
hasn't changed for performance.

>
> Hmm, by 'request' do you mean when a user clicks the rss feed icon to
> subscribe to a feed? If it is, my only concern here is for the new  
> feed
> entries. Since a user only subscribes to a feed once, if we have new  
> feed
> entries (e.g. new artifacts discovered after another repo scan) then  
> the rss
> would only be generated or updated if another user subscribes to the  
> feed
> :-)

I don't think anything happens when they subscribe to the feed - the  
same request is made every time the feed reader checks for an update.  
The URLs given inside the feed do need to remain consistent, so  
passing them through the request for the RSS makes the most sense.

How is the RSS accessed at the moment? I haven't checked the code -is  
there a ww action for it, or is it served as the flat file?

- Brett

--
Brett Porter
brett@apache.org
http://blogs.exist.com/bporter/


Re: svn commit: r645833 - in /archiva/trunk: archiva-jetty/src/main/conf/jetty.xml archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java

Posted by Maria Odea Ching <oc...@apache.org>.
On Wed, Apr 9, 2008 at 11:07 AM, Brett Porter <br...@apache.org> wrote:

> this sounds like a good optimisation, does it also take into account
> additions via upload (which triggers the consumers, just not the full scan)?
>


It just relies on the full scan. Hmm, I wasn't aware that artifact uploads
also triggers the consumers.. I'll take a look into this.


> Is it persisted to disk so it is still correct after a restart?


Yep, it's being written into the disk with different filenames and is
updated everytime new artifacts are discovered in the repo. Now that you've
mentioned this, I think I should also put a check or limit as to how many
entries in the feeds should be kept so as to prevent the size of the files
from bloating.

I wonder if instead of generating the full RSS, just the information about
> what is to be included could be stored/cached and then the RSS is generated
> on a request for it only so we can populate the host/port from the servlet
> context?
>

Hmm, by 'request' do you mean when a user clicks the rss feed icon to
subscribe to a feed? If it is, my only concern here is for the new feed
entries. Since a user only subscribes to a feed once, if we have new feed
entries (e.g. new artifacts discovered after another repo scan) then the rss
would only be generated or updated if another user subscribes to the feed
:-)

- Brett
>
>
> On 09/04/2008, at 12:00 PM, Maria Odea Ching wrote:
>
>  Unfortunately, not all the time.. The generation and update of the feeds
> > are
> > triggered after a repository scan, which can be scheduled or explicitly
> > executed.
> > I could get the servlet context when the scan is explicitly executed,
> > but I
> > don't think i can get it when it's executed by the task executor.
> >
> > -Deng
> >
> > On Tue, Apr 8, 2008 at 8:06 PM, Brett Porter <br...@apache.org> wrote:
> >
> >  Hi Deng,
> > >
> > > Is there any access to the servlet context to obtain this instead?
> > >
> > > - Brett
> >
> >
Thanks,
Deng

Re: svn commit: r645833 - in /archiva/trunk: archiva-jetty/src/main/conf/jetty.xml archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java

Posted by Brett Porter <br...@apache.org>.
this sounds like a good optimisation, does it also take into account  
additions via upload (which triggers the consumers, just not the full  
scan)? Is it persisted to disk so it is still correct after a restart?

I wonder if instead of generating the full RSS, just the information  
about what is to be included could be stored/cached and then the RSS  
is generated on a request for it only so we can populate the host/port  
from the servlet context?

- Brett

On 09/04/2008, at 12:00 PM, Maria Odea Ching wrote:

> Unfortunately, not all the time.. The generation and update of the  
> feeds are
> triggered after a repository scan, which can be scheduled or  
> explicitly
> executed.
> I could get the servlet context when the scan is explicitly  
> executed, but I
> don't think i can get it when it's executed by the task executor.
>
> -Deng
>
> On Tue, Apr 8, 2008 at 8:06 PM, Brett Porter <br...@apache.org> wrote:
>
>> Hi Deng,
>>
>> Is there any access to the servlet context to obtain this instead?
>>
>> - Brett
>>
>>
>> On 08/04/2008, at 8:37 PM, oching@apache.org wrote:
>>
>> 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;
>>> +    }
>>> +
>>> }
>>>
>>>
>>>
>> --
>> Brett Porter
>> brett@apache.org
>> http://blogs.exist.com/bporter/
>>
>>

--
Brett Porter
brett@apache.org
http://blogs.exist.com/bporter/


Re: svn commit: r645833 - in /archiva/trunk: archiva-jetty/src/main/conf/jetty.xml archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java

Posted by Maria Odea Ching <oc...@apache.org>.
Unfortunately, not all the time.. The generation and update of the feeds are
triggered after a repository scan, which can be scheduled or explicitly
executed.
I could get the servlet context when the scan is explicitly executed, but I
don't think i can get it when it's executed by the task executor.

-Deng

On Tue, Apr 8, 2008 at 8:06 PM, Brett Porter <br...@apache.org> wrote:

> Hi Deng,
>
> Is there any access to the servlet context to obtain this instead?
>
> - Brett
>
>
> On 08/04/2008, at 8:37 PM, oching@apache.org wrote:
>
>  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;
> > +    }
> > +
> > }
> >
> >
> >
> --
> Brett Porter
> brett@apache.org
> http://blogs.exist.com/bporter/
>
>

Re: svn commit: r645833 - in /archiva/trunk: archiva-jetty/src/main/conf/jetty.xml archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java

Posted by Brett Porter <br...@apache.org>.
Hi Deng,

Is there any access to the servlet context to obtain this instead?

- Brett

On 08/04/2008, at 8:37 PM, oching@apache.org wrote:

> 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;
> +    }
> +
> }
>
>

--
Brett Porter
brett@apache.org
http://blogs.exist.com/bporter/