Package org.restlet

Examples of org.restlet.Uniform


            return true;
        }

        // process the request asynchronously
        LOG.debug("Sending request: {} for exchangeId: {}", request, exchange.getExchangeId());
        client.handle(request, new Uniform() {
            @Override
            public void handle(Request request, Response response) {
                LOG.debug("Received response: {} for exchangeId: {}", response, exchange.getExchangeId());
                try {
                    if (response != null) {
View Full Code Here


            return true;
        }

        // process the request asynchronously
        LOG.debug("Sending request: {} for exchangeId: {}", request, exchange.getExchangeId());
        client.handle(request, new Uniform() {
            @Override
            public void handle(Request request, Response response) {
                LOG.debug("Received response: {} for exchangeId: {}", response, exchange.getExchangeId());
                try {
                    if (response != null) {
View Full Code Here

    public void commit(final ClientCall httpCall, Request request,
            Response response) throws Exception {
        if (httpCall != null) {
            // Check if the call is asynchronous
            if (request.getOnResponse() != null) {
                final Uniform userCallback = request.getOnResponse();

                // Send the request to the client
                httpCall.sendRequest(request, response, new Uniform() {
                    public void handle(Request request, Response response) {
                        try {
                            updateResponse(response,
                                    new Status(httpCall.getStatusCode(), null,
                                            httpCall.getReasonPhrase(), null),
                                    httpCall);
                            userCallback.handle(request, response);
                        } catch (Exception e) {
                            // Unexpected exception occurred
                            if ((response.getStatus() == null)
                                    || !response.getStatus().isError()) {
                                response.setStatus(
                                        Status.CONNECTOR_ERROR_INTERNAL, e);
                                userCallback.handle(request, response);
                            }
                        }
                    }
                });
            } else {
View Full Code Here

                            final Class<?> actualType = (parameterizedType
                                    .getActualTypeArguments()[0] instanceof Class<?>) ? (Class<?>) parameterizedType
                                    .getActualTypeArguments()[0] : null;

                            // Define the callback
                            Uniform callback = new Uniform() {
                                @SuppressWarnings("unchecked")
                                public void handle(Request request,
                                        Response response) {
                                    if (response.getStatus().isError()) {
                                        rCallback
View Full Code Here

     * {@link Client} based on the protocol of the resource's URI reference.
     *
     * @return The created next Restlet or null.
     */
    protected Uniform createNext() {
        Uniform result = null;

        // Prefer the outbound root
        result = getApplication().getOutboundRoot();

        if ((result == null) && (getContext() != null)) {
View Full Code Here

     * context is available.
     *
     * @return The next Restlet or null.
     */
    public Uniform getNext() {
        Uniform result = this.next;

        if (result == null) {
            synchronized (this) {
                if (result == null) {
                    result = createNext();
View Full Code Here

     * @return The response created.
     * @see #getNext()
     */
    public Response handle(Request request) {
        Response response = createResponse(request);
        Uniform next = getNext();

        if (next != null) {
            // Effectively handle the call
            handle(request, response, null, 0, next);

View Full Code Here

            Map<String,String> headers = progress.source.setup();
            Map<String,String> disposition = UploadSource.parseParameters(headers.get("Content-Disposition"));
            String filename = disposition.get("filename");
            is = progress.source.getInputStream();

            Uniform client = getContext().getClientDispatcher();
            //Client client = new Client(getContext().createChildContext(),appRef.getSchemeProtocol());
            Request appRequest = new Request(progress.update ? Method.PUT : Method.POST,appRef);
            appRequest.setRootRef(getRequest().getRootRef());
           
            if (appUsername!=null) {
               getLogger().info("Using username "+appUsername+" for authentication for APP target.");
               appRequest.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,appUsername,appPassword));
            } else if (getRequest().getChallengeResponse()!=null) {
                // pass along authentication
               getLogger().info("Passing along authentication to APP target.");
               appRequest.setChallengeResponse(getRequest().getChallengeResponse());
            }
            Cookie cookie = getRequest().getCookies().getFirst("I");
            if (cookie!=null) {
               appRequest.getCookies().add(cookie);
            }
           
            // add header for slug if new upload
            if (!progress.update && filename!=null) {
               getLogger().info("Upload filename: "+filename);
               Form appHeaders = new Form();
               appHeaders.add("slug",filename);
               appRequest.getAttributes().put("org.restlet.http.headers",appHeaders);
            }
           
            // setup body
            appRequest.setEntity(new InputRepresentation(is,MediaType.valueOf(headers.get("Content-Type"))));
           
            // make request
            Response appResponse = new Response(appRequest);
            client.handle(appRequest,appResponse);

            if (appResponse.getStatus().isSuccess()) {
               if (progress.update) {
                  progress.status = appResponse.getStatus().getCode();
               } else {
View Full Code Here

            return true;
        }

        // process the request asynchronously
        LOG.debug("Sending request: {} for exchangeId: {}", request, exchange.getExchangeId());
        client.handle(request, new Uniform() {
            @Override
            public void handle(Request request, Response response) {
                LOG.debug("Received response: {} for exchangeId: {}", response, exchange.getExchangeId());
                try {
                    if (response != null) {
View Full Code Here

            return true;
        }

        // process the request asynchronously
        LOG.debug("Sending request: {} for exchangeId: {}", request, exchange.getExchangeId());
        client.handle(request, new Uniform() {
            @Override
            public void handle(Request request, Response response) {
                LOG.debug("Received response: {} for exchangeId: {}", response, exchange.getExchangeId());
                try {
                    if (response != null) {
View Full Code Here

TOP

Related Classes of org.restlet.Uniform

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.