List of usage examples for java.net URISyntaxException getMessage
public String getMessage()
From source file:ws.bors.atd.SpellChecker.java
/** * Change the dictionary {@link Language} to use. * * @param language {@link Language} to check, default is {@link Language#ENGLISH} * @throws RuntimeException for when a {@link URISyntaxException} occurs. *//*w ww.ja v a 2s . co m*/ public void setLanguage(Language language) throws RuntimeException { try { this.language = language; String domain = atdServer.getHost(); if (domain.toLowerCase().contains("service.afterthedeadline.com")) { String[] parts = domain.split("\\."); parts[0] = this.language.toString(); atdServer = new URI(atdServer.getScheme(), atdServer.getUserInfo(), StringUtils.join(parts, "."), atdServer.getPort(), atdServer.getPath(), atdServer.getQuery(), atdServer.getFragment()); } } catch (URISyntaxException urise) { throw new RuntimeException(urise.getMessage(), urise); } }
From source file:org.dataconservancy.ui.it.support.CreateProjectRequest.java
public HttpPost asHttpPost() { if (!projectSet) { throw new IllegalStateException("A project must be set first: call setProject(Project)"); }//w w w . j a va 2 s . c o m HttpPost post = null; try { post = new HttpPost(uiUrlConfig.getProjectUrl().toURI()); } catch (URISyntaxException e) { throw new RuntimeException(e.getMessage(), e); } List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("project.id", projectId)); params.add(new BasicNameValuePair("project.name", projectName)); params.add(new BasicNameValuePair("project.description", projectDescription)); if (!awardNumbers.isEmpty()) { for (int i = 0; i < awardNumbers.size(); i++) { params.add(new BasicNameValuePair("numbers[" + i + "]", awardNumbers.get(i))); } } params.add(new BasicNameValuePair("project.fundingEntity", fundingEntity)); params.add(new BasicNameValuePair("project.startDate", startDate)); params.add(new BasicNameValuePair("project.endDate", endDate)); params.add(new BasicNameValuePair(STRIPES_EVENT, "Add Project")); if (!pis.isEmpty()) { int i = 0; for (String p : pis) { params.add(new BasicNameValuePair("projectAdminIDList[" + i + "]", p)); i++; } } try { post.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage(), e); } return post; }
From source file:ph.com.globe.connect.Location.java
/** * Get location request.//from w ww . j av a2 s . c o m * * @param address subscriber address * @param requestedAccuracy request accuracy * @return HttpResponse * @throws ApiException api exception * @throws HttpRequestException http request exception * @throws HttpResponseException http response exception */ public HttpResponse getLocation(String address, int requestedAccuracy) throws ApiException, HttpRequestException, HttpResponseException { // try parsing url try { // initialize url builder URIBuilder builder = new URIBuilder(this.LOCATION_URL); // set access token parameter builder.setParameter("access_token", this.accessToken); // set address parameter builder.setParameter("address", address); // set requested accuracy parameter builder.setParameter("requestedAccuracy", Integer.toString(requestedAccuracy)); // build the url String url = builder.build().toString(); // send request CloseableHttpResponse results = this.request // set url .setUrl(url) // send get request .sendGet(); return new HttpResponse(results); } catch (URISyntaxException e) { // throw exception throw new ApiException(e.getMessage()); } }
From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.MetricRegistryProfileFactoryBuilder.java
public ProfileFactory build(ServiceSettings settings) { return new ProfileFactory() { @Override// ww w.jav a 2s .c om protected ArtifactService getArtifactService() { return artifactService; } @Override protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { URI uri; try { String baseUrl; if (settings.getBasicAuthEnabled() != null && settings.getBasicAuthEnabled()) { baseUrl = settings.getAuthBaseUrl(); } else { baseUrl = settings.getBaseUrl(); } uri = new URIBuilder(baseUrl).setHost("localhost").setPath("/spectator/metrics").build(); } catch (URISyntaxException e) { throw new HalException(Problem.Severity.FATAL, "Unable to build service URL: " + e.getMessage()); } profile.appendContents("metrics_url: " + uri.toString()); } @Override protected Profile getBaseProfile(String name, String version, String outputFile) { return new Profile(name, version, outputFile, ""); } @Override public SpinnakerArtifact getArtifact() { return SpinnakerArtifact.SPINNAKER_MONITORING_DAEMON; } @Override protected String commentPrefix() { return "## "; } }; }
From source file:edu.cornell.mannlib.vitro.webapp.config.ConfigurationPropertiesSmokeTests.java
/** * Confirm that the default namespace is specified and a syntactically valid * URI. It should also end with "/individual/". *//*ww w . j av a 2s .c o m*/ private void checkDefaultNamespace(ServletContext ctx, ConfigurationProperties props, StartupStatus ss) { String ns = props.getProperty(PROPERTY_DEFAULT_NAMESPACE); if (ns == null || ns.isEmpty()) { ss.fatal(this, "runtime.properties does not contain a value for '" + PROPERTY_DEFAULT_NAMESPACE + "'"); return; } try { new URI(ns); } catch (URISyntaxException e) { ss.fatal(this, PROPERTY_DEFAULT_NAMESPACE + " '" + ns + "' is not a valid URI. " + (e.getMessage() != null ? e.getMessage() : "")); return; } String suffix = "/individual/"; if (!ns.endsWith(suffix)) { ss.warning(this, "Default namespace does not match the expected form " + "(does not end with '" + suffix + "'): '" + ns + "'"); } }
From source file:com.nesscomputing.jms.activemq.ServiceDiscoveryTransportFactory.java
/** * Extract the query string from a connection URI into a Map *///from w w w. j a v a 2s . co m @SuppressWarnings("PMD.PreserveStackTrace") private Map<String, String> findParameters(URI location) throws MalformedURLException { final Map<String, String> params; try { params = URISupport.parseParameters(location); } catch (final URISyntaxException e) { throw new MalformedURLException(e.getMessage()); } return params; }
From source file:org.sakaiproject.shortenedurl.impl.BitlyUrlService.java
/** * Make a GET request and append the Map of parameters onto the query string. * @param address the fully qualified URL to make the request to * @param parameters the Map of parameters, ie key,value pairs * @return/* w w w .ja va 2 s . co m*/ */ private String doGet(String address, Map<String, String> parameters) { try { List<NameValuePair> queryParams = new ArrayList<NameValuePair>(); for (Map.Entry<String, String> entry : parameters.entrySet()) { queryParams.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } URI uri = URIUtils.createURI(null, address, -1, null, URLEncodedUtils.format(queryParams, "UTF-8"), null); log.info(uri.toString()); return doGet(uri.toString()); } catch (URISyntaxException e) { log.error(e.getClass() + ":" + e.getMessage()); } return null; }
From source file:org.wso2.carbon.ml.core.impl.BAMInputAdapter.java
/** * Checks whether the data source uri refers to a valid table in BAM * //from w w w. ja v a2s .c o m * @param uri Data Source URI to be validated. * @return Boolean indicating validity * @throws MLInputAdapterException * @throws ClientProtocolException * @throws IOException */ private boolean isValidTable(URI uri) throws MLInputAdapterException, ClientProtocolException, IOException { httpClient = HttpClients.createDefault(); uriResourceParameters = uri.normalize().getPath().replaceFirst("/analytics/tables", "").replaceAll("^/", "") .replaceAll("/$", "").split("/"); // if BAM table name is not empty, return false. if (uriResourceParameters[0].isEmpty()) { return false; } // check whether the BAM table exists. try { URI tableCheckUri = new URI(uri.getScheme() + "://" + uri.getRawAuthority() + "/analytics/table_exists?tableName=" + uriResourceParameters[0]); HttpGet get = new HttpGet(tableCheckUri); CloseableHttpResponse response = httpClient.execute(get); BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); JSONObject outputJson = new JSONObject(br.readLine()); return "success".equalsIgnoreCase(outputJson.get("status").toString()); } catch (URISyntaxException e) { throw new MLInputAdapterException("Invalid Uri Syntax:" + e.getMessage(), e); } }
From source file:info.rmapproject.core.model.impl.openrdf.ORMapEventDeletionTest.java
/** * Test method for {@link info.rmapproject.core.model.impl.openrdf.ORMapEventDeletion#ORMapEventDeletion(info.rmapproject.core.model.RMapIri, info.rmapproject.core.model.event.RMapEventTargetType, info.rmapproject.core.model.RMapValue)}. * @throws RMapDefectiveArgumentException * @throws RMapException /*from w w w. ja v a 2 s . c o m*/ */ @Test public void testORMapEventDeletionRMapIriRMapEventTargetTypeRMapValue() throws RMapException, RMapDefectiveArgumentException { List<java.net.URI> resourceList = new ArrayList<java.net.URI>(); try { IRI creatorIRI = vf.createIRI("http://orcid.org/0000-0003-2069-1219"); resourceList.add(new java.net.URI("http://rmap-info.org")); resourceList.add(new java.net.URI("https://rmap-project.atlassian.net/wiki/display/RMAPPS/RMap+Wiki")); RMapIri associatedAgent = ORAdapter.openRdfIri2RMapIri(creatorIRI); RMapLiteral desc = new RMapLiteral("this is a deletion event"); ORMapDiSCO disco = new ORMapDiSCO(associatedAgent, resourceList); RMapRequestAgent requestAgent = new RMapRequestAgent(associatedAgent.getIri(), new java.net.URI("ark:/29297/testkey")); ORMapEventDeletion event = new ORMapEventDeletion(requestAgent, RMapEventTargetType.DISCO, desc); RMapIri discoId = ORAdapter.openRdfIri2RMapIri(disco.getDiscoContext()); List<RMapIri> deleted = new ArrayList<RMapIri>(); deleted.add(discoId); event.setDeletedObjectIds(deleted); Date end = new Date(); event.setEndTime(end); Model eventModel = event.getAsModel(); assertEquals(9, eventModel.size()); IRI context = event.getContext(); for (Statement stmt : eventModel) { assertEquals(context, stmt.getContext()); } assertEquals(RMapEventType.DELETION, event.getEventType()); assertEquals(RMapEventTargetType.DISCO, event.getEventTargetType()); } catch (URISyntaxException e) { e.printStackTrace(); fail(e.getMessage()); } }