rewrote browse to match white site

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@424215 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-07-21 07:43:54 +00:00
parent 9818d93f30
commit 57bf8e097a
20 changed files with 1080 additions and 559 deletions

View File

@ -18,9 +18,11 @@ package org.apache.maven.repository.indexing;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.repository.digest.Digester;
import org.apache.maven.repository.digest.DigesterException;
@ -29,8 +31,10 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
@ -74,7 +78,7 @@ public class ArtifactRepositoryIndex
{
deleteDocuments( getTermList( artifactList ) );
}
catch( IOException e )
catch ( IOException e )
{
throw new RepositoryIndexException( "Failed to delete an index document", e );
}
@ -254,4 +258,87 @@ public class ArtifactRepositoryIndex
files.append( name ).append( "\n" );
}
}
public List enumerateGroupIds()
throws IOException
{
IndexReader indexReader = IndexReader.open( getIndexPath() );
Set groups = new HashSet();
try
{
for ( int i = 0; i < indexReader.numDocs(); i ++ )
{
Document doc = indexReader.document( i );
groups.add( doc.getField( FLD_GROUPID ).stringValue() );
}
}
finally
{
indexReader.close();
}
List sortedGroups = new ArrayList( groups );
Collections.sort( sortedGroups );
return sortedGroups;
}
public List getArtifacts( String groupId )
throws IOException
{
IndexReader indexReader = IndexReader.open( getIndexPath() );
Set artifactIds = new HashSet();
try
{
for ( int i = 0; i < indexReader.numDocs(); i ++ )
{
Document doc = indexReader.document( i );
if ( doc.getField( FLD_GROUPID ).stringValue().equals( groupId ) )
{
artifactIds.add( doc.getField( FLD_ARTIFACTID ).stringValue() );
}
}
}
finally
{
indexReader.close();
}
List sortedArtifactIds = new ArrayList( artifactIds );
Collections.sort( sortedArtifactIds );
return sortedArtifactIds;
}
public List getVersions( String groupId, String artifactId )
throws IOException
{
IndexReader indexReader = IndexReader.open( getIndexPath() );
Set versions = new HashSet();
try
{
for ( int i = 0; i < indexReader.numDocs(); i ++ )
{
Document doc = indexReader.document( i );
if ( doc.getField( FLD_GROUPID ).stringValue().equals( groupId ) &&
doc.getField( FLD_ARTIFACTID ).stringValue().equals( artifactId ) )
{
// DefaultArtifactVersion is used for correct ordering
versions.add( new DefaultArtifactVersion( doc.getField( FLD_VERSION ).stringValue() ) );
}
}
}
finally
{
indexReader.close();
}
List sortedVersions = new ArrayList( versions );
Collections.sort( sortedVersions );
return sortedVersions;
}
}

View File

@ -95,6 +95,10 @@
<!-- TODO: actually, just exclude from WAR plugin -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
</dependency>
</dependencies>
<build>
<finalName>maven-repository-webapp</finalName>

View File

@ -1,88 +0,0 @@
package org.apache.maven.repository.manager.web.action;
/*
* 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.interceptor.ParameterAware;
import com.opensymphony.xwork.ActionSupport;
import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.configuration.ConfigurationStore;
import org.apache.maven.repository.manager.web.utils.ConfigurationManager;
import java.util.HashMap;
import java.util.Map;
/**
* This is the Action class of index.jsp, which is the initial page of the web application.
* It invokes the DiscovererScheduler to set the DiscoverJob in the scheduler.
*
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="baseAction"
* @todo don't like this as a base and as a forwarding action!
*/
public class BaseAction
extends ActionSupport
implements ParameterAware
{
/**
* @plexus.requirement
*/
private ConfigurationStore configurationStore;
private Map parameters;
public Map getParameters()
{
return parameters;
}
public void setParameters( Map parameters )
{
this.parameters = parameters;
}
/**
* Method that executes the action
*
* @return a String that specifies if the action executed was a success or a failure
*/
public String execute()
{
try
{
Configuration config = configurationStore.getConfigurationFromStore();
Map parameters = new HashMap();
parameters.put( ConfigurationManager.INDEXPATH, config.getIndexPath() );
parameters.put( ConfigurationManager.MIN_INDEXPATH, config.getMinimalIndexPath() );
parameters.put( ConfigurationManager.DISCOVERY_BLACKLIST_PATTERNS, config.getDiscoveryBlackListPatterns() );
parameters.put( ConfigurationManager.DISCOVER_SNAPSHOTS, Boolean.valueOf( config.isDiscoverSnapshots() ) );
parameters.put( ConfigurationManager.DISCOVERY_CRON_EXPRESSION, config.getIndexerCronExpression() );
this.parameters = parameters;
//Configuration configuration = new Configuration(); // TODO!
// execution.executeDiscovererIfIndexDoesNotExist( new File( config.getIndexPath() ) );
}
catch ( Exception e )
{
// TODO: better exception handling!
e.printStackTrace();
return ERROR;
}
return SUCCESS;
}
}

