List of usage examples for java.net URISyntaxException getMessage
public String getMessage()
From source file:com.microsoft.azure.hdinsight.spark.common.SparkSubmitModel.java
public SparkBatchRemoteDebugJob tryToCreateBatchSparkDebugJob( @NotNull final IClusterDetail selectedClusterDetail) throws HDIException, IOException { SparkBatchSubmission.getInstance().setCredentialsProvider(selectedClusterDetail.getHttpUserName(), selectedClusterDetail.getHttpPassword()); try {/* w ww.j a v a2s. c om*/ SparkBatchRemoteDebugJob debugJob = SparkBatchRemoteDebugJob.factory( SparkSubmitHelper.getLivyConnectionURL(selectedClusterDetail), submissionParameter, SparkBatchSubmission.getInstance()); debugJob.createBatchSparkJobWithDriverDebugging(); return debugJob; } catch (URISyntaxException ex) { throw new HDIException( "Bad Livy Connection URL " + SparkSubmitHelper.getLivyConnectionURL(selectedClusterDetail), ex); } catch (IOException ex) { HDInsightUtil.showErrorMessageOnSubmissionMessageWindow(project, String .format("Error : Failed to submit to spark cluster. error message : %s.", ex.getMessage())); throw ex; } }
From source file:org.nectarframework.base.service.nanohttp.NanoHttpService.java
private Response serveProxy(ProxyResolution proxyResolution, String uri, Method method, Map<String, String> headers, Map<String, List<String>> parms, String queryParameterString, Map<String, String> files) { String remoteTarget = uri.substring(proxyResolution.getPath().length() + 1); if (!remoteTarget.startsWith("/")) { remoteTarget = "/" + remoteTarget; }/*from w ww. j a va2 s . c om*/ CloseableHttpClient httpclient = HttpClients.createDefault(); URIBuilder remoteUri = new URIBuilder(); remoteUri.setScheme("http"); remoteUri.setHost(proxyResolution.getHost()); remoteUri.setPort(proxyResolution.getPort()); remoteUri.setPath(proxyResolution.getRequestPath() + remoteTarget); remoteUri.setCharset(Charset.defaultCharset()); for (String k : parms.keySet()) { remoteUri.addParameter(k, parms.get(k).get(0)); } HttpGet httpget; try { httpget = new HttpGet(remoteUri.build()); } catch (URISyntaxException e) { Log.warn(e); return newFixedLengthResponse(Status.INTERNAL_ERROR, NanoHttpService.MIME_PLAINTEXT, "SERVER INTERNAL ERROR: URISyntaxException" + e.getMessage()); } CloseableHttpResponse response = null; Response resp = null; try { response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream is = entity.getContent(); long isl = entity.getContentLength(); resp = new Response(Status.lookup(response.getStatusLine().getStatusCode()), null, is, isl); } else { resp = new Response(Status.lookup(response.getStatusLine().getStatusCode()), null, null, 0); } Header[] remoteHeaders = response.getAllHeaders(); for (Header h : remoteHeaders) { resp.addHeader(h.getName(), h.getValue()); } resp.setProxyResponse(response); } catch (IOException e) { Log.warn(e); return newFixedLengthResponse(Status.INTERNAL_ERROR, NanoHttpService.MIME_PLAINTEXT, "SERVER INTERNAL ERROR: IOException" + e.getMessage()); } return resp; }
From source file:com.myjeeva.digitalocean.impl.DigitalOceanClient.java
private URI createUri(ApiRequest request) { URIBuilder ub = new URIBuilder(); ub.setScheme(HTTPS_SCHEME);/*from w w w . ja va 2 s. co m*/ ub.setHost(apiHost); ub.setPath(createPath(request)); if (null != request.getPageNo()) { ub.setParameter(PARAM_PAGE_NO, request.getPageNo().toString()); } URI uri = null; try { uri = ub.build(); } catch (URISyntaxException use) { LOG.error(use.getMessage(), use); } return uri; }
From source file:net.pms.newgui.LooksFrame.java
public JComponent buildContent() { JPanel panel = new JPanel(new BorderLayout()); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false);// w w w .j a v a 2 s. c om toolBar.setRollover(true); toolBar.add(new JPanel()); if (PMS.getConfiguration().useWebInterface()) { webinterface = createToolBarButton(Messages.getString("LooksFrame.29"), "button-wif.png"); webinterface.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String error = null; if (PMS.get().getWebInterface() != null && isNotBlank(PMS.get().getWebInterface().getUrl())) { try { URI uri = new URI(PMS.get().getWebInterface().getUrl()); try { Desktop.getDesktop().browse(uri); } catch (RuntimeException | IOException be) { LOGGER.error("Cound not open the default web browser: {}", be.getMessage()); LOGGER.trace("", be); error = Messages.getString("LooksFrame.BrowserError") + "\n" + be.getMessage(); } } catch (URISyntaxException se) { LOGGER.error("Could not form a valid web interface URI from \"{}\": {}", PMS.get().getWebInterface().getUrl(), se.getMessage()); LOGGER.trace("", se); error = Messages.getString("LooksFrame.URIError"); } } else { error = Messages.getString("LooksFrame.URIError"); } if (error != null) { JOptionPane.showMessageDialog(null, error, Messages.getString("Dialog.Error"), JOptionPane.ERROR_MESSAGE); } } }); webinterface.setToolTipText(Messages.getString("LooksFrame.30")); webinterface.setEnabled(configuration.useWebInterface()); toolBar.add(webinterface); toolBar.addSeparator(new Dimension(20, 1)); } restartIcon = (AnimatedIcon) reload.getIcon(); restartRequredIcon.start(); setReloadable(false); reload.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reload.setEnabled(false); PMS.get().reset(); } }); reload.setToolTipText(Messages.getString("LooksFrame.28")); toolBar.add(reload); toolBar.addSeparator(new Dimension(20, 1)); AbstractButton quit = createToolBarButton(Messages.getString("LooksFrame.5"), "button-quit.png"); quit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { quit(); } }); toolBar.add(quit); if (System.getProperty(START_SERVICE) != null) { quit.setEnabled(false); } toolBar.add(new JPanel()); // Apply the orientation to the toolbar and all components in it ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale()); toolBar.applyComponentOrientation(orientation); toolBar.setBorder(new EmptyBorder(new Insets(8, 0, 0, 0))); panel.add(toolBar, BorderLayout.NORTH); panel.add(buildMain(), BorderLayout.CENTER); status = new JLabel(""); status.setBorder(BorderFactory.createEmptyBorder()); status.setComponentOrientation(orientation); // Calling applyComponentOrientation() here would be ideal. // Alas it horribly mutilates the layout of several tabs. //panel.applyComponentOrientation(orientation); panel.add(status, BorderLayout.SOUTH); return panel; }
From source file:com.microsoft.exchange.impl.ExchangeEventConverterImpl.java
/** * Convert the {@link String} argument to a mailto {@link URI} if possible. * /* w ww. j a v a2 s. c o m*/ * @param emailAddress * @return the email as a URI * @throws IllegalArgumentException * if conversion failed, or if the argument was empty * * <strong>WARNING</strong >A {@link CalendarItemType} may contain attendees that no longer have a valid email address. * If an event contains an attendee that has been deleted, the email address field takes the value of <legacyDn> example: <t:EmailAddress>/O=EXCHANGELABS/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=F450764bd9384fd3b7a38722504c8815-Documentati</t:EmailAddress> */ public URI emailToURI(final String emailAddress) { Validate.notEmpty(emailAddress, "emailAddress cannot be null"); URI uri = null; try { uri = new URI("mailto:" + emailAddress); } catch (URISyntaxException e) { log.debug("caught URISyntaxException trying to construct mailto URI for " + emailAddress + "\n" + e.getMessage()); } return uri; }
From source file:com.pidoco.juri.JURI.java
/** * Provides encoded URI - recreates the URI, should not be used if more changes will be applied to the wrapper. *///from w w w . j a v a 2 s . c om @Override public String toString() { if (changeUnderway) { CharSequence detail; try { detail = buildNoSideEffects(); } catch (URISyntaxException e) { detail = e.getMessage(); } LOG.warn("Called toString while change is underway - this must only happen during debugging!"); return detail.toString(); } return getCurrentUri().toASCIIString(); }
From source file:org.apache.sling.discovery.etcd.EtcdDiscoveryService.java
@Nonnull private URI parseEndpoint(@Nonnull String ep) { try {//from ww w. j a va 2 s . c o m return new URI(ep); } catch (URISyntaxException e) { LOG.info("Failed to parse endpoint: {}, using default endpoint: {}", new Object[] { ep, DEFAULT_ENDPOINT }); try { return new URI(DEFAULT_ENDPOINT); } catch (URISyntaxException shouldNeverHappen) { throw new IllegalStateException( String.format("Failed to create uri from the default endpoint: %s", e.getMessage())); } } }
From source file:com.cloud.network.resource.NccHttpCode.java
private ExternalNetworkResourceUsageAnswer getPublicIpBytesSentAndReceived( ExternalNetworkResourceUsageCommand cmd) throws ExecutionException { ExternalNetworkResourceUsageAnswer answer = new ExternalNetworkResourceUsageAnswer(cmd); long networkid = cmd.getNetworkid(); try {/* w ww. j av a 2 s . c o m*/ //TODO send GET cmd to get the network stats URI agentUri = null; String response = null; try { agentUri = new URI("https", null, _ip, DEFAULT_PORT, "/cs/adcaas/v1/networks/" + networkid + "/ipStats", null, null); org.json.JSONObject jsonBody = new JSONObject(); response = getHttpRequest(jsonBody.toString(), agentUri, _sessionid); JSONArray statsIPList = null; if (response != null) { statsIPList = new JSONObject(response).getJSONObject("stats").getJSONArray("ipBytes"); } if (statsIPList != null) { for (int i = 0; i < statsIPList.length(); i++) { JSONObject ipstat = statsIPList.getJSONObject(i); JSONObject ipvalues = ipstat.getJSONObject("ipstats"); if (ipstat != null) { long[] bytesSentAndReceived = new long[] { 0, 0 }; bytesSentAndReceived[0] = ipvalues.getLong("received"); bytesSentAndReceived[1] = ipvalues.getLong("sent"); if (bytesSentAndReceived[0] >= 0 && bytesSentAndReceived[1] >= 0) { answer.ipBytes.put(ipstat.getString("ip"), bytesSentAndReceived); } } } } s_logger.debug("IPStats Response :" + response); } catch (URISyntaxException e) { e.printStackTrace(); } catch (ExecutionException e) { s_logger.debug("Seesion Alive" + e.getMessage()); e.printStackTrace(); } } catch (Exception e) { s_logger.error("Failed to get bytes sent and recived statistics due to " + e); throw new ExecutionException(e.getMessage()); } return answer; }
From source file:org.dasein.cloud.azure.AzureMethod.java
public @Nullable Document getAsXML(@Nonnull String account, @Nonnull String resource) throws CloudException, InternalException { try {//from www. j a v a 2 s.c o m return getAsXML(account, new URI(endpoint + account + resource)); } catch (URISyntaxException e) { throw new InternalException( "Endpoint misconfiguration (" + endpoint + account + resource + "): " + e.getMessage()); } }