Example usage for java.net MalformedURLException getMessage

List of usage examples for java.net MalformedURLException getMessage

Introduction

In this page you can find the example usage for java.net MalformedURLException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.exquance.jenkins.plugins.conduit.ConduitAPIClient.java

/**
 * Post a URL-encoded "params" key with a JSON-encoded body as per the Conduit API
 * @param action The name of the Conduit method
 * @param params The data to be sent to the Conduit method
 * @return The request to perform//from  ww w  .ja va 2s .c o  m
 * @throws UnsupportedEncodingException when the POST data can't be encoded
 * @throws ConduitAPIException when the conduit URL is misconfigured
 */
public HttpUriRequest createRequest(String action, JSONObject params)
        throws UnsupportedEncodingException, ConduitAPIException {
    HttpPost post;
    try {
        post = new HttpPost(new URL(new URL(new URL(conduitURL), "/api/"), action).toURI());
    } catch (MalformedURLException e) {
        throw new ConduitAPIException(e.getMessage());
    } catch (URISyntaxException e) {
        throw new ConduitAPIException(e.getMessage());
    }

    JSONObject conduitParams = new JSONObject();
    conduitParams.put(API_TOKEN_KEY, conduitToken);
    params.put(CONDUIT_METADATA_KEY, conduitParams);

    List<NameValuePair> formData = new ArrayList<NameValuePair>();
    formData.add(new BasicNameValuePair("params", params.toString()));

    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formData, "UTF-8");
    post.setEntity(entity);

    return post;
}

From source file:org.jasig.portlet.ClassifiedsPortlet.service.AdminGroupService.java

private void parseXml() {

    URL portletXmlUrl = null;/* w  w  w.  j  av a 2s  . c  o  m*/
    try {
        portletXmlUrl = context.getResource(PORTLET_XML_PATH);
    } catch (MalformedURLException e) {
        log.error(e.getMessage());
    } finally {

        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            InputSource xmlInp = new InputSource(portletXmlUrl.openStream());
            DocumentBuilder dbl = dbf.newDocumentBuilder();
            doc = dbl.parse(xmlInp);
        } catch (ParserConfigurationException e) {
            log.error(e.getMessage());
        } catch (java.io.IOException e) {
            log.error(e.getMessage());
        } catch (org.xml.sax.SAXException e) {
            log.error(e.getMessage());
        } catch (Exception e) {
            log.error(e.getMessage());
        } finally {
            log.debug("Finished parsing " + PORTLET_XML_PATH + ".");
        }
    }
}

From source file:be.agiv.security.client.ClientProxySelector.java

/**
 * Sets the proxy for the (hostname of the) given location.
 * //from   www.  jav a 2s .  c  om
 * @param location
 *            the location on which the proxy settings apply.
 * @param proxyHost
 *            the host of the proxy.
 * @param proxyPort
 *            the port of the proxy.
 * @param proxyType
 *            the type of the proxy.
 */
public void setProxy(String location, String proxyHost, int proxyPort, Type proxyType) {
    String hostname;
    try {
        hostname = new URL(location).getHost();
    } catch (MalformedURLException e) {
        throw new RuntimeException("URL error: " + e.getMessage(), e);
    }
    if (null == proxyHost) {
        LOG.debug("removing proxy for: " + hostname);
        this.proxies.remove(hostname);
    } else {
        LOG.debug("setting proxy for: " + hostname);
        this.proxies.put(hostname, new Proxy(proxyType, new InetSocketAddress(proxyHost, proxyPort)));
    }
}

From source file:TextureImage.java

public void init() {
    if (texImage == null) {
        // the path to the image for an applet
        try {//from   w  ww.  ja  v a  2s . co  m
            texImage = new java.net.URL(getCodeBase().toString() + "/stone.jpg");
        } catch (java.net.MalformedURLException ex) {
            System.out.println(ex.getMessage());
            System.exit(1);
        }
    }
    setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

    Canvas3D c = new Canvas3D(config);
    add("Center", c);

    // Create a simple scene and attach it to the virtual universe
    BranchGroup scene = createSceneGraph();
    u = new SimpleUniverse(c);

    // This will move the ViewPlatform back a bit so the
    // objects in the scene can be viewed.
    u.getViewingPlatform().setNominalViewingTransform();

    u.addBranchGraph(scene);
}

From source file:be.fedict.eid.dss.document.odf.ODFSignatureService.java

@Override
protected URL getOpenDocumentURL() {
    try {//  ww w.  j  a  va 2s .c  om
        return this.tmpFile.toURI().toURL();
    } catch (MalformedURLException e) {
        throw new RuntimeException("URL error: " + e.getMessage(), e);
    }
}

From source file:io.hakbot.controller.plugin.RemoteInstanceAutoConfig.java

private RemoteInstance generateInstance(Plugin.Type pluginType, String pluginId, String instanceIdentifier) {
    final String type = pluginType.name().toLowerCase();
    final RemoteInstance instance = new RemoteInstance();
    instance.setAlias(StringUtils.trimToNull(
            Config.getInstance().getProperty(type + "." + pluginId + "." + instanceIdentifier + ".alias")));
    instance.setUsername(StringUtils.trimToNull(
            Config.getInstance().getProperty(type + "." + pluginId + "." + instanceIdentifier + ".username")));
    instance.setPassword(StringUtils.trimToNull(
            Config.getInstance().getProperty(type + "." + pluginId + "." + instanceIdentifier + ".password")));
    instance.setApiKey(StringUtils.trimToNull(
            Config.getInstance().getProperty(type + "." + pluginId + "." + instanceIdentifier + ".apikey")));
    instance.setToken(StringUtils.trimToNull(
            Config.getInstance().getProperty(type + "." + pluginId + "." + instanceIdentifier + ".token")));
    try {//from   w w  w .ja  v a  2 s. c o  m
        instance.setURL(new URL(StringUtils.trimToNull(
                Config.getInstance().getProperty(type + "." + pluginId + "." + instanceIdentifier + ".url"))));
    } catch (MalformedURLException e) {
        LOGGER.error("The URL specified for the server instance is not valid. " + e.getMessage());
    }
    return instance;
}

From source file:ch.sbb.releasetrain.utils.http.HttpUtilImpl.java

/**
 * authenticates the context if user and password are set
 *//*ww w  . jav a2 s . c  o  m*/
private HttpClientContext initAuthIfNeeded(String url) {

    HttpClientContext context = HttpClientContext.create();
    if (this.user.isEmpty() || this.password.isEmpty()) {
        log.debug(
                "http connection without autentication, because no user / password ist known to HttpUtilImpl ...");
        return context;
    }

    CredentialsProvider credsProvider = new BasicCredentialsProvider();
    credsProvider.setCredentials(new AuthScope(AuthScope.ANY), new UsernamePasswordCredentials(user, password));
    URL url4Host;
    try {
        url4Host = new URL(url);
    } catch (MalformedURLException e) {
        log.error(e.getMessage(), e);
        return context;
    }

    HttpHost targetHost = new HttpHost(url4Host.getHost(), url4Host.getPort(), url4Host.getProtocol());
    AuthCache authCache = new BasicAuthCache();
    BasicScheme basicAuth = new BasicScheme();
    authCache.put(targetHost, basicAuth);
    context.setCredentialsProvider(credsProvider);
    context.setAuthCache(authCache);
    return context;
}

From source file:org.jasig.portlet.announcements.service.PortletXMLGroupService.java

private void parseXml() {

    try {//from   w w  w  .j a  v  a  2s.c  o  m
        URL portletXmlUrl = context.getResource(PORTLET_XML_PATH);
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        InputSource xmlInp = new InputSource(portletXmlUrl.openStream());
        DocumentBuilder dbl = dbf.newDocumentBuilder();
        doc = dbl.parse(xmlInp);
        log.debug("Finished parsing " + PORTLET_XML_PATH + ".");
    } catch (MalformedURLException e) {
        log.error(e.getMessage());
    } catch (ParserConfigurationException e) {
        log.error(e.getMessage());
    } catch (java.io.IOException e) {
        log.error(e.getMessage());
    } catch (org.xml.sax.SAXException e) {
        log.error(e.getMessage());
    } catch (Exception e) {
        log.error(e.getMessage());
    }
}

From source file:org.apache.cxf.fediz.service.idp.STSPortFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    Assert.isTrue(applicationContext != null, "Application context must not be null");
    STSAuthenticationProvider authProvider = authenticationProvider;
    if (authProvider == null) {
        authProvider = applicationContext.getBean(STSAuthenticationProvider.class);
    }//from  www. j  a  va2s . c o  m
    Assert.isTrue(authProvider != null, "STSAuthenticationProvider must be configured");

    //Only update the port if HTTPS is used, otherwise ignored (like retrieving the WADL over HTTP)
    if (!isPortSet && request.isSecure()) {
        try {
            URL url = new URL(authProvider.getWsdlLocation());
            if (url.getPort() == 0) {
                URL updatedUrl = new URL(url.getProtocol(), url.getHost(), request.getLocalPort(),
                        url.getFile());
                setSTSWsdlUrl(authProvider, updatedUrl.toString());
                LOG.info("STSAuthenticationProvider.wsdlLocation set to " + updatedUrl.toString());
            } else {
                setSTSWsdlUrl(authProvider, url.toString());
            }
        } catch (MalformedURLException e) {
            LOG.error("Invalid Url '" + authProvider.getWsdlLocation() + "': " + e.getMessage());
        }
    }

    chain.doFilter(request, response);
}

From source file:gsn.wrappers.general.HttpGetWrapper.java

/**
 * From XML file it needs the followings :
 * <ul>/*from   ww  w .ja  va 2 s .  com*/
 * <li>url</li> The full url for retriving the binary data.
 * <li>rate</li> The interval in msec for updating/asking for new information.
 * <li>mime</li> Type of the binary data.
 * </ul>
 */
public boolean initialize() {
    this.addressBean = getActiveAddressBean();
    urlPath = this.addressBean.getPredicateValue("url");
    try {
        url = new URL(urlPath);
    } catch (MalformedURLException e) {
        logger.error("Loading the http wrapper failed : " + e.getMessage(), e);
        return false;
    }
    inputRate = this.addressBean.getPredicateValue("rate");
    if (inputRate == null || inputRate.trim().length() == 0)
        rate = DEFAULT_RATE;
    else
        rate = Integer.parseInt(inputRate);
    logger.debug("AXISWirelessCameraWrapper is now running @" + rate + " Rate.");
    return true;
}