View File

@ -0,0 +1,316 @@
package org.apache.maven.repository.manager.web.action;
/*
* 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.xwork.ActionSupport;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.configuration.ConfigurationStore;
import org.apache.maven.repository.configuration.ConfigurationStoreException;
import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
/**
* Browse the repository.
*
* @todo the tree part probably belongs in a browsing component, along with the methods currently in the indexer
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="browseAction"
*/
public class BrowseAction
extends ActionSupport
{
/**
* @plexus.requirement
*/
private RepositoryIndexingFactory factory;
/**
* @plexus.requirement
*/
private RepositoryIndexSearchLayer searchLayer;
/**
* @plexus.requirement
*/
private ConfiguredRepositoryFactory repositoryFactory;
/**
* @plexus.requirement
*/
private ConfigurationStore configurationStore;
private List groups;
private String groupId;
private static final String GROUP_SEPARATOR = "/";
private List artifactIds;
private String artifactId;
private List versions;
public String browse()
throws ConfigurationStoreException, RepositoryIndexException, IOException
{
ArtifactRepositoryIndex index = getIndex();
if ( !index.indexExists() )
{
addActionError( "The repository is not yet indexed. Please wait, and then try again." );
return ERROR;
}
GroupTreeNode rootNode = buildGroupTree( index );
this.groups = collateGroups( rootNode );
return SUCCESS;
}
public String browseGroup()
throws ConfigurationStoreException, RepositoryIndexException, IOException
{
ArtifactRepositoryIndex index = getIndex();
if ( !index.indexExists() )
{
addActionError( "The repository is not yet indexed. Please wait, and then try again." );
return ERROR;
}
GroupTreeNode rootNode = buildGroupTree( index );
if ( StringUtils.isEmpty( groupId ) )
{
// TODO: i18n
addActionError( "You must specify a group ID to browse" );
return ERROR;
}
StringTokenizer tok = new StringTokenizer( groupId, GROUP_SEPARATOR );
while ( tok.hasMoreTokens() )
{
String part = tok.nextToken();
if ( !rootNode.getChildren().containsKey( part ) )
{
// TODO: i18n
addActionError( "The group specified was not found" );
return ERROR;
}
else
{
rootNode = (GroupTreeNode) rootNode.getChildren().get( part );
}
}
this.groups = collateGroups( rootNode );
this.artifactIds = index.getArtifacts( groupId.replaceAll( GROUP_SEPARATOR, "." ) );
return SUCCESS;
}
public String browseArtifact()
throws ConfigurationStoreException, RepositoryIndexException, IOException
{
ArtifactRepositoryIndex index = getIndex();
if ( StringUtils.isEmpty( groupId ) )
{
// TODO: i18n
addActionError( "You must specify a group ID to browse" );
return ERROR;
}
if ( StringUtils.isEmpty( artifactId ) )
{
// TODO: i18n
addActionError( "You must specify a artifact ID to browse" );
return ERROR;
}
versions = index.getVersions( groupId.replaceAll( GROUP_SEPARATOR, "." ), artifactId );
if ( versions.isEmpty() )
{
// TODO: i18n
addActionError( "Could not find any artifacts with the given group and artifact ID" );
return ERROR;
}
return SUCCESS;
}
private GroupTreeNode buildGroupTree( ArtifactRepositoryIndex index )
throws IOException
{
// TODO: give action message if indexing is in progress
// TODO: this will be inefficient over a very large number of artifacts, should be cached
List groups = index.enumerateGroupIds();
GroupTreeNode rootNode = new GroupTreeNode();
// build a tree structure
for ( Iterator i = groups.iterator(); i.hasNext(); )
{
String groupId = (String) i.next();
StringTokenizer tok = new StringTokenizer( groupId, "." );
GroupTreeNode node = rootNode;
while ( tok.hasMoreTokens() )
{
String part = tok.nextToken();
if ( !node.getChildren().containsKey( part ) )
{
GroupTreeNode newNode = new GroupTreeNode( part, node );
node.addChild( newNode );
node = newNode;
}
else
{
node = (GroupTreeNode) node.getChildren().get( part );
}
}
}
return rootNode;
}
private List collateGroups( GroupTreeNode rootNode )
{
List groups = new ArrayList();
for ( Iterator i = rootNode.getChildren().values().iterator(); i.hasNext(); )
{
GroupTreeNode node = (GroupTreeNode) i.next();
while ( node.getChildren().size() == 1 )
{
node = (GroupTreeNode) node.getChildren().values().iterator().next();
}
groups.add( node.getFullName() );
}
return groups;
}
private ArtifactRepositoryIndex getIndex()
throws ConfigurationStoreException, RepositoryIndexException
{
Configuration configuration = configurationStore.getConfigurationFromStore();
File indexPath = new File( configuration.getIndexPath() );
ArtifactRepository repository = repositoryFactory.createRepository( configuration );
return factory.createArtifactRepositoryIndex( indexPath, repository );
}
public List getGroups()
{
return groups;
}
public List getArtifactIds()
{
return artifactIds;
}
public String getGroupId()
{
return groupId;
}
public void setGroupId( String groupId )
{
this.groupId = groupId;
}
public String getArtifactId()
{
return artifactId;
}
public void setArtifactId( String artifactId )
{
this.artifactId = artifactId;
}
public List getVersions()
{
return versions;
}
private static class GroupTreeNode
{
private final String name;
private final String fullName;
private final Map children = new TreeMap();
GroupTreeNode()
{
name = null;
fullName = null;
}
GroupTreeNode( String name, GroupTreeNode parent )
{
this.name = name;
this.fullName = parent.fullName != null ? parent.fullName + GROUP_SEPARATOR + name : name;
}
public String getName()
{
return name;
}
public String getFullName()
{
return fullName;
}
public Map getChildren()
{
return children;
}
public void addChild( GroupTreeNode newNode )
{
children.put( newNode.name, newNode );
}
}
}

