Author: oching
Date: Tue May  6 23:09:51 2008
New Revision: 653999

URL: http://svn.apache.org/viewvc?rev=653999&view=rev
Log:
[MRM-773]
-update feed link url from the request url
-set query import in ArtifactsByRepositoryConstraint

Modified:
    
archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java
    
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java
    
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml

Modified: 
archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java?rev=653999&r1=653998&r2=653999&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java
 Tue May  6 23:09:51 2008
@@ -44,11 +44,12 @@
         params = new Object[] { repoId };
        }
                
-       public ArtifactsByRepositoryConstraint( String repoId, Date 
whenGathered, String sortColumn )
+       public ArtifactsByRepositoryConstraint( String repoId, Date 
targetWhenGathered, String sortColumn )
     {
-           whereClause = "repositoryId == repoId && whenGathered >= 
whenGathered";        
-        declParams = new String[] { "String repoId", "Date whenGathered" };
-        params = new Object[] { repoId, whenGathered };
+           declImports = new String[] { "import java.util.Date" };
+           whereClause = "this.repositoryId == repoId && this.whenGathered >= 
targetWhenGathered";        
+        declParams = new String[] { "String repoId", "Date targetWhenGathered" 
};
+        params = new Object[] { repoId, targetWhenGathered };        
         this.sortColumn = sortColumn;
     }
                

Modified: 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java?rev=653999&r1=653998&r2=653999&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java
 Tue May  6 23:09:51 2008
@@ -98,8 +98,7 @@
 
     public void doGet( HttpServletRequest req, HttpServletResponse res )
         throws ServletException, IOException
-    {
-        log.info( "Request URL: " + req.getRequestURL() );
+    {       
         try
         {
             Map<String, String> map = new HashMap<String, String>();
@@ -107,28 +106,19 @@
             String repoId = req.getParameter( "repoId" );
             String groupId = req.getParameter( "groupId" );
             String artifactId = req.getParameter( "artifactId" );
-
-            if ( repoId != null )
+            
+            if ( isAuthorized( req ) )
             {
-
-                if ( isAuthorized( req ) )
-                {
+                if ( repoId != null )
+                {                   
                     // new artifacts in repo feed request
                     processor =
                         (RssFeedProcessor) wac.getBean( 
PlexusToSpringUtils.buildSpringId(
                                                                                
            RssFeedProcessor.class.getName(),
                                                                                
            "new-artifacts" ) );
-                    map.put( RssFeedProcessor.KEY_REPO_ID, repoId );
-                }
-                else
-                {
-                    res.sendError( HttpServletResponse.SC_UNAUTHORIZED, 
"Request is not authorized." );
-                    return;
+                    map.put( RssFeedProcessor.KEY_REPO_ID, repoId );           
         
                 }
-            }
-            else if ( ( groupId != null ) && ( artifactId != null ) )
-            {
-                if ( isAuthorized( req ) )
+                else if ( ( groupId != null ) && ( artifactId != null ) )
                 {
                     // new versions of artifact feed request
                     processor =
@@ -136,22 +126,31 @@
                                                                                
            RssFeedProcessor.class.getName(),
                                                                                
            "new-versions" ) );
                     map.put( RssFeedProcessor.KEY_GROUP_ID, groupId );
-                    map.put( RssFeedProcessor.KEY_ARTIFACT_ID, artifactId );
+                    map.put( RssFeedProcessor.KEY_ARTIFACT_ID, artifactId );   
                 
                 }
                 else
                 {
-                    res.sendError( HttpServletResponse.SC_UNAUTHORIZED, 
"Request is not authorized." );
+                    res.sendError( HttpServletResponse.SC_BAD_REQUEST, 
"Required fields not found in request." );
                     return;
                 }
             }
             else
             {
-                res.sendError( HttpServletResponse.SC_BAD_REQUEST, "Required 
fields not found in request." );
+                res.sendError( HttpServletResponse.SC_UNAUTHORIZED, "Request 
is not authorized." );
                 return;
             }
-
+            
             feed = processor.process( map );
             res.setContentType( MIME_TYPE );
+            
+            if ( repoId != null )
+            {
+                feed.setLink( req.getRequestURL() + "?repoId=" + repoId );
+            }
+            else if ( ( groupId != null ) && ( artifactId != null ) )
+            {
+                feed.setLink( req.getRequestURL() + "?groupId=" + groupId + 
"&artifactId=" + artifactId );
+            }
 
             SyndFeedOutput output = new SyndFeedOutput();
             output.output( feed, res.getWriter() );
@@ -193,7 +192,7 @@
         throws UserNotFoundException, AccountLockedException, 
AuthenticationException, AuthorizationException
     {
         String auth = req.getHeader( "Authorization" );
-
+        
         if ( auth == null )
         {
             return false;
@@ -219,7 +218,7 @@
         String[] userCredentials = usernamePassword.split( ":" );
         String username = userCredentials[0];
         String password = userCredentials[1];
-
+        
         AuthenticationDataSource dataSource = new 
PasswordBasedAuthenticationDataSource( username, password );
         SecuritySession session = null;
 
@@ -236,7 +235,7 @@
         session = securitySystem.authenticate( dataSource );
 
         for ( String repoId : repoIds )
-        {
+        {            
             if ( securitySystem.isAuthorized( session, 
ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS, repoId ) )
             {
                 return true;

Modified: 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml?rev=653999&r1=653998&r2=653999&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/web.xml
 Tue May  6 23:09:51 2008
@@ -93,7 +93,7 @@
   
   <servlet-mapping>
      <servlet-name>RssFeedServlet</servlet-name>
-     <url-pattern>/rss/*</url-pattern>
+     <url-pattern>/rss/rss_feeds</url-pattern>
   </servlet-mapping>
   
   <servlet-mapping>


Reply via email to