mirror of https://github.com/apache/archiva.git
[MRM-132] support /browse/group.id/artifactId/version format paths instead
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@428256 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
df0a99a436
commit
3c2fd21b53
|
@ -77,7 +77,7 @@ public class BrowseAction
|
|||
|
||||
private String groupId;
|
||||
|
||||
private static final String GROUP_SEPARATOR = "/";
|
||||
private static final String GROUP_SEPARATOR = ".";
|
||||
|
||||
private List artifactIds;
|
||||
|
||||
|
@ -142,7 +142,6 @@ public class BrowseAction
|
|||
|
||||
this.groups = collateGroups( rootNode );
|
||||
|
||||
String groupId = this.groupId.replaceAll( GROUP_SEPARATOR, "." );
|
||||
List records = index.search(
|
||||
new LuceneQuery( new TermQuery( new Term( StandardIndexRecordFields.GROUPID_EXACT, groupId ) ) ) );
|
||||
|
||||
|
@ -177,8 +176,6 @@ public class BrowseAction
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
String groupId = this.groupId.replaceAll( GROUP_SEPARATOR, "." );
|
||||
|
||||
BooleanQuery query = new BooleanQuery();
|
||||
query.add( new TermQuery( new Term( StandardIndexRecordFields.GROUPID_EXACT, groupId ) ),
|
||||
BooleanClause.Occur.MUST );
|
||||
|
@ -230,7 +227,7 @@ public class BrowseAction
|
|||
{
|
||||
String groupId = (String) i.next();
|
||||
|
||||
StringTokenizer tok = new StringTokenizer( groupId, "." );
|
||||
StringTokenizer tok = new StringTokenizer( groupId, GROUP_SEPARATOR );
|
||||
|
||||
GroupTreeNode node = rootNode;
|
||||
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
package org.apache.maven.repository.manager.web.mapper;
|
||||
|
||||
/*
|
||||
* Copyright 2005-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import com.opensymphony.webwork.dispatcher.mapper.ActionMapping;
|
||||
import com.opensymphony.webwork.dispatcher.mapper.DefaultActionMapper;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Map alternate URLs to specific actions. Used for the repository browser and the proxy.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
*/
|
||||
public class RepositoryActionMapper
|
||||
extends DefaultActionMapper
|
||||
{
|
||||
private static final String BROWSE_PREFIX = "/browse/";
|
||||
|
||||
public String getUriFromActionMapping( ActionMapping actionMapping )
|
||||
{
|
||||
Map params = actionMapping.getParams();
|
||||
if ( "browseGroup".equals( actionMapping.getName() ) )
|
||||
{
|
||||
return BROWSE_PREFIX + params.remove( "groupId" );
|
||||
}
|
||||
else if ( "browseArtifact".equals( actionMapping.getName() ) )
|
||||
{
|
||||
return BROWSE_PREFIX + params.remove( "groupId" ) + "/" + params.remove( "artifactId" );
|
||||
}
|
||||
else if ( "showArtifact".equals( actionMapping.getName() ) )
|
||||
{
|
||||
return BROWSE_PREFIX + params.remove( "groupId" ) + "/" + params.remove( "artifactId" ) + "/" +
|
||||
params.remove( "version" );
|
||||
}
|
||||
|
||||
return super.getUriFromActionMapping( actionMapping );
|
||||
}
|
||||
|
||||
public ActionMapping getMapping( HttpServletRequest httpServletRequest )
|
||||
{
|
||||
String path = httpServletRequest.getServletPath();
|
||||
if ( path.startsWith( BROWSE_PREFIX ) )
|
||||
{
|
||||
path = path.substring( BROWSE_PREFIX.length() );
|
||||
if ( path.length() == 0 )
|
||||
{
|
||||
return new ActionMapping( "browse", "/", "", null );
|
||||
}
|
||||
else
|
||||
{
|
||||
String[] parts = path.split( "/" );
|
||||
if ( parts.length == 1 )
|
||||
{
|
||||
Map params = new HashMap();
|
||||
params.put( "groupId", parts[0] );
|
||||
return new ActionMapping( "browseGroup", "/", "", params );
|
||||
}
|
||||
else if ( parts.length == 2 )
|
||||
{
|
||||
Map params = new HashMap();
|
||||
params.put( "groupId", parts[0] );
|
||||
params.put( "artifactId", parts[1] );
|
||||
return new ActionMapping( "browseArtifact", "/", "", params );
|
||||
}
|
||||
else if ( parts.length == 3 )
|
||||
{
|
||||
Map params = new HashMap();
|
||||
params.put( "groupId", parts[0] );
|
||||
params.put( "artifactId", parts[1] );
|
||||
params.put( "version", parts[2] );
|
||||
return new ActionMapping( "showArtifact", "/", "", params );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.getMapping( httpServletRequest );
|
||||
}
|
||||
}
|
|
@ -28,6 +28,9 @@ import java.net.URL;
|
|||
import java.util.HashMap;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @todo remove this!
|
||||
*/
|
||||
public class RepositoryProxyActionMapper
|
||||
extends DefaultActionMapper
|
||||
{
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# define our own action mapper here
|
||||
webwork.mapper.class=org.apache.maven.repository.proxy.web.actionmapper.RepositoryProxyActionMapper
|
||||
webwork.mapper.class=org.apache.maven.repository.manager.web.mapper.RepositoryActionMapper
|
||||
webwork.objectFactory = org.codehaus.plexus.xwork.PlexusObjectFactory
|
||||
|
|
Loading…
Reference in New Issue