]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Common/Class/Errors.php
baculum: Improve errors handling in API restore pages
[bacula/bacula] / gui / baculum / protected / Common / Class / Errors.php
1 <?php
2 /*
3  * Bacula(R) - The Network Backup Solution
4  * Baculum   - Bacula web interface
5  *
6  * Copyright (C) 2013-2016 Kern Sibbald
7  *
8  * The main author of Baculum is Marcin Haba.
9  * The original author of Bacula is Kern Sibbald, with contributions
10  * from many others, a complete list can be found in the file AUTHORS.
11  *
12  * You may use this file and others of this release according to the
13  * license defined in the LICENSE file, which includes the Affero General
14  * Public License, v3.0 ("AGPLv3") and some additional permissions and
15  * terms pursuant to its AGPLv3 Section 7.
16  *
17  * This notice must be preserved when any source code is
18  * conveyed and/or propagated.
19  *
20  * Bacula(R) is a registered trademark of Kern Sibbald.
21  */
22  
23 class GenericError {
24         const ERROR_NO_ERRORS = 0;
25         const ERROR_INVALID_COMMAND = 1;
26         const ERROR_INTERNAL_ERROR = 1000;
27
28         const MSG_ERROR_NO_ERRORS = '';
29         const MSG_ERROR_INVALID_COMMAND = 'Invalid command.';
30         const MSG_ERROR_INTERNAL_ERROR = 'Internal error.';
31 }
32
33 class DatabaseError extends GenericError {
34         const ERROR_DB_CONNECTION_PROBLEM = 2;
35         const ERROR_DATABASE_ACCESS_NOT_SUPPORTED = 3;
36         
37         const MSG_ERROR_DB_CONNECTION_PROBLEM = 'Problem with connection to database.';
38         const MSG_ERROR_DATABASE_ACCESS_NOT_SUPPORTED = 'Database access is not supported by this API instance.';
39 }
40
41 class BconsoleError extends GenericError {
42
43         const ERROR_BCONSOLE_CONNECTION_PROBLEM = 4;
44         const ERROR_INVALID_DIRECTOR = 5;
45
46         const MSG_ERROR_BCONSOLE_CONNECTION_PROBLEM = 'Problem with connection to bconsole.';
47         const MSG_ERROR_INVALID_DIRECTOR = 'Invalid director.';
48 }
49
50 class AuthorizationError extends GenericError {
51
52         const ERROR_AUTHORIZATION_TO_API_PROBLEM = 6;
53         const ERROR_ACCESS_ATTEMPT_TO_NOT_ALLOWED_RESOURCE = 7;
54
55         const MSG_ERROR_AUTHORIZATION_TO_API_PROBLEM = 'Problem with authorization to Baculum API.';
56         const MSG_ERROR_ACCESS_ATTEMPT_TO_NOT_ALLOWED_RESOURCE = 'Access attempt to not allowed resource. Permission denied.';
57 }
58
59 class ClientError extends GenericError {
60         const ERROR_CLIENT_DOES_NOT_EXISTS = 10;
61
62         const MSG_ERROR_CLIENT_DOES_NOT_EXISTS = 'Client with inputted clientid does not exist.';
63 }
64
65 class StorageError extends GenericError {
66         const ERROR_STORAGE_DOES_NOT_EXISTS = 20;
67
68         const MSG_ERROR_STORAGE_DOES_NOT_EXISTS = 'Storage with inputted storageid does not exist.';
69 }
70
71 class VolumeError extends GenericError {
72         const ERROR_VOLUME_DOES_NOT_EXISTS = 30;
73
74         const MSG_ERROR_VOLUME_DOES_NOT_EXISTS = 'Volume with inputted mediaid does not exist.';
75 }
76
77 class PoolError extends GenericError {
78         const ERROR_POOL_DOES_NOT_EXISTS = 40;
79         const ERROR_NO_VOLUMES_IN_POOL_TO_UPDATE = 41;
80
81         const MSG_ERROR_POOL_DOES_NOT_EXISTS = 'Pool with inputted poolid does not exist.';
82         const MSG_ERROR_NO_VOLUMES_IN_POOL_TO_UPDATE= 'Pool with inputted poolid does not contain any volume to update.';
83 }
84
85 class JobError extends GenericError {
86         const ERROR_JOB_DOES_NOT_EXISTS = 50;
87         const ERROR_INVALID_JOBLEVEL = 51;
88         const ERROR_FILESET_DOES_NOT_EXISTS = 52;
89         const ERROR_CLIENT_DOES_NOT_EXISTS = 53;
90         const ERROR_STORAGE_DOES_NOT_EXISTS = 54;
91         const ERROR_POOL_DOES_NOT_EXISTS = 55;
92         const ERROR_INVALID_RPATH = 56;
93         const ERROR_INVALID_WHERE_OPTION = 57;
94         const ERROR_INVALID_REPLACE_OPTION = 58;
95
96         const MSG_ERROR_JOB_DOES_NOT_EXISTS = 'Job with inputted jobid does not exist.';
97         const MSG_ERROR_INVALID_JOBLEVEL = 'Inputted job level is invalid.';
98         const MSG_ERROR_FILESET_DOES_NOT_EXISTS = 'FileSet resource does not exist.';
99         const MSG_ERROR_CLIENT_DOES_NOT_EXISTS = 'Client does not exist.';
100         const MSG_ERROR_STORAGE_DOES_NOT_EXISTS = 'Storage does not exist.';
101         const MSG_ERROR_POOL_DOES_NOT_EXISTS = 'Pool does not exist.';
102         const MSG_ERROR_INVALID_RPATH = 'Inputted rpath for restore is invalid. Proper format is b2[0-9]+.';
103         const MSG_ERROR_INVALID_WHERE_OPTION = 'Inputted "where" option is invalid.';
104         const MSG_ERROR_INVALID_REPLACE_OPTION = 'Inputted "replace" option is invalid.';
105 }
106
107 class FileSetError extends GenericError {
108         const ERROR_FILESET_DOES_NOT_EXISTS = 60;
109
110         const MSG_ERROR_FILESET_DOES_NOT_EXISTS = 'FileSet with inputted filesetid does not exist.';
111 }
112
113 class BVFSError extends GenericError {
114         const ERROR_JOB_DOES_NOT_EXISTS = 70;
115         const ERROR_INVALID_RPATH = 71;
116         const ERROR_INVALID_RESTORE_PATH = 72;
117
118         const MSG_ERROR_JOB_DOES_NOT_EXISTS = 'Job with inputted jobid does not exist.';
119         const MSG_ERROR_INVALID_RPATH = 'Inputted path for restore is invalid. Proper format is b2[0-9]+.';
120         const MSG_ERROR_INVALID_RESTORE_PATH = 'Inputted BVFS path param is invalid.';
121 }
122
123 class JSONToolsError extends GenericError {
124
125         const ERROR_JSON_TOOLS_DISABLED = 80;
126         const ERROR_JSON_TOOLS_CONNECTION_PROBLEM = 81;
127         const ERROR_JSON_TOOLS_WRONG_EXITCODE = 82;
128         const ERROR_JSON_TOOLS_UNABLE_TO_PARSE_OUTPUT = 83;
129         const ERROR_JSON_TOOL_NOT_CONFIGURED = 84;
130
131
132         const MSG_ERROR_JSON_TOOLS_DISABLED = 'JSON tools support is disabled.';
133         const MSG_ERROR_JSON_TOOLS_CONNECTION_PROBLEM = 'Problem with connection to a JSON tool.';
134         const MSG_ERROR_JSON_TOOLS_WRONG_EXITCODE = 'JSON tool returned wrong exitcode.';
135         const MSG_ERROR_JSON_TOOLS_UNABLE_TO_PARSE_OUTPUT = 'JSON tool output was unable to parse.';
136         const MSG_ERROR_JSON_TOOL_NOT_CONFIGURED = 'JSON tool not configured.';
137 }
138
139 class BaculaConfigError extends GenericError {
140
141         const ERROR_CONFIG_DIR_NOT_WRITABLE = 90;
142         const ERROR_UNEXPECTED_BACULA_CONFIG_VALUE = 91;
143         const ERROR_CONFIG_NO_JSONTOOL_READY = 92;
144         const ERROR_WRITE_TO_CONFIG_ERROR = 93;
145         const ERROR_CONFIG_VALIDATION_ERROR = 94;
146
147         const MSG_ERROR_CONFIG_DIR_NOT_WRITABLE = 'Config directory is not writable.';
148         const MSG_ERROR_UNEXPECTED_BACULA_CONFIG_VALUE = 'Unexpected Bacula config value.';
149         const MSG_ERROR_CONFIG_NO_JSONTOOL_READY = 'No JSON tool ready.';
150         const MSG_ERROR_WRITE_TO_CONFIG_ERROR = 'Write to config file error.';
151         const MSG_ERROR_CONFIG_VALIDATION_ERROR = 'Config validation error.';
152 }
153
154 class ConnectionError extends GenericError {
155
156         const ERROR_CONNECTION_TO_HOST_PROBLEM = 100;
157
158         const MSG_ERROR_CONNECTION_TO_HOST_PROBLEM = 'Problem with connection to remote host.';
159 }
160 ?>