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>
|
<artifactId>plexus-xwork-integration</artifactId>
|
||||||
<version>1.0-alpha-2-SNAPSHOT</version>
|
<version>1.0-alpha-2-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
<artifactId>plexus-container-default</artifactId>
|
||||||
|
<version>1.0-alpha-10-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.repository</groupId>
|
<groupId>org.apache.maven.repository</groupId>
|
||||||
<artifactId>maven-repository-indexer</artifactId>
|
<artifactId>maven-repository-indexer</artifactId>
|
||||||
|
@ -123,6 +128,14 @@
|
||||||
</instrumentation>
|
</instrumentation>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
<artifactId>plexus-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<fileName>plexus-request.xml</fileName>
|
||||||
|
<containerDescriptor>true</containerDescriptor>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<repositories>
|
<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.job.DiscovererScheduler;
|
||||||
import org.apache.maven.repository.manager.web.utils.ConfigurationManager;
|
import org.apache.maven.repository.manager.web.utils.ConfigurationManager;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
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.
|
* 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.
|
* 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
|
public class BaseAction
|
||||||
extends ActionSupport
|
extends ActionSupport
|
||||||
|
@ -83,7 +82,7 @@ public class BaseAction
|
||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
|
|
||||||
//Configuration configuration = new Configuration(); // TODO!
|
//Configuration configuration = new Configuration(); // TODO!
|
||||||
execution.executeDiscovererIfIndexDoesNotExist( new File( config.getIndexPath() ) );
|
// execution.executeDiscovererIfIndexDoesNotExist( new File( config.getIndexPath() ) );
|
||||||
discovererScheduler.setSchedule( config.getDiscoveryCronExpression() );
|
discovererScheduler.setSchedule( config.getDiscoveryCronExpression() );
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
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,20 +134,23 @@ public class ConfigurationManager
|
||||||
File file = getConfigFile();
|
File file = getConfigFile();
|
||||||
config = new Configuration();
|
config = new Configuration();
|
||||||
|
|
||||||
if ( !file.exists() )
|
if ( file != null )
|
||||||
{
|
{
|
||||||
writeXmlDocument( getConfigFile() );
|
if ( !file.exists() )
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
config = readXmlDocument( file );
|
writeXmlDocument( getConfigFile() );
|
||||||
}
|
}
|
||||||
catch ( XmlPullParserException xe )
|
else
|
||||||
{
|
{
|
||||||
// TODO: fix error handling!
|
try
|
||||||
xe.printStackTrace();
|
{
|
||||||
|
config = readXmlDocument( file );
|
||||||
|
}
|
||||||
|
catch ( XmlPullParserException xe )
|
||||||
|
{
|
||||||
|
// TODO: fix error handling!
|
||||||
|
xe.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,11 +205,14 @@ public class ConfigurationManager
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
URL xmlPath = getClass().getClassLoader().getResource( "../" + WEB_XML_FILE );
|
URL xmlPath = getClass().getClassLoader().getResource( "../" + WEB_XML_FILE );
|
||||||
String path = xmlPath.getFile();
|
if ( xmlPath != null )
|
||||||
int lastIndex = path.lastIndexOf( '/' );
|
{
|
||||||
path = path.substring( 0, lastIndex + 1 );
|
String path = xmlPath.getFile();
|
||||||
path = path + INDEX_CONFIG_FILE;
|
int lastIndex = path.lastIndexOf( '/' );
|
||||||
plexusDescriptor = new File( path );
|
path = path.substring( 0, lastIndex + 1 );
|
||||||
|
path = path + INDEX_CONFIG_FILE;
|
||||||
|
plexusDescriptor = new File( path );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return plexusDescriptor;
|
return plexusDescriptor;
|
||||||
|
|
|
@ -26,12 +26,23 @@
|
||||||
<!-- Default interceptor stack. -->
|
<!-- Default interceptor stack. -->
|
||||||
<default-interceptor-ref name="defaultStack"/>
|
<default-interceptor-ref name="defaultStack"/>
|
||||||
|
|
||||||
<!-- Action: Front page -->
|
<action name="index" class="baseAction">
|
||||||
<action name="index" class="org.apache.maven.repository.manager.web.action.BaseAction">
|
<result name="success" type="dispatcher">/WEB-INF/jsp/quickSearch.jsp</result>
|
||||||
<result name="success" type="dispatcher">/WEB-INF/jsp/index.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>
|
<result name="error" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
|
||||||
</action>
|
</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">
|
<action name="searchg" class="org.apache.maven.repository.manager.web.action.GeneralSearchAction">
|
||||||
<result name="success" type="dispatcher">/WEB-INF/jsp/generalresults.jsp</result>
|
<result name="success" type="dispatcher">/WEB-INF/jsp/generalresults.jsp</result>
|
||||||
<result name="error" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
|
<result name="error" type="dispatcher">/WEB-INF/jsp/index.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>
|
<plugin>
|
||||||
<groupId>org.codehaus.plexus</groupId>
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
<artifactId>plexus-maven-plugin</artifactId>
|
<artifactId>plexus-maven-plugin</artifactId>
|
||||||
|
<version>1.3-SNAPSHOT</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
@ -346,4 +347,11 @@
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</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>
|
</project>
|
||||||
|
|
Loading…
Reference in New Issue