Commit 3050fa87 authored by Matija Obreza's avatar Matija Obreza

Look-and-Feel updates, error messages updated

parent 720482ee
......@@ -31,6 +31,7 @@ import org.genesys2.server.service.UserService;
import org.genesys2.util.ReCaptchaUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
......@@ -137,4 +138,9 @@ public class HtmlController extends BaseController {
public String forgotPassword() {
return "/forgot-password";
}
@RequestMapping("/access-denied")
public void accessDenied() {
throw new AccessDeniedException("Spring Security denied access to the resource.");
}
}
......@@ -20,9 +20,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.genesys2.server.exception.NoUserFoundException;
import org.genesys2.server.exception.NotUniqueUserException;
import org.genesys2.server.exception.UserException;
import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.core.AuthenticationException;
......@@ -34,39 +32,27 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.ModelAndView;
@ControllerAdvice
public class UserControllerAdvice extends BaseController {
// EXCEPTION HANDLERS
// Users
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(value = { NoUserFoundException.class })
@ResponseBody
public String handleNoUserFoundException(NoUserFoundException e) {
return messageSource.getMessage("sample.error.user.not.found", new Object[] { e.getModelId() }, getLocale());
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(value = { UserException.class })
@ResponseBody
public String handleUserException(UserException e) {
return simpleExceptionHandler(e);
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(value = { NotUniqueUserException.class })
@ResponseBody
public String handleConstraintException(NotUniqueUserException e) {
return messageSource.getMessage("sample.error.not.unique.email", new Object[] { e.getEmail() }, getLocale());
}
@ResponseStatus(HttpStatus.FORBIDDEN)
@ExceptionHandler(value = { AccessDeniedException.class })
// @ResponseBody
public String handleAccessDeniedException(AccessDeniedException e) {
// return simpleExceptionHandler(e);
return "/errors/access-denied";
public ModelAndView handleAccessDeniedException(AccessDeniedException e) {
ModelAndView mav = new ModelAndView("/errors/error");
mav.addObject("exception", e);
return mav;
}
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(value = { ResourceNotFoundException.class })
// @ResponseBody
public ModelAndView handleResourceNotFoundException(ResourceNotFoundException e) {
ModelAndView mav = new ModelAndView("/errors/error");
mav.addObject("exception", e);
return mav;
}
@ResponseStatus(HttpStatus.UNAUTHORIZED)
......@@ -76,6 +62,15 @@ public class UserControllerAdvice extends BaseController {
return simpleExceptionHandler(e);
}
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(value = { Throwable.class })
// @ResponseBody
public ModelAndView handleAll(Throwable e) {
ModelAndView mav = new ModelAndView("/errors/error");
mav.addObject("exception", e);
return mav;
}
// do not pass validation
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(value = { MethodArgumentNotValidException.class })
......
......@@ -15,8 +15,17 @@
#-------------------------------------------------------------------------------
# Errors
error.access-denied=403 Access denied
error.access-denied.text=You do not have permission to access the resource.
http-error.401=Unauthorized
http-error.401.text=Authentication is required.
http-error.403=Access denied
http-error.403.text=You do not have permission to access the resource.
http-error.404=Not found
http-error.404.text=The requested resource could not be found but may be available again in the future.
http-error.500=Internal Server Error
http-error.500.text=An unexpected condition was encountered and no more specific message is suitable.
http-error.503=Service Unavailable
http-error.503.text=The server is currently unavailable (because it is overloaded or down for maintenance).
# Login
login.username=Username
......
......@@ -15,8 +15,8 @@
#-------------------------------------------------------------------------------
# Errors
error.access-denied=رفض الدخول 403
error.access-denied.text=ليس لديك إذن للوصول إلى المورد.
http-error.403=رفض الدخول 403
http-error.403.text=ليس لديك إذن للوصول إلى المورد.
# Login
login.username=اسم المستخدم
......
......@@ -15,8 +15,8 @@
#-------------------------------------------------------------------------------
# Errors
error.access-denied=403 Zugriff verweigert
error.access-denied.text=Sie haben keine Berechtigung, auf diese Ressource zuzugreifen
http-error.403=403 Zugriff verweigert
http-error.403.text=Sie haben keine Berechtigung, auf diese Ressource zuzugreifen
# Login
login.username=Benutzername
......
......@@ -15,8 +15,8 @@
#-------------------------------------------------------------------------------
# Errors
error.access-denied=403 Acceso denegado
error.access-denied.text=No tienes permiso para acceder al recurso.
http-error.403=403 Acceso denegado
http-error.403.text=No tienes permiso para acceder al recurso.
# Login
login.username=Nombre de usuario
......
......@@ -15,8 +15,8 @@
#-------------------------------------------------------------------------------
# Errors
error.access-denied=403 Accès refusé
error.access-denied.text=Vous n'avez pas la permission d'accéder à la ressource.
http-error.403=403 Accès refusé
http-error.403.text=Vous n'avez pas la permission d'accéder à la ressource.
# Login
login.username=Nom d'utilisateur
......
......@@ -15,8 +15,8 @@
#-------------------------------------------------------------------------------
# Errors
error.access-denied=403 Acesso negado
error.access-denied.text=Não tem autorização para aceder ao recurso.
http-error.403=403 Acesso negado
http-error.403.text=Não tem autorização para aceder ao recurso.
# Login
login.username=Nome de utilizador
......
......@@ -15,8 +15,8 @@
#-------------------------------------------------------------------------------
# Errors
error.access-denied=403 Доступ запрещен
error.access-denied.text=У вас нет разрешения на доступ к этому ресурсу.
http-error.403=403 Доступ запрещен
http-error.403.text=У вас нет разрешения на доступ к этому ресурсу.
# Login
login.username=Имя пользователя
......
......@@ -15,8 +15,8 @@
#-------------------------------------------------------------------------------
# Errors
error.access-denied=403 访问被拒绝
error.access-denied.text=您没有权限访问此资源。
http-error.403=403 访问被拒绝
http-error.403.text=您没有权限访问此资源。
# Login
login.username=用户名
......
......@@ -57,7 +57,7 @@
<sec:logout logout-url="/logout" logout-success-url="/" />
<sec:access-denied-handler error-page="/access-denied?error=1" />
<sec:access-denied-handler error-page="/access-denied" />
<sec:expression-handler ref="webExpressionHandler"/>
</sec:http>
......
<!DOCTYPE html>
<%@include file="init.jsp"%>
<html>
<head>
<meta charset="utf-8">
<title>Page Not Found :(</title>
<style>
::-moz-selection {
background: #b3d4fc;
text-shadow: none;
}
::selection {
background: #b3d4fc;
text-shadow: none;
}
html {
padding: 30px 10px;
font-size: 20px;
line-height: 1.4;
color: #737373;
background: #f0f0f0;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
html,
input {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
body {
max-width: 500px;
_width: 500px;
padding: 30px 20px 50px;
border: 1px solid #b3b3b3;
border-radius: 4px;
margin: 0 auto;
box-shadow: 0 1px 10px #a7a7a7, inset 0 1px 0 #fff;
background: #fcfcfc;
}
h1 {
margin: 0 10px;
font-size: 50px;
text-align: center;
}
h1 span {
color: #bbb;
}
h3 {
margin: 1.5em 0 0.5em;
}
p {
margin: 1em 0;
}
ul {
padding: 0 0 0 40px;
margin: 1em 0;
}
.container {
max-width: 380px;
_width: 380px;
margin: 0 auto;
}
/* google search */
#goog-fixurl ul {
list-style: none;
padding: 0;
margin: 0;
}
#goog-fixurl form {
margin: 0;
}
#goog-wm-qt,
#goog-wm-sb {
border: 1px solid #bbb;
font-size: 16px;
line-height: normal;
vertical-align: top;
color: #444;
border-radius: 2px;
}
#goog-wm-qt {
width: 220px;
height: 20px;
padding: 5px;
margin: 5px 10px 0 0;
box-shadow: inset 0 1px 1px #ccc;
}
#goog-wm-sb {
display: inline-block;
height: 32px;
padding: 0 10px;
margin: 5px 0 0;
white-space: nowrap;
cursor: pointer;
background-color: #f5f5f5;
background-image: -webkit-linear-gradient(rgba(255,255,255,0), #f1f1f1);
background-image: -moz-linear-gradient(rgba(255,255,255,0), #f1f1f1);
background-image: -ms-linear-gradient(rgba(255,255,255,0), #f1f1f1);
background-image: -o-linear-gradient(rgba(255,255,255,0), #f1f1f1);
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
*overflow: visible;
*display: inline;
*zoom: 1;
}
#goog-wm-sb:hover,
#goog-wm-sb:focus {
border-color: #aaa;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
background-color: #f8f8f8;
}
#goog-wm-qt:hover,
#goog-wm-qt:focus {
border-color: #105cb6;
outline: 0;
color: #222;
}
input::-moz-focus-inner {
padding: 0;
border: 0;
}
</style>
</head>
<body>
<div class="container">
<h1>Not found <span>:(</span></h1>
<p>Sorry, but the page you were trying to view does not exist.</p>
<p>It looks like this was the result of either:</p>
<ul>
<li>a mistyped address</li>
<li>an out-of-date link</li>
</ul>
<spring:message code="sample.error.unavailable"/>
<!-- <script>
var GOOG_FIXURL_LANG = (navigator.language || '').slice(0,2),GOOG_FIXURL_SITE = location.host;
</script>
<script src="http://linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script> -->
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<%@include file="init.jsp"%>
<html>
<head>
<title><spring:message code="sample.error.unexpected"/></title></head>
<body>
<h1>500</h1>
<p>
<spring:message code="sample.error.unexpected"/>
</p>
</body>
</html>
\ No newline at end of file
......@@ -49,8 +49,7 @@
</div>
</c:if>
<div class="pos-relative">
<div class="pseudo-right-col">
<div class="pseudo-right-col col-md-3">
<c:if test="${accessionGeo.latitude ne null}">
<div class="crop-location">
<h3><spring:message code="accession.collecting.site" /></h3>
......@@ -309,7 +308,6 @@
</tbody>
</table>
</div>
<c:if test="${methods.size() gt 0}">
......
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<html>
<head>
<title><spring:message code="http-error.401" /></title>
<style type="text/css">
* {margin:0; padding:0; outline:none; font-family:Arial, Helvetica, sans-serif; font-size:16px;}
body {background:#e7e5df;}
.container {margin:0 auto; width:1170px;}
.header {background:#4d4c46; height: 70px;}
.header .logo {display:block; padding:0 0 5px 0;}
.menu {background:#2b2924; border-bottom:10px solid #fff;}
.menu a {background:#2b2924; color:#fff; display:block; font-weight:bold; padding:10px 50px; text-decoration:none; text-transform:uppercase;}
.content {background:url('<c:url value="/html/images/bg_error.jpg" />') no-repeat; min-height:500px; margin-top:20px; position:relative; width:990px;}
.content .error-title {
color:#88ba42;
font-size:50px;
font-weight:bold;
line-height:130%;
padding-top:50px;
position:absolute;
top:57px;
left:50px;
text-align:center;
height:235px;
width:235px;
}
.content .error-title span {display:block; font-size:90px;}
.content .error-msg {float:right; margin:60px 40px 0 0; width:560px;}
.content .error-msg h1 {color:#fff; font-size:48px; padding:0 0 30px 0;}
.content .error-msg p {color:#fff; font-size:20px; padding:0 0 15px 0;}
.content .error-msg p small {font-size:16px;}
.content .error-msg ul {background:rgba(255, 255, 255, 0.2); padding:10px 0 10px 30px; width:300px;}
.content .error-msg ul li {color:#fff; font-style:italic; padding:3px 0;}
</style>
</head>
<body>
<div class="header">
<div class="container">
<a href="<c:url value="/" />" class="logo"><img src="<c:url value="/html/images/logo_genesys.png" />" alt="Genesys - Gateway to Genetic Resources" /></a>
</div>
</div>
<div class="menu">
<div class="container">
<a href="<c:url value="/" />">Home</a>
</div>
</div>
<div class="container">
<div class="content">
<div class="error-title"><span>401</span>error</div>
<div class="error-msg">
<h1>401 <spring:message code="http-error.401" /></h1>
<p><spring:message code="http-error.401.text" htmlEscape="false" /></p>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<html>
<head>
<title><spring:message code="http-error.404" /></title>
<style type="text/css">
* {margin:0; padding:0; outline:none; font-family:Arial, Helvetica, sans-serif; font-size:16px;}
body {background:#e7e5df;}
.container {margin:0 auto; width:1170px;}
.header {background:#4d4c46; height: 70px;}
.header .logo {display:block; padding:0 0 5px 0;}
.menu {background:#2b2924; border-bottom:10px solid #fff;}
.menu a {background:#2b2924; color:#fff; display:block; font-weight:bold; padding:10px 50px; text-decoration:none; text-transform:uppercase;}
.content {background:url('<c:url value="/html/images/bg_error.jpg" />') no-repeat; min-height:500px; margin-top:20px; position:relative; width:990px;}
.content .error-title {
color:#88ba42;
font-size:50px;
font-weight:bold;
line-height:130%;
padding-top:50px;
position:absolute;
top:57px;
left:50px;
text-align:center;
height:235px;
width:235px;
}
.content .error-title span {display:block; font-size:90px;}
.content .error-msg {float:right; margin:60px 40px 0 0; width:560px;}
.content .error-msg h1 {color:#fff; font-size:48px; padding:0 0 30px 0;}
.content .error-msg p {color:#fff; font-size:20px; padding:0 0 15px 0;}
.content .error-msg p small {font-size:16px;}
.content .error-msg ul {background:rgba(255, 255, 255, 0.2); padding:10px 0 10px 30px; width:300px;}
.content .error-msg ul li {color:#fff; font-style:italic; padding:3px 0;}
</style>
</head>
<body>
<div class="header">
<div class="container">
<a href="<c:url value="/" />" class="logo"><img src="<c:url value="/html/images/logo_genesys.png" />" alt="Genesys - Gateway to Genetic Resources" /></a>
</div>
</div>
<div class="menu">
<div class="container">
<a href="<c:url value="/" />">Home</a>
</div>
</div>
<div class="container">
<div class="content">
<div class="error-title"><span>404</span>error</div>
<div class="error-msg">
<h1>404 <spring:message code="http-error.404" /></h1>
<p><spring:message code="http-error.404.text" htmlEscape="false" /></p>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<html>
<head>
<title><spring:message code="http-error.500" /></title>
<style type="text/css">
* {margin:0; padding:0; outline:none; font-family:Arial, Helvetica, sans-serif; font-size:16px;}
body {background:#e7e5df;}
.container {margin:0 auto; width:1170px;}
.header {background:#4d4c46; height: 70px;}
.header .logo {display:block; padding:0 0 5px 0;}
.menu {background:#2b2924; border-bottom:10px solid #fff;}
.menu a {background:#2b2924; color:#fff; display:block; font-weight:bold; padding:10px 50px; text-decoration:none; text-transform:uppercase;}
.content {background:url('<c:url value="/html/images/bg_error.jpg" />') no-repeat; min-height:500px; margin-top:20px; position:relative; width:990px;}
.content .error-title {
color:#88ba42;
font-size:50px;
font-weight:bold;
line-height:130%;
padding-top:50px;
position:absolute;
top:57px;
left:50px;
text-align:center;
height:235px;
width:235px;
}
.content .error-title span {display:block; font-size:90px;}
.content .error-msg {float:right; margin:60px 40px 0 0; width:560px;}
.content .error-msg h1 {color:#fff; font-size:48px; padding:0 0 30px 0;}
.content .error-msg p {color:#fff; font-size:20px; padding:0 0 15px 0;}
.content .error-msg p small {font-size:16px;}
.content .error-msg ul {background:rgba(255, 255, 255, 0.2); padding:10px 0 10px 30px; width:300px;}
.content .error-msg ul li {color:#fff; font-style:italic; padding:3px 0;}
</style>
</head>
<body>
<div class="header">
<div class="container">
<a href="<c:url value="/" />" class="logo"><img src="<c:url value="/html/images/logo_genesys.png" />" alt="Genesys - Gateway to Genetic Resources" /></a>
</div>
</div>
<div class="menu">
<div class="container">
<a href="<c:url value="/" />">Home</a>
</div>
</div>
<div class="container">
<div class="content">
<div class="error-title"><span>500</span>error</div>
<div class="error-msg">
<h1>500 <spring:message code="http-error.500" /></h1>
<p><spring:message code="http-error.500.text" htmlEscape="false" /></p>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<html>
<head>
<title><spring:message code="http-error.503" /></title>
<style type="text/css">
* {margin:0; padding:0; outline:none; font-family:Arial, Helvetica, sans-serif; font-size:16px;}
body {background:#e7e5df;}
.container {margin:0 auto; width:1170px;}
.header {background:#4d4c46; height: 70px;}
.header .logo {display:block; padding:0 0 5px 0;}
.menu {background:#2b2924; border-bottom:10px solid #fff;}
.menu a {background:#2b2924; color:#fff; display:block; font-weight:bold; padding:10px 50px; text-decoration:none; text-transform:uppercase;}
.content {background:url('<c:url value="/html/images/bg_error.jpg"