mirror of https://github.com/apache/archiva.git
fixes to the xwork integration
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@419521 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5d2ddbae67
commit
39a41a4b29
|
@ -42,6 +42,11 @@
|
|||
<artifactId>plexus-xwork-integration</artifactId>
|
||||
<version>1.0-alpha-2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
<version>1.0-alpha-10-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.repository</groupId>
|
||||
<artifactId>maven-repository-indexer</artifactId>
|
||||
|
@ -123,6 +128,14 @@
|
|||
</instrumentation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<fileName>plexus-request.xml</fileName>
|
||||
<containerDescriptor>true</containerDescriptor>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.apache.maven.repository.manager.web.execution.DiscovererExecution;
|
|||
import org.apache.maven.repository.manager.web.job.DiscovererScheduler;
|
||||
import org.apache.maven.repository.manager.web.utils.ConfigurationManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -31,7 +30,7 @@ import java.util.Map;
|
|||
* This is the Action class of index.jsp, which is the initial page of the web application.
|
||||
* It invokes the DiscovererScheduler to set the DiscoverJob in the scheduler.
|
||||
*
|
||||
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.BaseAction"
|
||||
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="baseAction"
|
||||
*/
|
||||
public class BaseAction
|
||||
extends ActionSupport
|
||||
|
@ -83,7 +82,7 @@ public class BaseAction
|
|||
this.parameters = parameters;
|
||||
|
||||
//Configuration configuration = new Configuration(); // TODO!
|
||||
execution.executeDiscovererIfIndexDoesNotExist( new File( config.getIndexPath() ) );
|
||||
// execution.executeDiscovererIfIndexDoesNotExist( new File( config.getIndexPath() ) );
|
||||
discovererScheduler.setSchedule( config.getDiscoveryCronExpression() );
|
||||
}
|
||||
catch ( Exception e )
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
package org.apache.maven.repository.manager.web.action;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import com.opensymphony.xwork.Action;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.repository.configuration.Configuration;
|
||||
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
|
||||
import org.apache.maven.repository.indexing.RepositoryIndexException;
|
||||
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
|
||||
import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;
|
||||
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Searches for searchString in all indexed fields.
|
||||
*
|
||||
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="quickSearchAction"
|
||||
*/
|
||||
public class QuickSearchAction
|
||||
implements Action
|
||||
{
|
||||
/**
|
||||
* Query string.
|
||||
*/
|
||||
private String q;
|
||||
|
||||
/**
|
||||
* Search results.
|
||||
*/
|
||||
private List searchResult;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private RepositoryIndexingFactory factory;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private RepositoryIndexSearchLayer searchLayer;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArtifactRepositoryFactory repositoryFactory;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
|
||||
*/
|
||||
private Map repositoryLayouts;
|
||||
|
||||
public String execute()
|
||||
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException
|
||||
{
|
||||
if ( q != null && q.length() != 0 )
|
||||
{
|
||||
Configuration configuration = new Configuration(); // TODO!
|
||||
File indexPath = new File( configuration.getIndexPath() );
|
||||
|
||||
// TODO: [!] repository should only have been instantiated once
|
||||
File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
|
||||
String repoDir = repositoryDirectory.toURL().toString();
|
||||
|
||||
ArtifactRepositoryLayout layout =
|
||||
(ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
|
||||
ArtifactRepository repository =
|
||||
repositoryFactory.createArtifactRepository( "test", repoDir, layout, null, null );
|
||||
|
||||
ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );
|
||||
|
||||
searchResult = searchLayer.searchGeneral( q, index );
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
public String getQ()
|
||||
{
|
||||
return q;
|
||||
}
|
||||
|
||||
public void setQ( String q )
|
||||
{
|
||||
this.q = q;
|
||||
}
|
||||
|
||||
public List getSearchResult()
|
||||
{
|
||||
return searchResult;
|
||||
}
|
||||
|
||||
}
|
|
@ -134,6 +134,8 @@ public class ConfigurationManager
|
|||
File file = getConfigFile();
|
||||
config = new Configuration();
|
||||
|
||||
if ( file != null )
|
||||
{
|
||||
if ( !file.exists() )
|
||||
{
|
||||
writeXmlDocument( getConfigFile() );
|
||||
|
@ -150,6 +152,7 @@ public class ConfigurationManager
|
|||
xe.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
@ -202,12 +205,15 @@ public class ConfigurationManager
|
|||
else
|
||||
{
|
||||
URL xmlPath = getClass().getClassLoader().getResource( "../" + WEB_XML_FILE );
|
||||
if ( xmlPath != null )
|
||||
{
|
||||
String path = xmlPath.getFile();
|
||||
int lastIndex = path.lastIndexOf( '/' );
|
||||
path = path.substring( 0, lastIndex + 1 );
|
||||
path = path + INDEX_CONFIG_FILE;
|
||||
plexusDescriptor = new File( path );
|
||||
}
|
||||
}
|
||||
|
||||
return plexusDescriptor;
|
||||
}
|
||||
|
|
|
@ -26,11 +26,22 @@
|
|||
<!-- Default interceptor stack. -->
|
||||
<default-interceptor-ref name="defaultStack"/>
|
||||
|
||||
<!-- Action: Front page -->
|
||||
<action name="index" class="baseAction">
|
||||
<result name="success" type="dispatcher">/WEB-INF/jsp/quickSearch.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="quickSearch" class="quickSearchAction">
|
||||
<result name="success" type="dispatcher">/WEB-INF/jsp/results.jsp</result>
|
||||
<result name="error" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
|
||||
</action>
|
||||
|
||||
<!-- TODO! old actions -->
|
||||
<!--
|
||||
<action name="index" class="org.apache.maven.repository.manager.web.action.BaseAction">
|
||||
<result name="success" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
|
||||
<result name="error" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
|
||||
</action>
|
||||
-->
|
||||
|
||||
<action name="searchg" class="org.apache.maven.repository.manager.web.action.GeneralSearchAction">
|
||||
<result name="success" type="dispatcher">/WEB-INF/jsp/generalresults.jsp</result>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<%@ taglib prefix="ww" uri="/webwork" %>
|
||||
<%--
|
||||
~ 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.
|
||||
--%>
|
||||
|
||||
<html>
|
||||
<head><title>Quick Search</title></head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>Search</h1>
|
||||
|
||||
<div id="contentArea">
|
||||
<div id="searchBox">
|
||||
<ww:form action="quickSearch.action">
|
||||
<ww:textfield size="50" name="q" />
|
||||
<ww:submit label="Go!" />
|
||||
</ww:form>
|
||||
<p>
|
||||
Enter your search terms. A variety of data will be searched for your keywords.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
8
pom.xml
8
pom.xml
|
@ -80,6 +80,7 @@
|
|||
<plugin>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-maven-plugin</artifactId>
|
||||
<version>1.3-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
@ -346,4 +347,11 @@
|
|||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
<!-- TODO: remove, required only for plexus maven plugin -->
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>codehaus.snapshots</id>
|
||||
<url>http://snapshots.repository.codehaus.org</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue