Example usage for java.net URISyntaxException getMessage

List of usage examples for java.net URISyntaxException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns a string describing the parse error.

Usage

From source file:net.sourceforge.dita4publishers.impl.ditabos.UriToUriPointerRewritingBosVisitor.java

@Override
protected String constructNewHref(DitaBosMember member, BosMember depMember, Element ref)
        throws BosException, AddressingException {
    URI baseUri;//from   ww w  .  j a  v a  2  s . co m
    try {
        baseUri = AddressingUtil.getParent(member.getEffectiveUri());
    } catch (URISyntaxException e) {
        throw new AddressingException("URI syntax exception getting parent of URI \"" + member.getEffectiveUri()
                + "\": " + e.getMessage());
    } catch (MalformedURLException e) {
        throw new AddressingException("MalformedURLException getting parent of URI \""
                + member.getEffectiveUri() + "\": " + e.getMessage());
    } catch (IOException e) {
        throw new AddressingException(
                "IOException getting parent of URI \"" + member.getEffectiveUri() + "\": " + e.getMessage());
    }
    URI depUri = depMember.getEffectiveUri();
    String newHref = AddressingUtil.getRelativePath(depUri, baseUri);
    log.debug("New href=\"" + newHref + "\"");
    return newHref;
}

From source file:eu.optimis.vmmanager.rest.client.VMManagerRESTClient.java

/**
 * Used to create a VM by means of an OVF
 * @returns OVF with the information updated
 *///  w w w . j av  a  2 s . c o  m
public synchronized String addVM(String OVF, String trec_opt) throws VRMMSchedulerException {
    String ovf_ret = null;
    try {
        if (OVF != null) {
            WebResource resource = client.resource(this.getAddress()).path("compute").queryParam("trec_opt",
                    trec_opt);
            ovf_ret = resource.type(MediaType.APPLICATION_XML).post(String.class, OVF);
        }
    } catch (URISyntaxException e) {
        throw new VRMMSchedulerException(e.getMessage(), e);
    }
    return ovf_ret;
}

From source file:eu.supersede.fe.rest.NotificationRest.java

@RequestMapping("")
public List<Notification> getByUserId(Authentication authentication, HttpServletRequest request,
        @RequestParam(defaultValue = "true") Boolean toRead) {
    String scheme;/*from ww  w  .  j  a va2s  . c o m*/
    String host;
    String port;

    if (request.getHeader("x-forwarded-proto") != null || request.getHeader("x-forwarded-host") != null
            || request.getHeader("x-forwarded-port") != null) {
        scheme = request.getHeader("x-forwarded-proto") != null ? request.getHeader("x-forwarded-proto")
                : "http";
        host = request.getHeader("x-forwarded-host") != null ? request.getHeader("x-forwarded-host")
                : request.getServerName();
        port = request.getHeader("x-forwarded-port") != null ? request.getHeader("x-forwarded-port") : null;
    } else {
        scheme = request.getScheme();
        host = request.getServerName();
        port = new Integer(request.getServerPort()).toString();
    }

    String baseUrl = port != null ? scheme + "://" + host + ":" + port + "/#/" : scheme + "://" + host + "/#/";

    DatabaseUser currentUser = (DatabaseUser) authentication.getPrincipal();
    User u = users.getOne(currentUser.getUserId());
    List<Notification> ns;

    if (toRead) {
        ns = notifications.findByUserAndReadOrderByCreationTimeDesc(u, !toRead);
    } else {
        ns = notifications.findByUserOrderByCreationTimeDesc(u);
    }

    for (Notification n : ns) {
        if (n.getLink() != null && !n.getLink().equals("")) {
            try {
                URI uri = new URI(n.getLink());

                if (!uri.isAbsolute()) {
                    n.setLink(baseUrl + n.getLink());
                }
            } catch (URISyntaxException e) {
                log.debug("Error inside link: " + e.getMessage());
            }
        }
    }

    return ns;
}

From source file:cn.isif.util_plus.http.client.HttpRequest.java

