Package com.google.gerrit.server.project

Examples of com.google.gerrit.server.project.NoSuchChangeException


    final Change.Id changeId = patchSetId.getParentKey();
    result.setChangeId(changeId);
    final ChangeControl control = changeControlFactory.validateFor(changeId);
    final PatchSet patch = db.patchSets().get(patchSetId);
    if (patch == null) {
      throw new NoSuchChangeException(changeId);
    }
    if (!patch.isDraft()) {
      result.addError(new ReviewResult.Error(
          ReviewResult.Error.Type.NOT_A_DRAFT));
      return result;
    }

    if (!control.canDeleteDraft(db)) {
      result.addError(new ReviewResult.Error(
          ReviewResult.Error.Type.DELETE_NOT_PERMITTED));
      return result;
    }
    final Change change = control.getChange();

    try {
      ChangeUtil.deleteOnlyDraftPatchSet(patch, change, gitManager, replication, db);
    } catch (IOException e) {
      result.addError(new ReviewResult.Error(
          ReviewResult.Error.Type.GIT_ERROR, e.getMessage()));
    }

    List<PatchSet> restOfPatches = db.patchSets().byChange(changeId).toList();
    if (restOfPatches.size() == 0) {
      try {
        ChangeUtil.deleteDraftChange(patchSetId, gitManager, replication, db);
        result.setChangeId(null);
      } catch (IOException e) {
        result.addError(new ReviewResult.Error(
            ReviewResult.Error.Type.GIT_ERROR, e.getMessage()));
      }
    } else {
      PatchSet.Id highestId = null;
      for (PatchSet ps : restOfPatches) {
        if (highestId == null || ps.getPatchSetId() > highestId.get()) {
          highestId = ps.getId();
        }
      }
      if (change.currentPatchSetId().equals(patchSetId)) {
        change.removeLastPatchSetId();
        try {
          change.setCurrentPatchSet(patchSetInfoFactory.get(db, change.currPatchSetId()));
        } catch (PatchSetInfoNotAvailableException e) {
          throw new NoSuchChangeException(changeId);
        }
        db.changes().update(Collections.singleton(change));
      }
    }
    return result;
View Full Code Here


    final Change.Id changeId = patchSetId.getParentKey();
    result.setChangeId(changeId);
    final ChangeControl control = changeControlFactory.validateFor(changeId);
    final PatchSet patch = db.patchSets().get(patchSetId);
    if (patch == null) {
      throw new NoSuchChangeException(changeId);
    }
    if (!patch.isDraft()) {
      result.addError(new ReviewResult.Error(
          ReviewResult.Error.Type.NOT_A_DRAFT));
      return result;
View Full Code Here

    final PatchSet patch = db.patchSets().get(patchSetId);
    if (!control.canAbandon()) {
      result.addError(new ReviewResult.Error(
          ReviewResult.Error.Type.ABANDON_NOT_PERMITTED));
    } else if (patch == null) {
      throw new NoSuchChangeException(changeId);
    } else {

      // Create a message to accompany the abandoned change
      final ChangeMessage cmsg = new ChangeMessage(
          new ChangeMessage.Key(changeId, ChangeUtil.messageUUID(db)),
View Full Code Here

    final PatchSet patch = db.patchSets().get(patchSetId);
    final Change.Id changeId = patchSetId.getParentKey();
    final ChangeControl control = changeControlFactory.validateFor(changeId);
    result.setChangeId(changeId);
    if (patch == null) {
      throw new NoSuchChangeException(changeId);
    }

    List<SubmitRecord> submitResult = control.canSubmit(db, patch);
    if (submitResult.isEmpty()) {
      throw new IllegalStateException(
View Full Code Here

      PatchSetInfoNotAvailableException {

    final Change.Id changeId = patchSetId.getParentKey();
    final PatchSet patch = db.patchSets().get(patchSetId);
    if (patch == null) {
      throw new NoSuchChangeException(changeId);
    }

    final Repository git;
    try {
      git = gitManager.openRepository(db.changes().get(changeId).getProject());
    } catch (RepositoryNotFoundException e) {
      throw new NoSuchChangeException(changeId, e);
    };

    final RevWalk revWalk = new RevWalk(git);
    try {
      RevCommit commitToRevert =
View Full Code Here

      final GitReferenceUpdated replication, final ReviewDb db)
      throws NoSuchChangeException, OrmException, IOException {
    final Change.Id changeId = patchSetId.getParentKey();
    final Change change = db.changes().get(changeId);
    if (change == null || change.getStatus() != Change.Status.DRAFT) {
      throw new NoSuchChangeException(changeId);
    }

    for (PatchSet ps : db.patchSets().byChange(changeId)) {
      // These should all be draft patch sets.
      deleteOnlyDraftPatchSet(ps, change, gitManager, replication, db);
View Full Code Here

      final Change change, GitRepositoryManager gitManager,
      final GitReferenceUpdated replication, final ReviewDb db)
      throws NoSuchChangeException, OrmException, IOException {
    final PatchSet.Id patchSetId = patch.getId();
    if (patch == null || !patch.isDraft()) {
      throw new NoSuchChangeException(patchSetId.getParentKey());
    }

    Repository repo = gitManager.openRepository(change.getProject());
    try {
      RefUpdate update = repo.updateRef(patch.getRefName());
View Full Code Here

      return result;
    }

    final PatchSet patch = db.patchSets().get(patchSetId);
    if (patch == null) {
      throw new NoSuchChangeException(changeId);
    }

    final Branch.NameKey destBranch = control.getChange().getDest();
    if (!ProjectUtil.branchExists(repoManager, destBranch)) {
      result.addError(new ReviewResult.Error(
View Full Code Here

TOP

Related Classes of com.google.gerrit.server.project.NoSuchChangeException

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.