@Test public void testDownloadUnknownDirectory() { try { this.downloadHelper.downloadFile(ORNIDROID_TEST_WEB_BASE_IMAGE_URL + "/unknown_directory", "unknownFile.jpg", TEST_DIRECTORY); Assert.fail("an exception should have occurred"); } catch (final OrnidroidException e) { Assert.assertTrue( "Error is of type link broken", e.getErrorType() .equals(OrnidroidError.ORNIDROID_DOWNLOAD_ERROR_MEDIA_DOES_NOT_EXIST)); } }
public File downloadFile(final String baseUrl, final String fileName, final String destinationPath) throws OrnidroidException { URL url; File downloadedFile = null; try { url = new URL(baseUrl + File.separator + fileName); final DefaultDownloadable mediaFileDownloadable = new DefaultDownloadable( url, destinationPath); mediaFileDownloadable.download(); checkDownloadErrors(mediaFileDownloadable); url = new URL(baseUrl + File.separator + fileName + OrnidroidFile.PROPERTIES_SUFFIX); final DefaultDownloadable propertiesFileDownloadable = new DefaultDownloadable( url, destinationPath); propertiesFileDownloadable.download(); checkDownloadErrors(mediaFileDownloadable); if ((mediaFileDownloadable.getFile() != null) && mediaFileDownloadable.getFile().exists()) { downloadedFile = mediaFileDownloadable.getFile(); } } catch (final MalformedURLException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } return downloadedFile; }
DownloadHelperImpl implements DownloadHelperInterface { public File downloadFile(final String baseUrl, final String fileName, final String destinationPath) throws OrnidroidException { URL url; File downloadedFile = null; try { url = new URL(baseUrl + File.separator + fileName); final DefaultDownloadable mediaFileDownloadable = new DefaultDownloadable( url, destinationPath); mediaFileDownloadable.download(); checkDownloadErrors(mediaFileDownloadable); url = new URL(baseUrl + File.separator + fileName + OrnidroidFile.PROPERTIES_SUFFIX); final DefaultDownloadable propertiesFileDownloadable = new DefaultDownloadable( url, destinationPath); propertiesFileDownloadable.download(); checkDownloadErrors(mediaFileDownloadable); if ((mediaFileDownloadable.getFile() != null) && mediaFileDownloadable.getFile().exists()) { downloadedFile = mediaFileDownloadable.getFile(); } } catch (final MalformedURLException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } return downloadedFile; } }
DownloadHelperImpl implements DownloadHelperInterface { public File downloadFile(final String baseUrl, final String fileName, final String destinationPath) throws OrnidroidException { URL url; File downloadedFile = null; try { url = new URL(baseUrl + File.separator + fileName); final DefaultDownloadable mediaFileDownloadable = new DefaultDownloadable( url, destinationPath); mediaFileDownloadable.download(); checkDownloadErrors(mediaFileDownloadable); url = new URL(baseUrl + File.separator + fileName + OrnidroidFile.PROPERTIES_SUFFIX); final DefaultDownloadable propertiesFileDownloadable = new DefaultDownloadable( url, destinationPath); propertiesFileDownloadable.download(); checkDownloadErrors(mediaFileDownloadable); if ((mediaFileDownloadable.getFile() != null) && mediaFileDownloadable.getFile().exists()) { downloadedFile = mediaFileDownloadable.getFile(); } } catch (final MalformedURLException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } return downloadedFile; }  }
DownloadHelperImpl implements DownloadHelperInterface { public File downloadFile(final String baseUrl, final String fileName, final String destinationPath) throws OrnidroidException { URL url; File downloadedFile = null; try { url = new URL(baseUrl + File.separator + fileName); final DefaultDownloadable mediaFileDownloadable = new DefaultDownloadable( url, destinationPath); mediaFileDownloadable.download(); checkDownloadErrors(mediaFileDownloadable); url = new URL(baseUrl + File.separator + fileName + OrnidroidFile.PROPERTIES_SUFFIX); final DefaultDownloadable propertiesFileDownloadable = new DefaultDownloadable( url, destinationPath); propertiesFileDownloadable.download(); checkDownloadErrors(mediaFileDownloadable); if ((mediaFileDownloadable.getFile() != null) && mediaFileDownloadable.getFile().exists()) { downloadedFile = mediaFileDownloadable.getFile(); } } catch (final MalformedURLException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } return downloadedFile; }  File downloadFile(final String baseUrl, final String fileName,
			final String destinationPath); List<File> downloadFiles(final String ornidroidMediaHome,
			final String directoryName, final OrnidroidFileType fileType); String getBaseUrl(final String directoryName,
			final OrnidroidFileType fileType); String[] readContentFile(final String baseUrl,
			final String destinationPath); }
DownloadHelperImpl implements DownloadHelperInterface { public File downloadFile(final String baseUrl, final String fileName, final String destinationPath) throws OrnidroidException { URL url; File downloadedFile = null; try { url = new URL(baseUrl + File.separator + fileName); final DefaultDownloadable mediaFileDownloadable = new DefaultDownloadable( url, destinationPath); mediaFileDownloadable.download(); checkDownloadErrors(mediaFileDownloadable); url = new URL(baseUrl + File.separator + fileName + OrnidroidFile.PROPERTIES_SUFFIX); final DefaultDownloadable propertiesFileDownloadable = new DefaultDownloadable( url, destinationPath); propertiesFileDownloadable.download(); checkDownloadErrors(mediaFileDownloadable); if ((mediaFileDownloadable.getFile() != null) && mediaFileDownloadable.getFile().exists()) { downloadedFile = mediaFileDownloadable.getFile(); } } catch (final MalformedURLException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } return downloadedFile; }  File downloadFile(final String baseUrl, final String fileName,
			final String destinationPath); List<File> downloadFiles(final String ornidroidMediaHome,
			final String directoryName, final OrnidroidFileType fileType); String getBaseUrl(final String directoryName,
			final OrnidroidFileType fileType); String[] readContentFile(final String baseUrl,
			final String destinationPath);  }