mirror of https://github.com/apache/archiva.git
save the configuration
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@421155 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cd7b693b8e
commit
bbf080bf9d
|
@ -17,6 +17,7 @@ package org.apache.maven.repository.configuration;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.repository.configuration.io.xpp3.ConfigurationXpp3Reader;
|
import org.apache.maven.repository.configuration.io.xpp3.ConfigurationXpp3Reader;
|
||||||
|
import org.apache.maven.repository.configuration.io.xpp3.ConfigurationXpp3Writer;
|
||||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
@ -24,6 +25,7 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -105,8 +107,6 @@ public class DefaultConfigurationStore
|
||||||
public void storeConfiguration( Configuration configuration )
|
public void storeConfiguration( Configuration configuration )
|
||||||
throws ConfigurationStoreException
|
throws ConfigurationStoreException
|
||||||
{
|
{
|
||||||
// TODO: finish!
|
|
||||||
|
|
||||||
for ( Iterator i = listeners.iterator(); i.hasNext(); )
|
for ( Iterator i = listeners.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
ConfigurationChangeListener listener = (ConfigurationChangeListener) i.next();
|
ConfigurationChangeListener listener = (ConfigurationChangeListener) i.next();
|
||||||
|
@ -114,6 +114,21 @@ public class DefaultConfigurationStore
|
||||||
listener.notifyOfConfigurationChange( configuration );
|
listener.notifyOfConfigurationChange( configuration );
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new UnsupportedOperationException( "Not yet implemented: storeConfiguration" );
|
ConfigurationXpp3Writer writer = new ConfigurationXpp3Writer();
|
||||||
|
|
||||||
|
FileWriter fileWriter = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fileWriter = new FileWriter( file );
|
||||||
|
writer.write( fileWriter, configuration );
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new ConfigurationStoreException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IOUtil.close( fileWriter );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,10 @@ import org.apache.maven.repository.configuration.ConfigurationStore;
|
||||||
import org.apache.maven.repository.configuration.ConfigurationStoreException;
|
import org.apache.maven.repository.configuration.ConfigurationStoreException;
|
||||||
import org.apache.maven.repository.indexing.RepositoryIndexException;
|
import org.apache.maven.repository.indexing.RepositoryIndexException;
|
||||||
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
|
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
|
||||||
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the application.
|
* Configures the application.
|
||||||
|
@ -47,11 +49,42 @@ public class ConfigureAction
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
|
|
||||||
public String execute()
|
public String execute()
|
||||||
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException,
|
throws IOException, RepositoryIndexException, RepositoryIndexSearchException, ConfigurationStoreException
|
||||||
ConfigurationStoreException
|
|
||||||
{
|
{
|
||||||
// TODO! not yet implemented
|
// TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded
|
||||||
return ERROR;
|
|
||||||
|
// Normalize the path
|
||||||
|
File file = new File( configuration.getRepositoryDirectory() );
|
||||||
|
configuration.setRepositoryDirectory( file.getCanonicalPath() );
|
||||||
|
if ( !file.exists() )
|
||||||
|
{
|
||||||
|
file.mkdirs();
|
||||||
|
// TODO: error handling when this fails
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: these defaults belong in the model. They shouldn't be stored here, as you want them to re-default
|
||||||
|
// should the repository change even if these didn't
|
||||||
|
|
||||||
|
// TODO: these should be on an advanced configuration form, not the standard one
|
||||||
|
if ( StringUtils.isEmpty( configuration.getIndexPath() ) )
|
||||||
|
{
|
||||||
|
configuration.setIndexPath(
|
||||||
|
new File( configuration.getRepositoryDirectory(), ".index" ).getAbsolutePath() );
|
||||||
|
}
|
||||||
|
if ( StringUtils.isEmpty( configuration.getMinimalIndexPath() ) )
|
||||||
|
{
|
||||||
|
configuration.setMinimalIndexPath(
|
||||||
|
new File( configuration.getRepositoryDirectory(), ".index-minimal" ).getAbsolutePath() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Just double checking that our validation routines line up with what is expected in the configuration
|
||||||
|
assert configuration.isValid();
|
||||||
|
|
||||||
|
configurationStore.storeConfiguration( configuration );
|
||||||
|
|
||||||
|
addActionMessage( "Successfully saved configuration" );
|
||||||
|
|
||||||
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String doInput()
|
public String doInput()
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
|
|
||||||
<action name="saveConfiguration" class="configureAction">
|
<action name="saveConfiguration" class="configureAction">
|
||||||
<result name="input">/WEB-INF/jsp/admin/configure.jsp</result>
|
<result name="input">/WEB-INF/jsp/admin/configure.jsp</result>
|
||||||
<!-- TODO: need a SUCCESS handler! -->
|
<result>/WEB-INF/jsp/admin/configure.jsp</result>
|
||||||
</action>
|
</action>
|
||||||
</package>
|
</package>
|
||||||
</xwork>
|
</xwork>
|
||||||
|
|
|
@ -27,8 +27,9 @@
|
||||||
|
|
||||||
<div id="contentArea">
|
<div id="contentArea">
|
||||||
<div id="searchBox">
|
<div id="searchBox">
|
||||||
|
<ww:actionmessage />
|
||||||
<ww:form method="post" action="saveConfiguration" namespace="/admin" validate="true">
|
<ww:form method="post" action="saveConfiguration" namespace="/admin" validate="true">
|
||||||
<ww:textfield name="repositoryDirectory" label="Repository Directory" />
|
<ww:textfield name="repositoryDirectory" label="Repository Directory" size="100" />
|
||||||
<ww:textfield name="discoveryCronExpression" label="Discovery Cron Expression" />
|
<ww:textfield name="discoveryCronExpression" label="Discovery Cron Expression" />
|
||||||
<ww:submit value="Save Configuration" />
|
<ww:submit value="Save Configuration" />
|
||||||
</ww:form>
|
</ww:form>
|
||||||
|
|
|
@ -115,3 +115,10 @@
|
||||||
color: red;
|
color: red;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.actionMessage {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
sage {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue