* Adding distinction between repo.id and repo.urlName.

* Adding copy-paste block for repositories.
* Adding copy-paste block for dependency.
* Adding webdav url link in repository config.



git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@468167 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joakim Erdfelt 2006-10-26 22:04:46 +00:00
parent 90da8e7205
commit 188548089d
8 changed files with 116 additions and 8 deletions

View File

@ -20,6 +20,7 @@ import org.apache.maven.archiva.configuration.io.xpp3.ConfigurationXpp3Reader;
import org.apache.maven.archiva.configuration.io.xpp3.ConfigurationXpp3Writer;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
@ -99,6 +100,7 @@ public class DefaultConfigurationStore
try
{
configuration = reader.read( fileReader, false );
sanitizeConfiguration( configuration );
}
catch ( IOException e )
{
@ -116,6 +118,27 @@ public class DefaultConfigurationStore
return configuration;
}
/**
* Perform any Upgrades and Adjustments needed to bring configuration up to the
* current configuration format.
*
* @param config the configuration to upgrade and adjust.
*/
private void sanitizeConfiguration( Configuration config )
{
Iterator it = config.getRepositories().iterator();
while ( it.hasNext() )
{
RepositoryConfiguration repo = (RepositoryConfiguration) it.next();
// Ensure that the repo.urlName is set.
if ( StringUtils.isEmpty( repo.getUrlName() ) )
{
repo.setUrlName( repo.getId() );
}
}
}
public void storeConfiguration( Configuration configuration )
throws ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException
{

View File

@ -114,6 +114,19 @@
return valid;
}
public RepositoryConfiguration getRepositoryByUrlName( String urlName )
{
for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )
{
RepositoryConfiguration repository = (RepositoryConfiguration) i.next();
if ( repository.getUrlName().equals( urlName ) )
{
return repository;
}
}
return null;
}
public RepositoryConfiguration getRepositoryById( String id )
{
for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )
@ -256,6 +269,16 @@
<name>RepositoryConfiguration</name>
<version>1.0.0</version>
<fields>
<field>
<name>urlName</name>
<version>1.0.0</version>
<type>String</type>
<required>true</required>
<description>
The URL name for this repository.
Used to create the WebDAV URL for the repository such like - http://hostname.com/repository/${urlName}/
</description>
</field>
<field>
<name>directory</name>
<version>1.0.0</version>

View File

