Search in sources :

Example 26 with NoSuchPropertyException

use of jp.ossc.nimbus.beans.NoSuchPropertyException in project nimbus by nimbus-org.

the class DefaultExceptionHandlerService method handleException.

public void handleException(Throwable th, ServletRequest request, ServletResponse response) throws Throwable {
    if (logMessageCode != null) {
        final Logger log = super.getLogger();
        if (isOutputStackTraceLog) {
            log.write(logMessageCode, logMessageArguments, th);
        } else {
            log.write(logMessageCode, logMessageArguments);
        }
    }
    if (journal != null) {
        journal.addInfo(exceptionJournalKey, th, exceptionEditorFinder);
    }
    if (httpResponseStatus != -1 && response instanceof HttpServletResponse) {
        if (httpResponseStatusMessage == null) {
            ((HttpServletResponse) response).setStatus(httpResponseStatus);
        } else {
            ((HttpServletResponse) response).sendError(httpResponseStatus, httpResponseStatusMessage);
        }
    }
    if (responseObject != null || responseObjectServiceName != null) {
        Object resObj = responseObject;
        if (responseObjectServiceName != null) {
            resObj = ServiceManagerFactory.getServiceObject(responseObjectServiceName);
        }
        if (exceptionAndResponseObjectPropertyMapping != null) {
            Iterator entries = exceptionAndResponseObjectPropertyMapping.entrySet().iterator();
            while (entries.hasNext()) {
                Map.Entry entry = (Map.Entry) entries.next();
                try {
                    Object val = propertyAccess.get(th, (String) entry.getKey());
                    if (val != null) {
                        propertyAccess.set(resObj, (String) entry.getValue(), val);
                    }
                } catch (IllegalArgumentException e) {
                } catch (NoSuchPropertyException e) {
                } catch (InvocationTargetException e) {
                }
            }
        }
        request.setAttribute(responseObjectAttributeName, resObj);
    }
    if (isThrowException) {
        throw th;
    } else if (forwardPath != null) {
        final RequestDispatcher rd = request.getRequestDispatcher(forwardPath);
        if (rd != null) {
            request.setAttribute(REQUEST_ATTIBUTE_EXCEPTION_KEY, th);
            rd.forward(request, response);
        }
    } else if (redirectPath != null && response instanceof HttpServletResponse) {
        ((HttpServletResponse) response).sendRedirect(((HttpServletResponse) response).encodeRedirectURL(redirectPath));
    }
}
Also used : Iterator(java.util.Iterator) NoSuchPropertyException(jp.ossc.nimbus.beans.NoSuchPropertyException) HttpServletResponse(javax.servlet.http.HttpServletResponse) Logger(jp.ossc.nimbus.service.log.Logger) Map(java.util.Map) InvocationTargetException(java.lang.reflect.InvocationTargetException) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 27 with NoSuchPropertyException

use of jp.ossc.nimbus.beans.NoSuchPropertyException in project nimbus by nimbus-org.

the class PropertyWritableRecordFactoryService method getElementValue.

protected Object getElementValue(String key, Object elements, Map propMapping) {
    if (propMapping != null && propMapping.containsKey(key)) {
        final Logger logger = getLogger();
        final Property prop = (Property) propMapping.get(key);
        try {
            return prop.getProperty(elements);
        } catch (NoSuchPropertyException e) {
            return null;
        } catch (InvocationTargetException e) {
            logger.write(PWRF_00001, key, e);
            return null;
        }
    } else {
        return super.getElementValue(key, elements);
    }
}
Also used : NoSuchPropertyException(jp.ossc.nimbus.beans.NoSuchPropertyException) SimpleProperty(jp.ossc.nimbus.beans.SimpleProperty) Property(jp.ossc.nimbus.beans.Property)

Aggregations

NoSuchPropertyException (jp.ossc.nimbus.beans.NoSuchPropertyException)27 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 Map (java.util.Map)13 HashMap (java.util.HashMap)11 Iterator (java.util.Iterator)11 Property (jp.ossc.nimbus.beans.Property)8 RecordList (jp.ossc.nimbus.beans.dataset.RecordList)7 LinkedHashMap (java.util.LinkedHashMap)6 List (java.util.List)6 ArrayList (java.util.ArrayList)5 NestedProperty (jp.ossc.nimbus.beans.NestedProperty)5 SQLException (java.sql.SQLException)4 SimpleProperty (jp.ossc.nimbus.beans.SimpleProperty)4 DataSet (jp.ossc.nimbus.beans.dataset.DataSet)4 Record (jp.ossc.nimbus.beans.dataset.Record)4 ParameterMetaData (java.sql.ParameterMetaData)3 ResultSet (java.sql.ResultSet)3 ResultSetMetaData (java.sql.ResultSetMetaData)3 IndexedProperty (jp.ossc.nimbus.beans.IndexedProperty)3 PropertyEditor (java.beans.PropertyEditor)2