use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.
the class AllAccountsIndexer method indexAll.
@Override
public SiteIndexer.Result indexAll(final AccountIndex index) {
ProgressMonitor progress = new TextProgressMonitor(new PrintWriter(progressOut));
progress.start(2);
Stopwatch sw = Stopwatch.createStarted();
List<Account.Id> ids;
try {
ids = collectAccounts(progress);
} catch (OrmException e) {
log.error("Error collecting accounts", e);
return new SiteIndexer.Result(sw, false, 0, 0);
}
return reindexAccounts(index, ids, progress);
}
use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.
the class ChangeField method toProtos.
private static <T> List<byte[]> toProtos(ProtobufCodec<T> codec, Collection<T> objs) throws OrmException {
List<byte[]> result = Lists.newArrayListWithCapacity(objs.size());
ByteArrayOutputStream out = new ByteArrayOutputStream(256);
try {
for (T obj : objs) {
out.reset();
CodedOutputStream cos = CodedOutputStream.newInstance(out);
codec.encode(obj, cos);
cos.flush();
result.add(out.toByteArray());
}
} catch (IOException e) {
throw new OrmException(e);
}
return result;
}
use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.
the class IndexedChangeQuery method read.
@Override
public ResultSet<ChangeData> read() throws OrmException {
final DataSource<ChangeData> currSource = source;
final ResultSet<ChangeData> rs = currSource.read();
return new ResultSet<ChangeData>() {
@Override
public Iterator<ChangeData> iterator() {
return Iterables.transform(rs, cd -> {
fromSource.put(cd, currSource);
return cd;
}).iterator();
}
@Override
public List<ChangeData> toList() {
List<ChangeData> r = rs.toList();
for (ChangeData cd : r) {
fromSource.put(cd, currSource);
}
return r;
}
@Override
public void close() {
rs.close();
}
};
}
use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.
the class DbGroupMemberAuditListener method onDeleteAccountsFromGroup.
@Override
public void onDeleteAccountsFromGroup(Account.Id me, Collection<AccountGroupMember> removed) {
List<AccountGroupMemberAudit> auditInserts = new ArrayList<>();
List<AccountGroupMemberAudit> auditUpdates = new ArrayList<>();
try (ReviewDb db = schema.open()) {
for (AccountGroupMember m : removed) {
AccountGroupMemberAudit audit = null;
for (AccountGroupMemberAudit a : db.accountGroupMembersAudit().byGroupAccount(m.getAccountGroupId(), m.getAccountId())) {
if (a.isActive()) {
audit = a;
break;
}
}
if (audit != null) {
audit.removed(me, TimeUtil.nowTs());
auditUpdates.add(audit);
} else {
audit = new AccountGroupMemberAudit(m, me, TimeUtil.nowTs());
audit.removedLegacy();
auditInserts.add(audit);
}
}
db.accountGroupMembersAudit().update(auditUpdates);
db.accountGroupMembersAudit().insert(auditInserts);
} catch (OrmException e) {
logOrmExceptionForAccounts("Cannot log delete accounts from group event performed by user", me, removed, e);
}
}
use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.
the class DbGroupMemberAuditListener method onAddGroupsToGroup.
@Override
public void onAddGroupsToGroup(Account.Id me, Collection<AccountGroupById> added) {
List<AccountGroupByIdAud> includesAudit = new ArrayList<>();
for (AccountGroupById groupInclude : added) {
AccountGroupByIdAud audit = new AccountGroupByIdAud(groupInclude, me, TimeUtil.nowTs());
includesAudit.add(audit);
}
try (ReviewDb db = schema.open()) {
db.accountGroupByIdAud().insert(includesAudit);
} catch (OrmException e) {
logOrmExceptionForGroups("Cannot log add groups to group event performed by user", me, added, e);
}
}
Aggregations