List of usage examples for java.net URISyntaxException getMessage
public String getMessage()
From source file:com.adobe.acs.commons.adobeio.service.impl.EndpointServiceImpl.java
/** * Process the Adobe I/O action/* ww w.j a v a 2 s . c om*/ * * @param actionUrl * The url to be executed * @param queryParameters * The query parameters to pass * @param method * The method to be executed * @param payload * The payload of the call * @return JsonObject containing the result of the action * @throws Exception * Thrown when process-action throws an exception */ private JsonObject process(@NotNull final String actionUrl, @NotNull final Map<String, String> queryParameters, @NotNull final String method, final String[] headers, @NotNull final JsonObject payload) { if (isBlank(actionUrl) || isBlank(method)) { LOGGER.error("Method or url is null"); return new JsonObject(); } URI uri = null; try { URIBuilder builder = new URIBuilder(actionUrl); queryParameters.forEach((k, v) -> builder.addParameter(k, v)); uri = builder.build(); } catch (URISyntaxException uriexception) { LOGGER.error(uriexception.getMessage()); return new JsonObject(); } LOGGER.debug("Performing method = {}. queryParameters = {}. actionUrl = {}. payload = {}", method, queryParameters, uri, payload); try { if (StringUtils.equalsIgnoreCase(method, METHOD_POST)) { return processPost(uri, payload, headers); } else if (StringUtils.equalsIgnoreCase(method, METHOD_GET)) { return processGet(uri, headers); } else if (StringUtils.equalsIgnoreCase(method, "PATCH")) { return processPatch(uri, payload, headers); } else { return new JsonObject(); } } catch (IOException ioexception) { LOGGER.error(ioexception.getMessage()); return new JsonObject(); } }
From source file:org.yaoha.ApiConnector.java
public HttpResponse putNode(String changesetId, OsmNode node) throws ClientProtocolException, IOException, ParserConfigurationException, TransformerException, OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException { URI uri = null;// w w w . j a v a 2 s . com try { uri = new URI("http", apiUrl, "/api/0.6/node/" + String.valueOf(node.getID()), null); } catch (URISyntaxException e) { Log.e(ApiConnector.class.getSimpleName(), "Uploading node " + String.valueOf(node.getID()) + " failed:"); Log.e(ApiConnector.class.getSimpleName(), e.getMessage()); } HttpPut request = new HttpPut(uri); request.setHeader(userAgentHeader); String requestString = ""; requestString = node.serialize(changesetId); HttpEntity entity = new StringEntity(requestString, HTTP.UTF_8); request.setEntity(entity); consumer.sign(request); return client.execute(request); }
From source file:be.fedict.trust.ocsp.OcspTrustLinker.java
private URI toURI(String str) { try {/* www. j a v a2 s. c o m*/ URI uri = new URI(str); return uri; } catch (URISyntaxException e) { throw new InvalidParameterException("URI syntax error: " + e.getMessage()); } }
From source file:edu.cornell.med.icb.goby.modes.GenericToolsDriver.java
/** * Retrieve the class names of the likely modes. * * @return the list of class names/* w ww .ja v a 2 s .c o m*/ */ private List<String> modesClassNamesList() { final List<String> modesList = new LinkedList<String>(); try { final String modesPackage = ClassUtils.getPackageName(getClass()); final String[] files = new ResourceFinder().getResourceListing(getClass()); for (final String file : files) { if (file.endsWith("Mode.class")) { // Keep only classes whose class name end in "Mode" final String modeClassName = modesPackage + "." + file.substring(0, file.length() - 6); modesList.add(modeClassName); } } } catch (URISyntaxException e) { System.err.println("Could not list mode class names URISyntaxException: " + e.getMessage()); e.printStackTrace(); } catch (IOException e) { System.err.println("Could not list mode class names IOException: " + e.getMessage()); e.printStackTrace(); } return modesList; }
From source file:act.installer.pubchem.PubchemMeshSynonyms.java
private String getServiceFromHostParams(String hostIp, Integer port) { URI uri = null;//from w ww. j ava2 s . c o m try { uri = new URIBuilder().setScheme("http").setHost(hostIp).setPort(port).setPath("/sparql").build(); } catch (URISyntaxException e) { String msg = String.format("An error occurred when trying to build the SPARQL service URI: %s", e.getMessage()); LOGGER.error(msg); throw new RuntimeException(msg); } LOGGER.debug("Constructed the following URL for SPARQL service: %s", uri.toString()); return uri != null ? uri.toString() : null; }
From source file:com.example.guan.webrtc_android_7.common.WebSocketClient.java
public void connect(final String wsUrl, final String postUrl) { checkIfCalledOnValidThread();// w ww .ja v a2 s .c o m if (state != WebSocketConnectionState.NEW) { Log.e(TAG, "WebSocket is already connected."); return; } wsServerUrl = wsUrl; postServerUrl = postUrl; closeEvent = false; Log.d(TAG, "Connecting WebSocket to: " + wsUrl + ". Post URL: " + postUrl); ws = new WebSocketConnection(); wsObserver = new WebSocketObserver(); try { ws.connect(new URI(wsServerUrl), wsObserver); Log.d(TAG, "Success to Connect WebSocket!"); } catch (URISyntaxException e) { e.printStackTrace(); reportError(roomID, "URI error: " + e.getMessage()); } catch (WebSocketException e) { e.printStackTrace(); reportError(roomID, "WebSocket connection error: " + e.getMessage()); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.janoz.usenet.searchers.impl.NewzbinConnectorImpl.java
private URI constructURL(String path) throws MalformedURLException { try {//from w ww . j av a 2 s . c om return new URL(serverProtocol, serverAddress, serverPort, path).toURI(); } catch (URISyntaxException e) { throw new MalformedURLException(e.getMessage()); } }
From source file:com.blackducksoftware.tools.commonframework.core.config.ConfigurationManagerTest.java
@Test public void testSSLSettings() { final URL resourceUrl = Thread.currentThread().getContextClassLoader().getResource(testFileSSLMappings); Path resourcePath = null;/*w w w. j av a 2s .c o m*/ try { resourcePath = Paths.get(resourceUrl.toURI()); } catch (final URISyntaxException e) { Assert.fail(e.getMessage()); } final ConfigurationManager sslCM = new TestConfigurationManagerBean( resourcePath.toFile().getAbsolutePath()); final SSOBean ssoBean = sslCM.getSsoBean(); Assert.assertEquals("keystore_path", ssoBean.getKeyStorePath()); Assert.assertEquals("key_pass", ssoBean.getKeyStorePassword()); Assert.assertEquals("jks", ssoBean.getKeyStoreType()); Assert.assertEquals("truststore_path", ssoBean.getTrustStorePath()); Assert.assertEquals("trust_pass", ssoBean.getTrustStorePassword()); Assert.assertEquals("pk12", ssoBean.getTrustStoreType()); }
From source file:ph.com.globe.connect.Payment.java
/** * Build request url.//from w ww . j a va 2s. c o m * * @param url target url * @return String * @throws ApiException api exception */ protected String buildUrl(String url) throws ApiException { // try parsing url try { // initialize url builder URIBuilder builder = new URIBuilder(url); // set access token parameter builder.setParameter("access_token", this.accessToken); // build the url url = builder.build().toString(); return url; } catch (URISyntaxException e) { // throw exception throw new ApiException(e.getMessage()); } }
From source file:se.lu.nateko.edca.svc.DescribeFeatureType.java
/** * Method run in a separate worker thread when GetCapabilities.execute() is called. * Takes the server info from the ServerConnection supplied and stores it as a URI. * @param srvs An array of ServerConnection objects from which to form the URI. May only contain 1. */// w w w . j a va 2 s. com @Override protected DescribeFeatureType doInBackground(ServerConnection... srvs) { Log.d(TAG, "doInBackground(ServerConnection...) called."); /* Try to form an URI from the supplied ServerConnection info. */ if (srvs[0] == null) // Cannot connect unless there is an active connection. return this; String uriString = srvs[0].getAddress() + "/wfs?service=wfs&version=1.1.0&request=DescribeFeatureType&typeName=" + mLayerName; try { mServerURI = new URI(uriString); } catch (URISyntaxException e) { Log.e(TAG, e.getMessage() + ": " + uriString); } /* If there is already a layer stored with this name; clear its data to make room for the new DescribeFeatureType result. */ mService.getSQLhelper().getSQLiteDB().execSQL("DROP TABLE IF EXISTS " + LocalSQLDBhelper.TABLE_FIELD_PREFIX + Utilities.dropColons(mLayerName, Utilities.RETURN_LAST)); mService.getSQLhelper().createFieldTable(mLayerName); GeoHelper.deleteGeographyLayer(mLayerName); try { // Get or wait for exclusive access to the HttpClient. mHttpClient = mService.getHttpClient(); } catch (InterruptedException e) { Log.w(TAG, "Thread " + Thread.currentThread().getId() + ": " + e.toString()); } mHasResponse = describeFeatureTypeRequest(); // Make the DescribeFeatureType request to the server and record the success state. mService.unlockHttpClient(); // Release the lock on the HttpClient, allowing new connections to be made. Log.v(TAG, "DescribeFeatureType request succeeded: " + String.valueOf(mHasResponse)); if (mHasResponse) { /* Update the database and set a new active layer. */ mService.setActiveLayer(mService.generateGeographyLayer(mLayerName)); mService.deactivateLayers(); mService.getSQLhelper().updateData(LocalSQLDBhelper.TABLE_LAYER, mLayerRowId, LocalSQLDBhelper.KEY_LAYER_ID, new String[] { LocalSQLDBhelper.KEY_LAYER_USEMODE }, new String[] { String .valueOf(LocalSQLDBhelper.LAYER_MODE_ACTIVE * LocalSQLDBhelper.LAYER_MODE_DISPLAY) }); } return this; }