Author: brett Date: Thu Jul 20 01:38:56 2006 New Revision: 423825 URL: http://svn.apache.org/viewvc?rev=423825&view=rev Log: cleanup the checksum search
Added: maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SearchAction.java (contents, props changed) - copied, changed from r423734, maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/QuickSearchAction.java maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/SearchAction-checksumSearch-validation.xml (with props) maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/SearchAction-quickSearch-validation.xml (contents, props changed) - copied, changed from r423462, maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/QuickSearchAction-validation.xml maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/findArtifact.jsp (with props) Removed: maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/QuickSearchAction.java maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/QuickSearchAction-validation.xml Modified: maven/repository-manager/trunk/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/xwork.xml maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/quickSearch.jsp Modified: maven/repository-manager/trunk/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java?rev=423825&r1=423824&r2=423825&view=diff ============================================================================== --- maven/repository-manager/trunk/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java (original) +++ maven/repository-manager/trunk/maven-repository-artifact-applet/src/main/java/org/apache/maven/repository/applet/ChecksumApplet.java Thu Jul 20 01:38:56 2006 @@ -21,6 +21,7 @@ import java.awt.*; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.security.AccessController; @@ -65,28 +66,19 @@ } catch ( NoSuchAlgorithmException e ) { - return e; + return "Error checksumming file: " + e.getMessage(); + } + catch ( FileNotFoundException e ) + { + return "Couldn't find the file. " + e.getMessage(); } catch ( IOException e ) { - return e; + return "Error reading file: " + e.getMessage(); } } } ); - - //noinspection ChainOfInstanceofChecks - if ( o instanceof IOException ) - { - throw (IOException) o; - } - else if ( o instanceof NoSuchAlgorithmException ) - { - throw (NoSuchAlgorithmException) o; - } - else - { - return (String) o; - } + return (String) o; } protected String checksumFile( String file ) Copied: maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SearchAction.java (from r423734, maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/QuickSearchAction.java) URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SearchAction.java?p2=maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SearchAction.java&p1=maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/QuickSearchAction.java&r1=423734&r2=423825&rev=423825&view=diff ============================================================================== --- maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/QuickSearchAction.java (original) +++ maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SearchAction.java Thu Jul 20 01:38:56 2006 @@ -27,6 +27,7 @@ import org.apache.maven.repository.indexing.RepositoryIndexSearchException; import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer; import org.apache.maven.repository.indexing.RepositoryIndexingFactory; +import org.apache.maven.repository.indexing.query.SinglePhraseQuery; import java.io.File; import java.net.MalformedURLException; @@ -36,9 +37,9 @@ /** * Searches for searchString in all indexed fields. * - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="quickSearchAction" + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="searchAction" */ -public class QuickSearchAction +public class SearchAction extends ActionSupport { /** @@ -47,6 +48,11 @@ private String q; /** + * The MD5 to search by. + */ + private String md5; + + /** * Search results. */ private List searchResults; @@ -76,7 +82,7 @@ */ private ConfigurationStore configurationStore; - public String execute() + public String quickSearch() throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException, ConfigurationStoreException { @@ -84,12 +90,27 @@ assert q != null && q.length() != 0; - Configuration configuration = configurationStore.getConfigurationFromStore(); - File indexPath = new File( configuration.getIndexPath() ); + ArtifactRepositoryIndex index = getIndex(); - ArtifactRepository repository = repositoryFactory.createRepository( configuration ); + if ( !index.indexExists() ) + { + addActionError( "The repository is not yet indexed. Please wait, and then try again." ); + return ERROR; + } - ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository ); + searchResults = searchLayer.searchGeneral( q, index ); + + return SUCCESS; + } + + public String findArtifact() + throws ConfigurationStoreException, RepositoryIndexException, RepositoryIndexSearchException + { + // TODO: give action message if indexing is in progress + + assert md5 != null && md5.length() != 0; + + ArtifactRepositoryIndex index = getIndex(); if ( !index.indexExists() ) { @@ -97,11 +118,22 @@ return ERROR; } - searchResults = searchLayer.searchGeneral( q, index ); + searchResults = searchLayer.searchAdvanced( new SinglePhraseQuery( "md5", md5 ), index ); return SUCCESS; } + 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 String doInput() { return INPUT; @@ -115,6 +147,16 @@ public void setQ( String q ) { this.q = q; + } + + public String getMd5() + { + return md5; + } + + public void setMd5( String md5 ) + { + this.md5 = md5; } public List getSearchResults() Propchange: maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SearchAction.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/repository-manager/trunk/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SearchAction.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/SearchAction-checksumSearch-validation.xml URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/SearchAction-checksumSearch-validation.xml?rev=423825&view=auto ============================================================================== --- maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/SearchAction-checksumSearch-validation.xml (added) +++ maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/SearchAction-checksumSearch-validation.xml Thu Jul 20 01:38:56 2006 @@ -0,0 +1,29 @@ +<!-- + ~ 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. + --> + +<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> + +<validators> + <field name="md5"> + <field-validator type="requiredstring"> + <message> + You must select a file, or enter the checksum. If the file was given and you receive this message, + there may have been an error generating the checksum. + </message> + </field-validator> + </field> +</validators> \ No newline at end of file Propchange: maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/SearchAction-checksumSearch-validation.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/SearchAction-checksumSearch-validation.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/SearchAction-quickSearch-validation.xml (from r423462, maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/QuickSearchAction-validation.xml) URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/SearchAction-quickSearch-validation.xml?p2=maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/SearchAction-quickSearch-validation.xml&p1=maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/QuickSearchAction-validation.xml&r1=423462&r2=423825&rev=423825&view=diff ============================================================================== (empty) Propchange: maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/SearchAction-quickSearch-validation.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/SearchAction-quickSearch-validation.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/xwork.xml URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/xwork.xml?rev=423825&r1=423824&r2=423825&view=diff ============================================================================== --- maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/xwork.xml (original) +++ maven/repository-manager/trunk/maven-repository-webapp/src/main/resources/xwork.xml Thu Jul 20 01:38:56 2006 @@ -41,14 +41,24 @@ <result name="config-needed" type="redirect">/admin/configure.action</result> </global-results> - <action name="index" class="quickSearchAction" method="input"> + <action name="index" class="searchAction" method="input"> <result name="input">/WEB-INF/jsp/quickSearch.jsp</result> </action> - <action name="quickSearch" class="quickSearchAction"> + <action name="quickSearch" class="searchAction" method="quickSearch"> <result name="input">/WEB-INF/jsp/quickSearch.jsp</result> <result>/WEB-INF/jsp/results.jsp</result> <result name="error">/WEB-INF/jsp/quickSearch.jsp</result> + </action> + + <action name="findArtifact" class="searchAction" method="input"> + <result name="input">/WEB-INF/jsp/findArtifact.jsp</result> + </action> + + <action name="checksumSearch" class="searchAction" method="findArtifact"> + <result name="input">/WEB-INF/jsp/findArtifact.jsp</result> + <result>/WEB-INF/jsp/results.jsp</result> + <result name="error">/WEB-INF/jsp/findArtifact.jsp</result> </action> <!-- TODO! old actions Modified: maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp?rev=423825&r1=423824&r2=423825&view=diff ============================================================================== --- maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp (original) +++ maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp Thu Jul 20 01:38:56 2006 @@ -31,7 +31,7 @@ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> </head> -<body class="composite"> +<body onload="<decorator:getProperty property="body.onload" />" class="composite"> <div id="banner"> <span id="bannerLeft"> <img src="http://www.apache.org/images/asf_logo_wide.gif" alt="" width="537" height="51" /> @@ -71,11 +71,11 @@ <my:currentWWUrl action="index" namespace="/">Search</my:currentWWUrl> </li> - <%-- TODO - <li class="none"> - <a href="#">Find Artifact</a> - </li> + <li class="none"> + <my:currentWWUrl action="findArtifact" namespace="/">Find Artifact</my:currentWWUrl> + </li> + <%-- TODO <li class="none"> <a href="#">Browse</a> </li> Added: maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/findArtifact.jsp URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/findArtifact.jsp?rev=423825&view=auto ============================================================================== --- maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/findArtifact.jsp (added) +++ maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/findArtifact.jsp Thu Jul 20 01:38:56 2006 @@ -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" %> + +<html> +<head> + <title>Find Artifact</title> + <ww:head /> +</head> + +<body onload="document.checksumSearch.file.disabled = false"> + +<h1>Find Artifact</h1> + +<div id="contentArea"> + <div id="searchBox"> + <script type="text/javascript"> + function generateMd5( file, defVal ) + { + if ( file ) + { + var s = document.ChecksumApplet.generateMd5(file); + // If there is a space, it's an error message, not a checksum + if ( s.indexOf(" ") >= 0 ) + { + alert(s); + return ""; + } + else + return s; + } + return defVal; + } + </script> + + <noscript> + <span class="errorMessage">JavaScript is disabled: using the file browser will not work.</span> + </noscript> + + <ww:form method="POST" action="checksumSearch" namespace="/" + onsubmit="this.md5.value = generateMd5(this.file.value,this.md5.value); this.file.disabled = true"> + <tr> + <td class="tdLabel"><label for="checksumSearch_file" class="label">Search for:</label></td> + <td> + <input type="file" name="file" size="50" value="" id="checksumSearch_file" /> + </td> + </tr> + <ww:textfield label="Checksum" size="50" name="md5" /> + <ww:submit value="Go!" /> + </ww:form> + + <p> + Select the file you would like to locate in the remote repository. + The entire file will + <b>not</b> + be uploaded to the server. See the progress bar below for progress of + locally creating a checksum that is uploaded to the server after you hit "Go!". + <ww:actionerror /> + </p> + + <p> + <applet code="org/apache/maven/repository/applet/ChecksumApplet.class" + archive="maven-repository-artifact-applet.jar" + width="400" height="20" name="ChecksumApplet"> + </applet> + </p> + + </div> +</div> + +</body> +</html> \ No newline at end of file Propchange: maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/findArtifact.jsp ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/findArtifact.jsp ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/quickSearch.jsp URL: http://svn.apache.org/viewvc/maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/quickSearch.jsp?rev=423825&r1=423824&r2=423825&view=diff ============================================================================== --- maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/quickSearch.jsp (original) +++ maven/repository-manager/trunk/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/quickSearch.jsp Thu Jul 20 01:38:56 2006 @@ -1,4 +1,3 @@ -<%@ taglib prefix="ww" uri="/webwork" %> <%-- ~ Copyright 2005-2006 The Apache Software Foundation. ~ @@ -15,6 +14,7 @@ ~ limitations under the License. --%> +<%@ taglib prefix="ww" uri="/webwork" %> <html> <head> <title>Quick Search</title>