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

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

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

import com.google.inject.Inject;
import com.pugh.sockso.Constants;
import com.pugh.sockso.Properties;
import com.pugh.sockso.cache.CacheException;
import com.pugh.sockso.music.CoverArt;
import com.pugh.sockso.web.action.CoverSearch;

import java.io.IOException;

public class RemoteCoverer extends BaseCoverer {

    CoverSearch search;

    @Inject
    public RemoteCoverer( CoverSearch cs ) {
        this.search = cs;
    }

    /**
     *  Try and fetch a cover from a remote source (Amazon)
     *
     *  @param itemName
     *
     *  @return
     *
     *  @throws IOException
     *
     */

    public boolean serveCover( final String itemName ) throws IOException, CacheException {

        if ( !getProperties().get(Constants.COVERS_DISABLE_REMOTE_FETCHING).equals(Properties.YES) ) {

            final CoverArt cover = search.getCover(itemName);

            if ( cover != null ) {
                serveCover( cover, itemName, true );
                return true;
            }

        }

        return false;

    }

}
TOP

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

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.