private String getUrl(final String url) { StringBuffer content = new StringBuffer(); try { // check to see if this URL failed before thia session if ((getSession() != null) && (getSession().getAttribute("pentaho-HtmlComponent-failed-url-" + url) != null)) { //$NON-NLS-1$ return errorMessage; } if (BaseUIComponent.debug) { debug(Messages.getInstance().getString("Html.DEBUG_GETTING_CONTENT", url)); // $NON-NLS-1$ } if (HttpUtil.getURLContent(url, content)) { return content.toString(); } else { getSession() .setAttribute( "pentaho-HtmlComponent-failed-url-" + url, ""); // $NON-NLS-1$ //$NON-NLS-2$ return errorMessage; } } catch (Exception e) { if (errorMessage != null) { return errorMessage; } else { error( Messages.getInstance() .getErrorString("Html.ERROR_0001_COULD_NOT_GET_CONTENT", url)); // $NON-NLS-1$ return Messages.getInstance() .getErrorString("Html.ERROR_0001_COULD_NOT_GET_CONTENT", url); // $NON-NLS-1$ } } }
public static String getURLContent(final String uri) { try { StringBuffer content = new StringBuffer(); HttpUtil.getURLContent(uri, content); return content.toString(); } catch (Exception e) { // TODO: handle this error Logger.error( "org.pentaho.platform.util.web.HttpUtil", Messages.getInstance().getErrorString("HttpUtil.ERROR_0001_URL_ERROR", e.getMessage()), e); //$NON-NLS-1$ //$NON-NLS-2$ return null; } }