Examples of SimpleMessageException


Examples of org.damour.base.client.exceptions.SimpleMessageException

    Logger.log("Ping received from: " + getThreadLocalRequest().getRemoteAddr());
  }

  public String executeHQL(String query, boolean executeUpdate) {
    if (StringUtils.isEmpty(query)) {
      throw new SimpleMessageException("Query not supplied.");
    }
    User authUser = getAuthenticatedUser(session.get());
    if (authUser == null || !authUser.isAdministrator()) {
      throw new SimpleMessageException("Insufficient authorization.");
    }
    Transaction tx = null;
    try {
      tx = session.get().beginTransaction();
      String result;
      if (executeUpdate) {
        result = "Rows affected: " + session.get().createQuery(query).executeUpdate();
      } else {
        List<?> list = session.get().createQuery(query).list();
        result = "Objects returned: " + list.size() + "\r\n";
        for (int i = 0; i < list.size(); i++) {
          result += "Obj[" + i + "]: " + list.get(i).toString() + "\r\n";
        }
      }

      tx.commit();
      return result;
    } catch (Throwable t) {
      Logger.log(t);
      try {
        tx.rollback();
      } catch (Throwable tt) {
      }
      throw new SimpleMessageException(t.getMessage());
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.