View File

@ -1,147 +0,0 @@
package org.apache.maven.repository.manager.web.action;
/*
* 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.xwork.Action;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.repository.discovery.ArtifactDiscoverer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/**
* Browse the repository.
*
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.RepositoryBrowseAction"
*/
public class RepositoryBrowseAction
implements Action
{
/**
* @plexus.requirement role-hint="default"
*/
private ArtifactDiscoverer discoverer;
/**
* @plexus.requirement
*/
private ArtifactRepositoryFactory repositoryFactory;
/**
* @plexus.requirement role-hint="default"
*/
private ArtifactRepositoryLayout layout;
private String group;
private Map artifactMap;
private String folder;
private int idx;
public String execute()
{
// TODO! fix hardcoded path
String path = "E:/jeprox/maven-repository-manager/trunk/maven-repository-discovery/src/test/repository";
ArtifactRepository repository =
repositoryFactory.createArtifactRepository( "discoveryRepo", "file://" + path, layout, null, null );
List artifacts = discoverer.discoverArtifacts( repository, null, true );
Iterator iterator = artifacts.iterator();
artifactMap = new TreeMap();
while ( iterator.hasNext() )
{
Artifact artifact = (Artifact) iterator.next();
String groupId = artifact.getGroupId();
String key = groupId.replace( '.', '/' ) + "/" + artifact.getArtifactId() + "/" + artifact.getVersion();
List artifactList;
if ( artifactMap.containsKey( key ) )
{
artifactList = (List) artifactMap.get( key );
}
else
{
artifactList = new ArrayList();
}
artifactList.add( artifact );
Collections.sort( artifactList );
artifactMap.put( key, artifactList );
}
//set the index for folder level to be displayed
idx = 1;
folder = "";
return SUCCESS;
}
public Map getArtifactMap()
{
return artifactMap;
}
public String getGroup()
{
return group;
}
public void setGroup( String group )
{
this.group = group;
}
public String getFolder()
{
return folder;
}
public void setFolder( String folder )
{
this.folder = folder;
}
public int getIdx()
{
return idx;
}
public void setIdx( int index )
{
this.idx = index;
}
}

View File

@ -32,10 +32,9 @@ import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
import java.io.File;
import java.net.MalformedURLException;
import java.util.List;
import java.util.Map;
/**
* Searches for searchString in all indexed fields.
* Search all indexed fields by the given criteria.
*
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="searchAction"
*/
@ -72,11 +71,6 @@ public class SearchAction
*/
private ConfiguredRepositoryFactory repositoryFactory;
/**
* @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
*/
private Map repositoryLayouts;
/**
* @plexus.requirement
*/

View File

