added svn config to gui

This commit is contained in:
Sebastian Sdorra
2010-09-20 15:08:34 +02:00
parent 075e266620
commit d6d50a01cc
5 changed files with 226 additions and 0 deletions

View File

@@ -0,0 +1,101 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sonia.scm.api.rest.resources;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Inject;
import com.google.inject.Singleton;
import sonia.scm.repository.RepositoryManager;
import sonia.scm.repository.SvnConfig;
import sonia.scm.repository.SvnRepositoryHandler;
//~--- JDK imports ------------------------------------------------------------
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
/**
*
* @author Sebastian Sdorra
*/
@Singleton
@Path("config/repositories/svn")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public class SvnConfigResource
{
/**
* Constructs ...
*
*
* @param repositoryManager
*/
@Inject
public SvnConfigResource(RepositoryManager repositoryManager)
{
repositoryHandler = (SvnRepositoryHandler) repositoryManager.getHandler(
SvnRepositoryHandler.TYPE_NAME);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@GET
public SvnConfig getConfig()
{
SvnConfig config = repositoryHandler.getConfig();
if (config == null)
{
config = new SvnConfig();
repositoryHandler.setConfig(config);
}
return config;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param uriInfo
* @param config
*
* @return
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response setConfig(@Context UriInfo uriInfo, SvnConfig config)
{
repositoryHandler.setConfig(config);
repositoryHandler.storeConfig();
return Response.created(uriInfo.getRequestUri()).build();
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private SvnRepositoryHandler repositoryHandler;
}

View File

@@ -0,0 +1,46 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sonia.scm.web;
/**
*
* @author Sebastian Sdorra
*/
public class SvnWebPlugin implements ScmWebPlugin
{
/** Field description */
public static final String SCRIPT = "/sonia/scm/svn.config.js";
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param context
*/
@Override
public void contextDestroyed(ScmWebPluginContext context)
{
// do nothing
}
/**
* Method description
*
*
* @param context
*/
@Override
public void contextInitialized(ScmWebPluginContext context)
{
context.addScriptResource(new ClasspathWebResource(SCRIPT));
}
}

View File

@@ -0,0 +1 @@
sonia.scm.web.SvnWebPlugin

View File

@@ -0,0 +1,68 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
registerConfigPanel({
xtype : 'configForm',
title : 'Subversion Settings',
items : [{
xtype : 'textfield',
fieldLabel : 'Svnadmin Binary',
name : 'svnAdminBinary',
allowBlank : false
},{
xtype: 'textfield',
name: 'repositoryDirectory',
fieldLabel: 'Repository directory',
allowBlank : false
},{
xtype: 'textfield',
name: 'baseUrl',
fieldLabel: 'Base URL',
allowBlank : false
},{
xtype: 'textfield',
name: 'svnAccessFile',
fieldLabel: 'Svn Accessfile',
allowBlank : true
}],
onSubmit: function(values){
this.el.mask('Submit ...');
Ext.Ajax.request({
url: restUrl + 'config/repositories/svn.json',
method: 'POST',
jsonData: values,
scope: this,
disableCaching: true,
success: function(response){
this.el.unmask();
},
failure: function(){
this.el.unmask();
}
});
},
onLoad: function(el){
var tid = setTimeout( function(){ el.mask('Loading ...'); }, 100);
Ext.Ajax.request({
url: restUrl + 'config/repositories/svn.json',
method: 'GET',
scope: this,
disableCaching: true,
success: function(response){
var obj = Ext.decode(response.responseText);
this.load(obj);
clearTimeout(tid);
el.unmask();
},
failure: function(){
el.unmask();
clearTimeout(tid);
alert('failure');
}
});
}
});