@Test public void testGetFinalUrlInvalid() throws IOException { sut = new ConnectionFacade(new ArrayList<ConnectionFacadeDecorator>()) { @Override protected HttpURLConnection getConnection(final String inUrl, final String inAccountId) throws MalformedURLException { return null; } }; assertEquals(URL, sut.getFinalUrl(URL, ACCOUNT_ID)); }
public String getFinalUrl(final String url, final String inAccountId) throws IOException { HttpURLConnection connection = getConnection(url, inAccountId); if (connection != null && redirectCodes.contains(connection.getResponseCode())) { String redirUrl = connection.getHeaderField("Location"); log.trace("Found redirect header to: " + redirUrl); if (redirUrl.startsWith("http: { log.trace("Changing protocol to HTTP"); return redirUrl; } } return url; }
ConnectionFacade { public String getFinalUrl(final String url, final String inAccountId) throws IOException { HttpURLConnection connection = getConnection(url, inAccountId); if (connection != null && redirectCodes.contains(connection.getResponseCode())) { String redirUrl = connection.getHeaderField("Location"); log.trace("Found redirect header to: " + redirUrl); if (redirUrl.startsWith("http: { log.trace("Changing protocol to HTTP"); return redirUrl; } } return url; } }
ConnectionFacade { public String getFinalUrl(final String url, final String inAccountId) throws IOException { HttpURLConnection connection = getConnection(url, inAccountId); if (connection != null && redirectCodes.contains(connection.getResponseCode())) { String redirUrl = connection.getHeaderField("Location"); log.trace("Found redirect header to: " + redirUrl); if (redirUrl.startsWith("http: { log.trace("Changing protocol to HTTP"); return redirUrl; } } return url; } ConnectionFacade(final List<ConnectionFacadeDecorator> inDecorators); }
ConnectionFacade { public String getFinalUrl(final String url, final String inAccountId) throws IOException { HttpURLConnection connection = getConnection(url, inAccountId); if (connection != null && redirectCodes.contains(connection.getResponseCode())) { String redirUrl = connection.getHeaderField("Location"); log.trace("Found redirect header to: " + redirUrl); if (redirUrl.startsWith("http: { log.trace("Changing protocol to HTTP"); return redirUrl; } } return url; } ConnectionFacade(final List<ConnectionFacadeDecorator> inDecorators); final List<Integer> getRedirectCodes(); final void setRedirectCodes(final List<Integer> inRedirectCodes); final String getProxyPort(); final void setProxyPort(final String inProxyPort); final String getProxyHost(); final void setProxyHost(final String inProxyHost); final int getConnectionTimeOut(); final void setConnectionTimeOut(final int inConnectionTimeOut); String downloadFile(final String url, final String inAccountId); int getImgHeight(final String url, final String inAccountId); int getImgWidth(final String url, final String inAccountId); String getHost(final String url); String getProtocol(final String url); String getPath(final String url); String getFinalUrl(final String url, final String inAccountId); int getExpectedDownloadFileLimit(); void setExpectedDownloadFileLimit(final int inExpectedDownloadFileLimit); int getMaximumDownloadFileLimit(); void setMaximumDownloadFileLimit(final int inMaximumDownloadFileLimit); }
ConnectionFacade { public String getFinalUrl(final String url, final String inAccountId) throws IOException { HttpURLConnection connection = getConnection(url, inAccountId); if (connection != null && redirectCodes.contains(connection.getResponseCode())) { String redirUrl = connection.getHeaderField("Location"); log.trace("Found redirect header to: " + redirUrl); if (redirUrl.startsWith("http: { log.trace("Changing protocol to HTTP"); return redirUrl; } } return url; } ConnectionFacade(final List<ConnectionFacadeDecorator> inDecorators); final List<Integer> getRedirectCodes(); final void setRedirectCodes(final List<Integer> inRedirectCodes); final String getProxyPort(); final void setProxyPort(final String inProxyPort); final String getProxyHost(); final void setProxyHost(final String inProxyHost); final int getConnectionTimeOut(); final void setConnectionTimeOut(final int inConnectionTimeOut); String downloadFile(final String url, final String inAccountId); int getImgHeight(final String url, final String inAccountId); int getImgWidth(final String url, final String inAccountId); String getHost(final String url); String getProtocol(final String url); String getPath(final String url); String getFinalUrl(final String url, final String inAccountId); int getExpectedDownloadFileLimit(); void setExpectedDownloadFileLimit(final int inExpectedDownloadFileLimit); int getMaximumDownloadFileLimit(); void setMaximumDownloadFileLimit(final int inMaximumDownloadFileLimit);  }