David Ostrovsky
2014-03-15 282b8fd82c46ba6874fb24c8715af103645f3406
src/main/java/com/gitblit/servlet/RpcServlet.java
@@ -47,6 +47,8 @@
import com.gitblit.utils.RpcUtils;
import com.gitblit.utils.StringUtils;
import dagger.ObjectGraph;
/**
 * Handles remote procedure calls.
 *
@@ -57,18 +59,16 @@
   private static final long serialVersionUID = 1L;
   public static final int PROTOCOL_VERSION = 6;
   public static final int PROTOCOL_VERSION = 7;
   private final IStoredSettings settings;
   private IStoredSettings settings;
   private final IGitblit gitblit;
   private IGitblit gitblit;
   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);
   }
   /**
@@ -101,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);
@@ -320,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);
@@ -377,6 +383,19 @@
         } else {
            response.sendError(notAllowedCode);
         }
      } else if (RpcRequest.REINDEX_TICKETS.equals(reqType)) {
         if (allowManagement) {
            if (StringUtils.isEmpty(objectName)) {
               // reindex all tickets
               gitblit.getTicketService().reindex();
            } else {
               // reindex tickets in a specific repository
               RepositoryModel model = gitblit.getRepositoryModel(objectName);
               gitblit.getTicketService().reindex(model);
            }
         } else {
            response.sendError(notAllowedCode);
         }
      }
      // send the result of the request