Package com.pugh.sockso.web

Examples of com.pugh.sockso.web.BadRequestException


       
        // if the user isn't logged in then make sure that anonymous
        // uploads have been enabled
        if ( user == null )
            if ( !p.get(Constants.WWW_UPLOADS_ALLOW_ANONYMOUS).equals(Properties.YES) )
                throw new BadRequestException( locale.getString("www.error.noAnonymousUploads"), 403 );

        // check there is a valid collection set for uploads
        final Database db = getDatabase();
        final String uploadsPath = Utils.getUploadsPath( db, p );
        if ( uploadsPath.equals("") )
            throw new BadRequestException( locale.getString("www.error.noUploadsDirectory"), 500 );
        final File uploadsDir = new File( uploadsPath );
        if ( !uploadsDir.canWrite() )
            throw new BadRequestException( locale.getString("www.error.uploadsDirNotWritable"), 500 );

    }
View Full Code Here


       
        final int albumId = Integer.parseInt( getRequest().getUrlParam(2) );
        final Album album = Album.find( getDatabase(), albumId );
       
        if ( album == null ) {
            throw new BadRequestException( "Invalid album id" );
        }
       
        final List<Track> tracks = Track.getTracks( getDatabase(), "al", albumId );
       
        showTracks( tracks );
View Full Code Here

            getDatabase(),
            Integer.parseInt( getRequest().getUrlParam(2) )
        );

        if ( track == null ) {
            throw new BadRequestException( "Track not found", 404 );
        }
       
        showTrack( track );
       
    }
View Full Code Here

            getDatabase(),
            Integer.parseInt(getRequest().getUrlParam(2))
        );
       
        if ( album == null ) {
            throw new BadRequestException( "Invalid album id" );
        }
       
        showAlbum( album );
       
    }
View Full Code Here

            getDatabase(),
            Integer.parseInt( getRequest().getUrlParam(2) )
        );
       
        if ( artist == null ) {
            throw new BadRequestException( "Invalid artist ID", 404 );
        }
       
        showArtist( artist );
       
    }
View Full Code Here

       
        final Database db = getDatabase();
        final Playlist playlist = Playlist.find( db, Integer.parseInt( getRequest().getUrlParam(2) ) );
       
        if ( playlist == null ) {
            throw new BadRequestException( "Invalid playlist ID" );
        }
       
        showPlaylist( playlist, playlist.getTracks(db) );
       
    }
View Full Code Here

    }
   
    private void showBurp( final int statusCode, final String referer, final String expectContains ) throws Exception {
       
        final TestResponse res = new TestResponse();
        final BadRequestException e = new BadRequestException( "something", statusCode );

        final Request req = createMock( Request.class );
        expect( req.getHeader("Host") ).andReturn( "localhost" );
        expect( req.getHeader("Referer") ).andReturn( referer );
        replay( req );
View Full Code Here

        final Response res = getResponse();
        final Locale locale = getLocale();
        final Properties p = getProperties();

        if ( p.get(Constants.WWW_DOWNLOADS_DISABLE).equals(Properties.YES) )
            throw new BadRequestException( locale.getString("www.error.downloadsDisabled"), 403 );
       
        final Database db = getDatabase();
        final String[] args = req.getPlayParams( false );
        final List<Track> tracks = Track.getTracksFromPlayArgs( db, args );
        final String fileName = getFileName( tracks );
View Full Code Here

        final String type = req.getUrlParam( 1 );
       
        if ( type.equals("test") )
            sendTestResponse();
        else
            throw new BadRequestException( "unknown command", 400 );
       
    }
View Full Code Here

        final String type = req.getUrlParam( 1 );
       
        if ( type.equals("latest") )
            latest( getLatestTracks(20) );
       
        else throw new BadRequestException( "Unknown feed type (" + type + ")", 400 );
       
    }
View Full Code Here

TOP

Related Classes of com.pugh.sockso.web.BadRequestException

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.