archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r691866 - in /archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src: main/java/org/apache/maven/archiva/web/rss/ main/webapp/WEB-INF/ main/webapp/WEB-INF/jsp/ main/webapp/WEB-INF/jsp/admin/ test/java/org/apache/maven...
Date Thu, 04 Sep 2008 04:09:07 GMT
Author: oching
Date: Wed Sep  3 21:09:07 2008
New Revision: 691866

URL: http://svn.apache.org/viewvc?rev=691866&view=rev
Log:
merged -r687634 (MRM-839: updated the rss url for repositories and artifacts) from trunk

Modified:
    archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java
    archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp
    archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp
    archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml
    archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/rss/RssFeedServletTest.java
    archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/test/webapp/WEB-INF/feedServletTest-web.xml

Modified: archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java?rev=691866&r1=691865&r2=691866&view=diff
==============================================================================
--- archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java
(original)
+++ archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java
Wed Sep  3 21:09:07 2008
@@ -35,6 +35,7 @@
 import org.apache.commons.codec.Decoder;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.database.ArchivaDatabaseException;
 import org.apache.maven.archiva.security.AccessDeniedException;
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
@@ -106,22 +107,33 @@
     public void doGet( HttpServletRequest req, HttpServletResponse res )
         throws ServletException, IOException
     {
-        String repoId = req.getParameter( "repoId" );
-        String groupId = req.getParameter( "groupId" );
-        String artifactId = req.getParameter( "artifactId" );
+        String repoId = null;
+        String groupId = null;
+        String artifactId = null;
+        
+        String url = StringUtils.removeEnd( req.getRequestURL().toString(), "/" );      
   
+        if( StringUtils.countMatches( StringUtils.substringAfter( url, "feeds/" ), "/" )
> 0 )
+        {
+            artifactId = StringUtils.substringAfterLast( url, "/" );
+            groupId = StringUtils.substringBeforeLast( StringUtils.substringAfter( url, "feeds/"
), "/");
+            groupId = StringUtils.replaceChars( groupId, '/', '.' );
+        }
+        else if( StringUtils.countMatches( StringUtils.substringAfter( url, "feeds/" ), "/"
) == 0 )
+        {
+            repoId = StringUtils.substringAfterLast( url, "/" );
+        }
+        else
+        {
+            res.sendError( HttpServletResponse.SC_BAD_REQUEST, "Invalid request url." );
+            return;
+        }        
         
         try
         {
             Map<String, String> map = new HashMap<String, String>();
             SyndFeed feed = null;
-        
-            if ( ( repoId == null ) && ( groupId == null && artifactId ==
null ) )
-            {
-                res.sendError( HttpServletResponse.SC_BAD_REQUEST, "Required fields not found
in request." );
-                return;
-            }
-
-            if ( isAllowed( req ) )
+            
+            if ( isAllowed( req, repoId, groupId, artifactId ) )
             {
                 if ( repoId != null )
                 {
@@ -157,14 +169,14 @@
             }
             
             res.setContentType( MIME_TYPE );
-            
+                        
             if ( repoId != null )
-            {
-                feed.setLink( req.getRequestURL() + "?repoId=" + repoId );
+            {   
+                feed.setLink( req.getRequestURL().toString() );
             }
             else if ( ( groupId != null ) && ( artifactId != null ) )
             {
-                feed.setLink( req.getRequestURL() + "?groupId=" + groupId + "&artifactId="
+ artifactId );
+                feed.setLink( req.getRequestURL().toString() );                
             }
 
             SyndFeedOutput output = new SyndFeedOutput();
@@ -218,20 +230,23 @@
      * Basic authentication.
      * 
      * @param req
+     * @param repositoryId TODO
+     * @param groupId TODO
+     * @param artifactId TODO
      * @return
      */
-    private boolean isAllowed( HttpServletRequest req )
+    private boolean isAllowed( HttpServletRequest req, String repositoryId, String groupId,
String artifactId )
         throws UserNotFoundException, AccountLockedException, AuthenticationException, MustChangePasswordException,
         UnauthorizedException
     {
         String auth = req.getHeader( "Authorization" );
         List<String> repoIds = new ArrayList<String>();
 
-        if ( req.getParameter( "repoId" ) != null )
+        if ( repositoryId != null )
         {
-            repoIds.add( req.getParameter( "repoId" ) );
+            repoIds.add( repositoryId );
         }
-        else if ( req.getParameter( "artifactId" ) != null && req.getParameter( "groupId"
) != null )
+        else if ( artifactId != null && groupId != null )
         {
             if ( auth != null )
             {

Modified: archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp?rev=691866&r1=691865&r2=691866&view=diff
==============================================================================
--- archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp
(original)
+++ archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp
Wed Sep  3 21:09:07 2008
@@ -88,7 +88,7 @@
     </ww:a>
   </redback:ifAnyAuthorized>
   <c:url var="rssFeedIconUrl" value="/images/icons/rss-feed.png"/>
-  <a href="/archiva/rss/rss_feeds?repoId=${repository.id}">
+  <a href="/archiva/feeds/${repository.id}">
 	<img src="${rssFeedIconUrl}" />
   </a>
 </div>

Modified: archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp?rev=691866&r1=691865&r2=691866&view=diff
==============================================================================
--- archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp
(original)
+++ archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/browse.jsp
Wed Sep  3 21:09:07 2008
@@ -72,7 +72,7 @@
           </c:set>          
           <li>
           <a href="${url}">${artifactId}/</a>
-          <a href="/archiva/rss/rss_feeds?groupId=${groupId}&artifactId=${artifactId}">
+          <a href="/archiva/feeds/${groupId}/${artifactId}">
       		<img src="${rssFeedIconUrl}" />
     	  </a>
     	  </li>    

Modified: archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml?rev=691866&r1=691865&r2=691866&view=diff
==============================================================================
--- archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml
(original)
+++ archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml
Wed Sep  3 21:09:07 2008
@@ -93,7 +93,7 @@
   
   <servlet-mapping>
      <servlet-name>RssFeedServlet</servlet-name>
-     <url-pattern>/rss/rss_feeds</url-pattern>
+     <url-pattern>/feeds/*</url-pattern>
   </servlet-mapping>
   
   <servlet-mapping>

Modified: archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/rss/RssFeedServletTest.java
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/rss/RssFeedServletTest.java?rev=691866&r1=691865&r2=691866&view=diff
==============================================================================
--- archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/rss/RssFeedServletTest.java
(original)
+++ archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/rss/RssFeedServletTest.java
Wed Sep  3 21:09:07 2008
@@ -59,7 +59,7 @@
         throws Exception
     {
         RssFeedServlet servlet =
-            (RssFeedServlet) client.newInvocation( "http://localhost/rss/rss_feeds?repoId=test-repo"
).getServlet();
+            (RssFeedServlet) client.newInvocation( "http://localhost/feeds/test-repo" ).getServlet();
         assertNotNull( servlet );
     }
 
@@ -67,10 +67,10 @@
         throws Exception
     {
         RssFeedServlet servlet =
-            (RssFeedServlet) client.newInvocation( "http://localhost/rss/rss_feeds?repoId=test-repo"
).getServlet();
+            (RssFeedServlet) client.newInvocation( "http://localhost/feeds/test-repo" ).getServlet();
         assertNotNull( servlet );
 
-        WebRequest request = new GetMethodWebRequest( "http://localhost/rss/rss_feeds?repoId=test-repo"
);
+        WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/test-repo"
);
         
         BASE64Encoder encoder = new BASE64Encoder();
         String userPass = "user1:password1";
@@ -88,10 +88,10 @@
     {
         RssFeedServlet servlet =
             (RssFeedServlet) client.newInvocation(
-                                                   "http://localhost/rss/rss_feeds?groupId=org.apache.archiva&artifactId=artifact-two"
).getServlet();
+                                                   "http://localhost/feeds/org/apache/archiva/artifact-two"
).getServlet();
         assertNotNull( servlet );
 
-        WebRequest request = new GetMethodWebRequest( "http://localhost/rss/rss_feeds?groupId=org.apache.archiva&artifactId=artifact-two"
);
+        WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/org/apache/archiva/artifact-two"
);
         
         BASE64Encoder encoder = new BASE64Encoder();
         String userPass = "user1:password1";
@@ -109,12 +109,12 @@
     {
         RssFeedServlet servlet =
             (RssFeedServlet) client.newInvocation(
-                                                   "http://localhost/rss/rss_feeds?invalid_param=xxx"
).getServlet();
+                                                   "http://localhost/feeds?invalid_param=xxx"
).getServlet();
         assertNotNull( servlet );
 
         try
         {
-            WebResponse response = client.getResponse( "http://localhost/rss/rss_feeds?invalid_param=xxx"
);
+            WebResponse response = client.getResponse( "http://localhost/feeds?invalid_param=xxx"
);
         }
         catch ( HttpException he )
         {
@@ -127,11 +127,11 @@
     {
         RssFeedServlet servlet =
             (RssFeedServlet) client.newInvocation(
-                                                   "http://localhost/rss/rss_feeds?repoId=unauthorized-repo"
).getServlet();
+                                                   "http://localhost/feeds/unauthorized-repo"
).getServlet();
         assertNotNull( servlet );
     
         
-        WebRequest request = new GetMethodWebRequest( "http://localhost/rss/rss_feeds?repoId=unauthorized-repo"
);
+        WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo"
);
         
         Encoder encoder = new Base64();
         String userPass = "unauthUser:unauthPass";
@@ -153,11 +153,11 @@
     {
         RssFeedServlet servlet =
             (RssFeedServlet) client.newInvocation(
-                                                   "http://localhost/rss/rss_feeds?repoId=unauthorized-repo"
).getServlet();
+                                                   "http://localhost/feeds/unauthorized-repo"
).getServlet();
         assertNotNull( servlet );
     
         
-        WebRequest request = new GetMethodWebRequest( "http://localhost/rss/rss_feeds?repoId=unauthorized-repo"
);
+        WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo"
);
         
         BASE64Encoder encoder = new BASE64Encoder();
         String userPass = "user1:password1";

Modified: archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/test/webapp/WEB-INF/feedServletTest-web.xml
URL: http://svn.apache.org/viewvc/archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/test/webapp/WEB-INF/feedServletTest-web.xml?rev=691866&r1=691865&r2=691866&view=diff
==============================================================================
--- archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/test/webapp/WEB-INF/feedServletTest-web.xml
(original)
+++ archiva/branches/archiva-1.1.x/archiva-modules/archiva-web/archiva-webapp/src/test/webapp/WEB-INF/feedServletTest-web.xml
Wed Sep  3 21:09:07 2008
@@ -35,7 +35,7 @@
 
   <servlet-mapping>
   	<servlet-name>RssFeedServlet</servlet-name>
-	<url-pattern>/rss/*</url-pattern>
+	<url-pattern>/feeds/*</url-pattern>
   </servlet-mapping>
   
   <context-param>



Mime
View raw message