Package org.restlet

Examples of org.restlet.Request


     *            The entry URI.
     * @throws IOException
     */
    public Entry(Context context, String entryUri) throws IOException {
        this(context.getClientDispatcher().handle(
                new Request(Method.GET, entryUri)).getEntity());
    }
View Full Code Here


    private volatile Reference uniqueReference;

    @Override
    public Representation delete() throws ResourceException {
        if (this.directory.isModifiable()) {
            Request contextRequest = new Request(Method.DELETE, this.targetUri);
            Response contextResponse = new Response(contextRequest);

            if (this.directoryTarget && !this.indexTarget) {
                contextRequest.setResourceRef(this.targetUri);
                getClientDispatcher().handle(contextRequest, contextResponse);
            } else {
                // Check if there is only one representation
                // Try to get the unique representation of the resource
                ReferenceList references = getVariantsReferences();
                if (!references.isEmpty()) {
                    if (this.uniqueReference != null) {
                        contextRequest.setResourceRef(this.uniqueReference);
                        getClientDispatcher().handle(contextRequest,
                                contextResponse);
                    } else {
                        // We found variants, but not the right one
                        contextResponse
View Full Code Here

     *            The URI of the target resource.
     * @return A response with the representation if success.
     */
    private Response getRepresentation(String resourceUri) {
        return getClientDispatcher().handle(
                new Request(Method.GET, resourceUri));
    }
View Full Code Here

     */
    protected Response getRepresentation(String resourceUri,
            MediaType acceptedMediaType) {
        if (acceptedMediaType == null) {
            return getClientDispatcher().handle(
                    new Request(Method.GET, resourceUri));
        }

        Request request = new Request(Method.GET, resourceUri);
        request.getClientInfo().getAcceptedMediaTypes()
                .add(new Preference<MediaType>(acceptedMediaType));
        return getClientDispatcher().handle(request);
    }
View Full Code Here

    @Override
    public Representation put(Representation entity) throws ResourceException {
        if (this.directory.isModifiable()) {
            // Transfer of PUT calls is only allowed if the readOnly flag is
            // not set.
            Request contextRequest = new Request(Method.PUT, this.targetUri);

            // Add support of partial PUT calls.
            contextRequest.getRanges().addAll(getRanges());
            contextRequest.setEntity(entity);
            Response contextResponse = new Response(contextRequest);
            contextRequest.setResourceRef(this.targetUri);
            getClientDispatcher().handle(contextRequest, contextResponse);
            setStatus(contextResponse.getStatus());
        } else {
            setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED,
                    "The directory is not modifiable.");
View Full Code Here

     * @throws IOException
     */
    public Service(Client clientDispatcher, String serviceUri)
            throws IOException {
        this(clientDispatcher, serviceUri, clientDispatcher.handle(
                new Request(Method.GET, serviceUri)).getEntity());
    }
View Full Code Here

     * @throws IOException
     */
    public Service(Context context, String serviceUri) throws IOException {
        this(context.getClientDispatcher(), serviceUri, context
                .getClientDispatcher().handle(
                        new Request(Method.GET, serviceUri)).getEntity());
    }
View Full Code Here

     * @param uri
     *            The resource URI.
     * @return The result status.
     */
    public Status deleteResource(String uri) {
        return getClientDispatcher().handle(new Request(Method.DELETE, uri))
                .getStatus();
    }
View Full Code Here

     * @param uri
     *            The resource URI.
     * @return The resource representation.
     */
    public Representation getResource(String uri) {
        return getClientDispatcher().handle(new Request(Method.GET, uri))
                .getEntity();
    }
View Full Code Here

                        }
                    }
                }

                // Clone the prototype request
                Request request = getClientResource().createRequest(
                        getClientResource().getRequest());

                // The Java method was annotated
                request.setMethod(annotation.getRestletMethod());

                // Set the entity
                request.setEntity(requestEntity);

                // Updates the client preferences if they weren't changed
                if ((request.getClientInfo().getAcceptedCharacterSets().size() == 0)
                        && (request.getClientInfo().getAcceptedEncodings()
                                .size() == 0)
                        && (request.getClientInfo().getAcceptedLanguages()
                                .size() == 0)
                        && (request.getClientInfo().getAcceptedMediaTypes()
                                .size() == 0)) {
                    List<Variant> responseVariants = annotation
                            .getResponseVariants(getClientResource()
                                    .getMetadataService(), getClientResource()
                                    .getConverterService());

                    if (responseVariants != null) {
                        request.setClientInfo(new ClientInfo(responseVariants));
                    }
                }

                // Effectively handle the call
                Response response = getClientResource().handle(request);
View Full Code Here

TOP

Related Classes of org.restlet.Request

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.