Example usage for org.apache.wicket.request Request getClientUrl

List of usage examples for org.apache.wicket.request Request getClientUrl

Introduction

In this page you can find the example usage for org.apache.wicket.request Request getClientUrl.

Prototype

public abstract Url getClientUrl();

Source Link

Document

Returns the url against which the client, usually the browser, will resolve relative urls in the rendered markup.

Usage

From source file:org.brixcms.web.BrixRequestMapper.java

License:Apache License

@Override
public IRequestHandler mapRequest(Request request) {
    final Url url = request.getClientUrl();

    // TODO: This is just a quick fix
    if (url.getSegments().size() > 0) {
        if (url.getSegments().get(0).equals("webdav") || url.getSegments().get(0).equals("jcrwebdav")) {
            return null;
        }/*from   ww w.  j  a va  2  s. c  om*/
    }

    Path path = new Path("/" + url.toString());

    // root path handling
    if (path.isRoot()) {
        if (handleHomePage) {
            final BrixNode node = getNodeForUriPath(path);
            return SitePlugin.get().getNodePluginForNode(node).respond(new BrixNodeModel(node),
                    request.getRequestParameters());
        } else {
            return null;
        }
    }

    IRequestHandler handler = null;
    try {
        while (handler == null) {
            final BrixNode node = getNodeForUriPath(path);
            if (node != null) {
                handler = SitePlugin.get().getNodePluginForNode(node).respond(new BrixNodeModel(node),
                        request.getRequestParameters());
            }
            if (handler != null || path.toString().equals(".")) {
                break;
            }
            path = path.parent();
            if (path.isRoot()) {
                break;
            }
        }
    } catch (JcrException e) {
        logger.warn("JcrException caught due to incorrect url", e);
    }

    return handler;
}

From source file:org.tomochika1985.twitter.AppSession.java

License:Apache License

public Twitter getTwitterSession(Request request) throws NeedAuthenticationException {
    if (request == null)
        throw new IllegalArgumentException("'request' is missing");

    //?Twitter?????????
    if (twitterSession != null)
        return twitterSession;

    // AccessTokenDB?????????????AccessToken??
    // Twitter????????
    // ????AccessToken???????????OAuth??

    // OAuth?RequestToken???
    Twitter client = new TwitterClient();
    client.setOAuthConsumer(consumerKey, consumerSecret);

    RequestToken token = null;/*from   w  w  w. jav a  2s.  c o  m*/
    try {
        token = client.getOAuthRequestToken(RequestUtils.toAbsolutePath("login", "/"));
    } catch (TwitterException ex) {
        throw new RuntimeException(ex);
    }

    this.requestToken = token;
    this.lastAccessUrl = request.getClientUrl().toString();
    dirty();

    throw new RedirectToUrlException(token.getAuthorizationURL());
}