@ -88,7 +88,7 @@ public class RepositoryAccess
public class RequestPath
{
String repoId;
String repoName;
String path;
}
@ -125,11 +125,11 @@ public class RepositoryAccess
return;
}
RepositoryConfiguration repoconfig = config.getRepositoryById( reqpath.repoId );
RepositoryConfiguration repoconfig = config.getRepositoryByUrlName( reqpath.repoName );
if ( repoconfig == null )
{
routeToErrorPage( response, "Invalid Repository ID." );
routeToErrorPage( response, "Invalid Repository URL." );
return;
}
@ -247,7 +247,7 @@ public class RepositoryAccess
// Find the first 'path' of the pathInfo.
// Default: "/pathid" -> "pathid"
ret.repoId = requestPathInfo.substring( 1 );
ret.repoName = requestPathInfo.substring( 1 );
ret.path = "/";
// Find first element, if slash exists.
@ -255,7 +255,7 @@ public class RepositoryAccess
if ( slash > 0 )
{
// Filtered: "/central/org/apache/maven/" -> "central"
ret.repoId = requestPathInfo.substring( 1, slash );
ret.repoName = requestPathInfo.substring( 1, slash );
String repoPath = requestPathInfo.substring( slash );

View File

@ -16,6 +16,7 @@
<%@ taglib prefix="ww" uri="/webwork" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<ww:textfield name="urlName" label="URL Name" size="50" required="true"/>
<ww:textfield name="name" label="Name" size="50" required="true" />
<ww:textfield name="directory" label="Directory" size="100" required="true"/>
<ww:select list="#@java.util.LinkedHashMap@{'default' : 'Maven 2.x Repository', 'legacy' : 'Maven 1.x Repository'}"

View File

@ -79,6 +79,8 @@
</table>
</c:if>
<c:set var="urlbase">${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}/repository/</c:set>
<div>
<div style="float: right">
<%-- TODO replace with icons --%>
@ -119,6 +121,10 @@
<th>Directory</th>
<td>${repository.directory}</td>
</tr>
<tr>
<th>WebDAV URL</th>
<td><a href="${urlbase}${repository.urlName}">${urlbase}${repository.urlName}</a></td>
</tr>
<tr>
<th>Type</th>
<%-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this --%>
@ -135,11 +141,42 @@
</tr>
<tr>
<th>Snapshots Included</th>
<td class="${repository.includeSnapshots ? 'doneMark' : 'errorMark'}"></td>
<td class="${repository.includeSnapshots ? 'doneMark' : 'errorMark'} booleanIcon"> ${repository.includeSnapshots}</td>
</tr>
<tr>
<th>Indexed</th>
<td class="${repository.indexed ? 'doneMark' : 'errorMark'}"></td>
<td class="${repository.indexed ? 'doneMark' : 'errorMark'} booleanIcon"> ${repository.indexed}</td>
</tr>
<tr>
<th>POM Snippet</th>
<td>
<pre class="pom">
&lt;project>
...
&lt;distributionManagement>
&lt;${repository.includeSnapshots ? 'snapshotRepository' : 'repository'}>
&lt;id>${repository.id}&lt;/id>
&lt;url>dav:${urlbase}${repository.urlName}&lt;/url>
&lt;/${repository.includeSnapshots ? 'snapshotRepository' : 'repository'}>
&lt;/distributionManagement>
&lt;repositories>
&lt;repository>
&lt;id>${repository.id}&lt;/id>
&lt;name>${repository.name}&lt;/name>
&lt;url>${urlbase}${repository.urlName}&lt;/url>
&lt;releases>
&lt;enabled>${repository.includeSnapshots ? 'false' : 'true'}&lt;/enabled>
&lt;/releases>
&lt;snapshots>
&lt;enabled>${repository.includeSnapshots ? 'true' : 'false'}&lt;/enabled>
&lt;/snapshots>
&lt;/repository>
&lt;/repositories>
...
&lt;/project>
</pre>
</td>
</tr>
</table>
</div>

View File

@ -99,6 +99,18 @@
--%>
</table>
<c:if test="${model.packaging != 'pom'}">
<h2>POM Dependency Snippet</h2>
<pre class="pom">
&lt;dependency>
&lt;groupId>${model.groupId}&lt;/groupId>
&lt;artifactId>${model.artifactId}&lt;/artifactId>
&lt;version>${model.version}&lt;/version><c:if test="${model.packaging != 'jar'}">
&lt;type>${model.packaging}&lt;/type></c:if>
&lt;/dependency>
</pre>
</c:if>
<c:if test="${!empty(model.url) || model.organization != null || !empty(model.licenses)
|| model.issueManagement != null || model.ciManagement != null}">

View File

@ -170,6 +170,18 @@ dt {
background-image: url( ../images/icon_info_sml.gif );
}
.booleanIcon {
padding-left: 20px;
height: 20px;
}
pre.pom {
font-size: 0.9em;
border: 1px solid #ddddff;
background-color: #f8f8ff;
padding: 5px;
}
#leftColumn {
padding: 4px 4px 4px 4px;
overflow: hidden;

View File

@ -44,7 +44,7 @@ public class RepositoryAccessTest
assertNotNull( requestPath );
assertEquals( expectedId, requestPath.repoId );
assertEquals( expectedId, requestPath.repoName );
assertEquals( expectedPath, requestPath.path );
}