/** * PRECONDITION: argument <code>response</code> is non-null and has a method called <code> * getContentType</code> that takes no arguments and returns a String, with no side-effects. * * <p>This method allows us to get the contentType in both the servlet and portlet cases, without * introducing a compile-time dependency on the portlet api. * * @param response the current response * @return the content type of the response */ public static String getContentTypeFromResponse(Object response) { String result = null; if (null != response) { try { Method method = ReflectionUtils.lookupMethod( response.getClass(), "getContentType", RIConstants.EMPTY_CLASS_ARGS); if (null != method) { Object obj = method.invoke(response, RIConstants.EMPTY_METH_ARGS); if (null != obj) { result = obj.toString(); } } } catch (Exception e) { throw new FacesException(e); } } return result; }