mirror of https://github.com/apache/archiva.git
[MRM-773]
-update feed link url from the request url -set query import in ArtifactsByRepositoryConstraint git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@653999 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
584bd356c2
commit
94799fd790
|
@ -44,11 +44,12 @@ public class ArtifactsByRepositoryConstraint
|
||||||
params = new Object[] { repoId };
|
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";
|
declImports = new String[] { "import java.util.Date" };
|
||||||
declParams = new String[] { "String repoId", "Date whenGathered" };
|
whereClause = "this.repositoryId == repoId && this.whenGathered >= targetWhenGathered";
|
||||||
params = new Object[] { repoId, whenGathered };
|
declParams = new String[] { "String repoId", "Date targetWhenGathered" };
|
||||||
|
params = new Object[] { repoId, targetWhenGathered };
|
||||||
this.sortColumn = sortColumn;
|
this.sortColumn = sortColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,8 +98,7 @@ public class RssFeedServlet
|
||||||
|
|
||||||
public void doGet( HttpServletRequest req, HttpServletResponse res )
|
public void doGet( HttpServletRequest req, HttpServletResponse res )
|
||||||
throws ServletException, IOException
|
throws ServletException, IOException
|
||||||
{
|
{
|
||||||
log.info( "Request URL: " + req.getRequestURL() );
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
|
@ -107,28 +106,19 @@ public class RssFeedServlet
|
||||||
String repoId = req.getParameter( "repoId" );
|
String repoId = req.getParameter( "repoId" );
|
||||||
String groupId = req.getParameter( "groupId" );
|
String groupId = req.getParameter( "groupId" );
|
||||||
String artifactId = req.getParameter( "artifactId" );
|
String artifactId = req.getParameter( "artifactId" );
|
||||||
|
|
||||||
if ( repoId != null )
|
if ( isAuthorized( req ) )
|
||||||
{
|
{
|
||||||
|
if ( repoId != null )
|
||||||
if ( isAuthorized( req ) )
|
{
|
||||||
{
|
|
||||||
// new artifacts in repo feed request
|
// new artifacts in repo feed request
|
||||||
processor =
|
processor =
|
||||||
(RssFeedProcessor) wac.getBean( PlexusToSpringUtils.buildSpringId(
|
(RssFeedProcessor) wac.getBean( PlexusToSpringUtils.buildSpringId(
|
||||||
RssFeedProcessor.class.getName(),
|
RssFeedProcessor.class.getName(),
|
||||||
"new-artifacts" ) );
|
"new-artifacts" ) );
|
||||||
map.put( RssFeedProcessor.KEY_REPO_ID, repoId );
|
map.put( RssFeedProcessor.KEY_REPO_ID, repoId );
|
||||||
}
|
}
|
||||||
else
|
else if ( ( groupId != null ) && ( artifactId != null ) )
|
||||||
{
|
|
||||||
res.sendError( HttpServletResponse.SC_UNAUTHORIZED, "Request is not authorized." );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( ( groupId != null ) && ( artifactId != null ) )
|
|
||||||
{
|
|
||||||
if ( isAuthorized( req ) )
|
|
||||||
{
|
{
|
||||||
// new versions of artifact feed request
|
// new versions of artifact feed request
|
||||||
processor =
|
processor =
|
||||||
|
@ -136,22 +126,31 @@ public class RssFeedServlet
|
||||||
RssFeedProcessor.class.getName(),
|
RssFeedProcessor.class.getName(),
|
||||||
"new-versions" ) );
|
"new-versions" ) );
|
||||||
map.put( RssFeedProcessor.KEY_GROUP_ID, groupId );
|
map.put( RssFeedProcessor.KEY_GROUP_ID, groupId );
|
||||||
map.put( RssFeedProcessor.KEY_ARTIFACT_ID, artifactId );
|
map.put( RssFeedProcessor.KEY_ARTIFACT_ID, artifactId );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res.sendError( HttpServletResponse.SC_UNAUTHORIZED, "Request is not authorized." );
|
res.sendError( HttpServletResponse.SC_BAD_REQUEST, "Required fields not found in request." );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res.sendError( HttpServletResponse.SC_BAD_REQUEST, "Required fields not found in request." );
|
res.sendError( HttpServletResponse.SC_UNAUTHORIZED, "Request is not authorized." );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
feed = processor.process( map );
|
feed = processor.process( map );
|
||||||
res.setContentType( MIME_TYPE );
|
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();
|
SyndFeedOutput output = new SyndFeedOutput();
|
||||||
output.output( feed, res.getWriter() );
|
output.output( feed, res.getWriter() );
|
||||||
|
@ -193,7 +192,7 @@ public class RssFeedServlet
|
||||||
throws UserNotFoundException, AccountLockedException, AuthenticationException, AuthorizationException
|
throws UserNotFoundException, AccountLockedException, AuthenticationException, AuthorizationException
|
||||||
{
|
{
|
||||||
String auth = req.getHeader( "Authorization" );
|
String auth = req.getHeader( "Authorization" );
|
||||||
|
|
||||||
if ( auth == null )
|
if ( auth == null )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -219,7 +218,7 @@ public class RssFeedServlet
|
||||||
String[] userCredentials = usernamePassword.split( ":" );
|
String[] userCredentials = usernamePassword.split( ":" );
|
||||||
String username = userCredentials[0];
|
String username = userCredentials[0];
|
||||||
String password = userCredentials[1];
|
String password = userCredentials[1];
|
||||||
|
|
||||||
AuthenticationDataSource dataSource = new PasswordBasedAuthenticationDataSource( username, password );
|
AuthenticationDataSource dataSource = new PasswordBasedAuthenticationDataSource( username, password );
|
||||||
SecuritySession session = null;
|
SecuritySession session = null;
|
||||||
|
|
||||||
|
@ -236,7 +235,7 @@ public class RssFeedServlet
|
||||||
session = securitySystem.authenticate( dataSource );
|
session = securitySystem.authenticate( dataSource );
|
||||||
|
|
||||||
for ( String repoId : repoIds )
|
for ( String repoId : repoIds )
|
||||||
{
|
{
|
||||||
if ( securitySystem.isAuthorized( session, ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS, repoId ) )
|
if ( securitySystem.isAuthorized( session, ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS, repoId ) )
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
|
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>RssFeedServlet</servlet-name>
|
<servlet-name>RssFeedServlet</servlet-name>
|
||||||
<url-pattern>/rss/*</url-pattern>
|
<url-pattern>/rss/rss_feeds</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
|
|
Loading…
Reference in New Issue