Project

General

Profile

« Previous | Next » 

Revision 79180ba0

Added by Andreas Kohlbecker over 3 years ago

ref #7936 removing handler for redmine messaging exceptions

View differences:

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

  
11
import com.vaadin.server.ErrorEvent;
12
import com.vaadin.server.Page;
13
import com.vaadin.ui.Notification;
14
import com.vaadin.ui.Notification.Type;
15

  
16
import eu.etaxonomy.cdm.ext.common.ExternalServiceException;
17
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
18

  
19

  
20
public class ExternalServiceExceptionHandler extends ErrorTypeHandler<ExternalServiceException>{
21

  
22
    private static final long serialVersionUID = -5703485298578474572L;
23
    private String mainMessage;
24

  
25
    public ExternalServiceExceptionHandler(String mainMessage){
26
        this.mainMessage = mainMessage;
27
    }
28

  
29

  
30
    /**
31
     * {@inheritDoc}
32
     */
33
    @Override
34
    public Class<ExternalServiceException> supports() {
35
        return ExternalServiceException.class;
36
    }
37

  
38

  
39
    /**
40
     * {@inheritDoc}
41
     */
42
    @Override
43
    public void error(ErrorEvent event) {
44
        // only exception() needed in this class
45

  
46
    }
47

  
48
    @Override
49
    public void exception(ExternalServiceException exception) {
50
        Notification notification = new Notification(mainMessage,
51
                "<div><strong>Service:</strong> "+ exception.getExternalService() + "</div>" +
52
                "<div><strong>Problem:</strong> "+ exception.getProblem() + "</div>" +
53
                "<p>" + RegistrationUIDefaults.ERROR_CONTACT_MESSAGE_LINE + "</p>"
54
                , Type.ERROR_MESSAGE);
55
        notification.setHtmlContentAllowed(true);
56
        notification.show(Page.getCurrent());
57
    }
58

  
59

  
60

  
61
}

Also available in: Unified diff