mirror of https://github.com/apache/archiva.git
add a configuration interceptor that sends you to the configuration page if the app is not yet properly configured
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@421137 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d0304eb8a2
commit
cd7b693b8e
|
@ -75,6 +75,17 @@
|
|||
<description>Blacklisted patterns in the discovery process</description>
|
||||
</field>
|
||||
</fields>
|
||||
<codeSegments>
|
||||
<codeSegment>
|
||||
<version>1.0.0</version>
|
||||
<code><![CDATA[
|
||||
public boolean isValid()
|
||||
{
|
||||
return indexPath != null & repositoryDirectory != null;
|
||||
}
|
||||
]]></code>
|
||||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
</classes>
|
||||
</model>
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package org.apache.maven.repository.manager.web.action.admin;
|
||||
|
||||
/*
|
||||
* 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.ActionSupport;
|
||||
import com.opensymphony.xwork.ModelDriven;
|
||||
import com.opensymphony.xwork.Preparable;
|
||||
import org.apache.maven.repository.configuration.Configuration;
|
||||
import org.apache.maven.repository.configuration.ConfigurationStore;
|
||||
import org.apache.maven.repository.configuration.ConfigurationStoreException;
|
||||
import org.apache.maven.repository.indexing.RepositoryIndexException;
|
||||
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
/**
|
||||
* Configures the application.
|
||||
*
|
||||
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureAction"
|
||||
*/
|
||||
public class ConfigureAction
|
||||
extends ActionSupport
|
||||
implements ModelDriven, Preparable
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ConfigurationStore configurationStore;
|
||||
|
||||
/**
|
||||
* The configuration.
|
||||
*/
|
||||
private Configuration configuration;
|
||||
|
||||
public String execute()
|
||||
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException,
|
||||
ConfigurationStoreException
|
||||
{
|
||||
// TODO! not yet implemented
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
public String doInput()
|
||||
{
|
||||
return INPUT;
|
||||
}
|
||||
|
||||
public Object getModel()
|
||||
{
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public void prepare()
|
||||
throws Exception
|
||||
{
|
||||
configuration = configurationStore.getConfigurationFromStore();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package org.apache.maven.repository.manager.web.interceptor;
|
||||
|
||||
/*
|
||||
* 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.ActionInvocation;
|
||||
import com.opensymphony.xwork.interceptor.Interceptor;
|
||||
import org.apache.maven.repository.configuration.Configuration;
|
||||
import org.apache.maven.repository.configuration.ConfigurationStore;
|
||||
|
||||
/**
|
||||
* An interceptor that makes the application configuration available
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @todo might be a generally useful thing in plexus-xwork-integration
|
||||
* @plexus.component role="com.opensymphony.xwork.interceptor.Interceptor" role-hint="configurationInterceptor"
|
||||
*/
|
||||
public class ConfigurationInterceptor
|
||||
implements Interceptor
|
||||
{
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ConfigurationStore configurationStore;
|
||||
|
||||
public String intercept( ActionInvocation actionInvocation )
|
||||
throws Exception
|
||||
{
|
||||
Configuration configuration = configurationStore.getConfigurationFromStore();
|
||||
|
||||
if ( !configuration.isValid() )
|
||||
{
|
||||
return "config-needed";
|
||||
}
|
||||
else
|
||||
{
|
||||
return actionInvocation.invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy()
|
||||
{
|
||||
// This space left intentionally blank
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
// This space left intentionally blank
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<!--
|
||||
~ 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="repositoryDirectory">
|
||||
<field-validator type="requiredstring">
|
||||
<message>You must enter the repository directory.</message>
|
||||
</field-validator>
|
||||
</field>
|
||||
</validators>
|
|
@ -0,0 +1,26 @@
|
|||
<!--
|
||||
~ 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="q">
|
||||
<field-validator type="requiredstring">
|
||||
<message>You must enter some search terms.</message>
|
||||
</field-validator>
|
||||
</field>
|
||||
</validators>
|
|
@ -14,8 +14,8 @@
|
|||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN"
|
||||
"http://www.opensymphony.com/xwork/xwork-1.0.dtd">
|
||||
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.1//EN"
|
||||
"http://www.opensymphony.com/xwork/xwork-1.1.dtd">
|
||||
|
||||
<xwork>
|
||||
<!-- Include webwork defaults (from WebWork JAR). -->
|
||||
|
@ -23,18 +23,29 @@
|
|||
|
||||
<!-- Configuration for the default package. -->
|
||||
<package name="default" extends="webwork-default">
|
||||
<interceptors>
|
||||
<interceptor name="configuration" class="configurationInterceptor"/>
|
||||
<interceptor-stack name="configuredStack">
|
||||
<interceptor-ref name="defaultStack"/>
|
||||
<interceptor-ref name="configuration"/>
|
||||
</interceptor-stack>
|
||||
</interceptors>
|
||||
|
||||
<!-- Default interceptor stack. -->
|
||||
<default-interceptor-ref name="defaultStack"/>
|
||||
<default-interceptor-ref name="configuredStack"/>
|
||||
|
||||
<global-results>
|
||||
<!-- TODO: might want an extra message on the configure page when this first happens -->
|
||||
<result name="config-needed" type="redirect">/admin/configure.action</result>
|
||||
</global-results>
|
||||
|
||||
<action name="index" class="quickSearchAction" method="input">
|
||||
<result name="success" type="dispatcher">/WEB-INF/jsp/quickSearch.jsp</result>
|
||||
<interceptor-ref name="validationWorkflowStack"/>
|
||||
<result name="input">/WEB-INF/jsp/quickSearch.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="quickSearch" class="quickSearchAction">
|
||||
<result name="input" type="dispatcher">/WEB-INF/jsp/quickSearch.jsp</result>
|
||||
<result name="success" type="dispatcher">/WEB-INF/jsp/results.jsp</result>
|
||||
<interceptor-ref name="validationWorkflowStack"/>
|
||||
<result name="input">/WEB-INF/jsp/quickSearch.jsp</result>
|
||||
<result>/WEB-INF/jsp/results.jsp</result>
|
||||
</action>
|
||||
|
||||
<!-- TODO! old actions
|
||||
|
@ -74,5 +85,19 @@
|
|||
</action>
|
||||
-->
|
||||
</package>
|
||||
|
||||
<!-- Configuration for the admin package. -->
|
||||
<package name="admin" namespace="/admin" extends="webwork-default">
|
||||
<default-interceptor-ref name="defaultStack"/>
|
||||
|
||||
<action name="configure" class="configureAction" method="input">
|
||||
<result name="input">/WEB-INF/jsp/admin/configure.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="saveConfiguration" class="configureAction">
|
||||
<result name="input">/WEB-INF/jsp/admin/configure.jsp</result>
|
||||
<!-- TODO: need a SUCCESS handler! -->
|
||||
</action>
|
||||
</package>
|
||||
</xwork>
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<%@ 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>Configuration</title>
|
||||
<ww:head />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>Configuration</h1>
|
||||
|
||||
<div id="contentArea">
|
||||
<div id="searchBox">
|
||||
<ww:form method="post" action="saveConfiguration" namespace="/admin" validate="true">
|
||||
<ww:textfield name="repositoryDirectory" label="Repository Directory" />
|
||||
<ww:textfield name="discoveryCronExpression" label="Discovery Cron Expression" />
|
||||
<ww:submit value="Save Configuration" />
|
||||
</ww:form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -20,11 +20,11 @@
|
|||
<title>Maven Repository Manager :: <decorator:title default="Maven Repository Manager" /></title>
|
||||
|
||||
<style type="text/css" media="all">
|
||||
@import url( "./css/maven-base.css" );
|
||||
@import url( "./css/maven-theme.css" );
|
||||
@import url( "./css/site.css" );
|
||||
@import url( "<%= request.getContextPath() %>/css/maven-base.css" );
|
||||
@import url( "<%= request.getContextPath() %>/css/maven-theme.css" );
|
||||
@import url( "<%= request.getContextPath() %>/css/site.css" );
|
||||
</style>
|
||||
<link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
|
||||
<link rel="stylesheet" href="<%= request.getContextPath() %>/css/print.css" type="text/css" media="print" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
||||
</head>
|
||||
|
||||
|
|
Loading…
Reference in New Issue