use of ddf.catalog.operation.ResourceRequest in project ddf by codice.
the class ZipCompression method getResource.
private Resource getResource(Metacard metacard) {
Resource resource = null;
try {
ResourceRequest resourceRequest = new ResourceRequestById(metacard.getId());
ResourceResponse resourceResponse = catalogFramework.getLocalResource(resourceRequest);
resource = resourceResponse.getResource();
} catch (IOException | ResourceNotFoundException | ResourceNotSupportedException e) {
LOGGER.debug("Unable to retrieve content from metacard : {}", metacard.getId(), e);
}
return resource;
}
use of ddf.catalog.operation.ResourceRequest in project ddf by codice.
the class TestResourceUsagePlugin method getMockResourceRequest.
private ResourceRequest getMockResourceRequest(String resourceSize, String expectedUsername) {
setSubject(expectedUsername);
ResourceRequest resourceRequest = mock(ResourceRequest.class);
Map<String, Serializable> requestProperties = new HashMap<>();
requestProperties.put(SecurityConstants.SECURITY_SUBJECT, subject);
requestProperties.put(Metacard.RESOURCE_SIZE, resourceSize);
when(resourceRequest.getPropertyNames()).thenReturn(requestProperties.keySet());
when(resourceRequest.getPropertyValue(SecurityConstants.SECURITY_SUBJECT)).thenReturn(subject);
when(resourceRequest.getPropertyValue(Metacard.RESOURCE_SIZE)).thenReturn(resourceSize);
return resourceRequest;
}
use of ddf.catalog.operation.ResourceRequest in project ddf by codice.
the class TestResourceUsagePlugin method testPreResourcePersistenceException.
@Test
public void testPreResourcePersistenceException() throws StopProcessingException, PluginExecutionException, PersistenceException {
doThrow(PersistenceException.class).when(attributeStore).getCurrentDataUsageByUser(anyString());
ResourceRequest originalRequest = getMockLocalResourceRequest(RESOURCE_SIZE, TEST_USER);
ResourceRequest request = plugin.process(originalRequest);
assertThat(request, notNullValue());
assertThat(request, is(originalRequest));
}
use of ddf.catalog.operation.ResourceRequest in project ddf by codice.
the class TestResourceUsagePlugin method testPreResourceValidSize.
@Test
public void testPreResourceValidSize() throws StopProcessingException, PluginExecutionException, PersistenceException {
ArgumentCaptor<String> usernameArg = ArgumentCaptor.forClass(String.class);
ResourceRequest originalRequest = getMockLocalResourceRequest(RESOURCE_SIZE, TEST_USER);
ResourceRequest request = plugin.process(originalRequest);
assertThat(request, notNullValue());
assertThat(request, is(originalRequest));
verify(attributeStore).getDataLimitByUser(usernameArg.capture());
assertThat(usernameArg.getValue(), is(TEST_USER));
}
use of ddf.catalog.operation.ResourceRequest in project ddf by codice.
the class TestResourceUsagePlugin method testPreResourceRemoteSourceValidSize.
@Test
public void testPreResourceRemoteSourceValidSize() throws Exception {
plugin.setMonitorLocalSources(false);
ArgumentCaptor<String> usernameArg = ArgumentCaptor.forClass(String.class);
ResourceRequest originalRequest = getMockRemoteResourceRequest(RESOURCE_SIZE, TEST_USER);
ResourceRequest request = plugin.process(originalRequest);
assertThat(request, notNullValue());
assertThat(request, is(originalRequest));
verify(attributeStore).getDataLimitByUser(usernameArg.capture());
assertThat(usernameArg.getValue(), is(TEST_USER));
}
Aggregations