]> source.dussan.org Git - archiva.git/commitdiff
[MRM-144] various minor improvements to code
authorBrett Porter <brett@apache.org>
Fri, 1 Sep 2006 01:47:48 +0000 (01:47 +0000)
committerBrett Porter <brett@apache.org>
Fri, 1 Sep 2006 01:47:48 +0000 (01:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@439134 13f79535-47bb-0310-9956-ffa450edef68

13 files changed:
archiva-configuration/src/main/mdo/configuration.mdo
archiva-core/src/main/java/org/apache/maven/archiva/scheduler/IndexerTask.java
archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/AbstractArtifactDiscoverer.java
archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/AbstractDiscoverer.java
archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/ArtifactDiscoverer.java
archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/DefaultMetadataDiscoverer.java
archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/MetadataDiscoverer.java
archiva-discoverer/src/test/java/org/apache/maven/archiva/discovery/DefaultArtifactDiscovererTest.java
archiva-discoverer/src/test/java/org/apache/maven/archiva/discovery/LegacyArtifactDiscovererTest.java
archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteProxiedRepositoryAction.java
archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/proxiedRepositories.jsp
archiva-webapp/src/main/webapp/WEB-INF/jsp/include/quickSearchForm.jspf
archiva-webapp/src/main/webapp/WEB-INF/tags/displayUpdatePolicy.tag [new file with mode: 0644]

index eabc96a6026673b653b93771cf240938e6d754d8..87572e4480d48f029cc07d8c0a731e150a211c3a 100644 (file)
@@ -10,7 +10,6 @@
       <value>org.apache.maven.archiva.configuration</value>
     </default>
   </defaults>
-  <!-- TODO! break out subtypes such as <discovery> and create a list of blacklist -->
   <classes>
     <class rootElement="true" xml.tagName="configuration">
       <name>Configuration</name>
         <field>
           <name>globalBlackListPatterns</name>
           <version>1.0.0</version>
-          <type>String</type>
           <description>Blacklisted patterns in the discovery process</description>
+          <association>
+            <type>String</type>
+            <multiplicity>*</multiplicity>
+          </association>
         </field>
         <field>
           <name>proxy</name>
         <field>
           <name>blackListPatterns</name>
           <version>1.0.0</version>
-          <type>String</type>
           <description>Blacklisted patterns in the discovery process</description>
+          <association>
+            <type>String</type>
+            <multiplicity>*</multiplicity>
+          </association>
         </field>
       </fields>
     </class>
index 4468b2b1d031dd31bd97f3827358a03a43edddea..52487d4f0df76fcbd68cdac4ee863ce69b7df8fd 100644 (file)
@@ -106,8 +106,15 @@ public class IndexerTask
 
                 if ( repositoryConfiguration.isIndexed() )
                 {
-                    // TODO! include global ones
-                    String blacklistedPatterns = repositoryConfiguration.getBlackListPatterns();
+                    List blacklistedPatterns = new ArrayList();
+                    if ( repositoryConfiguration.getBlackListPatterns() != null )
+                    {
+                        blacklistedPatterns.addAll( repositoryConfiguration.getBlackListPatterns() );
+                    }
+                    if ( configuration.getGlobalBlackListPatterns() != null )
+                    {
+                        blacklistedPatterns.addAll( configuration.getGlobalBlackListPatterns() );
+                    }
                     boolean includeSnapshots = repositoryConfiguration.isIncludeSnapshots();
 
                     ArtifactRepository repository = repoFactory.createRepository( repositoryConfiguration );
index 5c184cd7cfe5df4ae6e1eecc95e46b6804795d52..9b3a8b98b0a0890ea001cd27d2a9616d336d3e35 100644 (file)
@@ -46,13 +46,13 @@ public abstract class AbstractArtifactDiscoverer
         "**/*.MD5", "**/*.sha1", "**/*.SHA1", "**/*snapshot-version", "*/website/**", "*/licenses/**", "*/licences/**",
         "**/.htaccess", "**/*.html", "**/*.asc", "**/*.txt", "**/*.xml", "**/README*", "**/CHANGELOG*", "**/KEYS*"};
 
-    private List scanForArtifactPaths( File repositoryBase, String blacklistedPatterns, long comparisonTimestamp )
+    private List scanForArtifactPaths( File repositoryBase, List blacklistedPatterns, long comparisonTimestamp )
     {
         return scanForArtifactPaths( repositoryBase, blacklistedPatterns, null, STANDARD_DISCOVERY_EXCLUDES,
                                      comparisonTimestamp );
     }
 
-    public List discoverArtifacts( ArtifactRepository repository, String operation, String blacklistedPatterns,
+    public List discoverArtifacts( ArtifactRepository repository, String operation, List blacklistedPatterns,
                                    boolean includeSnapshots )
         throws DiscovererException
     {
index 34abf41ebab77018e5a1ca2f51a91c48aae3774c..dc90ef0c0e4cc8d84eac0ae1de49c9d2d2dea382 100644 (file)
@@ -22,7 +22,6 @@ import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
 import org.codehaus.plexus.util.xml.Xpp3DomWriter;
@@ -89,7 +88,7 @@ public abstract class AbstractDiscoverer
         return kickedOutPaths.iterator();
     }
 
-    protected List scanForArtifactPaths( File repositoryBase, String blacklistedPatterns, String[] includes,
+    protected List scanForArtifactPaths( File repositoryBase, List blacklistedPatterns, String[] includes,
                                          String[] excludes, long comparisonTimestamp )
     {
         List allExcludes = new ArrayList();
@@ -98,10 +97,9 @@ public abstract class AbstractDiscoverer
         {
             allExcludes.addAll( Arrays.asList( excludes ) );
         }
-
-        if ( !StringUtils.isEmpty( blacklistedPatterns ) )
+        if ( blacklistedPatterns != null )
         {
-            allExcludes.addAll( Arrays.asList( blacklistedPatterns.split( "," ) ) );
+            allExcludes.addAll( blacklistedPatterns );
         }
 
         DirectoryScanner scanner = new DirectoryScanner();
index b818adb146ce382fbcc5dc1c3c8781715767617a..353a72f6e8db37598be55990736b69eec55106b3 100644 (file)
@@ -47,7 +47,7 @@ public interface ArtifactDiscoverer
      * @return the list of artifacts discovered
      * @throws DiscovererException if there was an unrecoverable problem discovering artifacts or recording progress
      */
-    List discoverArtifacts( ArtifactRepository repository, String operation, String blacklistedPatterns,
+    List discoverArtifacts( ArtifactRepository repository, String operation, List blacklistedPatterns,
                             boolean includeSnapshots )
         throws DiscovererException;
 
index 10ab005b54b35523950a1c34142effe5a7b27b89..7074774b990202f23de3b5cbbc5ca07eea8fcc2a 100644 (file)
@@ -62,7 +62,7 @@ public class DefaultMetadataDiscoverer
      */
     private static final String[] STANDARD_DISCOVERY_INCLUDES = {"**/maven-metadata.xml"};
 
-    public List discoverMetadata( ArtifactRepository repository, String operation, String blacklistedPatterns )
+    public List discoverMetadata( ArtifactRepository repository, String operation, List blacklistedPatterns )
         throws DiscovererException
     {
         if ( !"file".equals( repository.getProtocol() ) )
index 1492c0742e568d69e9e0823464a33feb272f529a..04990808b4633c1e179ae2126bdfb618ae3fe331 100644 (file)
@@ -35,7 +35,8 @@ public interface MetadataDiscoverer
      * @param operation           the operation being performed (used for timestamp comparison)
      * @param blacklistedPatterns Patterns that are to be excluded from the discovery process.
      * @return the list of artifacts found
+     * @throws DiscovererException if there is a problem during the discovery process
      */
-    List discoverMetadata( ArtifactRepository repository, String operation, String blacklistedPatterns )
+    List discoverMetadata( ArtifactRepository repository, String operation, List blacklistedPatterns )
         throws DiscovererException;
 }
index 355cbfbaf272539261409879e6d5cfb763e1cd9a..9c68b02b8665f9411332042ce8892a43c19606da 100644 (file)
@@ -37,6 +37,8 @@ import java.util.Map;
 public class DefaultArtifactDiscovererTest
     extends AbstractArtifactDiscovererTest
 {
+    private static final List JAVAX_BLACKLIST = Collections.singletonList( "javax/**" );
+
     protected String getLayout()
     {
         return "default";
@@ -105,7 +107,7 @@ public class DefaultArtifactDiscovererTest
     public void testBlacklistedExclude()
         throws DiscovererException
     {
-        List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, "javax/**", false );
+        List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, JAVAX_BLACKLIST, false );
         assertNotNull( "Check artifacts not null", artifacts );
         boolean found = false;
         for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
index e622372c003bfe1fc802e9df0b7c173bca9145fd..d514da90a2abe15db4c16e1c06851d40d844f15f 100644 (file)
@@ -21,6 +21,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
 
 import java.io.File;
 import java.net.MalformedURLException;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
@@ -28,11 +29,13 @@ import java.util.List;
  * Test the legacy artifact discoverer.
  *
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
- * @version $Id$
+ * @version $Id:LegacyArtifactDiscovererTest.java 437105 2006-08-26 17:22:22 +1000 (Sat, 26 Aug 2006) brett $
  */
 public class LegacyArtifactDiscovererTest
     extends AbstractArtifactDiscovererTest
 {
+    private static final List JAVAX_SQL_BLACKLIST = Collections.singletonList( "javax.sql/**" );
+
     protected String getLayout()
     {
         return "legacy";
@@ -100,7 +103,7 @@ public class LegacyArtifactDiscovererTest
     public void testBlacklistedExclude()
         throws DiscovererException
     {
-        List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, "javax.sql/**", false );
+        List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, JAVAX_SQL_BLACKLIST, false );
         assertNotNull( "Check artifacts not null", artifacts );
         boolean found = false;
         for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
index 5de9b9afc3f8df01ec28f61310aac6ab229cf9c5..346b42de6aca4f63e08ff96d93d67f096b473af4 100644 (file)
@@ -43,6 +43,6 @@ public class DeleteProxiedRepositoryAction
     protected void removeContents( AbstractRepositoryConfiguration existingRepository )
         throws IOException
     {
-        // TODO!
+        // TODO! delete it
     }
 }
index bf6334059062d81724892a8e926196aeb7eba811..317ee80e0df14cb98ae2bc355a48dbe3204c2e2a 100644 (file)
@@ -16,6 +16,7 @@
 
 <%@ taglib prefix="ww" uri="/webwork" %>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
 
 <html>
 <head>
 <h1>Administration</h1>
 
 <div id="contentArea">
-<h2>Proxied Repositories</h2>
+  <h2>Proxied Repositories</h2>
 
-<ww:set name="proxiedRepositories" value="proxiedRepositories"/>
-<c:if test="${empty(proxiedRepositories)}">
-  <strong>There are no proxied repositories configured yet.</strong>
-</c:if>
-<c:forEach items="${proxiedRepositories}" var="repository" varStatus="i">
-<div>
-<div style="float: right">
-    <%-- TODO replace with icons --%>
-  <a href="<ww:url action="editProxiedRepository" method="input"><ww:param name="repoId" value="%{'${repository.id}'}" /></ww:url>">Edit
-    Repository</a> | <a
-    href="<ww:url action="deleteProxiedRepository" method="input"><ww:param name="repoId" value="%{'${repository.id}'}" /></ww:url>">Delete
-  Repository</a>
-</div>
-<h3>${repository.name}</h3>
-<table>
-  <tr>
-    <th>Identifier</th>
-    <td>
-      <code>${repository.id}</code>
-    </td>
-  </tr>
-  <tr>
-    <th>URL</th>
-    <td><a href="${repository.url}">${repository.url}</a></td>
-  </tr>
-  <tr>
-    <th>Type</th>
-      <%-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this --%>
-    <td>
-      <c:choose>
-        <c:when test="${repository.layout == 'default'}">
-          Maven 2.x Repository
-        </c:when>
-        <c:otherwise>
-          Maven 1.x Repository
-        </c:otherwise>
-      </c:choose>
-    </td>
-  </tr>
-  <tr>
-    <th>Snapshots</th>
-    <td>
-        <%-- TODO! turn into a tag --%>
-      <c:choose>
-        <c:when test="${repository.snapshotsPolicy == 'disabled'}">
-          Disabled
-        </c:when>
-        <c:when test="${repository.snapshotsPolicy == 'always'}">
-          Updated every request
-        </c:when>
-        <c:when test="${repository.snapshotsPolicy == 'hourly'}">
-          Updated hourly
-        </c:when>
-        <c:when test="${repository.snapshotsPolicy == 'daily'}">
-          Updated daily
-        </c:when>
-        <c:when test="${repository.snapshotsPolicy == 'interval'}">
-          Updated every ${repository.snapshotsInterval} minutes
-        </c:when>
-      </c:choose>
-    </td>
-  </tr>
-  <tr>
-    <th>Releases</th>
-    <td>
-        <%-- TODO! turn into a tag --%>
-      <c:choose>
-        <c:when test="${repository.releasesPolicy == 'disabled'}">
-          Disabled
-        </c:when>
-        <c:when test="${repository.releasesPolicy == 'always'}">
-          Updated every request
-        </c:when>
-        <c:when test="${repository.releasesPolicy == 'hourly'}">
-          Updated hourly
-        </c:when>
-        <c:when test="${repository.releasesPolicy == 'daily'}">
-          Updated daily
-        </c:when>
-        <c:when test="${repository.releasesPolicy == 'interval'}">
-          Updated every ${repository.releasesInterval} minutes
-        </c:when>
-      </c:choose>
-    </td>
-  </tr>
-  <tr>
-    <th>Proxied through</th>
-    <td>
-        <%-- TODO: this is the hard way! would be nice if there was a ref in the model so it was directly linked --%>
-        ${repositoriesMap[repository.managedRepository].name}
-      (<code>${repositoriesMap[repository.managedRepository].id}</code>)
-    </td>
-  </tr>
-  <tr>
-    <th>Use HTTP Proxy</th>
-    <td class="${repository.useNetworkProxy ? 'doneMark' : 'errorMark'}"></td>
-  </tr>
-  <tr>
-    <th>Cache Failures</th>
-    <td class="${repository.cacheFailures ? 'doneMark' : 'errorMark'}"></td>
-  </tr>
-  <tr>
-    <th>Fail Whole Group</th>
-    <td class="${repository.hardFail ? 'doneMark' : 'errorMark'}"></td>
-  </tr>
-</table>
-</div>
-</c:forEach>
+  <ww:set name="proxiedRepositories" value="proxiedRepositories"/>
+  <c:if test="${empty(proxiedRepositories)}">
+    <strong>There are no proxied repositories configured yet.</strong>
+  </c:if>
+  <c:forEach items="${proxiedRepositories}" var="repository" varStatus="i">
+    <div>
+      <div style="float: right">
+          <%-- TODO replace with icons --%>
+        <a href="<ww:url action="editProxiedRepository" method="input"><ww:param name="repoId" value="%{'${repository.id}'}" /></ww:url>">Edit
+          Repository</a> | <a
+          href="<ww:url action="deleteProxiedRepository" method="input"><ww:param name="repoId" value="%{'${repository.id}'}" /></ww:url>">Delete
+        Repository</a>
+      </div>
+      <h3>${repository.name}</h3>
+      <table>
+        <tr>
+          <th>Identifier</th>
+          <td>
+            <code>${repository.id}</code>
+          </td>
+        </tr>
+        <tr>
+          <th>URL</th>
+          <td><a href="${repository.url}">${repository.url}</a></td>
+        </tr>
+        <tr>
+          <th>Type</th>
+            <%-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this --%>
+          <td>
+            <c:choose>
+              <c:when test="${repository.layout == 'default'}">
+                Maven 2.x Repository
+              </c:when>
+              <c:otherwise>
+                Maven 1.x Repository
+              </c:otherwise>
+            </c:choose>
+          </td>
+        </tr>
+        <tr>
+          <th>Snapshots</th>
+          <td>
+            <my:displayUpdatePolicy policy="${repository.snapshotsPolicy}" interval="${repository.snapshotsInterval}"/>
+          </td>
+        </tr>
+        <tr>
+          <th>Releases</th>
+          <td>
+            <my:displayUpdatePolicy policy="${repository.releasesPolicy}" interval="${repository.releasesInterval}"/>
+          </td>
+        </tr>
+        <tr>
+          <th>Proxied through</th>
+          <td>
+              <%-- TODO: this is the hard way! would be nice if there was a ref in the model so it was directly linked --%>
+              ${repositoriesMap[repository.managedRepository].name}
+            (<code>${repositoriesMap[repository.managedRepository].id}</code>)
+          </td>
+        </tr>
+        <tr>
+          <th>Use HTTP Proxy</th>
+          <td class="${repository.useNetworkProxy ? 'doneMark' : 'errorMark'}"></td>
+        </tr>
+        <tr>
+          <th>Cache Failures</th>
+          <td class="${repository.cacheFailures ? 'doneMark' : 'errorMark'}"></td>
+        </tr>
+        <tr>
+          <th>Fail Whole Group</th>
+          <td class="${repository.hardFail ? 'doneMark' : 'errorMark'}"></td>
+        </tr>
+      </table>
+    </div>
+  </c:forEach>
 
-<p>
-  <a href="<ww:url action="addProxiedRepository" method="input" />">Add Repository</a>
-</p>
+  <p>
+    <a href="<ww:url action="addProxiedRepository" method="input" />">Add Repository</a>
+  </p>
 </div>
 
 </body>
index 51495fa49c6020d69b31f53f6f49aa951310e812..a4d8318fc557748ec95de3d7b3e2b2e14fd2007f 100644 (file)
@@ -16,7 +16,7 @@
   --%>
 
 <div id="searchBox">
-  <ww:form method="post" action="quickSearch" validate="true">
+  <ww:form method="get" action="quickSearch" validate="true">
     <ww:textfield label="Search for" size="50" name="q"/>
     <ww:submit label="Go!"/>
   </ww:form>
diff --git a/archiva-webapp/src/main/webapp/WEB-INF/tags/displayUpdatePolicy.tag b/archiva-webapp/src/main/webapp/WEB-INF/tags/displayUpdatePolicy.tag
new file mode 100644 (file)
index 0000000..e69f526
--- /dev/null
@@ -0,0 +1,38 @@
+<%--
+  ~ 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.
+  --%>
+
+<%-- TODO: this could perhaps just be a i18n call --%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ attribute name="policy" required="true" %>
+<%@ attribute name="interval" %>
+
+<c:choose>
+  <c:when test="${policy == 'disabled'}">
+    Disabled
+  </c:when>
+  <c:when test="${policy == 'always'}">
+    Updated every request
+  </c:when>
+  <c:when test="${policy == 'hourly'}">
+    Updated hourly
+  </c:when>
+  <c:when test="${policy == 'daily'}">
+    Updated daily
+  </c:when>
+  <c:when test="${policy == 'interval'}">
+    Updated every ${interval} minutes
+  </c:when>
+</c:choose>
\ No newline at end of file