@Override
public URI getURI() {
    try {//w  ww.j  a va  2  s.c om
        if (uriCharset == null) {
            uriCharset = OtherUtils.getCharsetFromHttpRequest(this);
        }
        if (uriCharset == null) {
            uriCharset = Charset.forName(HTTP.UTF_8);
        }
        return uriBuilder.build(uriCharset);
    } catch (URISyntaxException e) {
        LogUtils.e(e.getMessage(), e);
        return null;
    }
}

From source file:org.dataconservancy.ui.it.support.ProjectAdminRequest.java

public HttpPost asHttpPost() {
    if (project == null || admin == null || admin.isEmpty()) {
        throw new IllegalStateException(
                "Project, or Admin not set: Call setNewAdminForProject or removeAdminFromProject first");
    }/*w w w  .  j a  v  a2s. c  om*/

    HttpPost post = null;
    try {
        post = new HttpPost(urlConfig.getProjectUrl().toURI());
    } catch (URISyntaxException e) {
        throw new RuntimeException(e.getMessage(), e);
    }

    List<NameValuePair> params = new ArrayList<NameValuePair>();

    if (userToBeAdded) {
        // Make sure all existing pis are kept on the project
        int i = 0;
        for (i = 0; i < project.getPis().size(); i++) {
            params.add(new BasicNameValuePair("projectAdminList[" + i + "]", project.getPis().get(i)));
        }
        params.add(new BasicNameValuePair("projectAdminList[" + i + "]", admin));
    } else {
        int index = 0;
        for (int i = 0; i < project.getPis().size(); i++) {
            String pi = project.getPis().get(i);
            if (!pi.equalsIgnoreCase(admin)) {
                params.add(new BasicNameValuePair("projectAdminList[" + index + "]", pi));
                index++;
            }
        }

    }
    params.add(new BasicNameValuePair("project.id", project.getId()));
    params.add(new BasicNameValuePair("project.name", project.getName()));
    params.add(new BasicNameValuePair("project.description", project.getDescription()));
    if (!project.getNumbers().isEmpty()) {
        for (int i = 0; i < project.getNumbers().size(); i++) {
            params.add(new BasicNameValuePair("project.numbers[" + i + "]", project.getNumbers().get(i)));
        }
    }
    params.add(new BasicNameValuePair("project.fundingEntity", project.getFundingEntity()));
    params.add(new BasicNameValuePair("project.startDate", project.getStartDate().toString()));
    params.add(new BasicNameValuePair("project.endDate", project.getEndDate().toString()));
    params.add(new BasicNameValuePair("forwardRequestSource", "/pages/view_projects_list.jsp"));
    params.add(new BasicNameValuePair(STRIPES_EVENT, "Update Project"));

    HttpEntity entity = null;
    try {
        entity = new UrlEncodedFormEntity(params, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e.getMessage(), e);
    }

    post.setEntity(entity);

    return post;
}

From source file:ws.bors.atd.SpellChecker.java

/**
 * Construct a new atd-java {@link SpellChecker} using the default English AtD server.
 *
 * @throws RuntimeException for when a {@link URISyntaxException} occurs.
 * @see <a href="http://www.AfterTheDeadline.com/api.slp">http://www.AfterTheDeadline.com/api.slp</a>
 *//* ww w .j a  v  a2 s . c  om*/
public SpellChecker() throws RuntimeException {
    try {
        atdServer = new URI("http://" + Language.ENGLISH + ".Service.AfterTheDeadline.com/checkDocument");
        apiKey = "https://github.com/paulbors/atd-java?" + System.currentTimeMillis();
        options = new DefaultSpellCheckerOptions();
    } catch (URISyntaxException urise) {
        throw new RuntimeException(urise.getMessage(), urise);
    }
}

From source file:ws.bors.atd.SpellChecker.java

/**
 * Construct a new atd-java {@link SpellChecker} using a custom AtD server and API key.
 *
 * @param atdServerUrl  Required, The AtD server to connect and send queries to.
 * @param apiKey        ID + 32 hex digits<br/><br/>Required, used to control server-side caching.<br/><br/>
 *                      The API key is used as both a synchronous locking point (e.g., only one request/key is
 *                      processed at a time) and to enable server-side caching of results and session information.
 *                      This makes subsequent requests for the same key much faster.
 *
 * @throws RuntimeException for when a {@link URISyntaxException} occurs.
 * @see <a href="http://www.AfterTheDeadline.com/api.slp">http://www.AfterTheDeadline.com/api.slp</a>
 *///from   www  .ja  v  a  2s.c  om
