1 package org.apache.maven.repository.manager.web.action;
\r
4 * Copyright 2005-2006 The Apache Software Foundation.
\r
6 * Licensed under the Apache License, Version 2.0 (the "License");
\r
7 * you may not use this file except in compliance with the License.
\r
8 * You may obtain a copy of the License at
\r
10 * http://www.apache.org/licenses/LICENSE-2.0
\r
12 * Unless required by applicable law or agreed to in writing, software
\r
13 * distributed under the License is distributed on an "AS IS" BASIS,
\r
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
15 * See the License for the specific language governing permissions and
\r
16 * limitations under the License.
\r
19 import com.opensymphony.webwork.interceptor.ParameterAware;
\r
20 import com.opensymphony.xwork.ActionSupport;
\r
21 import org.apache.maven.repository.configuration.Configuration;
\r
22 import org.apache.maven.repository.manager.web.execution.DiscovererExecution;
\r
23 import org.apache.maven.repository.manager.web.job.DiscovererScheduler;
\r
24 import org.apache.maven.repository.manager.web.utils.ConfigurationManager;
\r
26 import java.io.File;
\r
27 import java.util.HashMap;
\r
28 import java.util.Map;
\r
31 * This is the Action class of index.jsp, which is the initial page of the web application.
\r
32 * It invokes the DiscovererScheduler to set the DiscoverJob in the scheduler.
\r
34 * @plexus.component role="com.opensymphony.xwork.Action" role-hint="org.apache.maven.repository.manager.web.action.BaseAction"
\r
36 public class BaseAction
\r
37 extends ActionSupport
\r
38 implements ParameterAware
\r
41 * @plexus.requirement
\r
43 private DiscovererExecution execution;
\r
46 * @plexus.requirement
\r
48 private DiscovererScheduler discovererScheduler;
\r
51 * @plexus.requirement
\r
53 private ConfigurationManager configManager;
\r
55 private Map parameters;
\r
57 public Map getParameters()
\r
62 public void setParameters( Map parameters )
\r
64 this.parameters = parameters;
\r
68 * Method that executes the action
\r
70 * @return a String that specifies if the action executed was a success or a failure
\r
72 public String execute()
\r
76 Configuration config = configManager.getConfiguration();
\r
77 Map parameters = new HashMap();
\r
78 parameters.put( ConfigurationManager.INDEXPATH, config.getIndexPath() );
\r
79 parameters.put( ConfigurationManager.MIN_INDEXPATH, config.getMinimalIndexPath() );
\r
80 parameters.put( ConfigurationManager.DISCOVERY_BLACKLIST_PATTERNS, config.getDiscoveryBlackListPatterns() );
\r
81 parameters.put( ConfigurationManager.DISCOVER_SNAPSHOTS, Boolean.valueOf( config.isDiscoverSnapshots() ) );
\r
82 parameters.put( ConfigurationManager.DISCOVERY_CRON_EXPRESSION, config.getDiscoveryCronExpression() );
\r
83 this.parameters = parameters;
\r
85 //Configuration configuration = new Configuration(); // TODO!
\r
86 execution.executeDiscovererIfIndexDoesNotExist( new File( config.getIndexPath() ) );
\r
87 discovererScheduler.setSchedule( config.getDiscoveryCronExpression() );
\r
89 catch ( Exception e )
\r
91 // TODO: better exception handling!
\r
92 e.printStackTrace();
\r