Package com.pugh.sockso

Examples of com.pugh.sockso.Properties


       
    }

    public void testRecentUsers() {

        final Properties p = new StringProperties();
        final List<User> users = new ArrayList<User>();

        assertTrue( !render().contains("recentUsers") );

        final Renderer r1 = getTemplate();
View Full Code Here


    }

    public void testReturningJsonServerInfoIncludesAllRequiredFields() throws Exception {

        Properties p = new StringProperties();
        p.set( Constants.WWW_TITLE, "THEtitle" );
        p.set( Constants.WWW_TAGLINE, "THEtagline" );

        TestResponse res = new TestResponse();
        Jsoner j = new Jsoner( null, null );
        j.setProperties( p );
        j.setResponse( res );
View Full Code Here

    }

    public void testServerInfoReturnsRequireLoginAsOneWhenItIsEnabled() throws Exception {

        Properties p = new StringProperties();
        p.set( Constants.WWW_USERS_REQUIRE_LOGIN, Properties.YES );

        TestResponse res = new TestResponse();
        Jsoner j = new Jsoner( null, null );
        j.setResponse( res );
        j.setProperties( p );
View Full Code Here

    }

    public void testDoubleQuotesAreEscapedInServerInfoStrings() throws Exception {

        Properties p = new StringProperties();
        p.set( Constants.WWW_TITLE, "THE\"title" );
        p.set( Constants.WWW_TAGLINE, "THE\"tagline" );

        TestResponse res = new TestResponse();
        Jsoner j = new Jsoner( null, null );
        j.setProperties( p );
        j.setResponse( res );
View Full Code Here

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

        final Request req = getRequest();
        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 );
View Full Code Here

     *
     */

    protected void serveLocalCover( final String itemName, final String localPath ) throws IOException, CacheException {

        final Properties p = getProperties();
        final BufferedImage originalImage = ImageIO.read( new File( localPath ) );
        final CoverArt cover = new CoverArt(itemName, originalImage);

        cover.scale(
                (int) p.get(Constants.DEFAULT_ARTWORK_WIDTH, 115),
                (int) p.get(Constants.DEFAULT_ARTWORK_HEIGHT, 115));

        // only cache local cover images if we've been explicitly
        // told to do so (improves performance)

        serveCover(
            cover,
            itemName,
            p.get( Constants.COVERS_CACHE_LOCAL ).equals( Properties.YES )
        );

    }
View Full Code Here

     *
     */
   
    protected String getLocalCoverFileName( final String itemName ) {

        final Properties p = getProperties();
        final String typeName = isArtist(itemName) ? "artist" : "album";

        return p.get(
            isArtist(itemName) ? Constants.COVERS_ARTIST_FILE : Constants.COVERS_ALBUM_FILE,
            typeName
        );

    }
View Full Code Here

    protected File[] getLocalCoverFiles( final File[] trackDirs, final String coverFileName, final boolean isArtist ) {

        final ArrayList<File> files = new ArrayList<File>();
        final String[] exts = CoverArtCache.CACHE_IMAGE_EXTENSIONS;
        final Properties p = getProperties();

        for ( final File track : trackDirs ) {

            final String[] dirs = {
                track.getParent(),
                isArtist ? track.getParentFile().getParent() : null
            };

            // look for album info in this directory, but artist info in the
            // directory one level up as well (maybe "/My Music/artist/album/"
            // structure)
            for ( final String directory : dirs ) {
                if ( directory == null ) continue; // will be null if album
                for ( final String ext : exts ) {
                    final String path = directory + File.separator + coverFileName + "." + ext;
                    files.add( new File(path) );
                }
            }

            // Should we fallback and search for the first image
            // file in the track folder, regardless of its name ?
            if ( p.get(Constants.COVERS_FILE_FALLBACK).equals(Properties.YES) ) {
                final File fallbackFile = checkForFallbackFile( exts, track );
                if ( fallbackFile != null ) {
                    files.add( fallbackFile );
                }
            }
View Full Code Here

        ResultSet rs = null;
        PreparedStatement st = null;
       
        try {

            final Properties p = getProperties();
            final Database db = getDatabase();
            final String sql = Track.getSelectSql() + " , count(l.id) as playCount " +
                        " from tracks t " +
                            " inner join artists ar " +
                            " on ar.id = t.artist_id " +
                            " inner join albums al " +
                            " on al.id = t.album_id " +
                            " inner join genres g " +
                            " on g.id = t.genre_id " +
                            " left outer join play_log l " +
                            " on l.track_id = t.id " +
                        " group by artistId, artistName, albumId, albumName, albumYear, trackId, " +
                            " trackName, trackPath, trackNo, genreId, genreName, dateAdded " +
                        " having count(l.id) > 0 " +
                        " order by count(l.id) desc " +
                        " limit ? ";
            st = db.prepare( sql );
           
            st.setInt( 1, (int) p.get(Constants.WWW_BROWSE_POPULAR_TRACK_COUNT,20) );
           
            rs = st.executeQuery();

            final List<Track> tracks = new ArrayList<Track>();
            while ( rs.next() ) {
View Full Code Here

     */
   
    @Override
    public void handleRequest() throws SQLException, IOException {
       
        final Properties p = getProperties();
        final List<Track> tracks = getLatestTracks( (int) p.get(Constants.WWW_BROWSE_LATEST_TRACKS_COUNT,20) );
        final List<Artist> artists = getLatestArtists();
        final List<Album> albums = getLatestAlbums();
       
        showLatest( tracks, artists, albums );
       
View Full Code Here

TOP

Related Classes of com.pugh.sockso.Properties

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.