use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.
the class ProjectConfigSchemaUpdate method save.
public void save(PersonIdent personIdent, String commitMessage) throws OrmException {
if (!updated) {
return;
}
update.getCommitBuilder().setAuthor(personIdent);
update.getCommitBuilder().setCommitter(personIdent);
update.setMessage(commitMessage);
try {
commit(update);
} catch (IOException e) {
throw new OrmException(e);
}
}
use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.
the class SchemaUpdater method update.
public void update(final UpdateUI ui) throws OrmException {
try (ReviewDb db = ReviewDbUtil.unwrapDb(schema.open())) {
final SchemaVersion u = updater.get();
final CurrentSchemaVersion version = getSchemaVersion(db);
if (version == null) {
try {
creator.create(db);
} catch (IOException | ConfigInvalidException e) {
throw new OrmException("Cannot initialize schema", e);
}
} else {
try {
u.check(ui, version, db);
} catch (SQLException e) {
throw new OrmException("Cannot upgrade schema", e);
}
updateSystemConfig(db);
}
}
}
use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.
the class ChangeData method isMergeable.
public Boolean isMergeable() throws OrmException {
if (mergeable == null) {
Change c = change();
if (c == null) {
return null;
}
if (c.getStatus() == Change.Status.MERGED) {
mergeable = true;
} else if (c.getStatus() == Change.Status.ABANDONED) {
return null;
} else if (c.isWorkInProgress()) {
return null;
} else {
if (!lazyLoad) {
return null;
}
PatchSet ps = currentPatchSet();
try {
if (ps == null || !changeControl().isPatchVisible(ps, db)) {
return null;
}
} catch (OrmException e) {
if (e.getCause() instanceof NoSuchChangeException) {
return null;
}
throw e;
}
try (Repository repo = repoManager.openRepository(project())) {
Ref ref = repo.getRefDatabase().exactRef(c.getDest().get());
SubmitTypeRecord str = submitTypeRecord();
if (!str.isOk()) {
// No need to log, as SubmitRuleEvaluator already did it for us.
return false;
}
String mergeStrategy = mergeUtilFactory.create(projectCache.get(project())).mergeStrategyName();
mergeable = mergeabilityCache.get(ObjectId.fromString(ps.getRevision().get()), ref, str.type, mergeStrategy, c.getDest(), repo);
} catch (IOException e) {
throw new OrmException(e);
}
}
}
return mergeable;
}
use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.
the class ChangeData method reloadChange.
public Change reloadChange() throws OrmException {
try {
notes = notesFactory.createChecked(db, project, legacyId);
} catch (NoSuchChangeException e) {
throw new OrmException("Unable to load change " + legacyId, e);
}
change = notes.getChange();
setPatchSets(null);
return change;
}
use of com.google.gwtorm.server.OrmException in project gerrit by GerritCodeReview.
the class JdbcAccountPatchReviewStore method markReviewed.
@Override
public void markReviewed(PatchSet.Id psId, Account.Id accountId, Collection<String> paths) throws OrmException {
if (paths == null || paths.isEmpty()) {
return;
}
try (Connection con = ds.getConnection();
PreparedStatement stmt = con.prepareStatement("INSERT INTO account_patch_reviews " + "(account_id, change_id, patch_set_id, file_name) VALUES " + "(?, ?, ?, ?)")) {
for (String path : paths) {
stmt.setInt(1, accountId.get());
stmt.setInt(2, psId.getParentKey().get());
stmt.setInt(3, psId.get());
stmt.setString(4, path);
stmt.addBatch();
}
stmt.executeBatch();
} catch (SQLException e) {
OrmException ormException = convertError("insert", e);
if (ormException instanceof OrmDuplicateKeyException) {
return;
}
throw ormException;
}
}
Aggregations