]> source.dussan.org Git - archiva.git/commitdiff
* Adding distinction between repo.id and repo.urlName.
authorJoakim Erdfelt <joakime@apache.org>
Thu, 26 Oct 2006 22:04:46 +0000 (22:04 +0000)
committerJoakim Erdfelt <joakime@apache.org>
Thu, 26 Oct 2006 22:04:46 +0000 (22:04 +0000)
* 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

archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultConfigurationStore.java
archiva-configuration/src/main/mdo/configuration.mdo
archiva-webapp/src/main/java/org/apache/maven/archiva/web/servlet/repository/RepositoryAccess.java
archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf
archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/index.jsp
archiva-webapp/src/main/webapp/WEB-INF/jsp/include/artifactInfo.jspf
archiva-webapp/src/main/webapp/css/maven-theme.css
archiva-webapp/src/test/java/org/apache/maven/archiva/web/servlet/repository/RepositoryAccessTest.java

index 7a31d64d83c1c80e9c71672caa45cf725712f71f..759e635e8f89717fcd08af0659177c7604718341 100644 (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
     {
index 9fd0424271e093de27fbe80dcd92e316b4e7bbae..2b501d6c3509a2511a2c570082438543b8ecb6aa 100644 (file)
         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>
index 3970478f088c75c1324e5202f7867e2abdfcf1d1..3ae46df9cfe4ff0670390086808ac7a5edca43fc 100644 (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 );
 
index 3bcf34061af102b3569ac3775be9974c2afdfd91..220257acf7421f85612ccab96706902ce6dafe2b 100644 (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'}"
index 3e82d910a75e783f08f2024a952d1274dfbf271d..b9fe197be8959f028e5aa924404b4c511723c1f9 100644 (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 --%>
         <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">
+&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>
index d2ce2cad124819487cf000ac3976dd222e33edb7..fe3af8982c99505f2c6b58c84daa607202208cf7 100644 (file)
   --%>
 </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}">
 
index 8f1d8fc4befe2ba7bbdc542e29543a0d44b19b37..6823a115a10c872080439dbf5eb121c88a190aa6 100644 (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;
index 124bca8df142d42f125494c76abd8cf5eaefeb51..a9b73fda03c054d34df0a3ea4ce0dc8ba62bdcf7 100644 (file)
@@ -44,7 +44,7 @@ public class RepositoryAccessTest
 
         assertNotNull( requestPath );
 
-        assertEquals( expectedId, requestPath.repoId );
+        assertEquals( expectedId, requestPath.repoName );
         assertEquals( expectedPath, requestPath.path );
     }