Package org.restlet.data

Examples of org.restlet.data.Status


     * @param cause
     *            The wrapped cause error or exception.
     */
    public ResourceException(int code, String name, String description,
            String uri, Throwable cause) {
        this(new Status(code, cause, name, description, uri), cause);
    }
View Full Code Here


     *            The specification code of the encapsulated status.
     * @param cause
     *            The wrapped cause error or exception.
     */
    public ResourceException(int code, Throwable cause) {
        this(new Status(code, cause), cause);
    }
View Full Code Here

     *            The status to copy.
     * @param description
     *            The description of the encapsulated status.
     */
    public ResourceException(Status status, String description) {
        this(new Status(status, description));
    }
View Full Code Here

     *            The description of the encapsulated status.
     * @param cause
     *            The wrapped cause error or exception.
     */
    public ResourceException(Status status, String description, Throwable cause) {
        this(new Status(status, cause, description), cause);
    }
View Full Code Here

     *
     * @param cause
     *            The wrapped cause error or exception.
     */
    public ResourceException(Throwable cause) {
        this(new Status(Status.SERVER_ERROR_INTERNAL, cause), cause);
    }
View Full Code Here

     * @return
     * @see Request#evaluateConditions(Tag, Date)
     */
    private ResponseBuilder evaluatePreconditionsInternal(
            final Date lastModified, final EntityTag entityTag) {
        Status status = this.request.getConditions().getStatus(
                this.request.getMethod(), true,
                Converter.toRestletTag(entityTag), lastModified);

        if (status == null)
            return null;
        if (status.equals(Status.REDIRECTION_NOT_MODIFIED)) {
            final ResponseBuilder rb = Response.notModified();
            rb.lastModified(lastModified);
            rb.tag(entityTag);
            return rb;
        }
View Full Code Here

            getLogger().log(Level.FINER, message, throwable);
        } else if (getLogger().isLoggable(Level.FINE)) {
            getLogger().log(Level.FINE, message);
        }

        status = new Status(status, throwable, message);
        getInboundWay().onError(status);
        getOutboundWay().onError(status);
        close(false);
    }
View Full Code Here

     *            The high-level request.
     * @return The result status.
     */
    @Override
    public Status sendRequest(Request request) {
        Status result = null;

        try {
            final Representation entity = request.getEntity();

            // Set the request headers
            for (Parameter header : getRequestHeaders()) {
                if (!header.getName().equals(
                        HeaderConstants.HEADER_CONTENT_LENGTH)) {
                    getHttpRequest().addHeader(header.getName(),
                            header.getValue());
                }
            }

            // For those method that accept enclosing entities, provide it
            if ((entity != null)
                    && (getHttpRequest() instanceof HttpEntityEnclosingRequestBase)) {
                final HttpEntityEnclosingRequestBase eem = (HttpEntityEnclosingRequestBase) getHttpRequest();
                eem.setEntity(new AbstractHttpEntity() {
                    public InputStream getContent() throws IOException,
                            IllegalStateException {
                        return entity.getStream();
                    }

                    public long getContentLength() {
                        return entity.getSize();
                    }

                    public Header getContentType() {
                        return new BasicHeader(
                                HeaderConstants.HEADER_CONTENT_TYPE, (entity
                                        .getMediaType() != null) ? entity
                                        .getMediaType().toString() : null);
                    }

                    public boolean isRepeatable() {
                        return !entity.isTransient();
                    }

                    public boolean isStreaming() {
                        return (entity.getSize() == Representation.UNKNOWN_SIZE);
                    }

                    public void writeTo(OutputStream os) throws IOException {
                        entity.write(os);
                    }
                });
            }

            // Ensure that the connection is active
            this.httpResponse = this.clientHelper.getHttpClient().execute(
                    getHttpRequest());

            // Now we can access the status code, this MUST happen after closing
            // any open request stream.
            result = new Status(getStatusCode(), null, getReasonPhrase(), null);
        } catch (IOException ioe) {
            this.clientHelper
                    .getLogger()
                    .log(Level.WARNING,
                            "An error occurred during the communication with the remote HTTP server.",
                            ioe);
            result = new Status(Status.CONNECTOR_ERROR_COMMUNICATION, ioe);

            // Release the connection
            getHttpRequest().abort();
        }

View Full Code Here

                throw new IOException(
                        "Unable to parse the reason phrase. End of line reached too early.");
            }

            // Prepare the response
            Status status = createStatus(statusCode);
            Response response = createResponse(status);

            // Update the response
            response.setStatus(status, reasonPhrase);
            response.getServerInfo().setAddress(
View Full Code Here

     * @param throwable
     *            The caught error or exception.
     */
    protected void doCatch(Throwable throwable) {
        Level level = Level.INFO;
        Status status = getStatusService().getStatus(throwable, this);

        if (status.isServerError()) {
            level = Level.WARNING;
        } else if (status.isConnectorError()) {
            level = Level.INFO;
        } else if (status.isClientError()) {
            level = Level.FINE;
        }

        getLogger().log(level, "Exception or error caught in server resource",
                throwable);
View Full Code Here

TOP

Related Classes of org.restlet.data.Status

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.