@ -0,0 +1,153 @@
package org.apache.maven.repository.manager.web.action;
/*
* 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.xwork.ActionSupport;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Model;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.configuration.ConfigurationStore;
import org.apache.maven.repository.configuration.ConfigurationStoreException;
import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
/**
* Browse the repository.
*
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="showArtifactAction"
*/
public class ShowArtifactAction
extends ActionSupport
{
/**
* @plexus.requirement
*/
private ArtifactFactory artifactFactory;
/**
* @plexus.requirement
*/
private ConfiguredRepositoryFactory repositoryFactory;
/**
* @plexus.requirement
*/
private MavenProjectBuilder projectBuilder;
/**
* @plexus.requirement
*/
private ConfigurationStore configurationStore;
private String groupId;
private String artifactId;
private String version;
private Model model;
public String execute()
throws ConfigurationStoreException, IOException, XmlPullParserException, ProjectBuildingException
{
Configuration configuration = configurationStore.getConfigurationFromStore();
ArtifactRepository repository = repositoryFactory.createRepository( configuration );
if ( StringUtils.isEmpty( groupId ) )
{
// TODO: i18n
addActionError( "You must specify a group ID to browse" );
return ERROR;
}
if ( StringUtils.isEmpty( artifactId ) )
{
// TODO: i18n
addActionError( "You must specify a artifact ID to browse" );
return ERROR;
}
if ( StringUtils.isEmpty( version ) )
{
// TODO: i18n
addActionError( "You must specify a version to browse" );
return ERROR;
}
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, version );
// TODO: is this going to be problematic because repository is remote format, but being used as local?
// TODO: should it try to use the repo manager as a remote repo, proxying out?
// TODO: maybe we can decouple the assembly parts of the project builder from the repository handling
MavenProject project = projectBuilder.buildFromRepository( artifact, Collections.EMPTY_LIST, repository );
if ( !new File( repository.getBasedir(), repository.pathOf( artifact ) ).exists() )
{
// TODO: i18n
addActionError( "The given artifact was not found in the repository" );
return ERROR;
}
model = project.getModel();
return SUCCESS;
}
public Model getModel()
{
return model;
}
public String getGroupId()
{
return groupId;
}
public void setGroupId( String groupId )
{
this.groupId = groupId;
}
public String getArtifactId()
{
return artifactId;
}
public void setArtifactId( String artifactId )
{
this.artifactId = artifactId;
}
public String getVersion()
{
return version;
}
public void setVersion( String version )
{
this.version = version;
}
}

View File

@ -1,220 +0,0 @@
package org.apache.maven.repository.manager.web.utils;
/*
* Copyright 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 org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.configuration.io.xpp3.ConfigurationXpp3Reader;
import org.apache.maven.repository.configuration.io.xpp3.ConfigurationXpp3Writer;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
/**
* This class updates/sets the configuration values in the mrm-admin-config.xml file used
* for discovery and indexing.
*
* @plexus.component role="org.apache.maven.repository.manager.web.utils.ConfigurationManager"
*/
public class ConfigurationManager
{
public static final String WEB_XML_FILE = "web.xml";
public static final String INDEX_CONFIG_FILE = "mrm-admin-config.xml";
public static final String DISCOVER_SNAPSHOTS = "discoverSnapshots";
public static final String DISCOVERY_CRON_EXPRESSION = "discoveryCronExpression";
public static final String INDEXPATH = "indexPath";
public static final String MIN_INDEXPATH = "minimalIndexPath";
public static final String REPOSITORY_LAYOUT = "repositoryLayout";
public static final String REPOSITORY_DIRECTORY = "repositoryDirectory";
public static final String DISCOVERY_BLACKLIST_PATTERNS = "discoveryBlacklistPatterns";
private Configuration config;
private File plexusDescriptor;
/**
* Method for updating the configuration in mrm-admin-config.xml
*
* @param map contains the fields and the values to be updated in the configuration
*/
public void updateConfiguration( Map map )
throws IOException
{
File file = getConfigFile();
try
{
config = readXmlDocument( file );
}
catch ( XmlPullParserException de )
{
// TODO!
de.printStackTrace();
}
for ( Iterator iter = map.entrySet().iterator(); iter.hasNext(); )
{
Map.Entry entry = (Map.Entry) iter.next();
String name = (String) entry.getKey();
String value = (String) entry.getValue();
if ( name.equals( DISCOVERY_CRON_EXPRESSION ) )
{
config.setIndexerCronExpression( value );
}
if ( name.equals( REPOSITORY_LAYOUT ) )
{
config.setRepositoryLayout( value );
}
if ( name.equals( DISCOVER_SNAPSHOTS ) )
{
config.setDiscoverSnapshots( Boolean.valueOf( value ).booleanValue() );
}
if ( name.equals( REPOSITORY_DIRECTORY ) )
{
config.setRepositoryDirectory( value );
}
if ( name.equals( INDEXPATH ) )
{
config.setIndexPath( value );
}
if ( name.equals( MIN_INDEXPATH ) )
{
config.setMinimalIndexPath( value );
}
if ( name.equals( DISCOVERY_BLACKLIST_PATTERNS ) )
{
config.setDiscoveryBlackListPatterns( value );
}
}
writeXmlDocument( getConfigFile() );
}
/**
* Method that gets the properties set in the mrm-admin-config.xml for the configuration fields
* used in the schedule, indexing and discovery
*
* @return a Map that contains the elements in the properties of the configuration object
*/
public Configuration getConfiguration()
throws IOException
{
File file = getConfigFile();
config = new Configuration();
if ( file != null )
{
if ( !file.exists() )
{
writeXmlDocument( getConfigFile() );
}
else
{
try
{
config = readXmlDocument( file );
}
catch ( XmlPullParserException xe )
{
// TODO: fix error handling!
xe.printStackTrace();
}
}
}
return config;
}
/**
* Method that reads the xml file and returns a Configuration object
*
* @param file the xml file to be read
* @return a Document object that represents the contents of the xml file
* @throws FileNotFoundException
* @throws IOException
* @throws XmlPullParserException
*/
protected Configuration readXmlDocument( File file )
throws IOException, XmlPullParserException
{
ConfigurationXpp3Reader configReader = new ConfigurationXpp3Reader();
Reader reader = new FileReader( file );
Configuration config = configReader.read( reader );
return config;
}
/**
* Method for writing the configuration into the xml file
*
* @param file the file where the document will be written to
*/
protected void writeXmlDocument( File file )
throws IOException
{
Writer writer = new FileWriter( file );
ConfigurationXpp3Writer configWriter = new ConfigurationXpp3Writer();
configWriter.write( writer, config );
}
/**
* Method that returns the mrm-admin-config.xml file
*
* @return a File that references the plexus.xml
*/
protected File getConfigFile()
{
URL indexConfigXml = getClass().getClassLoader().getResource( "../" + INDEX_CONFIG_FILE );
if ( indexConfigXml != null )
{
plexusDescriptor = new File( indexConfigXml.getFile() );
}
else
{
URL xmlPath = getClass().getClassLoader().getResource( "../" + WEB_XML_FILE );
if ( xmlPath != null )
{
String path = xmlPath.getFile();
int lastIndex = path.lastIndexOf( '/' );
path = path.substring( 0, lastIndex + 1 );
path = path + INDEX_CONFIG_FILE;
plexusDescriptor = new File( path );
}
}
return plexusDescriptor;
}
}

