List of usage examples for java.net URISyntaxException URISyntaxException
public URISyntaxException(String input, String reason, int index)
From source file:org.apache.druid.storage.azure.AzureDataSegmentPullerTest.java
@Test(expected = RuntimeException.class) public void testDeleteOutputDirectoryWhenErrorIsRaisedPullingSegmentFiles() throws IOException, URISyntaxException, StorageException, SegmentLoadingException { final File outDir = Files.createTempDirectory("druid").toFile(); try {/*ww w .java 2 s.c o m*/ expect(azureStorage.getBlobInputStream(containerName, blobPath)) .andThrow(new URISyntaxException("error", "error", 404)); replayAll(); AzureDataSegmentPuller puller = new AzureDataSegmentPuller(azureStorage); puller.getSegmentFiles(containerName, blobPath, outDir); assertFalse(outDir.exists()); verifyAll(); } finally { org.apache.commons.io.FileUtils.deleteDirectory(outDir); } }
From source file:com.qwazr.crawler.web.manager.WebCrawlThread.java
WebCrawlThread(String sessionName, WebCrawlDefinition crawlDefinition) throws ServerException { timeTracker = new TimeTracker(); this.session = new CurrentSessionImpl(crawlDefinition, sessionName, timeTracker); this.crawlDefinition = crawlDefinition; if (crawlDefinition.browser_type == null) throw new ServerException(Status.NOT_ACCEPTABLE, "The browser_type is missing"); if (crawlDefinition.entry_url == null) throw new ServerException(Status.NOT_ACCEPTABLE, "The entry_url is missing"); parametersMatcherList = getRegExpMatcherList(crawlDefinition.parameters_patterns); exclusionMatcherList = getWildcardMatcherList(crawlDefinition.exclusion_patterns); inclusionMatcherList = getWildcardMatcherList(crawlDefinition.inclusion_patterns); if (crawlDefinition.robots_txt_enabled != null && crawlDefinition.robots_txt_enabled) robotsTxtMap = new HashMap<>(); else//from w w w .ja v a 2 s . co m robotsTxtMap = null; robotsTxtUserAgent = crawlDefinition.robots_txt_useragent == null ? "QWAZR_BOT" : crawlDefinition.robots_txt_useragent; try { URI uri = new URI(crawlDefinition.entry_url); String host = uri.getHost(); if (host == null) throw new URISyntaxException(crawlDefinition.entry_url, "No host found.", -1); internetDomainName = InternetDomainName.from(host); } catch (URISyntaxException e) { throw new ServerException(Status.NOT_ACCEPTABLE, e.getMessage()); } finally { timeTracker.next("Initialization"); } }
From source file:org.openrepose.filters.custom.extractdeviceid.ExtractDeviceIdFilter.java
static String extractMaasPath(String origUri) throws URISyntaxException { if (origUri == null) { throw new URISyntaxException("" + null, URI_SYNTAX_EXCEPTION_MESSAGE, 0); }/* w w w . j a va2s . c o m*/ String path = new URI(origUri).getPath(); int idxEntities = path.indexOf(ENTITIES); if (idxEntities < 0) { throw new URISyntaxException(origUri, URI_SYNTAX_EXCEPTION_MESSAGE, 0); } else if (path.length() < idxEntities + ENTITIES_LEN_PLUS_TWO) { idxEntities = origUri.indexOf(ENTITIES); throw new URISyntaxException(origUri, URI_SYNTAX_EXCEPTION_MESSAGE, idxEntities + ENTITIES_LEN_MINUS_ONE); } int idxEntityId = path.indexOf('/', idxEntities + ENTITIES_LEN_PLUS_TWO); if (idxEntityId < 0) { return path; } else { return path.substring(0, idxEntityId); } }