Package com.pugh.sockso.web.action.covers

Source Code of com.pugh.sockso.web.action.covers.DefaultCoverer

package com.pugh.sockso.web.action.covers;

import com.pugh.sockso.Properties;
import com.pugh.sockso.cache.CacheException;
import com.pugh.sockso.music.CoverArt;
import com.pugh.sockso.resources.Locale;

import java.io.IOException;

public class DefaultCoverer extends BaseCoverer {
   
    /**
     *  Server the default cover, this will always return true
     *
     *  @param itemName
     *
     *  @return
     *
     *  @throws IOException
     *
     */

    public boolean serveCover( final String itemName ) throws IOException, CacheException {
       
        final Locale locale = getLocale();
        final String noCoverId = "nocover-" + locale.getLangCode();
        final boolean coverIsCached = coverCache.isCached( noCoverId );
        final CoverArt cover = getNoCoverArt( noCoverId );

        serveCover( cover, "noCover", coverIsCached );

        return true;
       
    }

    /**
     *  Returns the image to use to indicate no cover art was found
     *
     *  @param itemName
     *
     *  @return
     *
     *  @throws IOException
     *
     */

    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));

    }
   
}
TOP

Related Classes of com.pugh.sockso.web.action.covers.DefaultCoverer

TOP
Copyright © 2018 www.massapi.com. 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.