use of com.google.gerrit.exceptions.StorageException in project gerrit by GerritCodeReview.
the class ChangeDraftUpdate method applyImpl.
@Override
protected CommitBuilder applyImpl(RevWalk rw, ObjectInserter ins, ObjectId curr) throws IOException {
CommitBuilder cb = new CommitBuilder();
cb.setMessage("Update draft comments");
try {
return storeCommentsInNotes(rw, ins, curr, cb);
} catch (ConfigInvalidException e) {
throw new StorageException(e);
}
}
use of com.google.gerrit.exceptions.StorageException in project gerrit by GerritCodeReview.
the class IntBlob method parse.
private static Optional<IntBlob> parse(Repository repo, String refName, ObjectReader or) throws IOException {
Ref ref = repo.exactRef(refName);
if (ref == null) {
return Optional.empty();
}
ObjectId id = ref.getObjectId();
ObjectLoader ol = or.open(id, OBJ_BLOB);
if (ol.getType() != OBJ_BLOB) {
// (certainly InMemoryRepository doesn't).
throw new IncorrectObjectTypeException(id, OBJ_BLOB);
}
String str = CharMatcher.whitespace().trimFrom(new String(ol.getCachedBytes(), UTF_8));
Integer value = Ints.tryParse(str);
if (value == null) {
throw new StorageException("invalid value in " + refName + " blob at " + id.name());
}
return Optional.of(IntBlob.create(id, value));
}
use of com.google.gerrit.exceptions.StorageException in project gerrit by GerritCodeReview.
the class GroupIndexerImpl method reindexIfStale.
@Override
public boolean reindexIfStale(AccountGroup.UUID uuid) {
try {
StalenessCheckResult stalenessCheckResult = stalenessChecker.check(uuid);
if (stalenessCheckResult.isStale()) {
logger.atInfo().log("Reindexing stale document %s", stalenessCheckResult);
index(uuid);
return true;
}
} catch (IOException e) {
throw new StorageException(e);
}
return false;
}
use of com.google.gerrit.exceptions.StorageException in project gerrit by GerritCodeReview.
the class AbstractChangeNotes method load.
public T load(Repository repo) {
if (loaded) {
return self();
}
if (args.failOnLoadForTest.get()) {
throw new StorageException("Reading from NoteDb is disabled");
}
try (Timer0.Context timer = args.metrics.readLatency.start();
// auto-rebuilding before this object may get passed to a ChangeUpdate.
LoadHandle handle = openHandle(repo, revision)) {
revision = handle.id();
onLoad(handle);
loaded = true;
} catch (ConfigInvalidException | IOException e) {
throw new StorageException(e);
}
return self();
}
use of com.google.gerrit.exceptions.StorageException in project gerrit by GerritCodeReview.
the class PrologRuleEvaluator method evaluate.
/**
* Evaluate the submit rules.
*
* @return {@link SubmitRecord} returned from the evaluated rules. Can include errors.
*/
public SubmitRecord evaluate() {
Change change;
try {
change = cd.change();
if (change == null) {
throw new StorageException("No change found");
}
if (projectState == null) {
throw new NoSuchProjectException(cd.project());
}
} catch (StorageException | NoSuchProjectException e) {
return ruleError("Error looking up change " + cd.getId(), e);
}
logger.atFine().log("input approvals: %s", cd.approvals());
List<Term> results;
try {
results = evaluateImpl("locate_submit_rule", "can_submit", "locate_submit_filter", "filter_submit_results");
} catch (RuleEvalException e) {
return ruleError(e.getMessage(), e);
}
if (results.isEmpty()) {
// whether or not that is actually possible given the permissions.
return ruleError(String.format("Submit rule '%s' for change %s of %s has no solution.", getSubmitRuleName(), cd.getId(), projectState.getName()));
}
SubmitRecord submitRecord = resultsToSubmitRecord(getSubmitRule(), results);
logger.atFine().log("submit record: %s", submitRecord);
return submitRecord;
}
Aggregations