@Test public void testReadContentsFromUnknownDirectory() { try { this.downloadHelper.readContentFile( ORNIDROID_TEST_WEB_BASE_IMAGE_URL + "/unknown_bird", TEST_DIRECTORY); Assert.fail("an exception should have occurred"); } catch (final OrnidroidException e) { Assert.assertTrue(true); } }
public String[] readContentFile(final String baseUrl, final String destinationPath) throws OrnidroidException { URL url; String[] filesToDownload = null; FileInputStream fis = null; try { url = new URL(baseUrl + File.separator + BasicConstants.CONTENTS_PROPERTIES); final DefaultDownloadable contentFileDownloadable = new DefaultDownloadable( url, destinationPath); contentFileDownloadable.refresh(); checkDownloadErrors(contentFileDownloadable); if (contentFileDownloadable.getFile().exists()) { filesToDownload = FileHelper .parseContentFile(contentFileDownloadable.getFile()); } } catch (final MalformedURLException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } catch (final FileNotFoundException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } catch (final IOException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } finally { if (null != fis) { try { fis.close(); fis = null; } catch (final IOException e) { throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } } } return filesToDownload; }
DownloadHelperImpl implements DownloadHelperInterface { public String[] readContentFile(final String baseUrl, final String destinationPath) throws OrnidroidException { URL url; String[] filesToDownload = null; FileInputStream fis = null; try { url = new URL(baseUrl + File.separator + BasicConstants.CONTENTS_PROPERTIES); final DefaultDownloadable contentFileDownloadable = new DefaultDownloadable( url, destinationPath); contentFileDownloadable.refresh(); checkDownloadErrors(contentFileDownloadable); if (contentFileDownloadable.getFile().exists()) { filesToDownload = FileHelper .parseContentFile(contentFileDownloadable.getFile()); } } catch (final MalformedURLException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } catch (final FileNotFoundException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } catch (final IOException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } finally { if (null != fis) { try { fis.close(); fis = null; } catch (final IOException e) { throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } } } return filesToDownload; } }
DownloadHelperImpl implements DownloadHelperInterface { public String[] readContentFile(final String baseUrl, final String destinationPath) throws OrnidroidException { URL url; String[] filesToDownload = null; FileInputStream fis = null; try { url = new URL(baseUrl + File.separator + BasicConstants.CONTENTS_PROPERTIES); final DefaultDownloadable contentFileDownloadable = new DefaultDownloadable( url, destinationPath); contentFileDownloadable.refresh(); checkDownloadErrors(contentFileDownloadable); if (contentFileDownloadable.getFile().exists()) { filesToDownload = FileHelper .parseContentFile(contentFileDownloadable.getFile()); } } catch (final MalformedURLException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } catch (final FileNotFoundException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } catch (final IOException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } finally { if (null != fis) { try { fis.close(); fis = null; } catch (final IOException e) { throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } } } return filesToDownload; }  }
DownloadHelperImpl implements DownloadHelperInterface { public String[] readContentFile(final String baseUrl, final String destinationPath) throws OrnidroidException { URL url; String[] filesToDownload = null; FileInputStream fis = null; try { url = new URL(baseUrl + File.separator + BasicConstants.CONTENTS_PROPERTIES); final DefaultDownloadable contentFileDownloadable = new DefaultDownloadable( url, destinationPath); contentFileDownloadable.refresh(); checkDownloadErrors(contentFileDownloadable); if (contentFileDownloadable.getFile().exists()) { filesToDownload = FileHelper .parseContentFile(contentFileDownloadable.getFile()); } } catch (final MalformedURLException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } catch (final FileNotFoundException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } catch (final IOException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } finally { if (null != fis) { try { fis.close(); fis = null; } catch (final IOException e) { throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } } } return filesToDownload; }  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 String[] readContentFile(final String baseUrl, final String destinationPath) throws OrnidroidException { URL url; String[] filesToDownload = null; FileInputStream fis = null; try { url = new URL(baseUrl + File.separator + BasicConstants.CONTENTS_PROPERTIES); final DefaultDownloadable contentFileDownloadable = new DefaultDownloadable( url, destinationPath); contentFileDownloadable.refresh(); checkDownloadErrors(contentFileDownloadable); if (contentFileDownloadable.getFile().exists()) { filesToDownload = FileHelper .parseContentFile(contentFileDownloadable.getFile()); } } catch (final MalformedURLException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } catch (final FileNotFoundException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } catch (final IOException e) { Log.e(BasicConstants.LOG_TAG, e.getMessage(), e); throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } finally { if (null != fis) { try { fis.close(); fis = null; } catch (final IOException e) { throw new OrnidroidException( OrnidroidError.ORNIDROID_DOWNLOAD_ERROR, e); } } } return filesToDownload; }  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);  }