Package com.pugh.sockso.web

Examples of com.pugh.sockso.web.Request


        String skin = "hsdjkahsdjkahsdk";

        Properties p = new StringProperties();
        p.set( "www.skin", skin );

        Request req = new TestRequest( "GET / HTTP/1.1" );

        Sharer s = new Sharer();
        s.setResponse( res );
        s.setRequest( req );
        s.setLocale( locale );
View Full Code Here


     *
     */
   
    protected void processActions( final ApiAction[] actions ) throws BadRequestException {
       
        final Request req = getRequest();
       
        for ( final ApiAction action : actions ) {

            if ( action.canHandle(req) && loginStatusOk(action) ) {
               
View Full Code Here

     *
     */
   
    public void handleRequest() throws IOException, BadRequestException, SQLException {

        final Request req = getRequest();
        final Response res = getResponse();
        final String type = req.getUrlParam( 1 );

        res.setCookiesEnabled( false );

        serveFile();

View Full Code Here

     *
     */

    protected String getPathFromRequest() {

        final Request req = getRequest();
        final StringBuffer path = new StringBuffer( "htdocs" );
       
        for ( int i=1; i<req.getParamCount(); i++ ) {
            path.append( "/" );
            path.append( req.getUrlParam(i) );
        }
       
        return path.toString()
                   .replaceAll( "\\.\\.", "" )         // remove double dots
                   .replaceAll( "\\/{2,999}", "/" );   // remove groups of forward slashes
View Full Code Here

     *
     */
   
    public void handleRequest() throws SQLException, IOException, BadRequestException {
       
        final Request req = getRequest();
        final int trackId = Integer.parseInt( req.getUrlParam( 1 ) );

        final Track track = Track.find( getDatabase(), trackId );

        if ( track == null ) {
            throw new BadRequestException( "Invalid track ID", 404 );
View Full Code Here

     *
     */
   
    public void handleRequest() throws IOException, BadRequestException, SQLException {
       
        final Request req = getRequest();
        final String type = req.getUrlParam( 1 );

        checkPermissions();
       
        if ( type.equals("do") )
            uploadFile();
View Full Code Here

    private void uploadFile() throws BadRequestException {

        checkUploadLooksOk();

        final Properties p = getProperties();
        final Request req = getRequest();
        final Locale locale = getLocale();
        final UploadFile file = req.getFile( "musicFile" );
        final String artist = req.getArgument( "artist" );
        final String album = req.getArgument( "album" );
        final String track = req.getArgument( "title" );

        // if we get here everything looks good, so lets try and save the file
        try {

            // make sure we've a directory to put the track in
View Full Code Here

     *
     */
   
    private void checkUploadLooksOk() throws BadRequestException {

        final Request req = getRequest();
        final Locale locale = getLocale();
        final UploadFile file = req.getFile( "musicFile" );

        if ( file == null )
            throw new BadRequestException( locale.getString("www.error.noFileUploaded") );

        // check mime type to see if it looks ok
        final String contentType = file.getContentType();
        log.debug( "File content type: " + contentType );
        if ( !Files.isValidMimeType(contentType) )
            throw new BadRequestException( locale.getString("www.error.unsupportedAudioFormat") );
       
        // check required fields
        final Database db = getDatabase();
        final Validater v = new Validater( db );
        final String artist = req.getArgument( "artist" );
        final String album = req.getArgument( "album" );
        final String track = req.getArgument( "title" );
        if ( !v.checkRequiredFields( new String[] { artist, album, track }) )
            throw new BadRequestException( locale.getString("www.error.missingField") );

    }
View Full Code Here

     */

    @Override
    public void handleRequest() throws SQLException, IOException, BadRequestException {
       
        final Request req = getRequest();

        if ( req.getUrlParam(2).equals("site") ) {
            showPlaylists(Playlist.findAllForSite(
                getDatabase(),
                getLimit(),
                getOffset()
            ));
        }

        else if ( req.getUrlParam(2).equals("user") ) {
            showPlaylists(Playlist.findAllForUser(
                getDatabase(),
                getPlaylistUser(),
                getLimit(),
                getOffset()
View Full Code Here

     *
     */
   
    protected User getPlaylistUser() {
       
        final Request req = getRequest();
       
        return req.getParamCount() == 4
            ? User.find( getDatabase(), Integer.parseInt(req.getUrlParam(3)) )
            : getUser();

    }
View Full Code Here

TOP

Related Classes of com.pugh.sockso.web.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.