Package org.eclipse.orion.server.git.objects

Examples of org.eclipse.orion.server.git.objects.Remote


        Repository db = null;
        try {
          db = repositoryForPath(request, new Path(resource.getPath()));
          URI cloneLocation = BaseToCloneConverter.getCloneLocation(resource, BaseToCloneConverter.FILE);
          String branch = db == null ? null : db.getBranch();
          Remote defaultRemote = db == null ? null : new Remote(cloneLocation, db, Constants.DEFAULT_REMOTE_NAME);
          RemoteBranch defaultRemoteBranch = db == null ? null : new RemoteBranch(cloneLocation, db, defaultRemote, branch);
          addGitLinks(request, resource, representation, cloneLocation, db, defaultRemoteBranch, branch);

          JSONArray children = representation.optJSONArray(ProtocolConstants.KEY_CHILDREN);
          if (children != null) {
View Full Code Here


    try {
      db = repositoryForPath(request, new Path(location.getPath()));
      if (db != null) {
        URI cloneLocation = BaseToCloneConverter.getCloneLocation(location, BaseToCloneConverter.FILE);
        String branch = db.getBranch();
        Remote defaultRemote = new Remote(cloneLocation, db, Constants.DEFAULT_REMOTE_NAME);
        RemoteBranch defaultRemoteBranch = new RemoteBranch(cloneLocation, db, defaultRemote, branch);
        addGitLinks(request, location, representation, cloneLocation, db, defaultRemoteBranch, branch);
      }
    } finally {
      if (db != null) {
View Full Code Here

      db = FileRepositoryBuilder.create(gitDir);
      Git git = new Git(db);
      Set<String> configNames = db.getConfig().getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION);
      for (String configN : configNames) {
        if (configN.equals(configName)) {
          Remote remote = new Remote(cloneLocation, db, configN);
          JSONObject result = remote.toJSON();
          if (!result.has(ProtocolConstants.KEY_CHILDREN)) {
            return new ServerStatus(Status.OK_STATUS, HttpServletResponse.SC_OK, result);
          }
          JSONArray children = result.getJSONArray(ProtocolConstants.KEY_CHILDREN);
          JSONArray filteredChildren = new JSONArray();
View Full Code Here

        db = FileRepositoryBuilder.create(gitDir);
        Set<String> configNames = db.getConfig().getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION);
        JSONObject result = new JSONObject();
        JSONArray children = new JSONArray();
        for (String configName : configNames) {
          Remote remote = new Remote(cloneLocation, db, configName);
          children.put(remote.toJSON(false));
        }
        result.put(ProtocolConstants.KEY_CHILDREN, children);
        result.put(ProtocolConstants.KEY_TYPE, Remote.TYPE);
        OrionServlet.writeJSONResponse(request, response, result, JsonURIUnqualificationStrategy.ALL_NO_GIT);
        return true;
      } finally {
        if (db != null) {
          db.close();
        }
      }
    } else if (p.segment(1).equals("file")) { //$NON-NLS-1$
      // /git/remote/{remote}/file/{path}
      RemoteDetailsJob job;
      String commits = request.getParameter(GitConstants.KEY_TAG_COMMITS);
      int commitsNumber = commits == null ? 0 : Integer.parseInt(commits);
      String nameFilter = request.getParameter("filter");
      String page = request.getParameter("page");
      if (page != null) {
        int pageNo = Integer.parseInt(page);
        int pageSize = request.getParameter("pageSize") == null ? PAGE_SIZE : Integer.parseInt(request.getParameter("pageSize"));
        job = new RemoteDetailsJob(TaskJobHandler.getUserId(request), p.segment(0), p.removeFirstSegments(1), BaseToCloneConverter.getCloneLocation(
            getURI(request), BaseToCloneConverter.REMOTE), commitsNumber, pageNo, pageSize, request.getRequestURI(), nameFilter);
      } else {
        job = new RemoteDetailsJob(TaskJobHandler.getUserId(request), p.segment(0), p.removeFirstSegments(1), BaseToCloneConverter.getCloneLocation(
            getURI(request), BaseToCloneConverter.REMOTE), commitsNumber, nameFilter);
      }
      return TaskJobHandler.handleTaskJob(request, response, job, statusHandler, JsonURIUnqualificationStrategy.ALL_NO_GIT);
    } else if (p.segment(2).equals("file")) { //$NON-NLS-1$
      // /git/remote/{remote}/{branch}/file/{path}
      File gitDir = GitUtils.getGitDir(p.removeFirstSegments(2));
      URI cloneLocation = BaseToCloneConverter.getCloneLocation(getURI(request), BaseToCloneConverter.REMOTE_BRANCH);
      Repository db = null;
      try {
        db = FileRepositoryBuilder.create(gitDir);
        Remote remote = new Remote(cloneLocation, db, p.segment(0));
        RemoteBranch remoteBranch = new RemoteBranch(cloneLocation, db, remote, GitUtils.decode(p.segment(1)));
        if (remoteBranch.exists()) {
          JSONObject result = remoteBranch.toJSON();
          OrionServlet.writeJSONResponse(request, response, result, JsonURIUnqualificationStrategy.ALL_NO_GIT);
          return true;
View Full Code Here

        rc.addPushRefSpec(new RefSpec(pushRefSpec));

      rc.update(config);
      config.save();

      Remote remote = new Remote(cloneLocation, db, remoteName);
      JSONObject result = new JSONObject();
      result.put(ProtocolConstants.KEY_LOCATION, remote.getLocation());
      OrionServlet.writeJSONResponse(request, response, result, JsonURIUnqualificationStrategy.ALL_NO_GIT);
      response.setHeader(ProtocolConstants.HEADER_LOCATION, result.getString(ProtocolConstants.KEY_LOCATION));
      response.setStatus(HttpServletResponse.SC_CREATED);
    } finally {
      if (db != null) {
View Full Code Here

TOP

Related Classes of org.eclipse.orion.server.git.objects.Remote

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.