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

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


        String tagName = gitSegment;
        URI cloneLocation = BaseToCloneConverter.getCloneLocation(getURI(request), BaseToCloneConverter.TAG);

        Ref ref = db.getRefDatabase().getRef(Constants.R_TAGS + tagName);
        if (ref != null) {
          Tag tag = new Tag(cloneLocation, db, ref);
          OrionServlet.writeJSONResponse(request, response, tag.toJSON(), JsonURIUnqualificationStrategy.ALL_NO_GIT);
          return true;
        } else {
          String msg = NLS.bind("Tag not found: {0}", tagName);
          return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, msg, null));
        }
View Full Code Here


      ObjectId objectId = db.resolve(commitId);
      RevCommit revCommit = walk.lookupCommit(objectId);

      Ref ref = tag(git, revCommit, tagName);
      URI cloneLocation = BaseToCloneConverter.getCloneLocation(getURI(request), BaseToCloneConverter.TAG_LIST);
      Tag tag = new Tag(cloneLocation, db, ref);
      OrionServlet.writeJSONResponse(request, response, tag.toJSON(), JsonURIUnqualificationStrategy.ALL_NO_GIT);
      return true;
    } catch (Exception e) {
      return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
          "An error occured when tagging.", e));
    } finally {
View Full Code Here

      List<Tag> tags = new ArrayList<Tag>();
      for (Ref ref : refs) {
        if (nameFilter != null && !nameFilter.equals("")) {
          String shortName = Repository.shortenRefName(ref.getName());
          if (shortName.toLowerCase().contains(nameFilter.toLowerCase())) {
            Tag tag = new Tag(cloneLocation, db, ref);
            tags.add(tag);
          }
        } else {
          Tag tag = new Tag(cloneLocation, db, ref);
          tags.add(tag);
        }
      }
      Collections.sort(tags, Tag.COMPARATOR);
      JSONArray children = new JSONArray();
      int firstTag = pageSize > 0 ? pageSize * (pageNo - 1) : 0;
      int lastTag = pageSize > 0 ? firstTag + pageSize - 1 : tags.size() - 1;
      lastTag = lastTag > tags.size() - 1 ? tags.size() - 1 : lastTag;
      if (pageNo > 1 && baseLocation != null) {
        String prev = baseLocation + "?page=" + (pageNo - 1) + "&pageSize=" + pageSize;
        if (nameFilter != null && !nameFilter.equals("")) {
          prev += "&filter=" + GitUtils.encode(nameFilter);
        }
        if (commitsSize > 0) {
          prev += "&" + GitConstants.KEY_TAG_COMMITS + "=" + commitsSize;
        }
        result.put(ProtocolConstants.KEY_PREVIOUS_LOCATION, prev);
      }
      if (lastTag < tags.size() - 1) {
        String next = baseLocation + "?page=" + (pageNo + 1) + "&pageSize=" + pageSize;
        if (nameFilter != null && !nameFilter.equals("")) {
          next += "&filter=" + GitUtils.encode(nameFilter);
        }
        if (commitsSize > 0) {
          next += "&" + GitConstants.KEY_TAG_COMMITS + "=" + commitsSize;
        }
        result.put(ProtocolConstants.KEY_NEXT_LOCATION, next);
      }
      for (int i = firstTag; i <= lastTag; i++) {
        Tag tag = tags.get(i);
        if (this.commitsSize == 0) {
          children.put(tag.toJSON());
        } else {
          // add info about commits if requested
          LogCommand lc = git.log();
          String toCommitName = tag.getRevCommitName();
          ObjectId toCommitId = db.resolve(toCommitName);
          Ref toCommitRef = db.getRef(toCommitName);
          toCommitId = getCommitObjectId(db, toCommitId);
          lc.add(toCommitId);
          lc.setMaxCount(this.commitsSize);
          Iterable<RevCommit> commits = lc.call();
          Log log = new Log(cloneLocation, db, commits, null, null, toCommitRef);
          log.setPaging(1, commitsSize);
          children.put(tag.toJSON(log.toJSON()));
        }
      }
      result.put(ProtocolConstants.KEY_CHILDREN, children);
      result.put(ProtocolConstants.KEY_TYPE, Tag.TYPE);
      return new ServerStatus(Status.OK_STATUS, HttpServletResponse.SC_OK, result);
View Full Code Here

TOP

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

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.