Subversion Repositories bacoAlunos

Compare Revisions

Ignore whitespace Rev 1483 → Rev 1484

/branches/v3/impl/src/java/pt/estgp/estgweb/web/WebProxy.java
1,11 → 1,9
package pt.estgp.estgweb.web;
 
import jomm.utils.StreamsUtils;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.log4j.Logger;
import pt.estgp.estgweb.utils.ConfigProperties;
import pt.estgp.estgweb.utils.StringsUtils;
 
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
18,9 → 16,11
import java.io.OutputStream;
import java.net.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import java.util.zip.InflaterInputStream;
import java.util.zip.ZipInputStream;
import java.util.zip.InflaterInputStream;
import java.util.zip.GZIPInputStream;
 
/**
* @author Jorge Machado
197,8 → 197,24
String pathFinal = path.indexOf("?") >=0 ? URIUtil.encodePath(path.substring(0,path.indexOf("?")), "ISO-8859-1") + "?" +path.substring(path.indexOf("?")+1) : path;
System.out.println(pathFinal);
}
 
static Map<String,Boolean> urlOKCACHE = new HashMap<String, Boolean>();
static Map<String,Integer> urlOKCACHE_LAST_CHECK_COUNT = new HashMap<String, Integer>();
 
public static boolean checkExist( String server, String path)
{
String serverPathKey = server + "$" + path;
Boolean urlOk = urlOKCACHE.get(serverPathKey);
if(urlOk != null)
{
int count = urlOKCACHE_LAST_CHECK_COUNT.get(serverPathKey);
if(count > 0)
{
count = count-1;
urlOKCACHE_LAST_CHECK_COUNT.put(serverPathKey,count);
return urlOk;
}
}
 
String serverUrl = ConfigProperties.getProperty("server." + server);
String serverEncoding = ConfigProperties.getProperty(server + ".encoding");
210,19 → 226,27
try
{
 
String pathFinal = path.indexOf("?") >=0 ? URIUtil.encodePath(path.substring(0,path.indexOf("?")), "ISO-8859-1") + path.substring(path.indexOf("?")) : path;
System.out.println("Getting: " + serverUrl + pathFinal);
URL url = new URL(serverUrl + pathFinal);
String pathFinal = path.indexOf("?") >= 0 ? URIUtil.encodePath(path.substring(0,path.indexOf("?")), "ISO-8859-1") + path.substring(path.indexOf("?")) : path;
 
 
URLConnection con = url.openConnection();
InputStream stream = con.getInputStream();
String out = StreamsUtils.readString(stream);
stream.close();
System.out.println("Getting: " + serverUrl + pathFinal + " CHECK TIME");
URL url = new URL(serverUrl + pathFinal);
HttpURLConnection huc = (HttpURLConnection) url.openConnection();
huc.setRequestMethod("HEAD");
urlOKCACHE_LAST_CHECK_COUNT.put(serverPathKey,10);
if(huc.getResponseCode() == HttpURLConnection.HTTP_OK)
{
urlOKCACHE.put(serverPathKey,true);
huc.disconnect();
return true;
}
else
{
urlOKCACHE.put(serverPathKey,false);
huc.disconnect();
return false;
}
 
if(out.trim().length() == 0)
return false;
return true;
}
catch (FileNotFoundException e)
{
/branches/v3/impl/src/web/layout/headerTools.jsp
1,3 → 1,4
<%@ page import="pt.estgp.estgweb.web.UserSessionProxy" %>
<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
6,7 → 7,18
<%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %>
 
<logic:present name="UserSession">
INTRANET - (<bean:write name="UserSession" property="user.name"/> online)
<%
if(UserSessionProxy.loadUserSessionFromRequest(request).getUser() == null)
{
response.sendError(401);
return;
}
%>
<logic:present name="UserSession" property="user">
<logic:notEmpty name="UserSession" property="user">
INTRANET - (<bean:write name="UserSession" property="user.name"/> online)
</logic:notEmpty>
</logic:present>
 
<div id="google_translate_element" class="pull-right"></div>
<script type="text/javascript">