List of usage examples for java.net MalformedURLException MalformedURLException
public MalformedURLException(String msg)
From source file:ZipURLStreamHandler.java
/** * Returns a ZipURLConnection for the specified URL. *///w ww .j a v a 2 s. co m public URLConnection openConnection(URL url) throws IOException { String urlFile = url.getFile(); int barIndex = urlFile.indexOf("|"); if (barIndex == -1) throw new MalformedURLException("Missing '|'"); String fileName = urlFile.substring(0, barIndex); String entryName = urlFile.substring(barIndex + 1); return new ZipURLConnection(url, new File(fileName), entryName); }
From source file:uk.ac.ucl.cs.cmic.giftcloud.uploader.GiftCloudServerFactory.java
public GiftCloudServer getGiftCloudServer() throws IOException { final Optional<String> optionalGiftCloudUrl = properties.getGiftCloudUrl(); // Check for an URL which is either not present or empty if (!optionalGiftCloudUrl.isPresent() || StringUtils.isBlank(optionalGiftCloudUrl.get())) { throw new MalformedURLException("Please set the URL for the GIFT-Cloud server."); }/*from ww w .j a va 2s. co m*/ final String giftCloudUrl = optionalGiftCloudUrl.get(); // We need to create new GiftCloudServer if one does not exist, or if the URL has changed if (!(giftCloudServer.isPresent() && giftCloudServer.get().matchesServer(giftCloudUrl))) { // The project list is no longer valid. We will update it after creating a new AutoUploader, but if that throws an exception, we want to leave the project list model in an invalid state projectListModel.invalidate(); giftCloudServer = Optional.of(new GiftCloudServer(filters, restClientFactory, giftCloudUrl, properties, userCallback, reporter)); // Now update the project list projectListModel.setItems(giftCloudServer.get().getListOfProjects()); } return giftCloudServer.get(); }
From source file:cn.edu.zzu.wemall.http.AsyncHttpRequest.java
private void makeRequest() throws IOException { if (!Thread.currentThread().isInterrupted()) { // Fixes #115 if (request.getURI().getScheme() == null) { // subclass of IOException so processed in the caller throw new MalformedURLException("No valid URI scheme was provided"); }//w w w. j a v a 2s.c om HttpResponse response = client.execute(request, context); if (!Thread.currentThread().isInterrupted()) { if (responseHandler != null) { responseHandler.sendResponseMessage(response); } } } }
From source file:org.commoncrawl.util.URLUtils.java
/** * canonicalize url/*from w w w . jav a 2s . co m*/ * * @param incomingURL * @param stripLeadingWWW * - set to true to string www. prefix from the domain if present * @return a canonical representation of the passed in URL that can be safely * used as a replacement for the original url * @throws MalformedURLException */ public static String canonicalizeURL(String incomingURL, boolean stripLeadingWWW) throws MalformedURLException { GoogleURL urlObject = new GoogleURL(incomingURL); if (!urlObject.isValid()) { throw new MalformedURLException("URL:" + incomingURL + " is invalid"); } return canonicalizeURL(urlObject, stripLeadingWWW); }
From source file:org.nuclos.common.activemq.NuclosHttpsTransportFactory.java
@Override protected Transport createTransport(URI location, WireFormat wf) throws MalformedURLException { if (location.getScheme().equals("myhttps")) { try {//from w w w.ja v a 2 s . c om location = new URI(location.toString().substring(2)); } catch (URISyntaxException e) { throw new MalformedURLException(e.toString()); } } final HttpsClientTransport result = (HttpsClientTransport) super.createTransport(location, wf); final HttpClient httpClient = getHttpClient(); result.setReceiveHttpClient(httpClient); result.setSendHttpClient(httpClient); return result; }
From source file:org.jasig.springframework.mock.web.portlet.MockPortletContext.java
public URL getResource(String path) throws java.net.MalformedURLException { if (servletContext == null) { return super.getResource(path); }/*from w ww .j a va 2 s . com*/ if (path == null || !path.startsWith("/")) { throw new MalformedURLException("path must start with a '/'"); } return servletContext.getResource(path); }
From source file:com.enjoy.nerd.http.AsyncHttpRequest.java
private void makeRequest() throws IOException { if (!Thread.currentThread().isInterrupted()) { // Fixes #115 if (request.getURI().getScheme() == null) { // subclass of IOException so processed in the caller throw new MalformedURLException("No valid URI scheme was provided"); }//from w w w.ja v a2 s . c o m HttpResponse response = client.execute(request, context); StatusLine status = response.getStatusLine(); if (status.getStatusCode() >= 300) { request.abort(); throw new HttpResponseException(status.getStatusCode(), status.getReasonPhrase()); } if (!Thread.currentThread().isInterrupted()) { if (responseHandler != null) { responseHandler.sendResponseMessage(response); } } } }
From source file:com.sonicle.webtop.core.app.servlet.BaseRequest.java
protected String[] splitPath(String pathInfo) throws MalformedURLException { String[] tokens = StringUtils.split(pathInfo, "/", 2); if (tokens.length != 2) throw new MalformedURLException("URL does not esplicitate service ID"); return tokens; }
From source file:org.sonatype.nexus.proxy.maven.routing.internal.AbstractHttpRemoteStrategy.java
protected String getRemoteUrlOf(final MavenProxyRepository mavenProxyRepository) throws MalformedURLException { final String remoteRepositoryRootUrl = mavenProxyRepository.getRemoteUrl(); final URL remoteUrl = new URL(remoteRepositoryRootUrl); if (!"http".equalsIgnoreCase(remoteUrl.getProtocol()) && !"https".equalsIgnoreCase(remoteUrl.getProtocol())) { throw new MalformedURLException("URL protocol unsupported: " + remoteRepositoryRootUrl); }//from w w w. java2 s . co m return remoteRepositoryRootUrl; }
From source file:org.ambraproject.configuration.WebAppListener.java
/** * Initialize the configuration singleton since this web application is getting deployed.<p> * * By default, WebAppListener uses the default ConfigurationStore initialization. This * usually means using /etc/.../ambra.xml. This can be overridden by setting the * org.ambraproject.configuration system property or webapp context variable to a URL or a name * resolvable as a resource.// www .j av a2 s . c o m * * @param event The servlet event associated with initializing this context * @throws Error on non-recoverable config load error */ public void contextInitialized(ServletContextEvent event) { ServletContext context = event.getServletContext(); FactoryConfig config = getFactoryConfig(context); try { URL url; // Locate the config url. if (config.name.startsWith("/WEB-INF")) { url = context.getResource(config.name); if (url == null) throw new MalformedURLException("'" + config.name + "' not found in the web-app context"); } else { try { // First see if it is a valid URL url = new URL(config.name); } catch (MalformedURLException e) { // Otherwise, load as a resource url = WebAppListener.class.getResource(config.name); if (url == null) throw e; } } // Now load the config log.info("Loading '" + url + "' (" + config.name + ") configured via " + config.source); ConfigurationStore.getInstance().loadConfiguration(url); // Setup an application scope attribute that something like freemarker or struts might use context.setAttribute("config", ConfigurationStore.getInstance().getConfiguration()); } catch (MalformedURLException e) { log.fatal(config.name + " defined by " + config.source + " is not a valid URL or resource", e); throw new Error("Failed to load configuration", e); } catch (ConfigurationException e) { log.fatal("Failed to initialize configuration factory.", e); throw new Error("Failed to load configuration", e); } }