View File

@ -39,6 +39,7 @@
<global-results>
<!-- TODO: might want an extra message on the configure page when this first happens -->
<result name="config-needed" type="redirect">/admin/configure.action</result>
<result name="error">/WEB-INF/jsp/generalError.jsp</result>
</global-results>
<action name="index" class="searchAction" method="input">
@ -61,6 +62,22 @@
<result name="error">/WEB-INF/jsp/findArtifact.jsp</result>
</action>
<action name="browse" class="browseAction" method="browse">
<result>/WEB-INF/jsp/browse.jsp</result>
</action>
<action name="browseGroup" class="browseAction" method="browseGroup">
<result>/WEB-INF/jsp/browseGroup.jsp</result>
</action>
<action name="browseArtifact" class="browseAction" method="browseArtifact">
<result>/WEB-INF/jsp/browseArtifact.jsp</result>
</action>
<action name="showArtifact" class="showArtifactAction">
<result>/WEB-INF/jsp/showArtifact.jsp</result>
</action>
<!-- TODO! old actions
<action name="proxy" class="org.apache.maven.repository.proxy.web.action.RepositoryProxyAction">
<result name="success" type="stream">
@ -71,11 +88,6 @@
<result name="notFound" type="dispatcher">notFoundError</result>
<result name="proxyError" type="dispatcher">proxyError</result>
</action>
<action name="browse" class="org.apache.maven.repository.manager.web.action.RepositoryBrowseAction">
<result name="success" type="dispatcher">/WEB-INF/jsp/browse.jsp</result>
<result name="error" type="dispatcher">/WEB-INF/jsp/browse.jsp</result>
</action>
-->
</package>

View File

