use of com.infiniteautomation.mango.util.exception.TranslatableRuntimeException in project ma-core-public by infiniteautomation.
the class EventInstanceService method acknowledgeMany.
public int acknowledgeMany(ConditionSortLimit conditions, TranslatableMessage message) {
// only users can ack events as it stores user id in events table
User user = Objects.requireNonNull(Common.getUser().getUser());
AtomicInteger total = new AtomicInteger();
long ackTimestamp = Common.timer.currentTimeMillis();
try {
if (!ackManyLock.tryLock(10, TimeUnit.SECONDS)) {
throw new TranslatableRuntimeException(new TranslatableMessage("events.acknowledgeManyFailed"));
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
try {
customizedQuery(conditions, (EventInstanceVO vo) -> {
if (hasEditPermission(user, vo)) {
EventInstance event = Common.eventManager.acknowledgeEventById(vo.getId(), ackTimestamp, user, message);
if (event != null && event.isAcknowledged()) {
total.incrementAndGet();
}
}
});
} finally {
ackManyLock.unlock();
}
return total.get();
}
use of com.infiniteautomation.mango.util.exception.TranslatableRuntimeException in project ma-core-public by infiniteautomation.
the class QueryBuilder method close.
public QueryBuilder<T> close() {
if (stack.isEmpty()) {
throw new TranslatableRuntimeException(new TranslatableMessage("dao.query.noGroupOpen"));
}
Condition condition = group.toCondition();
group = stack.pop();
group.conditions.add(condition);
return this;
}
Aggregations