Package org.restlet.resource

Examples of org.restlet.resource.ResourceException


            // We have input data - do command
            // Check method constraints
            if( !constraints.isValid( interactionMethod, current(), module ) )
            {
                throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND );
            }

            // Create argument
            Object[] arguments = requestReader.readRequest( Request.getCurrent(), interactionMethod );
            Request.getCurrent().getAttributes().put( ARGUMENTS, arguments );
View Full Code Here


                return;
            }
            else
            {
                // 404
                throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND );
            }
        }

        // Check if this is a request to show the form for this interaction
        if( ( request
                  .getMethod()
                  .isSafe() && queryMethod.getParameterTypes().length != 0 && request
                                                                                  .getResourceRef()
                                                                                  .getQuery() == null ) ||
            ( !request
                .getMethod()
                .isSafe() && queryMethod.getParameterTypes().length != 0 && !( request
                                                                                   .getEntity()
                                                                                   .isAvailable() || request
                                                                                                         .getResourceRef()
                                                                                                         .getQuery() != null || queryMethod
                .getParameterTypes()[ 0 ].equals( Response.class ) ) ) )
        {
            // Show form
            try
            {
                // Tell client to try again
                response.setStatus( Status.CLIENT_ERROR_UNPROCESSABLE_ENTITY );
                response.getAllowedMethods().add( org.restlet.data.Method.GET );
                response.getAllowedMethods().add( org.restlet.data.Method.POST );
                result( formForMethod( queryMethod ) );
            }
            catch( Exception e )
            {
                handleException( response, e );
            }
        }
        else
        {
            // Check timestamps
            ResourceValidity validity = (ResourceValidity) request.getAttributes().get( RESOURCE_VALIDITY );
            if( validity != null )
            {
                validity.checkRequest();
            }

            // We have input data - do query
            // Check method constraints
            if( !constraints.isValid( queryMethod, current(), module ) )
            {
                throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND );
            }

            try
            {
                // Create argument
View Full Code Here

                startEvent = Long.parseLong( indices[0] );
                endEvent = Long.parseLong( indices[1] );
                limit = 1+endEvent-startEvent;

            } else
                throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND );

            if (startEvent > 0)
            {
                long previousStart = Math.max(0, startEvent-pageSize);
                long previousEnd = startEvent-1;

                Link link = new Link( new Reference( previousStart+","+previousEnd ), new Relation( "previous" ), MediaType.APPLICATION_ATOM );
                link.setTitle( "Previous page" );
                links.add( link );
            }

            long nextStart = endEvent+1;
            long nextEnd = nextStart+pageSize-1;

            if (nextStart < eventCount)
                if (nextEnd >= eventCount)
                {
                    Link next = new Link( new Reference( nextStart+"" ), new Relation( "next" ), MediaType.APPLICATION_ATOM );
                    next.setTitle( "Working set" );
                    links.add( next );
                } else
                {
                    Link next = new Link( new Reference( nextStart+","+nextEnd ), new Relation( "next" ), MediaType.APPLICATION_ATOM );
                    next.setTitle( "Next page" );
                    links.add( next );
                }
        }

        try
        {
            source.events( startEvent, limit ).transferTo( Outputs.collection( eventsValues ) );
        } catch (Throwable throwable)
        {
            throw new ResourceException( Status.SERVER_ERROR_INTERNAL, throwable );
        }

        Link last = new Link( new Reference( "0,"+(pageSize-1) ), new Relation( "last" ), MediaType.APPLICATION_ATOM );
        last.setTitle( "Last archive page" );
        links.add( last );
View Full Code Here

                return specificationResponseHandlerEntry.getValue().handleResponse( response, client );
            }
        }

        // No handlers, throw exception
        throw new ResourceException( response.getStatus() );
    }
View Full Code Here

        else if( MediaType.APPLICATION_ATOM.equals( variant.getMediaType() ) )
        {
            return representAtom();
        }

        throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND );
    }
View Full Code Here

                }
            };
        }
        catch( Exception e )
        {
            throw new ResourceException( e );
        }
    }
View Full Code Here

            return representation;
        }
        catch( EntityFinderException e )
        {
            throw new ResourceException( Status.SERVER_ERROR_INTERNAL, e );
        }
    }
View Full Code Here

            representation.setCharacterSet( CharacterSet.UTF_8 );
            return representation;
        }
        catch( EntityFinderException e )
        {
            throw new ResourceException( e );
        }
    }
View Full Code Here

            return feed;
        }
        catch( Exception e )
        {
            throw new ResourceException( e );
        }
    }
View Full Code Here

             * Status.CLIENT_ERROR_CONFLICT ); }
             */
        }
        catch( Exception e )
        {
            throw new ResourceException( e );
        }

        return new EmptyRepresentation();
    }
View Full Code Here

TOP

Related Classes of org.restlet.resource.ResourceException

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.