@ -14,96 +14,61 @@
~ limitations under the License.
--%>
<%@ taglib uri="webwork" prefix="ww" %>
<%@ taglib prefix="ww" uri="/webwork" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Repository Browser</title>
<title>Browse Repository</title>
<ww:head />
</head>
<body>
<h3><a href="<ww:url value="browse!edit.action"><ww:param name="idx" value="0"/></ww:url>">basedir</a> /
<ww:set name="previousFolder" value="''" />
<ww:set name="counter" value="0" />
<ww:if test="folder != ''">
<ww:set name="folderHeader" value="folder.split('/')" />
<ww:iterator value="#folderHeader">
<ww:set name="counter" value="#counter + 1" />
<ww:if test="#previousFolder == ''">
<ww:set name="previousFolder" value="top" />
</ww:if>
<ww:else>
<ww:set name="previousFolder" value="#previousFolder + '/' + top" />
</ww:else>
<ww:if test="idx > (#counter + 1)"><a href="<ww:url value="browse!edit.action"><ww:param name="idx"><ww:property
value="#counter" /></ww:param><ww:param name="folder"></ww:param></ww:url>"></ww:if><ww:property /></a> /
</ww:iterator>
</ww:if>
</h3>
<br />
<ww:set name="previousFolder" value="'the previous folder'"/>
<ww:set name="in" value="idx" scope="page"/>
<ww:iterator value="artifactMap.keySet().iterator()">
<ww:set name="groupName" value="top"/>
<ww:if test="idx == 1 || (folder != '' and #groupName.startsWith(folder))">
<%
<h1>Browse Repository</h1>
<div id="contentArea">
<div id="nameColumn">
<h2>Groups</h2>
<ul>
<ww:set name="groups" value="groups" />
<c:forEach items="${groups}" var="groupId">
<ww:url id="url" action="browseGroup" namespace="/">
<ww:param name="groupId" value="%{'${groupId}'}" />
</ww:url>
<li><a href="${url}">${groupId}/</a></li>
</c:forEach>
</ul>
</div>
int ctr = 1;
%>
<ww:set name="groupFolder" value="#groupName.split('/')"/>
<ww:iterator value="#groupFolder">
<%
if (ctr == ((Integer)pageContext.getAttribute("in")).intValue()) {
%>
<ww:if test="top != #previousFolder">
<ww:set name="previousFolder" value="top"/>
<a href="<ww:url value="browse!edit.action"><ww:param name="folder"><ww:property value="folder"/><ww:if test="folder != ''">/</ww:if><ww:property/></ww:param><ww:param name="idx" value="idx"/></ww:url>"">
<ww:property/>/
</ a><br>
</ww:if>
<%
}
ctr++;
%>
</ww:iterator>
</ww:if>
</ww:iterator>
<ww:if test="folder != ''">
<ww:set name="previousFolder" value="''" />
<ww:set name="artifactList" value="artifactMap.get(folder)" />
<ww:iterator value="#artifactList">
<table border="1">
<tr align="left">
<th>Group ID</th>
<td><ww:property value="groupId" /></td>
<%-- TODO: later, when supported in metadata
<div id="categoryColumn">
<h2>Category</h2>
<table>
<tr>
<td>
<a href="#">Java</a>
</td>
</tr>
<tr align="left">
<th>Artifact ID</th>
<td><ww:property value="artifactId" /></td>
</tr>
<tr align="left">
<th>Version</th>
<td><ww:property value="version" /></td>
</tr>
<tr align="left">
<th>Derivatives</th>
<td><ww:property value="groupId" /></td>
</tr>
<tr align="left">
<th>Parent</th>
<td><ww:property value="folder" /></td>
<tr>
<td>
<a href="#">Ruby</a>
</td>
</tr>
</table>
<br />
</ww:iterator>
</ww:if>
</div>
<h2>Labels</h2>
<div id="labels">
<p>
<a href="#">jdo</a>
<a href="#">j2ee</a>
<a href="#">maven</a>
</p>
</div>
--%>
</div>
</body>
</html>

View File

@ -0,0 +1,66 @@
<%--
~ 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.
--%>
<%@ taglib prefix="ww" uri="/webwork" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Browse Repository</title>
<ww:head />
</head>
<body>
<h1>Browse Repository</h1>
<div id="contentArea">
<div id="nameColumn">
<p>
<c:forTokens items="${groupId}" delims="./" var="part">
<c:choose>
<c:when test="${empty(cumulativeGroup)}">
<c:set var="cumulativeGroup" value="${part}" />
</c:when>
<c:otherwise>
<c:set var="cumulativeGroup" value="${cumulativeGroup}/${part}" />
</c:otherwise>
</c:choose>
<ww:url id="url" action="browseGroup" namespace="/">
<ww:param name="groupId" value="%{'${cumulativeGroup}'}" />
</ww:url>
<a href="${url}">${part}</a> /
</c:forTokens>
<strong>${artifactId}</strong>
</p>
<h2>Versions</h2>
<ul>
<ww:set name="versions" value="versions" />
<c:forEach items="${versions}" var="version">
<ww:url id="url" action="showArtifact" namespace="/">
<ww:param name="groupId" value="%{'${groupId}'}" />
<ww:param name="artifactId" value="%{'${artifactId}'}" />
<ww:param name="version" value="%{'${version}'}" />
</ww:url>
<li><a href="${url}">${version}/</a></li>
</c:forEach>
</ul>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,86 @@
<%--
~ 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.
--%>
<%@ taglib prefix="ww" uri="/webwork" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Browse Repository</title>
<ww:head />
</head>
<body>
<h1>Browse Repository</h1>
<div id="contentArea">
<div id="nameColumn">
<p>
<c:forTokens items="${groupId}" delims="./" var="part" varStatus="status">
<c:choose>
<c:when test="${empty(cumulativeGroup)}">
<c:set var="cumulativeGroup" value="${part}" />
</c:when>
<c:otherwise>
<c:set var="cumulativeGroup" value="${cumulativeGroup}/${part}" />
</c:otherwise>
</c:choose>
<c:choose>
<c:when test="${status.last}">
<strong>${part}</strong>
</c:when>
<c:otherwise>
<ww:url id="url" action="browseGroup" namespace="/">
<ww:param name="groupId" value="%{'${cumulativeGroup}'}" />
</ww:url>
<a href="${url}">${part}</a> /
</c:otherwise>
</c:choose>
</c:forTokens>
</p>
<ww:set name="groups" value="groups" />
<c:if test="${!empty(groups)}">
<h2>Group / Artifact</h2>
<ul>
<c:forEach items="${groups}" var="groupId">
<ww:url id="url" action="browseGroup" namespace="/">
<ww:param name="groupId" value="%{'${groupId}'}" />
</ww:url>
<li><a href="${url}">${groupId}/</a></li>
</c:forEach>
</ul>
</c:if>
<ww:set name="artifactIds" value="artifactIds" />
<c:if test="${!empty(artifactIds)}">
<h2>Artifacts</h2>
<ul>
<c:forEach items="${artifactIds}" var="artifactId">
<ww:url id="url" action="browseArtifact" namespace="/">
<ww:param name="groupId" value="%{'${groupId}'}" />
<ww:param name="artifactId" value="%{'${artifactId}'}" />
</ww:url>
<li><a href="${url}">${artifactId}/</a></li>
</c:forEach>
</ul>
</c:if>
</div>
</div>
</body>
</html>

