Search in sources :

Example 61 with OrmException

use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.

the class ChangeDraftUpdate method applyImpl.

@Override
protected CommitBuilder applyImpl(RevWalk rw, ObjectInserter ins, ObjectId curr) throws OrmException, IOException {
    CommitBuilder cb = new CommitBuilder();
    cb.setMessage("Update draft comments");
    try {
        return storeCommentsInNotes(rw, ins, curr, cb);
    } catch (ConfigInvalidException e) {
        throw new OrmException(e);
    }
}
Also used : ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) OrmException(com.google.gwtorm.server.OrmException) CommitBuilder(org.eclipse.jgit.lib.CommitBuilder)

Example 62 with OrmException

use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.

the class PRED_get_legacy_label_types_1 method exec.

@Override
public Operation exec(Prolog engine) throws PrologException {
    engine.setB0();
    Term a1 = arg1.dereference();
    List<LabelType> list;
    try {
        list = StoredValues.CHANGE_DATA.get(engine).getLabelTypes().getLabelTypes();
    } catch (OrmException err) {
        throw new JavaException(this, 1, err);
    }
    Term head = Prolog.Nil;
    for (int idx = list.size() - 1; 0 <= idx; idx--) {
        head = new ListTerm(export(list.get(idx)), head);
    }
    if (!a1.unify(head, engine.trail)) {
        return engine.fail();
    }
    return cont;
}
Also used : JavaException(com.googlecode.prolog_cafe.exceptions.JavaException) OrmException(com.google.gwtorm.server.OrmException) ListTerm(com.googlecode.prolog_cafe.lang.ListTerm) LabelType(com.google.gerrit.common.data.LabelType) Term(com.googlecode.prolog_cafe.lang.Term) IntegerTerm(com.googlecode.prolog_cafe.lang.IntegerTerm) StructureTerm(com.googlecode.prolog_cafe.lang.StructureTerm) SymbolTerm(com.googlecode.prolog_cafe.lang.SymbolTerm) ListTerm(com.googlecode.prolog_cafe.lang.ListTerm)

Example 63 with OrmException

use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.

the class PRED_unresolved_comments_count_1 method exec.

@Override
public Operation exec(Prolog engine) throws PrologException {
    engine.setB0();
    Term a1 = arg1.dereference();
    try {
        Integer count = StoredValues.CHANGE_DATA.get(engine).unresolvedCommentCount();
        if (!a1.unify(new IntegerTerm(count != null ? count : 0), engine.trail)) {
            return engine.fail();
        }
    } catch (OrmException err) {
        throw new JavaException(this, 1, err);
    }
    return cont;
}
Also used : IntegerTerm(com.googlecode.prolog_cafe.lang.IntegerTerm) JavaException(com.googlecode.prolog_cafe.exceptions.JavaException) OrmException(com.google.gwtorm.server.OrmException) Term(com.googlecode.prolog_cafe.lang.Term) IntegerTerm(com.googlecode.prolog_cafe.lang.IntegerTerm)

Example 64 with OrmException

use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.

the class RenameGroupCommand method run.

@Override
protected void run() throws Failure {
    try {
        GroupResource rsrc = groups.parse(TopLevelResource.INSTANCE, IdString.fromDecoded(groupName));
        PutName.Input input = new PutName.Input();
        input.name = newGroupName;
        putName.apply(rsrc, input);
    } catch (RestApiException | OrmException | IOException | NoSuchGroupException e) {
        throw die(e);
    }
}
Also used : OrmException(com.google.gwtorm.server.OrmException) PutName(com.google.gerrit.server.group.PutName) IOException(java.io.IOException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) GroupResource(com.google.gerrit.server.group.GroupResource) NoSuchGroupException(com.google.gerrit.common.errors.NoSuchGroupException)

Example 65 with OrmException

use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.

the class GetRelatedIT method clearGroups.

private void clearGroups(final PatchSet.Id psId) throws Exception {
    try (BatchUpdate bu = batchUpdateFactory.create(db, project, user(user), TimeUtil.nowTs())) {
        bu.addOp(psId.getParentKey(), new BatchUpdateOp() {

            @Override
            public boolean updateChange(ChangeContext ctx) throws OrmException {
                PatchSet ps = psUtil.get(ctx.getDb(), ctx.getNotes(), psId);
                psUtil.setGroups(ctx.getDb(), ctx.getUpdate(psId), ps, ImmutableList.<String>of());
                ctx.dontBumpLastUpdatedOn();
                return true;
            }
        });
        bu.execute();
    }
}
Also used : ChangeContext(com.google.gerrit.server.update.ChangeContext) OrmException(com.google.gwtorm.server.OrmException) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) BatchUpdate(com.google.gerrit.server.update.BatchUpdate) BatchUpdateOp(com.google.gerrit.server.update.BatchUpdateOp)

Aggregations

OrmException (com.google.gwtorm.server.OrmException)172 IOException (java.io.IOException)78 Change (com.google.gerrit.reviewdb.client.Change)50 Repository (org.eclipse.jgit.lib.Repository)41 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)33 ReviewDb (com.google.gerrit.reviewdb.server.ReviewDb)31 ObjectId (org.eclipse.jgit.lib.ObjectId)29 Account (com.google.gerrit.reviewdb.client.Account)28 RevWalk (org.eclipse.jgit.revwalk.RevWalk)28 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)24 ChangeData (com.google.gerrit.server.query.change.ChangeData)24 Map (java.util.Map)22 ArrayList (java.util.ArrayList)21 ChangeNotes (com.google.gerrit.server.notedb.ChangeNotes)20 Inject (com.google.inject.Inject)18 Provider (com.google.inject.Provider)17 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)16 Set (java.util.Set)16 BatchUpdate (com.google.gerrit.server.update.BatchUpdate)15 CurrentUser (com.google.gerrit.server.CurrentUser)14