|
|
|
|
@ -17,9 +17,11 @@ import java.io.FileInputStream;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import javax.faces.context.ExternalContext;
|
|
|
|
|
import javax.faces.context.FacesContext;
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
|
import utils.JSFUtils;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -143,27 +145,61 @@ public class Global {
|
|
|
|
|
ctx.release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void redirectToPlanos(FacesContext fc, Utilizador currentUser)
|
|
|
|
|
{
|
|
|
|
|
String curUser = "?user=" + currentUser.getId().toString();
|
|
|
|
|
String estab = "";
|
|
|
|
|
if(currentUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_GESTOR)
|
|
|
|
|
{
|
|
|
|
|
//obtem estabelecimento da lista de estabelecimentos
|
|
|
|
|
estab = "&estab_gestor=" + currentUser.getEstabelecimento_gestor().intValue();
|
|
|
|
|
}
|
|
|
|
|
fc = fc.getCurrentInstance();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
JSFUtils.redirect(fc, Global.PLANOS_ACTUACAO_URL + curUser + estab);
|
|
|
|
|
//JSFUtils.dispatch(fc, Global.PLANOS_ACTUACAO_URL + curUser);
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrorLogger.logException( ex );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void redirectToPlanos( FacesContext fc, Utilizador currentUser )
|
|
|
|
|
{
|
|
|
|
|
if ( fc != null )
|
|
|
|
|
{
|
|
|
|
|
// String url = Global.PLANOS_ACTUACAO_URL;
|
|
|
|
|
String url = "http://localhost:8084/PlanosActuacao/faces/ListaPlanos.jsp";
|
|
|
|
|
|
|
|
|
|
ExternalContext ec = fc.getExternalContext();
|
|
|
|
|
if ( ec != null )
|
|
|
|
|
{
|
|
|
|
|
HttpSession session = ( HttpSession ) ec.getSession( false );
|
|
|
|
|
if ( session != null )
|
|
|
|
|
{
|
|
|
|
|
url += "?sessionID=" + session.getId();
|
|
|
|
|
|
|
|
|
|
int userType = currentUser == null ? -1 : currentUser.getTipo() == null ? -1 : currentUser.getTipo().intValue();
|
|
|
|
|
if ( userType == Global.TIPO_UTILIZADOR_GESTOR )
|
|
|
|
|
{
|
|
|
|
|
url += "&estab_gestor=" + currentUser.getEstabelecimento_gestor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
System.out.println( "\tRedirecting to : " + url );
|
|
|
|
|
JSFUtils.redirect( fc, url );
|
|
|
|
|
}
|
|
|
|
|
catch ( Exception e )
|
|
|
|
|
{
|
|
|
|
|
ErrorLogger.logException( e );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public static void redirectToPlanos( FacesContext fc, Utilizador currentUser )
|
|
|
|
|
// {
|
|
|
|
|
// String curUser = "?user=" + currentUser.getId().toString();
|
|
|
|
|
// String estab = "";
|
|
|
|
|
// if ( currentUser.getTipo().intValue() == Global.TIPO_UTILIZADOR_GESTOR )
|
|
|
|
|
// {
|
|
|
|
|
// estab = "&estab_gestor=" + currentUser.getEstabelecimento_gestor().intValue();
|
|
|
|
|
// }
|
|
|
|
|
// fc = fc.getCurrentInstance();
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
// JSFUtils.redirect(fc, Global.PLANOS_ACTUACAO_URL + curUser + estab);
|
|
|
|
|
// }
|
|
|
|
|
// catch(Exception ex)
|
|
|
|
|
// {
|
|
|
|
|
// ErrorLogger.logException( ex );
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|