Package com.pugh.sockso

Examples of com.pugh.sockso.Properties


        coverer = null;
    }

    public void testGetLocalCoverFileName() {

        final Properties p = createNiceMock(Properties.class);
        expect(p.get((String) anyObject(), (String) anyObject())).andReturn("artist").times(1);
        expect(p.get((String) anyObject(), (String) anyObject())).andReturn("album").times(1);
        replay(p);

        coverer.setProperties(p);

        assertTrue(coverer.getLocalCoverFileName("ar123").equals("artist"));
View Full Code Here


public class DownloaderTest extends SocksoTestCase {

    public void testGetTrackZipPath() {
       
        final Properties p = new StringProperties();
        final Downloader d = new Downloader();
       
        d.setProperties( p );
       
        final Artist artist = TestUtils.getArtist();
View Full Code Here

        assertEquals( "artist-various_albums.zip", d.getFileName(tracks) );
    }

    public void testExceptionThrownWhenDownloadsAreDisabled() throws Exception {
        Downloader d = new Downloader();
        Properties p = new StringProperties();
        p.set( Constants.WWW_DOWNLOADS_DISABLE, Properties.YES );
        boolean gotException = false;
        d.setProperties( p );
        d.setLocale( new TestLocale() );
        try { d.handleRequest(); }
        catch ( BadRequestException e ) { gotException = true; }
View Full Code Here

        TestResponse res = new TestResponse();
        Server sv = createNiceMock( Server.class );
        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 );
View Full Code Here

     */
   
    @Override
    public boolean requiresLogin() {

        final Properties p = getProperties();

        return p.get( Constants.STREAM_REQUIRE_LOGIN ).equals( Properties.YES );

    }
View Full Code Here

    }


    protected Encoder getEncoder( final Track track ) throws IOException {

        final Properties p = getProperties();
        final String ext = Utils.getExt(track.getPath());

        final String type = p.get(Constants.PROP_ENCODERS_PREFIX + ext);

        if ( type.equals("") ) {
            return null;
        }

        Encoders.Type encoderType;

        try {
            encoderType = Encoders.Type.valueOf(type);
        } catch (IllegalArgumentException e) {
            log.error("Encoder type not found", e);
            return null;
        }

        switch (encoderType) {

            // 1. use a builtin encoder?
            case BUILTIN:

                final String name = p.get(Constants.PROP_ENCODERS_PREFIX + ext + ".name");
                final BuiltinEncoder encoder = Encoders.getBuiltinEncoderByName(name).getEncoder();

                if ( encoder != null ) {

                    return encoder;
                }

            // 2. use a custom command to encode?
            case CUSTOM:

                final String command = p.get(Constants.PROP_ENCODERS_PREFIX + ext + ".command");

                if ( !command.equals("") ) {
                   
                    return new CustomEncoder(command);
                }
View Full Code Here

     */

    protected CoverArt getNoCoverArt( String noCoverId ) throws IOException, CacheException {

        final Locale locale = getLocale();
        final Properties properties = getProperties();
       
        return coverCache.isCached( noCoverId )
                ? coverCache.getCoverArt(noCoverId)
                : new CoverArt(noCoverId, CoverArt.createNoCoverImage(properties, locale));

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
            final Database db = getDatabase();
            final File dir = new File( Utils.getUploadsPath(db,p) + "/"+artist+" - "+album );
            if ( !dir.exists() )
                if ( !dir.mkdir() )
                    throw new BadRequestException( locale.getString("www.error.cantCreateTrackFolder"), 500 );

            // write the track to disk
            final File tempFile = file.getTemporaryFile();
            final File newFile = new File( getNewUploadFilename(dir,track,Utils.getExt(file.getFilename())) );

            tempFile.renameTo( newFile );

            // rescan the folder to add new track to collection
            final int collectionId = Integer.parseInt( p.get(Constants.WWW_UPLOADS_COLLECTION_ID) );
            cm.scanDirectory( collectionId, dir );
            cm.fireCollectionManagerEvent( CollectionManagerListener.UPDATE_COMPLETE, "Collection Updated!" );

            // show user confirmation
            final TUploadComplete tpl = new TUploadComplete();           
View Full Code Here

   
    private void checkPermissions() throws BadRequestException {
       
        final User user = getUser();
        final Locale locale = getLocale();
        final Properties p = getProperties();

        // check uploads are enabled
        Utils.checkFeatureEnabled( p, "uploads.enabled" );
       
        // 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 );
View Full Code Here

        return false;
    }
   
    public void register() throws IOException, BadRequestException, SQLException {

        final Properties p = getProperties();
        final Request req = getRequest();
        final User user = getUser();
        final Locale locale = getLocale();
       
        if ( p.get(Constants.WWW_USERS_DISABLE_REGISTRATION).equals(Properties.YES) )
            throw new BadRequestException( locale.getString("www.error.registrationDisabled"), 403 );
        if ( user != null )
            throw new BadRequestException( locale.getString("www.error.alreadyLoggedIn"), 403 );

        final String todo = req.getArgument( "todo" );
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.