Project

General

Profile

Revision 3769d06b

ID3769d06b7895addc37edc2cc7b73d3a3327a6cd6
Parent fe2906f6
Child 1251ffed

Added by Andreas Müller about 1 year ago

ref #7745 some exception handling for subtree filter

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/exception/FilterException.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.exception;
10

  
11
/**
12
 * This Exception is for throwing an exception if a filter prevents a method
13
 * from returning any value except an empty one.
14
 * This is because the filter condition itself can never be <code>true</code>
15
 * (e.g. because a given subtree ID does not exist in the database at all)
16
 * or because non of the data matches the filter.
17
 * <BR>
18
 * In the first case it is recommended to set the invalidFilter parameter to <code>true</code>
19
 * to indicate that the filter itself might be not correct.
20
 *
21
 * @author a.mueller
22
 * @since 14.09.2018
23
 */
24
public class FilterException extends Exception {
25

  
26
    private static final long serialVersionUID = 7491596488082796101L;
27

  
28
    private boolean invalidFilter;
29

  
30
    public FilterException(boolean invalidFilter) {
31
        super();
32
        this.setInvalidFilter(invalidFilter);
33
    }
34

  
35
    public FilterException(String message, boolean invalidFilter) {
36
        super(message);
37
        this.setInvalidFilter(invalidFilter);
38
    }
39

  
40
    /**
41
     * @param cause
42
     */
43
    public FilterException(Throwable cause, boolean invalidFilter) {
44
        super(cause);
45
        this.setInvalidFilter(invalidFilter);
46
    }
47

  
48
    /**
49
     * @param message
50
     * @param cause
51
     */
52
    public FilterException(String message, Throwable cause, boolean invalidFilter) {
53
        super(message, cause);
54
        this.setInvalidFilter(invalidFilter);
55
    }
56

  
57
    public boolean isInvalidFilter() {
58
        return invalidFilter;
59
    }
60

  
61
    public void setInvalidFilter(boolean invalidFilter) {
62
        this.invalidFilter = invalidFilter;
63
    }
64

  
65
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/BaseListController.java
140 140
        if (subtreeUuid != null){
141 141
            subtree = taxonNodeService.find(subtreeUuid);
142 142
            if(subtree == null) {
143
                response.sendError(404 , "TaxonNode not found using " + subtreeUuid );
143
                response.sendError(404 , "Taxon node for subtree not found: " + subtreeUuid );
144 144
                //will not happen
145 145
                return null;
146 146
            }
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/HttpStatusMessage.java
35 35
    public final static HttpStatusMessage INTERNAL_ERROR = new HttpStatusMessage(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "internal server error");
36 36

  
37 37
    public final static HttpStatusMessage ACCESS_DENIED = new HttpStatusMessage(HttpServletResponse.SC_FORBIDDEN, "access denied");
38
    public final static HttpStatusMessage SUBTREE_FILTER_INVALID = new HttpStatusMessage(HttpServletResponse.SC_NOT_FOUND, "invalid uuid for subtree filter");
38 39

  
39 40

  
40 41
    private int statusCode;

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)