diff --git a/plugins/scm-svn-plugin/pom.xml b/plugins/scm-svn-plugin/pom.xml index 650325decd..3c1923ada0 100644 --- a/plugins/scm-svn-plugin/pom.xml +++ b/plugins/scm-svn-plugin/pom.xml @@ -15,4 +15,14 @@ 1.0-SNAPSHOT scm-svn-plugin + + + + sonia.scm + scm-web-api + 1.0-SNAPSHOT + + + + diff --git a/plugins/scm-svn-plugin/src/main/java/sonia/scm/api/rest/resources/SvnConfigResource.java b/plugins/scm-svn-plugin/src/main/java/sonia/scm/api/rest/resources/SvnConfigResource.java new file mode 100644 index 0000000000..3744c59574 --- /dev/null +++ b/plugins/scm-svn-plugin/src/main/java/sonia/scm/api/rest/resources/SvnConfigResource.java @@ -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; +} diff --git a/plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnWebPlugin.java b/plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnWebPlugin.java new file mode 100644 index 0000000000..d61927c9c3 --- /dev/null +++ b/plugins/scm-svn-plugin/src/main/java/sonia/scm/web/SvnWebPlugin.java @@ -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)); + } +} diff --git a/plugins/scm-svn-plugin/src/main/resources/META-INF/services/sonia.scm.web.ScmWebPlugin b/plugins/scm-svn-plugin/src/main/resources/META-INF/services/sonia.scm.web.ScmWebPlugin new file mode 100644 index 0000000000..db9924452d --- /dev/null +++ b/plugins/scm-svn-plugin/src/main/resources/META-INF/services/sonia.scm.web.ScmWebPlugin @@ -0,0 +1 @@ +sonia.scm.web.SvnWebPlugin \ No newline at end of file diff --git a/plugins/scm-svn-plugin/src/main/resources/sonia/scm/svn.config.js b/plugins/scm-svn-plugin/src/main/resources/sonia/scm/svn.config.js new file mode 100644 index 0000000000..d3075055a2 --- /dev/null +++ b/plugins/scm-svn-plugin/src/main/resources/sonia/scm/svn.config.js @@ -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'); + } + }); + } + +});