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:io.github.jhipster.security.uaa.LoadBalancedResourceDetails.java

@Override
public String getAccessTokenUri() {
    if (loadBalancerClient != null && tokenServiceId != null && !tokenServiceId.isEmpty()) {
        try {/* w ww  .  j a v a  2  s.  co m*/
            return loadBalancerClient.reconstructURI(loadBalancerClient.choose(tokenServiceId),
                    new URI(super.getAccessTokenUri())).toString();
        } catch (URISyntaxException e) {
            log.error("{}: {}", e.getClass().toString(), e.getMessage());

            return super.getAccessTokenUri();
        }
    } else {
        return super.getAccessTokenUri();
    }
}

From source file:org.llorllale.youtrack.api.session.UsernamePassword.java

@Override
public Session session() throws AuthenticationException, IOException {
    try {/*from  w  w w .j  a v a  2 s.c o m*/
        final HttpResponse response = this.httpClient
                .execute(new HttpPost(new URIBuilder(this.youtrackUrl.toString().concat("/user/login"))
                        .setParameter("login", this.username)
                        .setParameter("password", new String(this.password)).build()));

        //@checkstyle todo there is more branching here
        if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
            throw new AuthenticationException("Invalid credentials.");
        }

        final String cookieHeader = "Cookie";
        final Cookie cookie = Arrays.asList(response.getAllHeaders()).stream()
                .filter(header -> "Set-Cookie".equals(header.getName()))
                .map(header -> new DefaultCookie(cookieHeader, header.getValue().split(";")[0]))
                .reduce((cookieA, cookieB) -> new DefaultCookie(cookieHeader,
                        cookieA.value().concat("; ").concat(cookieB.value())))
                .get();

        return new DefaultSession(this.youtrackUrl, cookie);
    } catch (URISyntaxException e) {
        throw new IOException(e.getMessage());
    }
}

From source file:it.smartcommunitylab.aac.oauth.ExtOAuth2SuccessHandler.java

protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
        throws IOException, ServletException {

    OAuth2Authentication oauth = (OAuth2Authentication) authentication;
    @SuppressWarnings("unchecked")
    Map<String, Object> details = (Map<String, Object>) oauth.getUserAuthentication().getDetails();
    details = preprocess(details);// w ww .ja  v a  2s.  com
    try {
        URIBuilder builder = new URIBuilder(getDefaultTargetUrl());
        for (String key : details.keySet()) {
            builder.addParameter(key, details.get(key).toString());
            request.setAttribute(key, details.get(key));
        }
        request.getRequestDispatcher(builder.build().toString()).forward(request, response);
        //         response.sendRedirect("forward:"+builder.build().toString());
        //         getRedirectStrategy().sendRedirect(request, response, builder.build().toString());
    } catch (URISyntaxException e) {
        throw new ServletException(e.getMessage());
    }
}

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

public HttpPost asHttpPost() {

    if (collectionIdToView == null) {
        throw new RuntimeException(
                "Id of the collection to be viewed has not been set. Call setCollectionIdToView() first");
    }// ww  w . ja v a 2 s  .c  o  m

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

    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("selectedCollectionId", "collectionIdToView"));
    params.add(new BasicNameValuePair(STRIPES_EVENT, "View Collections Details"));

    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:org.onebusaway.alexa.MainSpeechlet.java

public SpeechletResponse onLaunch(LaunchRequest request, Session session) throws SpeechletException {
    Optional<ObaUserDataItem> optUserData = obaDao.getUserData(session);
    if (optUserData.isPresent()) {
        try {/*w  ww.ja va  2  s  .c  o  m*/
            return getAuthedSpeechlet(optUserData.get()).onLaunch(request, session);
        } catch (URISyntaxException e) {
            log.error("Launch exception: " + e.getMessage());
            log.error("Backtrace:\n" + e.getStackTrace());
            throw new SpeechletException("Error creating user data on Launch using ObaBaseUrl: " + e);
        }
    } else {
        return anonSpeechlet.onLaunch(request, session);
    }
}

From source file:org.onebusaway.alexa.MainSpeechlet.java

