use of ddf.catalog.operation.ResourceRequest in project ddf by codice.
the class TestResourceUsagePlugin method testPreResourceLocalSourceSizeNotFound.
@Test
public void testPreResourceLocalSourceSizeNotFound() throws PersistenceException, PluginExecutionException, StopProcessingException {
ResourceRequest originalRequest = getMockLocalResourceRequest(null, TEST_USER);
ResourceRequest request = plugin.process(originalRequest);
assertThat(request, is(notNullValue()));
assertThat(request, is(originalRequest));
verify(attributeStore, never()).getDataLimitByUser(anyString());
verify(attributeStore, never()).getCurrentDataUsageByUser(anyString());
}
use of ddf.catalog.operation.ResourceRequest in project ddf by codice.
the class TestResourceUsagePlugin method testPreResourceNoSubject.
@Test
public void testPreResourceNoSubject() throws StopProcessingException, PluginExecutionException, PersistenceException {
ResourceRequest originalRequest = getMockResourceRequestNoSubject(RESOURCE_SIZE);
ResourceRequest request = plugin.process(originalRequest);
assertThat(request, is(notNullValue()));
assertThat(request, is(originalRequest));
verify(attributeStore, never()).getDataLimitByUser(anyString());
verify(attributeStore, never()).getCurrentDataUsageByUser(anyString());
}
use of ddf.catalog.operation.ResourceRequest in project ddf by codice.
the class TestResourceUsagePlugin method getMockResourceRequestNoSubject.
private ResourceRequest getMockResourceRequestNoSubject(String resourceSize) {
ResourceRequest resourceRequest = getMockResourceRequest(resourceSize, null);
when(resourceRequest.getPropertyValue(SecurityConstants.SECURITY_SUBJECT)).thenReturn(null);
return resourceRequest;
}
use of ddf.catalog.operation.ResourceRequest in project ddf by codice.
the class TestResourceUsagePlugin method testPreResourceLocalSourceInvalidSize.
@Test
public void testPreResourceLocalSourceInvalidSize() throws StopProcessingException, PluginExecutionException, PersistenceException {
ResourceRequest originalRequest = getMockLocalResourceRequest("47 bytes", TEST_USER);
ResourceRequest request = plugin.process(originalRequest);
assertThat(request, is(notNullValue()));
assertThat(request, is(originalRequest));
verify(attributeStore, never()).getDataLimitByUser(anyString());
verify(attributeStore, never()).getCurrentDataUsageByUser(anyString());
}
use of ddf.catalog.operation.ResourceRequest in project ddf by codice.
the class ProcessingPostIngestPlugin method getProcessResource.
private ProcessResource getProcessResource(Metacard metacard, Subject subject) {
LOGGER.trace("Attempting to retrieve process resource metacard with id \"{}\" and sourceId \"{}\".", metacard.getId(), metacard.getSourceId());
ResourceRequest request = new ResourceRequestById(metacard.getId());
if (subject == null) {
LOGGER.debug("No available subject to fetch metacard resource. Returning null");
return null;
}
return subject.execute(() -> {
try {
ResourceResponse response = catalogFramework.getResource(request, metacard.getSourceId());
Resource resource = response.getResource();
ProcessResource processResource = new ProcessResourceImpl(metacard.getId(), resource.getInputStream(), resource.getMimeTypeValue(), resource.getName(), resource.getSize(), false);
return processResource;
} catch (IOException | ResourceNotFoundException | ResourceNotSupportedException | RuntimeException e) {
LOGGER.debug("Unable to get resource id:{}, sourceId:{}. Returning null", metacard.getId(), metacard.getSourceId(), e);
}
return null;
});
}
Aggregations