public SpellChecker(String atdServerUrl, String apiKey) throws RuntimeException {
    this();
    try {
        this.atdServer = new URI(atdServerUrl);
        this.apiKey = apiKey;
    } catch (URISyntaxException urise) {
        throw new RuntimeException(urise.getMessage(), urise);
    }
}

From source file:disono.webmons.com.utilities.library.SocketIO.SocketIOConnector.java

/**
 * Initialize// w  ww  .  jav  a2s. c  o m
 *
 * @return
 */
private Socket _init(String url, IO.Options options) {
    try {
        String path = (url != null) ? url : Configurations.envString("socketIOURL");
        return this.mSocket = IO.socket(path, options);
    } catch (URISyntaxException e) {
        Log.e(TAG, e.getMessage());
    }

    return null;
}

From source file:org.dspace.submit.lookup.ArXivService.java

protected List<Record> search(String query, String arxivid, int max_result) throws IOException, HttpException {
    List<Record> results = new ArrayList<Record>();
    HttpGet method = null;/*from   ww w . j a  v a 2s .c o m*/
    try {
        HttpClient client = new DefaultHttpClient();
        HttpParams params = client.getParams();
        params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout);

        try {
            URIBuilder uriBuilder = new URIBuilder("http://export.arxiv.org/api/query");
            uriBuilder.addParameter("id_list", arxivid);
            uriBuilder.addParameter("search_query", query);
            uriBuilder.addParameter("max_results", String.valueOf(max_result));
            method = new HttpGet(uriBuilder.build());
        } catch (URISyntaxException ex) {
            throw new HttpException(ex.getMessage());
        }

        // Execute the method.
        HttpResponse response = client.execute(method);
        StatusLine responseStatus = response.getStatusLine();
        int statusCode = responseStatus.getStatusCode();

        if (statusCode != HttpStatus.SC_OK) {
            if (statusCode == HttpStatus.SC_BAD_REQUEST)
                throw new RuntimeException("arXiv query is not valid");
            else
                throw new RuntimeException("Http call failed: " + responseStatus);
        }

        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setValidating(false);
            factory.setIgnoringComments(true);
            factory.setIgnoringElementContentWhitespace(true);

            DocumentBuilder db = factory.newDocumentBuilder();
            Document inDoc = db.parse(response.getEntity().getContent());

            Element xmlRoot = inDoc.getDocumentElement();
            List<Element> dataRoots = XMLUtils.getElementList(xmlRoot, "entry");

            for (Element dataRoot : dataRoots) {
                Record crossitem = ArxivUtils.convertArxixDomToRecord(dataRoot);
                if (crossitem != null) {
                    results.add(crossitem);
                }
            }
        } catch (Exception e) {
            throw new RuntimeException("ArXiv identifier is not valid or not exist");
        }
    } finally {
        if (method != null) {
            method.releaseConnection();
        }
    }

    return results;
}

From source file:org.geosdi.geoplatform.connector.CatalogContextTest.java

@Before
public void setUp() throws Exception {
    try {/*w  w  w. j  a  va2  s  .c  o  m*/
        HttpClient client = new DefaultHttpClient();

        List<NameValuePair> qparams = new ArrayList<NameValuePair>();
        qparams.add(new BasicNameValuePair("SERVICE", "CSW"));
        qparams.add(new BasicNameValuePair("REQUEST", "GetCapabilities"));

        URI uri = URIUtils.createURI("http", CSW_HOST, -1, CSW_PATH, URLEncodedUtils.format(qparams, "UTF-8"),
                null);

        HttpGet get = new HttpGet(uri);

        HttpResponse response = client.execute(get);

        this.entity = response.getEntity();

    } catch (URISyntaxException ex) {
        logger.error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " + ex.getMessage());
    } catch (ClientProtocolException ex) {
        logger.error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " + ex.getMessage());
    } catch (IOException ex) {
        logger.error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " + ex.getMessage());
    }
}