use of ddf.catalog.transform.CatalogTransformerException in project alliance by codice.
the class OverviewSupplier method apply.
@Override
public Optional<BufferedImage> apply(Metacard metacard, Map<String, Serializable> arguments) {
try {
final Map<String, Serializable> resourceTransformerArguments = new HashMap<>();
resourceTransformerArguments.put(ContentItem.QUALIFIER_KEYWORD, "overview");
final BinaryContent overviewContent = resourceMetacardTransformer.transform(metacard, resourceTransformerArguments);
try (final InputStream inputStream = overviewContent.getInputStream()) {
return Optional.ofNullable(ImageIO.read(inputStream));
}
} catch (IOException | CatalogTransformerException e) {
LOGGER.debug("Could not get the overview image.", e);
}
return Optional.empty();
}
use of ddf.catalog.transform.CatalogTransformerException in project alliance by codice.
the class MpegTsInputTransformer method extractInnerTransformerMetadata.
/**
* Call the inner transformer with the content data and return a metacard based on {@link
* #metacardTypes} that is populated by the inner transformer and with the content type set to
* {@link #CONTENT_TYPE}.
*
* @param id metacard identifier
* @param fileBackedOutputStream used to provide a byte source
* @return metacard
* @throws IOException
* @throws CatalogTransformerException
*/
private MetacardImpl extractInnerTransformerMetadata(String id, TemporaryFileBackedOutputStream fileBackedOutputStream) throws IOException, CatalogTransformerException {
try (InputStream inputStream = fileBackedOutputStream.asByteSource().openStream()) {
MetacardType metacardType = metacardTypes.stream().findFirst().orElseThrow(() -> new CatalogTransformerException("no matching metacard type found! id = " + id));
Metacard innerMetacard = innerTransformer.transform(inputStream, id);
MetacardImpl metacard = new MetacardImpl(innerMetacard, metacardType);
metacard.setContentTypeName(CONTENT_TYPE);
return metacard;
}
}
use of ddf.catalog.transform.CatalogTransformerException in project alliance by codice.
the class MpegTsInputTransformer method populateFileBackedOutputStream.
private void populateFileBackedOutputStream(InputStream inputStream, TemporaryFileBackedOutputStream fbos) throws CatalogTransformerException {
try {
int c = IOUtils.copy(inputStream, fbos);
LOGGER.debug("copied {} bytes from input stream to file backed output stream", c);
} catch (IOException e) {
throw new CatalogTransformerException("Could not copy bytes of content message.", e);
}
}
use of ddf.catalog.transform.CatalogTransformerException in project alliance by codice.
the class MpegTsInputTransformer method extractStanag4609Metadata.
private void extractStanag4609Metadata(MetacardImpl metacard, TemporaryFileBackedOutputStream fbos) throws IOException, CatalogTransformerException {
Stanag4609Parser stanag4609Parser = stanagParserFactory.createParser(fbos.asByteSource());
Map<Integer, List<DecodedKLVMetadataPacket>> decodedMetadata;
try {
decodedMetadata = stanag4609Parser.parse();
} catch (Stanag4609ParseException e) {
throw new CatalogTransformerException("failed to extract STANAG 4609 metadata", e);
}
Map<String, KlvHandler> handlers = klvHandlerFactory.createStanag4609Handlers();
stanag4609Processor.handle(handlers, defaultKlvHandler, decodedMetadata);
KlvProcessor.Configuration klvProcessConfiguration = new KlvProcessor.Configuration();
klvProcessConfiguration.set(KlvProcessor.Configuration.SUBSAMPLE_COUNT, subsampleCount);
klvProcessConfiguration.getGeometryOperatorContext().setDistanceTolerance(distanceTolerance);
klvProcessor.process(handlers, metacard, klvProcessConfiguration);
}
use of ddf.catalog.transform.CatalogTransformerException in project ddf by codice.
the class CatalogFrameworkImplTest method testQueryTransformWithTransformException.
@Test(expected = CatalogTransformerException.class)
public void testQueryTransformWithTransformException() throws Exception {
BundleContext context = mock(BundleContext.class);
QueryResponseTransformer transformer = mock(QueryResponseTransformer.class);
ServiceReference reference = mock(ServiceReference.class);
ServiceReference[] serviceReferences = new ServiceReference[] { reference };
when(context.getServiceReferences(anyString(), anyString())).thenReturn(serviceReferences);
when(context.getService(isA(ServiceReference.class))).thenReturn(transformer);
when(transformer.transform(isA(SourceResponse.class), isA(Map.class))).thenThrow(new CatalogTransformerException("Could not transform"));
CatalogFramework framework = this.createDummyCatalogFramework(provider, storageProvider, context, eventAdmin, true);
SourceResponse response = new SourceResponseImpl(null, null);
framework.transform(response, "NONE", new HashMap<String, Serializable>());
}
Aggregations