use of ddf.catalog.resource.ResourceNotFoundException in project ddf by codice.
the class OpenSearchSource method retrieveResource.
@Override
public ResourceResponse retrieveResource(URI uri, Map<String, Serializable> requestProperties) throws ResourceNotFoundException, ResourceNotSupportedException, IOException {
final String methodName = "retrieveResource";
LOGGER.trace("ENTRY: {}", methodName);
if (requestProperties == null) {
throw new ResourceNotFoundException("Could not retrieve resource with null properties.");
}
Serializable serializableId = requestProperties.get(Metacard.ID);
if (serializableId != null) {
String metacardId = serializableId.toString();
WebClient restClient = null;
restClient = newRestClient(null, metacardId, true, null);
return resourceReader.retrieveResource(restClient.getCurrentURI(), requestProperties);
}
LOGGER.trace("EXIT: {}", methodName);
throw new ResourceNotFoundException(COULD_NOT_RETRIEVE_RESOURCE_MESSAGE);
}
use of ddf.catalog.resource.ResourceNotFoundException in project ddf by codice.
the class TestResourceMetacardTransformer method testNullResourceUri.
@Test
public void testNullResourceUri() throws Exception {
thrown.expect(CatalogTransformerException.class);
thrown.expectMessage("Unable to retrieve resource.");
Metacard metacard = getMockMetacard(null);
CatalogFramework framework = getFrameworkException(new ResourceNotFoundException(""));
ResourceMetacardTransformer resourceTransformer = new ResourceMetacardTransformer(framework);
resourceTransformer.transform(metacard, new HashMap<String, Serializable>());
}
use of ddf.catalog.resource.ResourceNotFoundException in project ddf by codice.
the class ResourceReaderTest method testUrlToNonExistentFile.
@Test
public void testUrlToNonExistentFile() throws Exception {
URLResourceReader resourceReader = new URLResourceReader(mimeTypeMapper);
String filePath = ABSOLUTE_PATH + TEST_PATH + "NonExistentFile.jpg";
HashMap<String, Serializable> arguments = new HashMap<String, Serializable>();
try {
LOGGER.info("Getting resource: {}", filePath);
File file = new File(filePath);
URI uri = file.toURI();
resourceReader.retrieveResource(uri, arguments);
} catch (IOException e) {
LOGGER.info("Successfully caught IOException");
fail();
} catch (ResourceNotFoundException e) {
LOGGER.info("Caught ResourceNotFoundException");
assert (true);
}
}
use of ddf.catalog.resource.ResourceNotFoundException in project ddf by codice.
the class ResourceReaderTest method testURLResourceIOException.
@Test
public void testURLResourceIOException() throws Exception {
URLResourceReader resourceReader = new URLResourceReader(mimeTypeMapper);
String filePath = "JUMANJI!!!!";
HashMap<String, Serializable> arguments = new HashMap<String, Serializable>();
try {
LOGGER.info("Getting resource: {}", filePath);
URI uri = new URI(FILE_SCHEME_PLUS_SEP + filePath);
resourceReader.retrieveResource(uri, arguments);
} catch (IOException e) {
LOGGER.info("Successfully caught IOException");
fail();
} catch (ResourceNotFoundException e) {
LOGGER.info("Caught ResourceNotFoundException");
assert (true);
} catch (URISyntaxException e) {
LOGGER.info("Caught unexpected URISyntaxException");
fail();
}
}
use of ddf.catalog.resource.ResourceNotFoundException in project ddf by codice.
the class ResourceReaderTest method testURLResourceReaderBadQualifier.
@Test
public void testURLResourceReaderBadQualifier() {
URLResourceReader resourceReader = new TestURLResourceReader(mimeTypeMapper);
resourceReader.setRootResourceDirectories(ImmutableSet.of(ABSOLUTE_PATH + TEST_PATH));
String filePath = TEST_PATH + MPEG_FILE_NAME_1;
HashMap<String, Serializable> arguments = new HashMap<String, Serializable>();
try {
LOGGER.info("Getting resource: {}", filePath);
URI uri = new URI(FILE_SCHEME_PLUS_SEP + filePath);
resourceReader.retrieveResource(uri, arguments);
} catch (IOException e) {
LOGGER.info("Successfully caught expected IOException");
fail();
} catch (ResourceNotFoundException e) {
LOGGER.info("Caught unexpected ResourceNotFoundException");
assert (true);
} catch (URISyntaxException e) {
LOGGER.info("Caught unexpected URISyntaxException");
fail();
}
}
Aggregations