1 package org.apache.maven.repository.manager.web.action.admin;
4 * Copyright 2005-2006 The Apache Software Foundation.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import com.opensymphony.xwork.ActionSupport;
20 import com.opensymphony.xwork.ModelDriven;
21 import com.opensymphony.xwork.Preparable;
22 import org.apache.maven.repository.configuration.Configuration;
23 import org.apache.maven.repository.configuration.ConfigurationStore;
24 import org.apache.maven.repository.configuration.ConfigurationStoreException;
25 import org.apache.maven.repository.indexing.RepositoryIndexException;
26 import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
27 import org.codehaus.plexus.util.StringUtils;
30 import java.io.IOException;
33 * Configures the application.
35 * @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureAction" instantiation-strategy="per-lookup"
37 public class ConfigureAction
39 implements ModelDriven, Preparable
44 private ConfigurationStore configurationStore;
49 private Configuration configuration;
51 public String execute()
52 throws IOException, RepositoryIndexException, RepositoryIndexSearchException, ConfigurationStoreException
54 // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded
57 File file = new File( configuration.getRepositoryDirectory() );
58 configuration.setRepositoryDirectory( file.getCanonicalPath() );
62 // TODO: error handling when this fails, or is not a directory
65 // TODO: these defaults belong in the model. They shouldn't be stored here, as you want them to re-default
66 // should the repository change even if these didn't
68 // TODO: these should be on an advanced configuration form, not the standard one
69 if ( StringUtils.isEmpty( configuration.getIndexPath() ) )
71 configuration.setIndexPath(
72 new File( configuration.getRepositoryDirectory(), ".index" ).getAbsolutePath() );
74 if ( StringUtils.isEmpty( configuration.getMinimalIndexPath() ) )
76 configuration.setMinimalIndexPath(
77 new File( configuration.getRepositoryDirectory(), ".index-minimal" ).getAbsolutePath() );
80 // Just double checking that our validation routines line up with what is expected in the configuration
81 assert configuration.isValid();
83 configurationStore.storeConfiguration( configuration );
85 addActionMessage( "Successfully saved configuration" );
90 public String doInput()
95 public Object getModel()
100 public void prepare()
103 configuration = configurationStore.getConfigurationFromStore();