<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>
</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>
import org.apache.maven.repository.manager.web.job.DiscovererScheduler;\r
import org.apache.maven.repository.manager.web.utils.ConfigurationManager;\r
\r
-import java.io.File;\r
import java.util.HashMap;\r
import java.util.Map;\r
\r
* This is the Action class of index.jsp, which is the initial page of the web application.\r
* It invokes the DiscovererScheduler to set the DiscoverJob in the scheduler.\r
*\r
- * @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.BaseAction"\r
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="baseAction"\r
*/\r
public class BaseAction\r
extends ActionSupport\r
this.parameters = parameters;\r
\r
//Configuration configuration = new Configuration(); // TODO!\r
- execution.executeDiscovererIfIndexDoesNotExist( new File( config.getIndexPath() ) );\r
+// execution.executeDiscovererIfIndexDoesNotExist( new File( config.getIndexPath() ) );\r
discovererScheduler.setSchedule( config.getDiscoveryCronExpression() );\r
}\r
catch ( Exception e )\r
--- /dev/null
+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;
+ }
+
+}
File file = getConfigFile();
config = new Configuration();
- if ( !file.exists() )
+ if ( file != null )
{
- writeXmlDocument( getConfigFile() );
- }
- else
- {
- try
+ if ( !file.exists() )
{
- config = readXmlDocument( file );
+ writeXmlDocument( getConfigFile() );
}
- catch ( XmlPullParserException xe )
+ else
{
- // TODO: fix error handling!
- xe.printStackTrace();
+ try
+ {
+ config = readXmlDocument( file );
+ }
+ catch ( XmlPullParserException xe )
+ {
+ // TODO: fix error handling!
+ xe.printStackTrace();
+ }
}
}
else
{
URL xmlPath = getClass().getClassLoader().getResource( "../" + WEB_XML_FILE );
- String path = xmlPath.getFile();
- int lastIndex = path.lastIndexOf( '/' );
- path = path.substring( 0, lastIndex + 1 );
- path = path + INDEX_CONFIG_FILE;
- plexusDescriptor = new File( path );
+ 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;
<!-- Default interceptor stack. -->
<default-interceptor-ref name="defaultStack"/>
- <!-- Action: Front page -->
- <action name="index" class="org.apache.maven.repository.manager.web.action.BaseAction">
- <result name="success" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
+ <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>
<result name="error" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
<action name="configureScheduler" class="org.apache.maven.repository.manager.web.action.SchedulerConfigurationAction">
<result name="success" type="dispatcher">/WEB-INF/jsp/indexConfigUpdateSuccess.jsp</result>
<result name="error" type="dispatcher">/WEB-INF/jsp/index.jsp</result>
- </action>
+ </action>
</package>
</xwork>
--- /dev/null
+<%@ 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>
\ No newline at end of file
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-maven-plugin</artifactId>
+ <version>1.3-SNAPSHOT</version>
<executions>
<execution>
<goals>
<groupId>org.apache.maven.repository</groupId>
<artifactId>maven-repository-converter</artifactId>
<version>${pom.version}</version>
- </dependency>
+ </dependency>
</dependencies>
</dependencyManagement>
<reporting>
</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>