View File

@ -75,11 +75,9 @@
<my:currentWWUrl action="findArtifact" namespace="/">Find Artifact</my:currentWWUrl>
</li>
<%-- TODO
<li class="none">
<a href="#">Browse</a>
<my:currentWWUrl action="browse" namespace="/">Browse</my:currentWWUrl>
</li>
--%>
</ul>
<h5>Manage</h5>
<ul>

View File

@ -0,0 +1,33 @@
<%--
~ 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.
--%>
<%@ taglib prefix="ww" uri="/webwork" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Error Occurred</title>
<ww:head />
</head>
<body>
<h1>Error Occurred</h1>
<ww:actionerror />
</body>
</html>

View File

@ -41,7 +41,7 @@
<th></th>
--%>
</tr>
<ww:set name="searchResults" scope="request" value="searchResults" />
<ww:set name="searchResults" value="searchResults" />
<c:forEach items="${searchResults}" var="result" varStatus="i">
<tr class="${i.index % 2 == 0 ? "b" : "a"}">
<td><c:out value="${result.artifact.groupId}" /></td>

View File

@ -0,0 +1,254 @@
<%--
~ 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.
--%>
<%@ taglib prefix="ww" uri="/webwork" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Browse Repository</title>
<ww:head />
</head>
<body>
<%-- TODO: image by type
<img src="images/jar.png" width="100" height="100" alt="jar" style="float: left" />
--%>
<%-- TODO: download link
<div class="downloadButton">
<a href="#">Download</a>
</div>
--%>
<ww:set name="model" value="model" />
<h1>
<c:choose>
<c:when test="${empty(model.name)}">
${model.artifactId}
</c:when>
<c:otherwise>
${model.name}
</c:otherwise>
</c:choose>
</h1>
<div id="contentArea">
<div id="tabs">
<p>
<strong>Info</strong>
<%-- TODO: perhaps using ajax?
<a href="TODO">Dependencies</a>
<a href="TODO">Depended On</a>
<a href="TODO">Mailing Lists</a>
<a href="TODO">Developers</a>
<a href="TODO">POM</a>
--%>
</p>
</div>
<div id="tabArea">
<p>
<c:forTokens items="${model.groupId}" delims="." var="part">
<c:choose>
<c:when test="${empty(cumulativeGroup)}">
<c:set var="cumulativeGroup" value="${part}" />
</c:when>
<c:otherwise>
<c:set var="cumulativeGroup" value="${cumulativeGroup}/${part}" />
</c:otherwise>
</c:choose>
<ww:url id="url" action="browseGroup" namespace="/">
<ww:param name="groupId" value="%{'${cumulativeGroup}'}" />
</ww:url>
<a href="${url}">${part}</a> /
</c:forTokens>
<ww:url id="url" action="browseArtifact" namespace="/">
<ww:param name="groupId" value="%{'${model.groupId}'}" />
<ww:param name="artifactId" value="%{'${model.artifactId}'}" />
</ww:url>
<a href="${url}">${model.artifactId}</a> /
<strong>${model.version}</strong>
<!-- TODO: new versions?
(<strong class="statusFailed">Newer version available:</strong>
<a href="artifact.html">2.0.3</a>)
-->
</p>
<p>${mode.description}</p>
<table>
<tr>
<th>Group ID</th>
<td>${model.groupId}</td>
</tr>
<tr>
<th>Artifact ID</th>
<td>${model.artifactId}</td>
</tr>
<tr>
<th>Version</th>
<td>${model.version}</td>
</tr>
<%-- TODO: derivatives
<tr>
<th>Derivatives</th>
<td>
<a href="#">Source</a>
|
<a href="#">Javadoc</a>
</td>
</tr>
--%>
<c:if test="${model.parent != null}">
<tr>
<th>Parent</th>
<td>
${model.parent.groupId} ${model.parent.artifactId} ${model.parent.version}
<ww:url id="url" action="showArtifact" namespace="/">
<ww:param name="groupId" value="%{'${model.parent.groupId}'}" />
<ww:param name="artifactId" value="%{'${model.parent.artifactId}'}" />
<ww:param name="version" value="%{'${model.parent.version}'}" />
</ww:url>
(<a href="${url}">View</a>)
</td>
</tr>
</c:if>
<%-- TODO: deployment timestamp
<tr>
<th>Deployment Date</th>
<td>
15 Jan 2006, 20:38:00 +1000
</td>
</tr>
--%>
<!-- TODO: origin
<tr>
<th>Origin</th>
<td>
<a href="TODO">Apache Repository</a>
</td>
</tr>
-->
</table>
<c:if test="${model.organization != null || !empty(model.licenses)
|| model.issueManagement != null || model.ciManagement != null}">
<h2>Other Details</h2>
<table>
<c:if test="${model.organization != null}">
<tr>
<th>Organisation</th>
<td>
<c:choose>
<c:when test="${model.organization != null}">
<a href="${model.organization.url}">${model.organization.name}</a>
</c:when>
<c:otherwise>
${model.organization.name}
</c:otherwise>
</c:choose>
</td>
</tr>
</c:if>
<c:if test="${!empty(model.licenses)}">
<c:forEach items="${model.licenses}" var="license">
<tr>
<th>License</th>
<td>
<c:choose>
<c:when test="${!empty(license.url)}">
<a href="${license.url}">${license.name}</a>
</c:when>
<c:otherwise>
${license.name}
</c:otherwise>
</c:choose>
</td>
</tr>
</c:forEach>
</c:if>
<c:if test="${model.issueManagement != null}">
<tr>
<th>Issue Tracker</th>
<td>
<c:choose>
<c:when test="${!empty(model.issueManagement.url)}">
<a href="${model.issueManagement.url}">${model.issueManagement.system}</a>
</c:when>
<c:otherwise>
${model.issueManagement.system}
</c:otherwise>
</c:choose>
</td>
</tr>
</c:if>
<c:if test="${model.ciManagement != null}">
<tr>
<th>Continuous Integration</th>
<td>
<c:choose>
<c:when test="${!empty(model.ciManagement.url)}">
<a href="${model.ciManagement.url}">${model.ciManagement.system}</a>
</c:when>
<c:otherwise>
${model.ciManagement.system}
</c:otherwise>
</c:choose>
</td>
</tr>
</c:if>
</table>
</c:if>
<c:if test="${model.scm != null}">
<h2>SCM</h2>
<table>
<c:if test="${!empty(model.scm.connection)}">
<tr>
<th>Connection</th>
<td>
<code>${model.scm.connection}</code>
</td>
</tr>
</c:if>
<c:if test="${!empty(model.scm.developerConnection)}">
<tr>
<th>Dev. Connection</th>
<td>
<code>${model.scm.developerConnection}</code>
</td>
</tr>
</c:if>
<c:if test="${!empty(model.scm.url)}">
<tr>
<th>Viewer</th>
<td>
<a href="${model.scm.url}">${model.scm.url}</a>
</td>
</tr>
</c:if>
</table>
</c:if>
</div>
</div>
</body>
</html>

View File

@ -30,7 +30,7 @@
padding: 1em;
}
#tabs b {
#tabs strong {
border: 1px solid black;
padding-left: 1em;
padding-right: 1em;

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 B

18
pom.xml
View File

@ -152,27 +152,32 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-repository-metadata</artifactId>
<version>2.0.2</version>
<version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0.2</version>
<version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0.2</version>
<version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact-manager</artifactId>
<version>2.0.2</version>
<version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model-converter</artifactId>
<version>2.0.2</version>
<version>${maven.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
@ -364,4 +369,7 @@
<url>http://snapshots.repository.codehaus.org</url>
</pluginRepository>
</pluginRepositories>
<properties>
<maven.version>2.0.4</maven.version>
</properties>
</project>