forked from Coded/SIPRP
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.5 KiB
62 lines
1.5 KiB
/*
|
|
* To change this template, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
|
|
package utils;
|
|
|
|
import com.evolute.utils.error.ErrorLogger;
|
|
import db.providers.RelatoriosDataProvider;
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
import java.io.OutputStream;
|
|
import javax.faces.context.FacesContext;
|
|
import javax.servlet.ServletContext;
|
|
|
|
/**
|
|
*
|
|
* @author lluis
|
|
*/
|
|
public class Logos {
|
|
|
|
public String getLogo(Integer empresaId)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public String getLogo( FacesContext fc, Integer empresaId )
|
|
{
|
|
String result = null;
|
|
try
|
|
{
|
|
//get image from db :
|
|
// RelatoriosDataProvider rdp = new RelatoriosDataProvider();
|
|
RelatoriosDataProvider rdp = RelatoriosDataProvider.getInstance();
|
|
|
|
byte[] logo = rdp.getLogoByEmpresa( empresaId );
|
|
if ( logo != null )
|
|
{
|
|
int len = logo.length;
|
|
|
|
ServletContext context = (ServletContext) fc.getExternalContext().getContext();
|
|
File logoFolder = new File( context.getRealPath( Global.LOGOS_FOLDER ) );
|
|
|
|
String logoFilename = logoFolder + "/logo_empresa" + empresaId.toString() + ".jpg";
|
|
|
|
OutputStream outImej = new FileOutputStream(logoFilename);
|
|
outImej.write(logo, 0, len);
|
|
System.out.println("LOGO PATH : " + logoFilename);
|
|
outImej.close();
|
|
result = Global.LOGOS_FOLDER + "/logo_empresa" + empresaId.toString() + ".jpg";
|
|
}
|
|
}
|
|
catch ( Exception ex )
|
|
{
|
|
ErrorLogger.logException( ex );
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
}
|