/** * @param unused */ public void setUpgradeSessionFactoryBeanName(final String unused) { throw new ConfigException(getClass() + ": property [upgradeSessionFactoryBeanName] is obsolete, " + "use [jdbcSessionFactoryBeanName] instead and " + "optionnaly [jndiSessionFactoryBeanName]"); }
@Override public void handleException() throws ExceptionHandlingException { logger.error(throwable); throw new ExceptionHandlingException(throwable); }
/** * @return The request attributes. * @throws NoRequestBoundException */ static RequestAttributes getContextAttributes() throws NoRequestBoundException { RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); if (requestAttributes == null) { throw new NoRequestBoundException(); } if (!(requestAttributes instanceof ServletRequestAttributes) && !(requestAttributes instanceof PortletRequestAttributes)) { throw new IllegalArgumentException( "requestAttributes of unknown class [" + requestAttributes.getClass() + "]"); } return requestAttributes; }
throw e; } catch (Throwable t) { throw new DownloadException(t);
/** * @param unused */ public void setSessionFactoryBeanName(final String unused) { throw new ConfigException(getClass() + ": property [sessionFactoryBeanName] is obsolete, " + "use [jdbcSessionFactoryBeanName] instead and " + "optionnaly [jndiSessionFactoryBeanName]"); }
throw e; } catch (Throwable t) { throw new DownloadException(t);
/** * @return a safe exception service. */ private static ExceptionService createSafeExceptionService() { try { return new SafeExceptionServiceImpl(); } catch (Throwable t) { LOGGER.error("An exception was thhrown while getting a safe implementation, giving up", t); throw new ExceptionHandlingException(t); } }
@Override public void afterPropertiesSet() throws Exception { if (jdbcSessionFactoryBeanName == null && jndiSessionFactoryBeanName == null) { throw new ConfigException("properties [jdbcSessionFactoryBeanName] " + "and [jndiSessionFactoryBeanName] of class [" + getClass().getName() + "] can not be both null"); } }
throw e; } catch (Throwable t) { throw new DownloadException(t);
@Override public void handleException() throws ExceptionHandlingException { // try to log the throwable try { logTextReport(getThrowable(), getTextReport()); } catch (Throwable t) { logger.error("The following error was thrown by the application:", throwable); logger.error("Another throwable was thrown while logging the first one (giving up):", t); throw new ExceptionHandlingException(t); } }
@Override public void setTransactionnal(final boolean transactionnal) { throw new ConfigException( "property [" + transactionnal + "] is always true for class [" + getClass().getName() + "]"); }
logger.error("The following error was thrown by the application:", getThrowable()); logger.error("Another exception was thrown while logging the first one (giving up):", e); throw new ExceptionHandlingException(e); logger.error("The following error was thrown by the application:", getThrowable()); logger.error("another exception was thrown while sending an email alert (giving up):", e); throw new ExceptionHandlingException(e);
@Override public void initDao() throws Exception { if (jdbcHibernateTemplateBeanName == null && useJdbc ) { throw new ConfigException("property [jdbcHibernateTemplateBeanName] of " + getClass().getName() + "] can not be null when property [useJdbc] is true"); } if (jndiHibernateTemplateBeanName == null && useJndi ) { throw new ConfigException("property [jndiHibernateTemplateBeanName] of " + getClass().getName() + "] can not be null when property [useJndi] is true"); } if (!useJdbc && !useJndi) { throw new ConfigException("properties [useJdbc] and [useJndi] of class [" + getClass().getName() + "] can not be both false"); } }
/** * Add an exception view. * @param className * @param exceptionView */ @SuppressWarnings("unchecked") private void addExceptionView(final String className, final String exceptionView) { try { Class<?> clazz = Class.forName(className); if (!(Throwable.class.isAssignableFrom(clazz))) { throw new ConfigException("class [" + className + "] is not a subclass of [" + Throwable.class + "]"); } Class <? extends Throwable> exceptionClazz = (Class <? extends Throwable>) clazz; this.exceptionViews.put(exceptionClazz, exceptionView); } catch (ClassNotFoundException e) { throw new ConfigException(e); } }
/** * Add a 'no email' exception. * @param className */ @SuppressWarnings("unchecked") private void addNoEmailException(final String className) { try { Class<?> clazz = Class.forName(className); if (!(Exception.class.isAssignableFrom(clazz))) { throw new ConfigException("class [" + className + "] is not a subclass of [" + Exception.class + "]"); } Class<? extends Throwable> exceptionClazz = (Class<? extends Throwable>) clazz; this.noEmailExceptions.add(exceptionClazz); } catch (ClassNotFoundException e) { throw new ConfigException(e); } }
@Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); if (jdbcUpgradeSessionFactoryBeanName == null && jndiUpgradeSessionFactoryBeanName == null) { throw new ConfigException("properties [jdbcUpgradeSessionFactoryBeanName] " + "and [jndiUpgradeSessionFactoryBeanName] of class [" + getClass().getName() + "] can not be both null"); } Assert.hasText(createSessionFactoryBeanName, "property [createSessionFactoryBeanName] of class [" + getClass().getName() + "] can not be null"); }
/** * @param t * @param to * @param interceipt * @return the cache key that corresponds to a user and an exception. */ private String getCacheKey( final Throwable t, final InternetAddress to, final boolean interceipt) { try { MessageDigest md = MessageDigest.getInstance("MD5"); md.reset(); md.update(ExceptionUtils.getPrintableStackTrace(t).getBytes()); return to.toString() + " - " + new String(md.digest()) + interceipt; } catch (NoSuchAlgorithmException e2) { throw new ConfigException(e2); } }
@Override public void afterPropertiesSet() { super.afterPropertiesSet(); if (!exceptionViews.containsKey(Exception.class)) { setExceptionView(DEFAULT_EXCEPTION_VIEW); } if (!StringUtils.hasText(logLevel)) { logLevel = ERROR; } if (!ERROR.equalsIgnoreCase(logLevel) && !WARN.equalsIgnoreCase(logLevel) && !INFO.equalsIgnoreCase(logLevel) && !TRACE.equalsIgnoreCase(logLevel) && !DEBUG.equalsIgnoreCase(logLevel)) { throw new ConfigException("invalid value for property [logLevel], " + "accepted values are ERROR, WARN, INFO, TRACE and DEBUG"); } }
/** * return all list UrlPatternDescriptor. */ private List<UrlPatternDescriptor> getUrlDescriptor() { //ADD Action Map<String, UrlPatternDescriptor> treatments = BeanUtils.getBeansOfClass(UrlPatternDescriptor.class); List<UrlPatternDescriptor> urlP = new ArrayList<UrlPatternDescriptor>(); for (String name : treatments.keySet()) { if (logger.isDebugEnabled()) { logger.debug("get to roles bean [" + name + "]..."); } UrlPatternDescriptor bean = treatments.get(name); if (bean == null) { throw new ConfigException("bean [" + name + "] is null, " + "application doesn't init action."); } urlP.add(bean); } return urlP; }
/** * return all list UrlPatternDescriptor. */ private List<UrlPatternDescriptor> getUrlDescriptor() { //ADD Action Map<String, UrlPatternDescriptor> treatments = BeanUtils.getBeansOfClass(UrlPatternDescriptor.class); List<UrlPatternDescriptor> urlP = new ArrayList<UrlPatternDescriptor>(); for (String name : treatments.keySet()) { if (logger.isDebugEnabled()) { logger.debug("get to roles bean [" + name + "]..."); } UrlPatternDescriptor bean = treatments.get(name); if (bean == null) { throw new ConfigException("bean [" + name + "] is null, " + "application doesn't init action."); } urlP.add(bean); } return urlP; }