/** * Constructor. * * @param client HTTP client used to fetch remove metadata * @param backgroundTaskTimer timer used to schedule background metadata refresh tasks * @param metadataURL the URL to fetch the metadata * @param backupFilePath the file that will keep a backup copy of the metadata, * * @throws MetadataProviderException thrown if the URL is not a valid URL, the metadata can not be retrieved from * the URL */ public FileBackedHTTPMetadataProvider(Timer backgroundTaskTimer, HttpClient client, String metadataURL, String backupFilePath) throws MetadataProviderException { super(backgroundTaskTimer, client, metadataURL); setBackupFile(backupFilePath); }
/** {@inheritDoc} */ protected void doInitialization() throws MetadataProviderException { try { validateBackupFile(metadataBackupFile); } catch (MetadataProviderException e) { if (isFailFastInitialization()) { log.error("Metadata backup file path was invalid, initialization is fatal"); throw e; } else { log.error("Metadata backup file path was invalid, continuing without known good backup file"); } } super.doInitialization(); }
/** {@inheritDoc} */ protected void postProcessMetadata(byte[] metadataBytes, Document metadataDom, XMLObject metadata) throws MetadataProviderException { try { validateBackupFile(metadataBackupFile); FileOutputStream out = new FileOutputStream(metadataBackupFile); out.write(metadataBytes); out.flush(); out.close(); } catch (MetadataProviderException e) { log.error("Unable to write metadata to backup file: " + metadataBackupFile.getAbsoluteFile(), e); } catch (IOException e) { log.error("Unable to write metadata to backup file: " + metadataBackupFile.getAbsoluteFile(), e); } finally { super.postProcessMetadata(metadataBytes, metadataDom, metadata); } } }
/** * Constructor. * * @param metadataURL the URL to fetch the metadata * @param requestTimeout the time, in milliseconds, to wait for the metadata server to respond * @param backupFilePath the file that will keep a backup copy of the metadata, * * @throws MetadataProviderException thrown if the URL is not a valid URL, the metadata can not be retrieved from * the URL */ @Deprecated public FileBackedHTTPMetadataProvider(String metadataURL, int requestTimeout, String backupFilePath) throws MetadataProviderException { super(metadataURL, requestTimeout); setBackupFile(backupFilePath); }