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;
try
{
configuration = reader.read( fileReader, false );
+ sanitizeConfiguration( configuration );
}
catch ( IOException e )
{
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
{
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(); )
<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>
public class RequestPath
{
- String repoId;
+ String repoName;
String path;
}
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;
}
// 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.
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 );
<%@ 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'}"
</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 --%>
<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 --%>
</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">
+<project>
+ ...
+ <distributionManagement>
+ <${repository.includeSnapshots ? 'snapshotRepository' : 'repository'}>
+ <id>${repository.id}</id>
+ <url>dav:${urlbase}${repository.urlName}</url>
+ </${repository.includeSnapshots ? 'snapshotRepository' : 'repository'}>
+ </distributionManagement>
+
+ <repositories>
+ <repository>
+ <id>${repository.id}</id>
+ <name>${repository.name}</name>
+ <url>${urlbase}${repository.urlName}</url>
+ <releases>
+ <enabled>${repository.includeSnapshots ? 'false' : 'true'}</enabled>
+ </releases>
+ <snapshots>
+ <enabled>${repository.includeSnapshots ? 'true' : 'false'}</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ ...
+</project>
+</pre>
+ </td>
</tr>
</table>
</div>
--%>
</table>
+<c:if test="${model.packaging != 'pom'}">
+<h2>POM Dependency Snippet</h2>
+<pre class="pom">
+ <dependency>
+ <groupId>${model.groupId}</groupId>
+ <artifactId>${model.artifactId}</artifactId>
+ <version>${model.version}</version><c:if test="${model.packaging != 'jar'}">
+ <type>${model.packaging}</type></c:if>
+ </dependency>
+</pre>
+</c:if>
+
<c:if test="${!empty(model.url) || model.organization != null || !empty(model.licenses)
|| model.issueManagement != null || model.ciManagement != null}">
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;
assertNotNull( requestPath );
- assertEquals( expectedId, requestPath.repoId );
+ assertEquals( expectedId, requestPath.repoName );
assertEquals( expectedPath, requestPath.path );
}