]> source.dussan.org Git - archiva.git/commitdiff
add a configuration interceptor that sends you to the configuration page if the app...
authorBrett Porter <brett@apache.org>
Wed, 12 Jul 2006 05:39:51 +0000 (05:39 +0000)
committerBrett Porter <brett@apache.org>
Wed, 12 Jul 2006 05:39:51 +0000 (05:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@421137 13f79535-47bb-0310-9956-ffa450edef68

maven-repository-configuration/src/main/mdo/configuration.mdo
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureAction.java [new file with mode: 0644]
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/interceptor/ConfigurationInterceptor.java [new file with mode: 0644]
maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureAction-validation.xml [new file with mode: 0644]
maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/quickSearchAction-validation.xml [new file with mode: 0644]
maven-repository-webapp/src/main/resources/xwork.xml
maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/configure.jsp [new file with mode: 0644]
maven-repository-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp

index 32501f53d1b7bd5458ca8bf20c6061bbb78fd8ac..189a3f6af59df8e22df720e5e9db723ba762163e 100644 (file)
           <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>
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureAction.java
new file mode 100644 (file)
index 0000000..f19b1ba
--- /dev/null
@@ -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();
+    }
+}
\ No newline at end of file
diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/interceptor/ConfigurationInterceptor.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/interceptor/ConfigurationInterceptor.java
new file mode 100644 (file)
index 0000000..2e332e3
--- /dev/null
@@ -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
+    }
+}
diff --git a/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureAction-validation.xml b/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureAction-validation.xml
new file mode 100644 (file)
index 0000000..1a58a6a
--- /dev/null
@@ -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>
\ No newline at end of file
diff --git a/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/quickSearchAction-validation.xml b/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/quickSearchAction-validation.xml
new file mode 100644 (file)
index 0000000..961cb7c
--- /dev/null
@@ -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>
\ No newline at end of file
index 813ecda2bfebd7db571a688a226adda634750bf5..635ec2da6c4b570880bff93a9f4c9390cc3ebf40 100644 (file)
@@ -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). -->
 
   <!-- 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
     </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>
 
diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/configure.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/configure.jsp
new file mode 100644 (file)
index 0000000..0c6f9ed
--- /dev/null
@@ -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>
\ No newline at end of file
index 9c513c40841dd3f56b3d23e9507f118a87bbd7e3..10750a8a97c20895ac895c6403c58364abece344 100644 (file)
   <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>