public SpeechletResponse onIntent(final IntentRequest request, final Session session)
        throws SpeechletException {
    try {/*from   w w w . j a va  2s.  com*/
        Optional<ObaUserDataItem> optUserData = obaDao.getUserData(session);
        if (optUserData.isPresent()) {
            return getAuthedSpeechlet(optUserData.get()).onIntent(request, session);
        } else {
            return anonSpeechlet.onIntent(request, session);
        }
    } catch (URISyntaxException e) {
        log.error("Intent exception: " + e.getMessage());
        log.error("Backtrace:\n" + e.getStackTrace());
        throw new SpeechletException("Error creating user data on Intent using ObaBaseUrl: " + e);
    } catch (Exception e) {
        log.error("Intent exception: " + e.getMessage());
        log.error("Backtrace:\n" + e.getStackTrace());
        throw e;
    }
}

From source file:com.nadmm.airports.tfr.TfrService.java

private void getTfrList(Intent intent) {
    boolean force = intent.getBooleanExtra(FORCE_REFRESH, false);

    File tfrFile = getFile(TFR_CACHE_NAME);
    if (!tfrFile.exists() || force) {
        URI uri;/* w  w w  .  j a  va2s .  co  m*/
        try {
            uri = URIUtils.createURI("http", TFR_HOST, 80, TFR_PATH, TFR_QUERY, null);
            fetch(uri, tfrFile);
        } catch (URISyntaxException e) {
            UiUtils.showToast(this, "TFR: " + e.getMessage());
        }
    }

    TfrList tfrList = new TfrList();
    mParser.parse(tfrFile, tfrList);
    Collections.sort(tfrList.entries);

    Intent result = makeResultIntent(intent.getAction());
    result.putExtra(TFR_LIST, tfrList);
    sendResultIntent(result);
}

From source file:com.macrossx.wechat.impl.WechatUserHelper.java

public Optional<WechatUserGet> userGet(String nextOpenid) {
    try {//from   w  ww.  jav  a 2 s .c  om
        Optional<WechatAccessToken> token = helper.getAccessToken();
        if (token.isPresent()) {
            WechatAccessToken accessToken = token.get();
            HttpGet httpGet = new HttpGet();

            httpGet.setURI(new URI(MessageFormat.format(WechatConstants.USER_GET_URL,
                    accessToken.getAccess_token(), nextOpenid == null ? "" : nextOpenid)));
            return new WechatHttpClient().send(httpGet, WechatUserGet.class);
        }
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        log.info(e.getMessage());
    }
    return Optional.empty();
}

From source file:com.macrossx.wechat.impl.WechatUserHelper.java

public Optional<WechatUserInfo> userInfo(String openid) {
    try {/*from   ww w  .ja  v  a  2 s .  co m*/
        Optional<WechatAccessToken> token = helper.getAccessToken();
        if (token.isPresent()) {
            WechatAccessToken accessToken = token.get();
            HttpGet httpGet = new HttpGet();

            httpGet.setURI(new URI(MessageFormat.format(WechatConstants.USER_INFO_URL,
                    accessToken.getAccess_token(), openid)));
            return new WechatHttpClient().send(httpGet, WechatUserInfo.class);
        }
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        log.info(e.getMessage());
    }
    return Optional.empty();
}

From source file:com.nadmm.airports.tfr.TfrImageService.java

private void getTfrImage(Intent intent) {
    Tfr tfr = (Tfr) intent.getSerializableExtra(TFR_ENTRY);
    String notamId = tfr.notamId;
    int start = notamId.indexOf(' ');
    if (start > 0) {
        notamId = notamId.substring(start + 1);
    }//from w  w  w  .  j av a  2 s.c o  m
    notamId = notamId.replace("/", "_");

    String name = "sect_" + notamId + ".gif";
    File imageFile = getFile(name);

    if (!imageFile.exists()) {
        URI uri;
        try {
            uri = URIUtils.createURI("http", TFR_HOST, 80, TFR_PATH + "/" + name, null, null);
            fetch(uri, imageFile);
        } catch (URISyntaxException e) {
            UiUtils.showToast(this, "TFR: " + e.getMessage());
        }
    }

    Intent result = makeResultIntent(intent.getAction());
    if (imageFile.exists()) {
        result.putExtra(TFR_IMAGE_PATH, imageFile.getAbsolutePath());
    }
    sendResultIntent(result);
}