private URL fileToUrl(File file) { Validate.notNull(file, "File to get URL of can not be a null object."); try { URL url = file.getAbsoluteFile().toURI().toURL(); return url; } catch (MalformedURLException ex) { throw new IllegalArgumentException(String.format("Unable to get URL of file %s", file.getAbsolutePath()), ex.getCause()); } } }
private URL fileToUrl(File file) { Validate.notNull(file, "File to get URL of can not be a null object."); try { URL url = file.getAbsoluteFile().toURI().toURL(); return url; } catch (MalformedURLException ex) { throw new IllegalArgumentException(String.format("Unable to get URL of file %s", file.getAbsolutePath()), ex.getCause()); } } }
public JMXConnector connect() throws CollectorException { try { JMXServiceURL jmxServiceURL = new JMXServiceURL(this.jmxServiceURL); jmxConnector = JMXConnectorFactory.connect(jmxServiceURL, jmxEnv); } catch (MalformedURLException e) { throw new CollectorException(String.format("%s occurred. URL: %s. Reason: %s", e.getClass().getCanonicalName(), this.jmxServiceURL, e.getCause()), e); } catch (IOException e) { throw new CollectorException(String.format("%s occurred. URL: %s. Reason: %s", e.getClass().getCanonicalName(), this.jmxServiceURL, e.getCause()), e); } return jmxConnector; }
/** * Get URL */ public URL getURL () throws OpenAS2Exception { URI uri = null; try { uri = m_aRequestBuilder.getUri (); return uri.toURL (); } catch (final MalformedURLException ex) { if (LOGGER.isErrorEnabled ()) LOGGER.error ("Failed to get URL from connection, URI: " + uri.toASCIIString (), ex); throw new OpenAS2Exception (ex.getCause ()); } }
private String getURLFromLocationWithRoot(String location) { URL contextRoot = locationStore.get().getURL(); if (contextRoot != null) { try { return new URL(contextRoot, location).toExternalForm(); } catch (MalformedURLException ex) { throw new LocationException("URL to construct is malformed.", ex.getCause()); } } throw new LocationException(String.format( "The location %s is not valid URI and no contextRoot was discovered to treat it as relative URL", location)); }
private String getURLFromLocationWithRoot(String location) { URL contextRoot = locationStore.get().getURL(); if (contextRoot != null) { try { return new URL(contextRoot, location).toExternalForm(); } catch (MalformedURLException ex) { throw new LocationException("URL to construct is malformed.", ex.getCause()); } } throw new LocationException(String.format( "The location %s is not valid URI and no contextRoot was discovered to treat it as relative URL", location)); }
private void searchWar() { final String path = "/WEB-INF/jbpm4jsf-config.xml"; final FacesContext facesContext = FacesContext.getCurrentInstance(); final ExternalContext externalContext = facesContext.getExternalContext(); final ServletContext servletContext = (ServletContext) externalContext.getContext(); try { final URL resource = servletContext.getResource(path); handleConfiguration(resource); } catch (MalformedURLException e) { final FacesException ex = new FacesException("Failed to read configuration resource: " + e.getMessage(), e.getCause()); ex.setStackTrace(e.getStackTrace()); throw ex; } }
} catch (MalformedURLException mue) { LOGGER.log(Level.WARNING, "Trying to configure a GitHub Enterprise server: " + apiUri, mue.getCause()); return FormValidation.error("The endpoint does not look like a GitHub Enterprise (malformed URL)"); } catch (JsonParseException jpe) {
exceptionCaught(ctx, exception.getCause()); } catch (Exception exception) { LOG.error("Error occurred during redirection", exception);
} catch (MalformedURLException exception) { LOG.error("MalformedURLException occurred when deciding whether a redirection is required", exception); exceptionCaught(ctx, exception.getCause());
public void testConnection(org.geoserver.geofence.gui.client.model.GSInstanceModel instance) throws ApplicationException { try { String response = getURL(instance.getBaseURL() + "/rest/geofence/info", instance.getUsername(), instance.getPassword()); if(response != null) { if(!response.equals(instance.getName())) { if(response.contains("Geoserver Configuration API")) { // some heuristic here logger.error("GeoFence probe not installed on " + instance.getName()); throw new ApplicationException("GeoFence probe not installed on " + instance.getName()); } else { logger.error("Wrong instance name: " + response); throw new ApplicationException("Wrong instance name: " + instance.getName() + ", should be :" + response); } } } else { throw new ApplicationException("Error contacting GeoServer"); } } catch (MalformedURLException e) { logger.error(e.getLocalizedMessage(), e.getCause()); throw new ApplicationException(e.getLocalizedMessage(), e.getCause()); } }
vmwareViJavaAccess.connect(); } catch (MalformedURLException e) { logger.warn("Error connecting VMware management server '{}': '{}' exception: {} cause: '{}'", vmwareManagementServer, e.getMessage(), e.getClass().getName(), e.getCause()); return PollStatus.unavailable("Error connecting VMware management server '" + vmwareManagementServer + "'"); } catch (RemoteException e) {
vmwareViJavaAccess.connect(); } catch (MalformedURLException e) { logger.warn("Error connecting VMware management server '{}': '{}' exception: {} cause: '{}'", vmwareManagementServer, e.getMessage(), e.getClass().getName(), e.getCause()); return PollStatus.unavailable("Error connecting VMware management server '" + vmwareManagementServer + "'"); } catch (RemoteException e) {
vmwareViJavaAccess.connect(); } catch (MalformedURLException e) { logger.warn("Error connecting VMware management server '{}': '{}' exception: {} cause: '{}'", vmwareManagementServer, e.getMessage(), e.getClass().getName(), e.getCause()); return builder.build(); } catch (RemoteException e) {
vmwareViJavaAccess.connect(); } catch (MalformedURLException e) { logger.warn("Error connecting VMware management server '{}': '{}' exception: {} cause: '{}'", vmwareManagementServer, e.getMessage(), e.getClass().getName(), e.getCause()); return builder.build(); } catch (RemoteException e) {
vmwareViJavaAccess.connect(); } catch (MalformedURLException e) { logger.warn("Error connecting VMware management server '{}': '{}' exception: {} cause: '{}'", vmwareManagementServer, e.getMessage(), e.getClass().getName(), e.getCause()); return builder.build(); } catch (RemoteException e) {
vmwareViJavaAccess.connect(); } catch (MalformedURLException e) { logger.warn("Error connecting VMware management server '{}': '{}' exception: {} cause: '{}'", vmwareManagementServer, e.getMessage(), e.getClass().getName(), e.getCause()); return builder.build(); } catch (RemoteException e) {