Search in sources :

Example 1 with RepositoryRouter

use of org.locationtech.geogig.rest.repository.RepositoryRouter in project GeoGig by boundlessgeo.

the class Main method createRoot.

@Override
public Restlet createRoot() {
    Router router = new Router() {

        @Override
        protected synchronized void init(Request request, Response response) {
            super.init(request, response);
            if (!isStarted()) {
                return;
            }
            request.getAttributes().put(RepositoryProvider.KEY, repoProvider);
        }
    };
    Router repo = new RepositoryRouter();
    Router osm = new OSMRouter();
    router.attach("/tasks", TaskStatusResource.class);
    router.attach("/tasks/{taskId}.{extension}", TaskStatusResource.class);
    router.attach("/tasks/{taskId}", TaskStatusResource.class);
    router.attach("/osm", osm);
    router.attach("/repo", repo);
    router.attach("/{command}.{extension}", CommandResource.class);
    router.attach("/{command}", CommandResource.class);
    org.restlet.Context context = getContext();
    // enable support for compressing responses if the client supports it.
    // NOTE: restlet 1.0.8 leaves a dangling thread on each request (see
    // EncodeRepresentation.getStream()
    // This problem is fixed in latest versions (2.x) of restlet. See the javadocs for
    // FixedEncoder for further detail
    // Encoder responseEncoder = new com.noelios.restlet.application.Encoder(context);
    FixedEncoder encoder = new FixedEncoder(context);
    encoder.setEncodeRequest(false);
    encoder.setEncodeResponse(true);
    encoder.setNext(router);
    Decoder decoder = new Decoder(context);
    decoder.setDecodeRequest(true);
    decoder.setDecodeResponse(false);
    decoder.setNext(encoder);
    return decoder;
}
Also used : Response(org.restlet.data.Response) OSMRouter(org.locationtech.geogig.rest.osm.OSMRouter) FixedEncoder(org.locationtech.geogig.rest.repository.FixedEncoder) Request(org.restlet.data.Request) OSMRouter(org.locationtech.geogig.rest.osm.OSMRouter) RepositoryRouter(org.locationtech.geogig.rest.repository.RepositoryRouter) Router(org.restlet.Router) RepositoryRouter(org.locationtech.geogig.rest.repository.RepositoryRouter) Decoder(com.noelios.restlet.application.Decoder)

Aggregations

Decoder (com.noelios.restlet.application.Decoder)1 OSMRouter (org.locationtech.geogig.rest.osm.OSMRouter)1 FixedEncoder (org.locationtech.geogig.rest.repository.FixedEncoder)1 RepositoryRouter (org.locationtech.geogig.rest.repository.RepositoryRouter)1 Router (org.restlet.Router)1 Request (org.restlet.data.Request)1 Response (org.restlet.data.Response)1