Project

General

Profile

Download (1.29 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2018 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.vaadin.event.error;
11

    
12
import org.springframework.orm.hibernate5.HibernateSystemException;
13

    
14
import com.vaadin.ui.Notification;
15

    
16
import eu.etaxonomy.cdm.database.PermissionDeniedException;
17
import eu.etaxonomy.cdm.i18n.Messages;
18

    
19
/**
20
 * @author freimeier
21
 * @date 26.02.2018
22
 *
23
 */
24
public class HibernateSystemErrorHandler extends ErrorTypeHandler<HibernateSystemException>{
25

    
26
    private static final long serialVersionUID = -5703485298578474572L;
27

    
28
    /* (non-Javadoc)
29
     * @see eu.etaxonomy.cdm.vaadin.util.errorhandler.ErrorTypeHandler#handleError(com.vaadin.server.ErrorEvent)
30
     */
31
    @Override
32
    public void handleError(HibernateSystemException exception) {
33
        if(exception != null) {
34
            if(exception.getCause().getClass().equals(PermissionDeniedException.class)) {
35
                Notification.show(Messages.getLocalizedString(Messages.PermissionDeniedErrorHandler_ERROR_MSG));
36
            }else {
37
                Notification.show(exception.getCause().getMessage());
38
            }
39
        }
40
    }
41

    
42
}
(3-3/3)