Example usage for java.net URISyntaxException printStackTrace

List of usage examples for java.net URISyntaxException printStackTrace

Introduction

In this page you can find the example usage for java.net URISyntaxException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:pl.llp.aircasting.util.http.HttpBuilder.java

private <T> HttpResult<T> doDelete(Type target) {
    try {/*from  w ww  .j a  va2 s .  c o  m*/
        URI path = createPath(address, query());
        HttpDelete delete = new HttpDelete(path);

        return doRequest(delete, target);
    } catch (URISyntaxException e) {
        e.printStackTrace();
        return error();
    }
}

From source file:ca.licef.lompad.Classification.java

public boolean delete() {
    try {/*from  ww w. j a  v a2 s .c o m*/
        File file = new File(new URI(getUrl().toString()));
        boolean isDeleted = file.delete();
        if (isDeleted)
            Classification.classifs.remove(getUrl());
        return (isDeleted);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    return (false);
}

From source file:org.mindswap.swoop.renderer.ontology.SwoopSpeciesValidationRenderer.java

License:asdf

private String reformatInHTML(String source) {
    // if the following is true, then we assume that the String source
    // is already properly formatted with HLinks
    if (source.indexOf("<a href=") != -1) {

        // replace <http with &lt;http to escape <
        // so < will be displayed in the species validation
        // pane rather than being treated as a tag.
        source = source.replaceAll("<http", "&lt;http");
        return source;

    }//from   w  w w. ja v  a2  s  .  c  o  m
    //System.out.println(source);
    source = source.replaceAll(SPACE, " ");
    try {
        StringTokenizer tokens = new StringTokenizer(source);
        String result = "";
        while (tokens.hasMoreTokens()) {
            String token = tokens.nextToken();
            String temp = "";
            for (int i = 0; i < POPULAR_SCHEME_NAMES.length; i++) {
                int index = -1;
                if ((index = token.indexOf(POPULAR_SCHEME_NAMES[i])) != -1) {
                    String head = token.substring(0, index);
                    String tail = token.substring(index);
                    String tip = "";

                    int x = 0;
                    int y = 0;
                    int z = 0;
                    int w = 0;
                    int ind = Integer.MAX_VALUE;
                    if ((x = tail.indexOf("<")) != -1)
                        ind = Math.min(ind, x);
                    if ((y = tail.indexOf(">")) != -1)
                        ind = Math.min(ind, y);
                    if ((z = tail.indexOf("(")) != -1)
                        ind = Math.min(ind, z);
                    if ((w = tail.indexOf(")")) != -1)
                        ind = Math.min(ind, w);

                    if (ind != Integer.MAX_VALUE) {
                        tip = tail.substring(ind);
                        tail = tail.substring(0, ind);
                    }
                    temp = head + encodeHLink(tail, myModel.shortForm(new URI(tail))) + tip;
                    break;
                }
                temp = token;
            }
            result = result + SPACE + temp;
        }

        // replace <http with &lt;http to escape <
        // so < will be displayed in the species validation
        // pane rather than being treated as a tag.
        result = result.replaceAll("<http", "&lt;http");
        return result;
    } catch (URISyntaxException ex) {
        ex.printStackTrace();
    }

    // replace <http with &lt;http to escape <
    // so < will be displayed in the species validation
    // pane rather than being treated as a tag.
    source = source.replaceAll("<http", "&lt;http");
    return source; // exception has occurred.  No 'pretty printing' is returned
}

From source file:org.openhab.binding.gpioremotecontrol.internal.GpioRemoteControlBinding.java

private void removeUnusedConnections() {
    try {// ww w  .j  a v  a 2  s. c  o m
        for (GpioRemoteControlBindingProvider provider : providers) {
            keyLoop: for (URI keyUri : provider.getClientMap().keySet()) {
                for (String itemName : provider.getItemNames()) {
                    URI uri = new URI("ws://" + provider.getConfig(itemName).getHostWithPort());
                    if (uri.equals(keyUri)) {
                        continue keyLoop;
                    }
                    provider.getClientMap().get(keyUri).close(); //Close unused connection   
                    provider.getClientMap().remove(keyUri); //If non Item uses the URI, remove the connection            
                }
            }
        }
    } catch (URISyntaxException e) {
        e.printStackTrace();
    } catch (Exception e) {
        logger.debug("Exception in removeUnusedConnections. Shit happens...");
    }
}

From source file:com.mollie.api.resource.BaseResource.java

/**
 * Creates a valid query string from the supplied options that can be used
 * as url parameters. The method returns null if there was an error building
 * the query string./*  www.j  av a  2 s. com*/
 * 
 * @param options options to build a query string from
 * @return a valid query string or null.
 */
private String buildQueryFromMap(Map<String, String> options) {
    URIBuilder ub = null;
    String queryString = null;

    try {
        ub = new URIBuilder();

        for (Map.Entry<String, String> entry : options.entrySet()) {
            ub.addParameter(entry.getKey(), entry.getValue());
        }

        queryString = ub.build().getQuery();
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    return queryString;
}

From source file:com.squid.kraken.v4.auth.OAuth2LoginServlet.java

@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    boolean isSso = false;
    if (request.getParameter(REDIRECT_URI) != null) {
        String redirectUri = request.getParameter(REDIRECT_URI);
        isSso = isSso(request, redirectUri);
    }/*from  w ww .  j ava  2  s  .  c om*/
    if ((request.getParameter(LOGIN) != null) || (request.getParameter(STEP) != null) || isSso) {
        // perform auth
        try {
            login(request, response);
        } catch (URISyntaxException e) {
            e.printStackTrace();
            request.setAttribute(KRAKEN_UNAVAILABLE, Boolean.TRUE);
            showLogin(request, response);
        }
    } else {
        showLogin(request, response);
    }
}

From source file:com.mellanox.jxio.ServerPortal.java

private URI replaceIPinURI(URI uriForForward, String uriIPAddress) {
    URI newUri = null;// ww  w  . j  a v  a  2 s .  c o  m
    try {
        newUri = new URI(uriForForward.getScheme(), uriForForward.getUserInfo(),
                new URI(uriIPAddress).getHost(), uriForForward.getPort(), uriForForward.getPath(),
                uriForForward.getQuery(), uriForForward.getFragment());
    } catch (URISyntaxException e) {
        e.printStackTrace();
        LOG.error(this.toLogString() + "URISyntaxException occured while trying to create a new URI");
    }
    return newUri;
}

From source file:org.epop.dataprovider.pubmed.PubMedSearch.java

@Override
protected Reader getHTMLDoc(String htmlParams, int pageTurnLimit, boolean initialWait) {

    try {/*w  ww.j av a2 s.  co  m*/

        if (initialWait)
            Thread.sleep(DELAY);

        // TODO (low) implemented cleaner solution (desired num. of results
        // in AtomicRequest instead of page turns)
        PubMedDisplayUnits desiredResultUnit = PubMedDisplayUnits
                .getDispmaxParamByDesiredResults(pageTurnLimit * SEARCH_STEP);

        String uriString = PUBMED_SEARCH + "?" + htmlParams;
        if (desiredResultUnit != null)
            uriString += "&dispmax=" + desiredResultUnit;
        URI uri = new URI(uriString);
        HTMLPage page = new HTMLPage(uri);

        return new StringReader(page.getRawCode());

    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ParserConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return null;
    //
    // // return the result as string
    // return new StringReader(responseBody);

}

From source file:com.mellanox.jxio.ServerPortal.java

private URI replacePortInURI(URI uri, int newPort) {
    URI newUri = null;//from   ww w.  j a  v  a 2 s.  c  o  m
    try {
        newUri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), newPort, uri.getPath(),
                uri.getQuery(), uri.getFragment());
        if (LOG.isDebugEnabled()) {
            LOG.debug(this.toLogString() + "uri with port " + newPort + " is " + newUri.toString());
        }
    } catch (URISyntaxException e) {
        e.printStackTrace();
        LOG.error(this.toLogString() + "URISyntaxException occured while trying to create a new URI");
    }

    return newUri;
}

From source file:i5.las2peer.services.analytics.AnalyticsClass.java

private String getResponse(String uri) {

    CloseableHttpResponse response = null;
    URI httpRequest;/*  w ww .  j  a  va2  s.c o  m*/
    String preferenceString = null;

    try {
        httpRequest = new URI(uri);

        CloseableHttpClient httpPreferenceService = HttpClients.createDefault();
        HttpGet getPreferences = new HttpGet(httpRequest);
        response = httpPreferenceService.execute(getPreferences);

        HttpEntity entity = response.getEntity();

        if (entity != null) {
            InputStream instream = entity.getContent();
            preferenceString = convertStreamToString(instream);
            //System.out.println("RESPONSE: " + preferenceString);
            instream.close();
        }

    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return preferenceString;

}