use of org.codice.ddf.catalog.plugin.metacard.backup.storage.internal.MetacardBackupStorageProvider in project ddf by codice.
the class MetacardBackupPlugin method backupData.
private void backupData(BinaryContent content, String metacardId) throws PluginExecutionException {
byte[] contentBytes = getContentBytes(content, metacardId);
LOGGER.trace("Writing backup from {} to backup provider(s)", metacardId);
for (MetacardBackupStorageProvider storageProvider : storageBackupPlugins) {
if (metacardOutputProviderIds.contains(storageProvider.getId())) {
try {
storageProvider.store(metacardId, contentBytes);
} catch (IOException | MetacardBackupException e) {
LOGGER.debug("Unable to backup {} to backup provider: {}.", metacardId, storageProvider.getId(), e);
}
}
}
}
use of org.codice.ddf.catalog.plugin.metacard.backup.storage.internal.MetacardBackupStorageProvider in project ddf by codice.
the class MetacardBackupPluginTest method setUp.
@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
metacardTransformer = mock(MetacardTransformer.class);
BinaryContent binaryContent = new BinaryContentImpl(new ByteArrayInputStream(XML_METADATA.getBytes(StandardCharsets.UTF_8)));
when(metacardTransformer.transform(any(Metacard.class), anyMap())).thenReturn(binaryContent);
doThrow(new MetacardBackupException("Not Implemented")).when(mockProvider).store(any(), any());
doThrow(new MetacardBackupException("Not Implemented")).when(mockProvider).delete(any());
doReturn(MOCK_ID).when(mockProvider).getId();
metacardBackupPlugin = new MetacardBackupPlugin();
metacardBackupPlugin.setMetacardTransformerId(METACARD_TRANSFORMER_ID);
metacardBackupPlugin.setMetacardTransformer(metacardTransformer);
createRequest = generateProcessRequest(ProcessCreateItem.class, true);
updateRequest = generateProcessRequest(ProcessUpdateItem.class, true);
deleteRequest = generateDeleteRequest();
fileStorageProvider.setId(FILE_STORAGE_PROVIDER_ID);
fileStorageProvider.setOutputDirectory(OUTPUT_DIRECTORY);
metacardBackupPlugin.setMetacardOutputProviderIds(Collections.singletonList(FILE_STORAGE_PROVIDER_ID));
metacardBackupPlugin.setStorageBackupPlugins(Arrays.asList(new MetacardBackupStorageProvider[] { fileStorageProvider }));
}
Aggregations