Examples of GUIExceptionWrapper


Examples of de.sub.goobi.helper.exceptions.GUIExceptionWrapper

    }

    try {
      chain.doFilter(request, response);
    } catch (Exception e) {
      throw new ServletException(new GUIExceptionWrapper("Unexpected Error.", e));
    } finally {

      /* --------------------------------
       * die Hibernate-Session von der Datenbank trennen
       * --------------------------------*/
 
View Full Code Here

Examples of de.sub.goobi.helper.exceptions.GUIExceptionWrapper

      } else {
        currentSession = disconnectedSession;
      }

    } catch (Exception e) {
      throw new ServletException(new GUIExceptionWrapper(Helper.getTranslation("err_noConnectionEstablished") + " Establishing Sessions", e));
    }

    try {
      ManagedSessionContext.bind(currentSession);
    } catch (Exception e) {
      throw new ServletException(new GUIExceptionWrapper(Helper.getTranslation("err_noConnectionEstablished") + " ManagedSessionContext", e));
    }

 
    try {
      chain.doFilter(request, response);

      // cleanup after unhandled exception in program flow
    } catch (Exception e) {
      try {
        currentSession = ManagedSessionContext.unbind(this.sf);
     
      } catch (Exception e2) {
        e.setStackTrace(e2.getStackTrace());
        currentSession.disconnect();
      }

      try {
        currentSession.disconnect();
      } catch (Exception e3) {
        e.setStackTrace(e3.getStackTrace());
      }

      throw new ServletException(new GUIExceptionWrapper("Unexpected Error after calling chain.doFilter", e));
    }

    try {

      currentSession = ManagedSessionContext.unbind(this.sf);
      // now we update the hibernate session in the http session
      // or delete it in there
      // end or continue the long-running conversation?
      if (request.getAttribute(END_OF_CONVERSATION_FLAG) != null || request.getParameter(END_OF_CONVERSATION_FLAG) != null) {
        currentSession.close();
        httpSession.setAttribute(HIBERNATE_SESSION_KEY, null);
        httpSession.setMaxInactiveInterval(60);
        log.debug("<<< End of conversation");
      } else {
        //this is the only regular way aout of this filter while
        //http session is running
        httpSession.setAttribute(HIBERNATE_SESSION_KEY, currentSession);
      }

    } catch (StaleObjectStateException staleEx) {

      // Row was updated or deleted by another transaction (or
      // unsaved-value mapping was incorrect)
      throw new ServletException(new GUIExceptionWrapper("StaleObject", staleEx));

    } catch (Throwable thrbl) {
      throw new ServletException(new GUIExceptionWrapper("Unknown Exception - Execution was terminated abnormally", thrbl));
    }
  }
View Full Code Here

Examples of de.sub.goobi.helper.exceptions.GUIExceptionWrapper

      } else {
        currentSession = disconnectedSession;
      }

    } catch (Exception e) {
      throw new ServletException(new GUIExceptionWrapper(Helper.getTranslation("err_noConnectionEstablished") + " Establishing Sessions", e));
    }

    try {
      ManagedSessionContext.bind(currentSession);
    } catch (Exception e) {
      throw new ServletException(new GUIExceptionWrapper(Helper.getTranslation("err_noConnectionEstablished") + " ManagedSessionContext", e));
    }

    try {
      currentSession.beginTransaction();
    } catch (HibernateException e) {
      log.error("no database connection available", e);
      ManagedSessionContext.unbind(this.sf);
      throw new ServletException(new GUIExceptionWrapper(Helper.getTranslation("err_noConnectionEstablished") + " BeginTransaction", e));
    }

    // #################################
    // #################################
    // #################################
    // #################################
    // #### entering next filter ####

    try {
      chain.doFilter(request, response);

      // #################################
      // #################################
      // #################################
      // #################################

      // cleanup after unhandled exception in program flow
    } catch (Exception e) {
      try {
        currentSession = ManagedSessionContext.unbind(this.sf);
        currentSession.getTransaction().commit();

      } catch (Exception e2) {
        e.setStackTrace(e2.getStackTrace());
        currentSession.disconnect();
      }

      try {
        currentSession.disconnect();
      } catch (Exception e3) {
        e.setStackTrace(e3.getStackTrace());
      }

      throw new ServletException(new GUIExceptionWrapper("Unexpected Error after calling chain.doFilter", e));
    }

    try {

      currentSession = ManagedSessionContext.unbind(this.sf);

      // for the purpose of rollback we catch exception here and notify
      // gui of error
      try {
        currentSession.getTransaction().commit();
      } catch (Exception e) {
        try {
          log.error("error while committing", e);
          if (currentSession.getTransaction().isActive()) {
            currentSession.getTransaction().rollback();
            currentSession.close();
            throw new ServletException(new GUIExceptionWrapper("Unexpected Error while trying to commit and rollback active transaction."
                + "Data is probably not saved", e));
          }
        } catch (Throwable thrbl) {
          if (currentSession != null) {
            currentSession.close();
          }
          throw new ServletException(new GUIExceptionWrapper("Unexpected Error while trying to commit inactive transaction."
              + "Data is probably not saved", e));
        }
      }

      // now we update the hibernate session in the http session
      // or delete it in there
      // end or continue the long-running conversation?
      if (request.getAttribute(END_OF_CONVERSATION_FLAG) != null || request.getParameter(END_OF_CONVERSATION_FLAG) != null) {
        currentSession.close();
        httpSession.setAttribute(HIBERNATE_SESSION_KEY, null);
        httpSession.setMaxInactiveInterval(60);
        log.debug("<<< End of conversation");
      } else {
        //this is the only regular way aout of this filter while
        //http session is running
        httpSession.setAttribute(HIBERNATE_SESSION_KEY, currentSession);
      }

    } catch (StaleObjectStateException staleEx) {

      // Row was updated or deleted by another transaction (or
      // unsaved-value mapping was incorrect)
      throw new ServletException(new GUIExceptionWrapper("StaleObject", staleEx));

    } catch (Throwable thrbl) {
      throw new ServletException(new GUIExceptionWrapper("Unknown Exception - Execution was terminated abnormally", thrbl));
    }
  }
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.