本文整理汇总了Java中com.google.gwtorm.server.OrmException类的典型用法代码示例。如果您正苦于以下问题:Java OrmException类的具体用法?Java OrmException怎么用?Java OrmException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OrmException类属于com.google.gwtorm.server包,在下文中一共展示了OrmException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAccessSection
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
private AccessSectionInfo createAccessSection(
Map<AccountGroup.UUID, GroupInfo> groups, AccessSection section) throws OrmException {
AccessSectionInfo accessSectionInfo = new AccessSectionInfo();
accessSectionInfo.permissions = new HashMap<>();
for (Permission p : section.getPermissions()) {
PermissionInfo pInfo = new PermissionInfo(p.getLabel(), p.getExclusiveGroup() ? true : null);
pInfo.rules = new HashMap<>();
for (PermissionRule r : p.getRules()) {
PermissionRuleInfo info =
new PermissionRuleInfo(ACTION_TYPE.get(r.getAction()), r.getForce());
if (r.hasRange()) {
info.max = r.getMax();
info.min = r.getMin();
}
AccountGroup.UUID group = r.getGroup().getUUID();
if (group != null) {
pInfo.rules.put(group.get(), info);
loadGroup(groups, group);
}
}
accessSectionInfo.permissions.put(p.getName(), pInfo);
}
return accessSectionInfo;
}
示例2: scanReviewDb
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
private Stream<ChangeNotesResult> scanReviewDb(Repository repo, ReviewDb db)
throws IOException {
// Scan IDs that might exist in ReviewDb, assuming that each change has at least one patch set
// ref. Not all changes might exist: some patch set refs might have been written where the
// corresponding ReviewDb write failed. These will be silently filtered out by the batch get
// call below, which is intended.
Set<Change.Id> ids = scanChangeIds(repo).fromPatchSetRefs();
// A batch size of N may overload get(Iterable), so use something smaller, but still >1.
return Streams.stream(Iterators.partition(ids.iterator(), 30))
.flatMap(
batch -> {
try {
return Streams.stream(ReviewDbUtil.unwrapDb(db).changes().get(batch))
.map(this::toResult)
.filter(Objects::nonNull);
} catch (OrmException e) {
// Return this error for each Id in the input batch.
return batch.stream().map(id -> ChangeNotesResult.error(id, e));
}
});
}
示例3: getRecipientsFromFooters
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
public static MailRecipients getRecipientsFromFooters(
AccountResolver accountResolver, List<FooterLine> footerLines)
throws OrmException, IOException {
MailRecipients recipients = new MailRecipients();
for (FooterLine footerLine : footerLines) {
try {
if (isReviewer(footerLine)) {
recipients.reviewers.add(toAccountId(accountResolver, footerLine.getValue().trim()));
} else if (footerLine.matches(FooterKey.CC)) {
recipients.cc.add(toAccountId(accountResolver, footerLine.getValue().trim()));
}
} catch (NoSuchAccountException e) {
continue;
}
}
return recipients;
}
示例4: onHashtagsEdited
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
@Override
public void onHashtagsEdited(HashtagsEditedListener.Event ev) {
try {
Change change = getChange(ev.getChange());
HashtagsChangedEvent event = new HashtagsChangedEvent(change);
event.change = changeAttributeSupplier(change);
event.editor = accountAttributeSupplier(ev.getWho());
event.hashtags = hashtagArray(ev.getHashtags());
event.added = hashtagArray(ev.getAddedHashtags());
event.removed = hashtagArray(ev.getRemovedHashtags());
dispatcher.get().postEvent(change, event);
} catch (OrmException | PermissionBackendException e) {
log.error("Failed to dispatch event", e);
}
}
示例5: updateChange
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
@Override
public boolean updateChange(ChangeContext ctx) throws OrmException {
StringBuilder sb =
new StringBuilder("Patch Set ")
.append(psId.get())
.append(": Cherry Picked")
.append("\n\n")
.append("This patchset was cherry picked to branch ")
.append(destBranch)
.append(" as commit ")
.append(cherryPickCommit.name());
ChangeMessage changeMessage =
ChangeMessagesUtil.newMessage(
psId,
ctx.getUser(),
ctx.getWhen(),
sb.toString(),
ChangeMessagesUtil.TAG_CHERRY_PICK_CHANGE);
cmUtil.addChangeMessage(ctx.getDb(), ctx.getUpdate(psId), changeMessage);
return true;
}
示例6: preUpdateSchema
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
@Override
protected void preUpdateSchema(ReviewDb db) throws OrmException, SQLException {
JdbcSchema schema = (JdbcSchema) db;
Connection connection = schema.getConnection();
String tableName = "patch_sets";
String oldColumnName = "push_certficate";
String newColumnName = "push_certificate";
Set<String> columns = schema.getDialect().listColumns(connection, tableName);
if (columns.contains(oldColumnName)) {
renameColumn(db, tableName, oldColumnName, newColumnName);
}
try (Statement stmt = schema.getConnection().createStatement()) {
stmt.execute("ALTER TABLE " + tableName + " MODIFY " + newColumnName + " clob");
} catch (SQLException e) {
// Ignore. Type may have already been modified manually.
}
}
示例7: markReviewed
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
@Override
public boolean markReviewed(PatchSet.Id psId, Account.Id accountId, String path)
throws OrmException {
try (Connection con = ds.getConnection();
PreparedStatement stmt =
con.prepareStatement(
"INSERT INTO account_patch_reviews "
+ "(account_id, change_id, patch_set_id, file_name) VALUES "
+ "(?, ?, ?, ?)")) {
stmt.setInt(1, accountId.get());
stmt.setInt(2, psId.getParentKey().get());
stmt.setInt(3, psId.get());
stmt.setString(4, path);
stmt.executeUpdate();
return true;
} catch (SQLException e) {
OrmException ormException = convertError("insert", e);
if (ormException instanceof OrmDuplicateKeyException) {
return false;
}
throw ormException;
}
}
示例8: updateGroups
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
private static void updateGroups(
ReviewDb db, GroupCollector collector, ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha)
throws OrmException {
Map<PatchSet.Id, PatchSet> patchSets =
db.patchSets().toMap(db.patchSets().get(patchSetsBySha.values()));
for (Map.Entry<ObjectId, Collection<String>> e : collector.getGroups().asMap().entrySet()) {
for (PatchSet.Id psId : patchSetsBySha.get(e.getKey())) {
PatchSet ps = patchSets.get(psId);
if (ps != null) {
ps.setGroups(ImmutableList.copyOf(e.getValue()));
}
}
}
db.patchSets().update(patchSets.values());
}
示例9: byChange
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
public ImmutableMap<Account.Id, StarRef> byChange(Change.Id changeId) throws OrmException {
try (Repository repo = repoManager.openRepository(allUsers)) {
ImmutableMap.Builder<Account.Id, StarRef> builder = ImmutableMap.builder();
for (String refPart : getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId))) {
Integer id = Ints.tryParse(refPart);
if (id == null) {
continue;
}
Account.Id accountId = new Account.Id(id);
builder.put(accountId, readLabels(repo, RefNames.refsStarredChanges(changeId, accountId)));
}
return builder.build();
} catch (IOException e) {
throw new OrmException(
String.format("Get accounts that starred change %d failed", changeId.get()), e);
}
}
示例10: updateChange
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
@Override
public boolean updateChange(ChangeContext ctx)
throws RestApiException, OrmException, IOException, NoSuchChangeException {
checkState(
ctx.getOrder() == Order.DB_BEFORE_REPO, "must use DeleteChangeOp with DB_BEFORE_REPO");
checkState(id == null, "cannot reuse DeleteChangeOp");
id = ctx.getChange().getId();
Collection<PatchSet> patchSets = psUtil.byChange(ctx.getDb(), ctx.getNotes());
ensureDeletable(ctx, id, patchSets);
// Cleaning up is only possible as long as the change and its elements are
// still part of the database.
cleanUpReferences(ctx, id, patchSets);
deleteChangeElementsFromDb(ctx, id);
ctx.deleteChange();
return true;
}
示例11: init
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
@Override
protected void init() throws EmailException {
super.init();
try {
// Upgrade watching owners from CC and BCC to TO.
Watchers matching =
getWatchers(NotifyType.NEW_CHANGES, !change.isWorkInProgress() && !change.isPrivate());
// TODO(hiesel): Remove special handling for owners
StreamSupport.stream(matching.all().accounts.spliterator(), false)
.filter(acc -> isOwnerOfProjectOrBranch(acc))
.forEach(acc -> add(RecipientType.TO, acc));
// Add everyone else. Owners added above will not be duplicated.
add(RecipientType.TO, matching.to);
add(RecipientType.CC, matching.cc);
add(RecipientType.BCC, matching.bcc);
} catch (OrmException err) {
// Just don't CC everyone. Better to send a partial message to those
// we already have queued up then to fail deliver entirely to people
// who have a lower interest in the change.
log.warn("Cannot notify watchers for new change", err);
}
includeWatchers(NotifyType.NEW_PATCHSETS, !change.isWorkInProgress() && !change.isPrivate());
}
示例12: format
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
public AgreementInfo format(ContributorAgreement ca) {
AgreementInfo info = new AgreementInfo();
info.name = ca.getName();
info.description = ca.getDescription();
info.url = ca.getAgreementUrl();
GroupReference autoVerifyGroup = ca.getAutoVerify();
if (autoVerifyGroup != null && self.get().isIdentifiedUser()) {
IdentifiedUser user = identifiedUserFactory.create(self.get().getAccountId());
try {
GroupControl gc = genericGroupControlFactory.controlFor(user, autoVerifyGroup.getUUID());
GroupResource group = new GroupResource(gc);
info.autoVerifyGroup = groupJson.format(group);
} catch (NoSuchGroupException | OrmException e) {
log.warn(
"autoverify group \""
+ autoVerifyGroup.getName()
+ "\" does not exist, referenced in CLA \""
+ ca.getName()
+ "\"");
}
}
return info;
}
示例13: byUserName
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
private AuthResult byUserName(String userName) {
try {
List<AccountState> accountStates =
queryProvider.get().byExternalId(SCHEME_USERNAME, userName);
if (accountStates.isEmpty()) {
getServletContext().log("No accounts with username " + userName + " found");
return null;
}
if (accountStates.size() > 1) {
getServletContext().log("Multiple accounts with username " + userName + " found");
return null;
}
return auth(accountStates.get(0).getAccount().getId());
} catch (OrmException e) {
getServletContext().log("cannot query account index", e);
return null;
}
}
示例14: apply
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
@Override
public Response<EmailInfo> apply(AccountResource rsrc, EmailInput input)
throws AuthException, BadRequestException, ResourceConflictException,
ResourceNotFoundException, OrmException, EmailException, MethodNotAllowedException,
IOException, ConfigInvalidException, PermissionBackendException {
if (self.get() != rsrc.getUser() || input.noConfirmation) {
permissionBackend.user(self).check(GlobalPermission.MODIFY_ACCOUNT);
}
if (input == null) {
input = new EmailInput();
}
if (!validator.isValid(email)) {
throw new BadRequestException("invalid email address");
}
if (!realm.allowsEdit(AccountFieldName.REGISTER_NEW_EMAIL)) {
throw new MethodNotAllowedException("realm does not allow adding emails");
}
return apply(rsrc.getUser(), input);
}
示例15: unresolvedCommentCount
import com.google.gwtorm.server.OrmException; //导入依赖的package包/类
public Integer unresolvedCommentCount() throws OrmException {
if (unresolvedCommentCount == null) {
if (!lazyLoad) {
return null;
}
List<Comment> comments =
Stream.concat(publishedComments().stream(), robotComments().stream()).collect(toList());
Set<String> nonLeafSet = comments.stream().map(c -> c.parentUuid).collect(toSet());
Long count =
comments.stream().filter(c -> (c.unresolved && !nonLeafSet.contains(c.key.uuid))).count();
unresolvedCommentCount = count.intValue();
}
return unresolvedCommentCount;
}