source: DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/VerboseOutput.java @ 4903

Last change on this file since 4903 was 4903, checked in by olhsha@mpi.nl, 10 years ago

tested and debugged on localhost. Error status messages are corrected.

File size: 3.9 KB
Line 
1/*
2 * Copyright (C) 2013 DASISH
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 */
18package eu.dasish.annotation.backend.rest;
19
20import java.io.IOException;
21import javax.servlet.http.HttpServletResponse;
22import org.slf4j.Logger;
23
24/**
25 *
26 * @author olhsha
27 */
28public class VerboseOutput {
29
30    private Logger logger;
31
32    public VerboseOutput(Logger logger) {
33        this.logger = logger;
34    }
35
36 
37
38    private String _FORBIDDEN_RESOURCE_ACTION(String identifier, String resource, String action, String ownerName, String ownerEMail) {
39        return " The logged-in principal cannot " + action + " the " + resource + " with the identifier " + identifier + ". Contact the resource's owner " + ownerName + " via the e-mail " + ownerEMail;
40    }
41
42
43    public void FORBIDDEN_NOTEBOOK_READING(String identifier, String ownerName, String ownerEMail) throws IOException  {
44        logger.debug(this._FORBIDDEN_RESOURCE_ACTION(identifier, "notebook", "read", ownerName, ownerEMail));
45    }
46
47    public void FORBIDDEN_NOTEBOOK_WRITING(String identifier, String ownerName, String ownerEMail) throws IOException  {
48        logger.debug(this._FORBIDDEN_RESOURCE_ACTION(identifier, "notebook", "write", ownerName, ownerEMail));
49    }
50
51    public void FORBIDDEN_ANNOTATION_READING(String identifier, String ownerName, String ownerEMail) throws IOException {
52        logger.debug(this._FORBIDDEN_RESOURCE_ACTION(identifier, "annotation", "read", ownerName, ownerEMail));;
53    }
54   
55     public void FORBIDDEN_ANNOTATION_BODY_WRITING(String identifier, String ownerName, String ownerEMail) throws IOException {
56        logger.debug(this._FORBIDDEN_RESOURCE_ACTION(identifier, "annotation", "write", ownerName, ownerEMail));;
57    }
58
59
60    public void FORBIDDEN_ANNOTATION_DELETING(String identifier, String ownerName, String ownerEMail) throws IOException {
61        logger.debug(this._FORBIDDEN_RESOURCE_ACTION(identifier, "annotation", "delete", ownerName, ownerEMail));
62    }
63
64    public void FORBIDDEN_ACCESS_CHANGING(String identifier, String ownerName, String ownerEMail) throws IOException {
65        logger.debug(this._FORBIDDEN_RESOURCE_ACTION(identifier, "resource", "access change", ownerName, ownerEMail));
66    }
67
68
69   
70
71    public void INVALID_ACCESS_MODE(String accessMode) throws IOException {
72        logger.debug(accessMode + " is an invalid access value, which must be either owner, or read, or write.");
73    }
74
75    public void IDENTIFIER_MISMATCH(String identifier) throws IOException {
76        logger.debug("Wrong request: the annotation (notebook) identifier   " + identifier + " and the annotation (notebook) ID from the request body do not match.");
77    }
78
79    public void ADMIN_RIGHTS_EXPECTED(String adminName, String adminEmail) throws IOException {
80        logger.debug("The request can be performed only by the principal with the admin rights. Contact the admin " + adminName + " via e-mail " + adminEmail);
81    }
82   
83     public void ADMIN_RIGHTS_EXPECTED() throws IOException {
84        logger.debug("The request can be performed only by the principal with the admin rights.");
85    }
86
87    public void DEVELOPER_RIGHTS_EXPECTED() throws IOException {
88        logger.debug("The request can be performed only by the principal with the developer's or admin rights. The logged in principal does not have either developer's or admin rights.");
89    }
90 
91}
92
Note: See TracBrowser for help on using the repository browser.