From b23b67c1cc0b2541580f23c9aec97c0b84a823f4 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Fri, 21 Feb 2014 09:56:37 -0500 Subject: [PATCH] Select default/configured gc period in create/edit repository page --- src/main/java/com/gitblit/servlet/RpcServlet.java | 38 ++++++++++++++++++++------------------ 1 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/gitblit/servlet/RpcServlet.java b/src/main/java/com/gitblit/servlet/RpcServlet.java index 481a8ba..28f0d5b 100644 --- a/src/main/java/com/gitblit/servlet/RpcServlet.java +++ b/src/main/java/com/gitblit/servlet/RpcServlet.java @@ -23,8 +23,6 @@ import java.util.List; import java.util.Map; -import javax.inject.Inject; -import javax.inject.Singleton; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -49,30 +47,28 @@ import com.gitblit.utils.RpcUtils; import com.gitblit.utils.StringUtils; +import dagger.ObjectGraph; + /** * Handles remote procedure calls. * * @author James Moger * */ -@Singleton public class RpcServlet extends JsonServlet { private static final long serialVersionUID = 1L; public static final int PROTOCOL_VERSION = 6; - private final IStoredSettings settings; + private IStoredSettings settings; - private final IGitblit gitblit; + private IGitblit gitblit; - @Inject - public RpcServlet(IGitblit gitblit) { - - super(); - - this.settings = gitblit.getSettings(); - this.gitblit = gitblit; + @Override + protected void inject(ObjectGraph dagger) { + this.settings = dagger.get(IStoredSettings.class); + this.gitblit = dagger.get(IGitblit.class); } /** @@ -105,7 +101,10 @@ result = PROTOCOL_VERSION; } else if (RpcRequest.LIST_REPOSITORIES.equals(reqType)) { // Determine the Gitblit clone url - String gitblitUrl = HttpUtils.getGitblitURL(request); + String gitblitUrl = settings.getString(Keys.web.canonicalUrl, null); + if (StringUtils.isEmpty(gitblitUrl)) { + gitblitUrl = HttpUtils.getGitblitURL(request); + } StringBuilder sb = new StringBuilder(); sb.append(gitblitUrl); sb.append(Constants.R_PATH); @@ -218,7 +217,7 @@ // create user UserModel model = deserialize(request, response, UserModel.class); try { - gitblit.updateUserModel(model.username, model, true); + gitblit.addUser(model); } catch (GitBlitException e) { response.setStatus(failureCode); } @@ -231,7 +230,7 @@ username = model.username; } try { - gitblit.updateUserModel(username, model, false); + gitblit.reviseUser(username, model); } catch (GitBlitException e) { response.setStatus(failureCode); } @@ -245,7 +244,7 @@ // create team TeamModel model = deserialize(request, response, TeamModel.class); try { - gitblit.updateTeamModel(model.name, model, true); + gitblit.addTeam(model); } catch (GitBlitException e) { response.setStatus(failureCode); } @@ -258,7 +257,7 @@ teamname = model.name; } try { - gitblit.updateTeamModel(teamname, model, false); + gitblit.reviseTeam(teamname, model); } catch (GitBlitException e) { response.setStatus(failureCode); } @@ -324,7 +323,10 @@ } else if (RpcRequest.LIST_FEDERATION_SETS.equals(reqType)) { // return the list of federation sets if (allowAdmin && gitblit.canFederate()) { - String gitblitUrl = HttpUtils.getGitblitURL(request); + String gitblitUrl = settings.getString(Keys.web.canonicalUrl, null); + if (StringUtils.isEmpty(gitblitUrl)) { + gitblitUrl = HttpUtils.getGitblitURL(request); + } result = gitblit.getFederationSets(gitblitUrl); } else { response.sendError(notAllowedCode); -- Gitblit v1.9.1