use of ddf.catalog.plugin.PluginExecutionException in project ddf by codice.
the class RestReplicatorPlugin method transform.
private String transform(Metacard m, WebClient client) throws PluginExecutionException {
BinaryContent binaryContent;
try {
binaryContent = transformer.transform(m, new HashMap<>());
client.type(getValidMimeType(binaryContent.getMimeTypeValue()));
return new String(binaryContent.getByteArray(), StandardCharsets.UTF_8);
} catch (IOException e) {
LOGGER.debug("Could not understand metacard.", e);
throw new PluginExecutionException("Could not send metacard.");
} catch (CatalogTransformerException e) {
LOGGER.debug("Could not transform metacard.", e);
throw new PluginExecutionException("Could not send metacard.");
}
}
use of ddf.catalog.plugin.PluginExecutionException in project ddf by codice.
the class MetacardBackupPlugin method processRequest.
private void processRequest(ProcessRequest<? extends ProcessResourceItem> processRequest) throws PluginExecutionException {
if (CollectionUtils.isEmpty(storageBackupPlugins)) {
throw new PluginExecutionException("Unable to backup ingested metacard; no metacard backup storage provider configured.");
}
if (metacardTransformer == null) {
throw new PluginExecutionException("Unable to backup ingested metacard; no Metacard Transformer found.");
}
List<? extends ProcessResourceItem> processResourceItems = processRequest.getProcessItems();
for (ProcessResourceItem processResourceItem : processResourceItems) {
Metacard metacard = processResourceItem.getMetacard();
if (shouldBackupMetacard(metacard)) {
try {
LOGGER.trace("Backing up metacard : {}", metacard.getId());
BinaryContent binaryContent = metacardTransformer.transform(metacard, Collections.emptyMap());
backupData(binaryContent, metacard.getId());
} catch (CatalogTransformerException e) {
LOGGER.debug("Unable to transform metacard with id {}.", metacard.getId(), e);
throw new PluginExecutionException(String.format("Unable to transform metacard with id %s.", metacard.getId()));
}
}
}
}
use of ddf.catalog.plugin.PluginExecutionException in project ddf by codice.
the class ExpirationDatePlugin method process.
/**
* Modify metacard expiration dates (pre-ingest).
*/
@Override
public CreateRequest process(CreateRequest createRequest) throws PluginExecutionException, StopProcessingException {
LOGGER.debug("START Pre-Ingest Plugin: {}.process(CreateRequest createRequest)", this.getClass().getName());
if (createRequest == null || createRequest.getMetacards() == null || createRequest.getMetacards().isEmpty()) {
throw new PluginExecutionException("No metacards to validate or CreateRequest is null");
}
List<Metacard> metacards = createRequest.getMetacards();
for (Metacard metacard : metacards) {
updateExpirationDate(metacard);
}
LOGGER.debug("END Pre-Ingest Plugin: {}.process(CreateRequest createRequest)", this.getClass().getName());
return createRequest;
}
use of ddf.catalog.plugin.PluginExecutionException in project ddf by codice.
the class RegistryIdPostIngestPlugin method init.
/**
* Init method initializes the id sets from the catalog. If the catalog is not available it
* will retry later.
*/
public void init() {
try {
List<Metacard> registryMetacards;
Filter registryFilter = filterBuilder.anyOf(filterBuilder.attribute(Metacard.TAGS).is().equalTo().text(RegistryConstants.REGISTRY_TAG), filterBuilder.attribute(Metacard.TAGS).is().equalTo().text(RegistryConstants.REGISTRY_TAG_INTERNAL));
QueryImpl query = new QueryImpl(registryFilter);
query.setPageSize(PAGE_SIZE);
QueryRequest request = new QueryRequestImpl(query);
QueryResponse response = security.runAsAdminWithException(() -> security.runWithSubjectOrElevate(() -> catalogFramework.query(request)));
if (response == null) {
throw new PluginExecutionException("Failed to initialize RegistryIdPostIngestPlugin. Query for registry metacards came back null");
}
registryMetacards = response.getResults().stream().map(Result::getMetacard).collect(Collectors.toList());
addIdsFromMetacards(registryMetacards);
} catch (PrivilegedActionException | PluginExecutionException e) {
LOGGER.debug("Error getting registry metacards. Will try again later");
executorService.schedule(this::init, RETRY_INTERVAL, TimeUnit.SECONDS);
}
}
use of ddf.catalog.plugin.PluginExecutionException in project ddf by codice.
the class VideoThumbnailPlugin method createThumbnail.
private void createThumbnail(final ContentItem contentItem, final Path contentPath) throws PluginExecutionException {
LOGGER.debug("About to create video thumbnail.");
try {
limitFFmpegProcessesSemaphore.acquire();
try {
final byte[] thumbnailBytes = createThumbnail(contentPath.toAbsolutePath().toString());
addThumbnailAttribute(contentItem, thumbnailBytes);
LOGGER.debug("Successfully created video thumbnail.");
} finally {
limitFFmpegProcessesSemaphore.release();
}
} catch (IOException | InterruptedException e) {
throw new PluginExecutionException(e);
} finally {
deleteImageFiles();
}
}
Aggregations