forked from Coded/SIPRP
22/12/2008
git-svn-id: https://svn.coded.pt/svn/SIPRP@860 bb69d46d-e84e-40c8-a05a-06db0d6337410'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
parent
67f565642b
commit
5451952448
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package utils;
|
||||
|
||||
import db.providers.RelatoriosDataProvider;
|
||||
import global.Global;
|
||||
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)
|
||||
{
|
||||
try
|
||||
{
|
||||
//get image from db :
|
||||
RelatoriosDataProvider rdp = new RelatoriosDataProvider();
|
||||
byte[] logo = rdp.getLogoByEmpresa(empresaId);
|
||||
int len = logo.length;
|
||||
|
||||
ServletContext context = (ServletContext) fc.getExternalContext().getContext();
|
||||
File logoFolder = new File(context.getRealPath(Global.LOGOS_FOLDER));
|
||||
|
||||
String logoFilename = logoFolder + "/logo_empresa.jpg";
|
||||
|
||||
OutputStream outImej = new FileOutputStream(logoFilename);
|
||||
outImej.write(logo, 0, len);
|
||||
System.out.println("LOGO PATH : " + logoFilename);
|
||||
outImej.close();
|
||||
return Global.LOGOS_FOLDER + "/logo_empresa.jpg";
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue