Package org.restlet.routing

Examples of org.restlet.routing.Redirector


        // remove...
        if (callback == null)
            callback = request.getCookies().getFirstValue(
                    INTERNAL_SERVER_COOKIE);
        if (callback != null) {
            Redirector dispatcher = new Redirector(getContext(), callback,
                    Redirector.MODE_CLIENT_TEMPORARY);

            // //TODO maybe move it to use Principal.
            getContext().getAttributes().put("id", id); // same app
            dispatcher.handle(request, response);
            response.getCookieSettings().remove(INTERNAL_SERVER_COOKIE);
        } else {
            JSONObject obj = new JSONObject();
            try {
                obj.put("id", id);
                // for(String s : axRequired.keySet()) {
                // obj.put(s, axRequired.get(s));
                // }
                // for(String s : axOptional.keySet()) {
                // obj.put(s, axOptional.get(s));
                // }
            } catch (JSONException e) {
                getLogger().log(Level.WARNING, "Failed to get the ID!", e);
            }

            String jcallback = response.getCookieSettings().getFirstValue(
                    EXTERNAL_SERVER_COOKIE);
            if (jcallback == null)
                jcallback = request.getCookies().getFirstValue(
                        EXTERNAL_SERVER_COOKIE);
            if (jcallback != null) {
                Redirector dispatcher = new Redirector(getContext(), jcallback,
                        Redirector.MODE_SERVER_OUTBOUND);
                request.setEntity(new JsonRepresentation(obj));
                request.setMethod(Method.POST);
                dispatcher.handle(request, response);
                response.getCookieSettings().remove(EXTERNAL_SERVER_COOKIE);
            } else {
                response.setEntity(new JsonRepresentation(obj));
            }
        }
View Full Code Here


        clientComponent.getClients().add(Protocol.HTTP);
        proxyComponent.getClients().add(Protocol.HTTP);

        // Create the proxy Restlet
        final String target = "http://localhost:" + (TEST_PORT + 1) + "{rr}";
        final Redirector proxy = new Redirector(proxyComponent.getContext()
                .createChildContext(), target, Redirector.MODE_SERVER_OUTBOUND);

        // Create a new Restlet that will display some path information.
        final Restlet trace = new Restlet(originComponent.getContext()
                .createChildContext()) {
View Full Code Here

    @Override
    public Restlet createInboundRoot() {
        final Router router = new Router(getContext());

        // Redirect by defaul to the lst of users.
        router.attachDefault(new Redirector(getContext(), "/users",
                Redirector.MODE_CLIENT_PERMANENT));

        final Directory imgDirectory = new Directory(getContext(),
                LocalReference.createFileReference(webRootPath + "/images"));
        // Add a route for the image resources
View Full Code Here

        // Create a root router
        Router router = new Router(getContext());

        // Create a Redirector to Google search service
        String target = "http://www.google.com/search?q=site:mysite.org+{keywords}";
        Redirector redirector = new Redirector(getContext(), target,
                Redirector.MODE_CLIENT_TEMPORARY);

        // While routing requests to the redirector, extract the "kwd" query
        // parameter. For instance :
        // http://localhost:8111/search?kwd=myKeyword1+myKeyword2
View Full Code Here

                    ref.addQueryParameter("grantedScope", Scopes.toScope(r));
            }
        }

        getLogger().info("Redir = " + ref);
        Redirector dispatcher = new Redirector(getContext(), ref.toString(),
                Redirector.MODE_SERVER_OUTBOUND);
        // getRequest().setCookies(getResponse().getCookieSettings().get
        // getRequest().setCookies(cookies)
        getRequest().getAttributes().put(ClientCookieID, session.getId());
        dispatcher.handle(getRequest(), getResponse());
        return getResponseEntity();

    }
View Full Code Here

            }
           
            Reference targetRef = new Reference(to);
            Restlet restlet = null;
            if (targetRef.isAbsolute() && targetRef.getScheme().equals("riap")) {
               restlet = new Redirector(parentContext,to,Redirector.MODE_SERVER_INBOUND);
            } else {
               restlet = new Redirector(parentContext,to,Redirector.MODE_CLIENT_SEE_OTHER);
            }
            if (defaultRoute) {
               router.attachDefault(restlet);
            } else if (router!=null) {
               String [] extraction = null;
View Full Code Here

                    ref.addQueryParameter("grantedScope", Scopes.toScope(r));
            }
        }

        getLogger().info("Redir = " + ref);
        Redirector dispatcher = new Redirector(getContext(), ref.toString(),
                Redirector.MODE_SERVER_OUTBOUND);
        dispatcher.handle(getRequest(), getResponse());
        return getResponseEntity();

    }
View Full Code Here

      Router router = new Router(getContext());
      router.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
      Filter guard = new UserGuard(getContext(),ChallengeScheme.HTTP_BASIC,"Atom User",auth);
      guard.setNext(router);
     
      Redirector byId = new IdRedirector(getContext(),this,atomDB,RESOURCE_BASE);
      router.attach("/id/",byId);
     
      ProtocolByPathFinder byPath = new ProtocolByPathFinder(getContext(),this,RESOURCE_BASE,app,atomDB,storage);
      router.attach(RESOURCE_BASE.toString(),byPath);
      router.attach("/R",byPath);
View Full Code Here

        String restapihost = getContext().getParameters().getFirstValue("restapi.host", "localhost");
        String restapiport = getContext().getParameters().getFirstValue("restapi.port", "8111");

        String target = "http://" + restapihost + ":" + restapiport + "/v2{rr}";
        router.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
        Redirector redirector = new Redirector(getContext(), target, Redirector.MODE_SERVER_OUTBOUND);
        router.attach("/v2", redirector);
        router.attach("/", new Directory(getContext(), "war:///"));
        return router;
    }
View Full Code Here

    ;
 
  public void createRedirector(String ip) {
        System.out.println("creating redirector: " + ip);
        String target = "http://" + ip + "8111/v2{rr}";
        Redirector redirector = new Redirector(getContext(), target, Redirector.MODE_SERVER_OUTBOUND);
//    router.attach("/v1", redirector);
        ((Router) getInboundRoot()).attach("/v2", redirector);
        System.out.println("Finishing redirector");
    }
View Full Code Here

TOP

Related Classes of org.restlet.routing.Redirector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.