Package com.google.gerrit.server.project

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


  public VoidResult call() throws NoSuchChangeException, OrmException, IOException {

    final Change.Id changeId = patchSetId.getParentKey();
    final ChangeControl control = changeControlFactory.validateFor(changeId);
    if (!control.canDeleteDraft(db)) {
      throw new NoSuchChangeException(changeId);
    }

    ChangeUtil.deleteDraftChange(patchSetId, gitManager, replication, db);
    return VoidResult.INSTANCE;
  }
View Full Code Here


    final RestoreChange restoreChange = restoreChangeProvider.get();
    restoreChange.setChangeId(patchSetId.getParentKey());
    restoreChange.setMessage(message);
    final ReviewResult result = restoreChange.call();
    if (result.getErrors().size() > 0) {
      throw new NoSuchChangeException(result.getChangeId());
    }
    return changeDetailFactory.create(result.getChangeId()).call();
  }
View Full Code Here

    control = changeControlFactory.validateFor(changeId);
    change = control.getChange();
    projectKey = change.getProject();
    patchSet = db.patchSets().get(patchSetId);
    if (patchSet == null) {
      throw new NoSuchChangeException(changeId);
    }

    aId = psa != null ? toObjectId(db, psa) : null;
    bId = toObjectId(db, psb);

    final Repository git;
    try {
      git = repoManager.openRepository(projectKey);
    } catch (RepositoryNotFoundException e) {
      log.error("Repository " + projectKey + " not found", e);
      throw new NoSuchChangeException(changeId, e);
    } catch (IOException e) {
      log.error("Cannot open repository " + projectKey, e);
      throw new NoSuchChangeException(changeId, e);
    }
    try {
      final PatchList list = listFor(keyFor(diffPrefs.getIgnoreWhitespace()));
      final PatchScriptBuilder b = newBuilder(list, git);
      final PatchListEntry content = list.get(patchKey.getFileName());

      loadCommentsAndHistory(content.getChangeType(), //
          content.getOldName(), //
          content.getNewName());

        return b.toPatchScript(content, comments, history);
    } catch (PatchListNotAvailableException e) {
      throw new NoSuchChangeException(changeId, e);
    } catch (IOException e) {
      log.error("File content unavailable", e);
      throw new NoSuchChangeException(changeId, e);
    } catch (org.eclipse.jgit.errors.LargeObjectException err) {
      throw new LargeObjectException("File content is too large", err);
    } finally {
      git.close();
    }
View Full Code Here

  }

  private ObjectId toObjectId(final ReviewDb db, final PatchSet.Id psId)
      throws OrmException, NoSuchChangeException {
    if (!changeId.equals(psId.getParentKey())) {
      throw new NoSuchChangeException(changeId);
    }

    final PatchSet ps = db.patchSets().get(psId);
    if (ps == null || ps.getRevision() == null
        || ps.getRevision().get() == null) {
      throw new NoSuchChangeException(changeId);
    }

    try {
      return ObjectId.fromString(ps.getRevision().get());
    } catch (IllegalArgumentException e) {
      log.error("Patch set " + psId + " has invalid revision");
      throw new NoSuchChangeException(changeId, e);
    }
  }
View Full Code Here

  private void validatePatchSetId(final PatchSet.Id psId)
      throws NoSuchChangeException {
    if (psId == null) { // OK, means use base;
    } else if (changeId.equals(psId.getParentKey())) { // OK, same change;
    } else {
      throw new NoSuchChangeException(changeId);
    }
  }
View Full Code Here

    db.changes().beginTransaction(changeId);
    try {
      changeControlFactory.validateFor(changeId);
      if (db.patchSets().get(patchSetId) == null) {
        throw new NoSuchChangeException(changeId);
      }

      final Account.Id me = currentUser.getAccountId();
      if (comment.getKey().get() == null) {
        if (comment.getLine() < 1) {
          throw new IllegalStateException("Comment line must be >= 1, not "
              + comment.getLine());
        }

        if (comment.getParentUuid() != null) {
          final PatchLineComment parent =
              db.patchComments().get(
                  new PatchLineComment.Key(patchKey, comment.getParentUuid()));
          if (parent == null || parent.getSide() != comment.getSide()) {
            throw new IllegalStateException("Parent comment must be on same side");
          }
        }

        final PatchLineComment nc =
            new PatchLineComment(new PatchLineComment.Key(patchKey, ChangeUtil
                .messageUUID(db)), comment.getLine(), me, comment.getParentUuid());
        nc.setSide(comment.getSide());
        nc.setMessage(comment.getMessage());
        db.patchComments().insert(Collections.singleton(nc));
        db.commit();
        return nc;

      } else {
        if (!me.equals(comment.getAuthor())) {
          throw new NoSuchChangeException(changeId);
        }
        comment.updated();
        db.patchComments().update(Collections.singleton(comment));
        db.commit();
        return comment;
View Full Code Here

    final Change.Id changeId = patchSetId.getParentKey();
    final ChangeControl ctl = changeControlFactory.validateFor(changeId);
    change = ctl.getChange();
    patchSet = db.patchSets().get(patchSetId);
    if (patchSet == null) {
      throw new NoSuchChangeException(changeId);
    }
    drafts = drafts();

    db.changes().beginTransaction(changeId);
    try {
View Full Code Here

      MissingObjectException, IncorrectObjectTypeException, IOException {

    final Change.Id changeId = patchSetId.getParentKey();
    final ChangeControl control = changeControlFactory.validateFor(changeId);
    if (!control.canAddPatchSet()) {
      throw new NoSuchChangeException(changeId);
    }

    Change.Id revertedChangeId = ChangeUtil.revert(patchSetId, currentUser, message, db,
        revertedSenderFactory, hooks, gitManager, patchSetInfoFactory,
        replication, myIdent);
View Full Code Here

    final AbandonChange abandonChange = abandonChangeProvider.get();
    abandonChange.setChangeId(patchSetId.getParentKey());
    abandonChange.setMessage(message);
    final ReviewResult result = abandonChange.call();
    if (result.getErrors().size() > 0) {
      throw new NoSuchChangeException(result.getChangeId());
    }
    return changeDetailFactory.create(result.getChangeId()).call();
  }
View Full Code Here

            // deleted was the only patch set in the change
            return null;
          }
          return changeDetailFactory.create(result.getChangeId()).call();
        } catch (NoSuchChangeException e) {
          throw new Failure(new NoSuchChangeException(result.getChangeId()));
        } catch (NoSuchEntityException e) {
          throw new Failure(e);
        } catch (PatchSetInfoNotAvailableException e) {
          throw new Failure(e);
        } catch (RepositoryNotFoundException e) {
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.