use of org.activityinfo.legacy.shared.exception.UnexpectedCommandException in project activityinfo by bedatadriven.
the class TimeoutDispatcherMock method execute.
@Override
public <T extends CommandResult> void execute(Command<T> command, AsyncCallback<T> callback) {
executeCounter.incrementAndGet();
callback.onFailure(new UnexpectedCommandException());
}
use of org.activityinfo.legacy.shared.exception.UnexpectedCommandException in project activityinfo by bedatadriven.
the class UpdateReportModelHandler method execute.
@Override
public CommandResult execute(final UpdateReportModel cmd, final User user) throws CommandException {
Query query = em.createQuery("select r from ReportDefinition r where r.id in (:id)").setParameter("id", cmd.getModel().getId());
ReportDefinition result = (ReportDefinition) query.getSingleResult();
if (result.getOwner().getId() != user.getId()) {
throw new IllegalAccessCommandException("Current user does not have the right to edit this report");
}
// Invalidate the cache BEFORE attempting to update the database,
// otherwise, we will leave the system in an inconsistent state if
// the database update succeeds, but the memcache delete fails.
invalidateMemcache(cmd.getModel().getId());
// Now that we're sure that the memcache is clear of the old copy,
// we can safely update the underlying persistant datastore
result.setTitle(cmd.getModel().getTitle());
try {
result.setXml(ReportParserJaxb.createXML(cmd.getModel()));
} catch (JAXBException e) {
throw new UnexpectedCommandException(e);
}
em.persist(result);
return null;
}
Aggregations