Commit 000deb8c by Riku Silvola

i18 muutoksia ja error logger

1 parent e82919b4
......@@ -3,22 +3,26 @@
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<title></title>
<title>Error</title>
</h:head>
<h:body>
<br/>
<center>
<img src="#{request.contextPath}/resources/media/error.jpg" />
<h1>LOL, ERROR!</h1>
<br/>
<c:if test="#{sessionHandler.isInDevelopmentMode() eq false}">
<h:outputText escape="false" style="color: red;" value="ERR##{errorPageView.time}" />
</c:if>
<!-- <c:if test="#{sessionHandler.isInDevelopmentMode() eq true}"> -->
<h1>#{i18n['error.error']}</h1>
<p>${i18n['error.contact']}
<br/><h:outputText escape="false" style="color: red;" value="#{errorPageView.time}" /><br/><br/>
<!-- Trail:<br/><h:outputText escape="false" style="color: red;" value="#{errorPageView.trail}" /> -->
<a href="#{request.contextPath}">Home</a>
</p>
<!-- </c:if> -->
<br/><br/>
</center>
<c:when test="#{sessionHandler.isInDevelopmentMode()}">
<br/>
<center>
<img src="#{request.contextPath}/resources/media/error.jpg" />
<h1>LOL, ERROR!</h1>
<br/>
</center>
<h:outputText escape="false" value="#{errorPageView.stackTrace}" />
</c:when>
</h:body>
</html>
\ No newline at end of file
package fi.insomnia.bortal;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Queue;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.faces.context.FacesContext;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
......@@ -45,7 +48,8 @@ public class HostnameFilter implements Filter {
public void destroy() {
// Nothing...
}
@SessionScoped
Queue<String> trail = new LinkedList<String>();
/**
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
*/
......@@ -113,6 +117,13 @@ public class HostnameFilter implements Filter {
{
sessionmgmt.updateSessionUser(httpRequest.getSession().getId(), httpRequest.getUserPrincipal().getName());
}
if (trail.size() == 10) {
trail.remove();
}
if (!httpRequest.getRequestURI().matches(".*(resource).*")) {
trail.add(httpRequest.getRequestURI());
httpRequest.getSession().setAttribute("trail", trail);
}
}
// pass the request along the filter chain
......
......@@ -71,6 +71,9 @@ bortalApplication.user.WRITE_ROLES = Modify roles
cardTemplate.emptyCardTemplate = ----
error.contact = If this happens again, contact Info with the following code:
error.error = You have encountered an error.
eventorg.create = Create
global.cancel = Cancel
......
......@@ -125,6 +125,9 @@ editplacegroup.header = Placegroup information
entry.edit = Edit entry
error.contact = If this happens again, contact Info with the following code:
error.error = You have encountered an error.
event.defaultRole = Default user role
event.edit = Edit
event.endTime = End time
......
......@@ -20,6 +20,9 @@ actionlog.user = User
bill.billMarkedPaidMail.message = Your deposit number {0} has been marked as paid.
bill.billMarkedPaidMail.subject = [Streamparty] Your credits have been updated
error.contact = If this happens again, contact Info with the following code:
error.error = You have encountered an error.
eventorg.create = Create
eventorg.edit = Edit
......
......@@ -123,6 +123,9 @@ editplacegroup.header = Paikkaryhm\u00E4n tiedot
entry.edit = Muokkaa
error.contact = Jos t\u00E4m\u00E4 toistuu, ota seuraava koodi talteen ja ota yhteys Infoon:
error.error = Olet kohdannut virheen.
event.defaultRole = K\u00E4ytt\u00E4jien oletusrooli
event.edit = Muokkaa
event.endTime = Lopetusp\u00E4iv\u00E4
......
......@@ -20,6 +20,9 @@ actionlog.user = Tekij\u00E4
bill.billMarkedPaidMail.message = Laskusi numero {0} on merkitty maksetuksi. Voit nyt siirty\u00E4 lippukauppaan varamaamaan haluamasi paikat. \nTervetuloa tapahtumaan!\n\nTerveisin,\nInsomnia lippupalvelu\nwww.insomnia.fi
bill.billMarkedPaidMail.subject = [INSOMNIA] Lasku merkitty maksetuksi
error.contact = Jos t\u00E4m\u00E4 toistuu, ota seuraava koodi talteen ja ota yhteys Infoon:
error.error = Olet kohdannut virheen.
eventorg.create = Luo
eventorg.edit = Muokkaa
......
package fi.insomnia.bortal.web;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.misc.Queue;
import java.util.Queue;
import java.io.PrintWriter;
......@@ -17,7 +19,7 @@ import java.util.Calendar;
import java.util.Map;
@Named
@SessionScoped
@RequestScoped
public class ErrorPageView implements Serializable {
/**
......@@ -27,8 +29,8 @@ public class ErrorPageView implements Serializable {
// private static final long serialVersionUID = -2179309061036632342L;
String trace;
// maintain a trail of pages visited (10?)
Queue trail = new Queue();
@Inject
private transient FacesContext context;
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(ErrorPageView.class);
......@@ -49,8 +51,21 @@ public class ErrorPageView implements Serializable {
}
public Long getTime(){
return Calendar.getInstance().getTimeInMillis();
public String getTime(){
return "0x" + Long.toHexString(Calendar.getInstance().getTimeInMillis());
}
public String getTrail() {
HttpServletRequest req = (HttpServletRequest) getContext().getExternalContext().getRequest();
Object trail = req.getSession().getAttribute("trail");
return trail != null ? trail.toString().replace(", ", "\n") : "u gots no trail!";
}
public FacesContext getContext() {
return context;
}
public void setContext(FacesContext context) {
this.context = context;
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!