/*
Copyright (C) 2000-2010  Ministere de la culture et de la communication (France), AJLSM
See LICENCE file
*/
package fr.gouv.culture.sdx.exception;

/**
 * Error codes for exception during SDX processing.
 *
 * <p>
 * The codes are integer between 0 and 7001, but this range could grow as needed.
 * <p>
 * The numbers between 1 and 99 are configuration errors.
 * The numbers between 100 and 199 are errors within our
 * Utilites class. The numbers between 200 and 299 are
 * internal SDX errors. The numbers between 1000 and 1999 are
 * application errors. The numbers between 6000 and 6999
 * are user errors. TODO:The numbers between 4000 and 4999 are
 * authentification errors. Most of the other error categories
 * are organized according to the Java package and then the class they are
 * generated within.
 * <p>
 * If a configuration error occurs, it shoud be difficult to
 * recover without modifying SDX configuration. The internal
 * errors are errors resulting from an abnormal behaviour of
 * SDX, mostly because of unavailable resources (database, files, etc.).
 * <p>
 * Application errors are exceptions thrown because of bad
 * programming in applications : unknown application, document
 * base or repository, missing arguments, unknown field name, etc.
 * A change in the program logic or code (XSP, Java, URL) should
 * correct the problem.
 * <p>
 * A user exception is thrown after a bad usage of SDX from a
 * end-user. These should almost never happen.
 * <p>
 * TODO: An authentification error is throw when a user or an application
 * attempts to use a protected resource without the appropriate
 * permissions.
 *
 */
public interface SDXExceptionCode {

    //TODORefactor:implement some public priorities and change SDXException class to handle these?-rbp
    /*Error priorities*/
    public static final String PRIORITY_CONFIG_FAILURE = "SDX CONFIGURATION FAILURE:";

    /*GENERIC error*/
    public final static int ERROR_GENERIC = 0;

    /*CONFIGURATION errors  - 0-99 */
    //public static final int ERROR_COMP_MANAGER_NULL
    public static final int ERROR_NO_SDX_CONFIG_FILE = 1;
    public static final int ERROR_SDX_CONFIG_FILE_READ = 2;
    public static final int ERROR_APP_CONFIG_FILE_READ = 3;
    public static final int ERROR_NO_APPS_FOR_CONFIG = 4;
    public static final int ERROR_CONFIGURE_INTERNAL_FIELDS = 5;
    public static final int ERROR_NO_APP_CONFIG_FILE = 6;
    public static final int ERROR_NO_DOCUMENTBASES_IN_CONFIG = 7;
    public static final int ERROR_CONFIGURE_DOCUMENT_BASE = 8;
    public static final int ERROR_CONFIGURE_REPOSITORY = 9;
    public static final int ERROR_CLASS_NOT_INSTANCEOF_SDX_INTERFACE = 10;
    public static final int ERROR_NO_REPOSITORIES_IN_CONFIG = 11;
    public static final int ERROR_NO_APP_PUBLIC_ID = 12;
    public static final int ERROR_NO_USER_DOCUMENTBASE_CONFIG = 13;
    public static final int ERROR_NO_FIELD_LIST_CONFIG = 14;
    public static final int ERROR_NO_INTERNAL_FIELDS_CONFIG = 15;
    public static final int ERROR_NO_PIPELINE_CONFIG = 16;
    public static final int ERROR_NO_TRANSFORMATIONS_IN_CONFIG = 17;
    public static final int ERROR_INVALID_ID_VALUE = 18;
    public static final int ERROR_INVALID_ATTRIBUTE = 19;
    public static final int ERROR_NO_CACHE_REPO_CONFIG = 20;
    public static final int ERROR_NO_FIELDS_IN_CONFIG = 21;
    public static final int ERROR_NO_APP_DIRECTORY = 22;
    public static final int ERROR_NO_PIPELINES_IN_CONFIG = 23;
    public static final int ERROR_CONFIGURE_PIPELINE = 24;
    public static final int ERROR_ENTITY_CATALOG_ADD = 25;
    public static final int ERROR_ACQUIRE_RESOLVER = 26;
    public static final int ERROR_NO_CATALOGS_DEFINED = 27;
    public static final int ERROR_NO_APP_REPOS_DEFINED = 28;
    public static final int ERROR_LOAD_REFERENCED_REPO = 29;
    public static final int ERROR_DEFAULT_FIELD_EXISTS = 30;
    public static final int ERROR_UNRECOGNIZED_DOCUMENTBASE_CONFIG = 31;
    public static final int ERROR_CONFIGURE_APP = 32;
    public static final int ERROR_NO_SECURITY_MANAGER = 33;
    public static final int ERROR_SYSTEM_PROPERTY = 34;
    public static final int ERROR_SYSTEM_PRIVILEGES = 35;
    public static final int ERROR_CREATE_RMI_REGISTRY = 36;
    public static final int ERROR_CONFIGURE_QUERY_PARSER = 37;
    public static final int ERROR_BIND_REMOTE_INDEX = 38;
    public static final int ERROR_CONFIGURE_ID_GENERATOR = 39;
    public static final int ERROR_CONFIGURE_TRANSFORMATION = 40;
    public static final int ERROR_CONFIGURE_THESAURUS = 41;
    public static final int ERROR_LOAD_REFERENCED_FIELD_LIST = 42;
    public static final int ERROR_NO_APP_FIELD_LISTS_DEFINED = 43;
    public static final int ERROR_NO_OAI_DC_METADATA_FORMAT = 44;
    public static final int ERROR_SDX_OAI_FIELD_NOT_BRIEF = 45;
    public static final int ERROR_OBJECT_WITH_ID_EXISTS = 46;
    public static final int ERROR_UNKNOWN_OAI_GRANULARITY = 47;
    public static final int ERROR_SDX_APPLICATIONS_FILE_UNREADABLE = 48;
    public static final int ERROR_CONFIGURE_LUCENE_INDEX = 49;
    public static final int ERROR_CONFIGURE_INDEXATION_LOGGER = 50;
    public static final int INFO_DOCUMENTBASE_CONFIGURING = 51;
    public static final int INFO_DOCUMENTBASE_ID_SETTING = 52;
    public static final int INFO_DOCUMENTBASE_CONFIGURED = 53;
    public static final int INFO_APPLICATIONS_CONFIGURING = 54;
    public static final int ERROR_APPLICATION_CONFIGURATION_FAILED = 55;
    public static final int INFO_APPLICATION_LOAD_DYNAMIC_CONFIGURATION_FAILED = 56;
    public static final int INFO_APPLICATION_CONFIGURING = 57;
    public static final int INFO_APPLICATION_CONFIGURED = 58;
    public static final int INFO_SDX_FRAMEWORK_LOADING = 59;
    public static final int INFO_THESAURUS_CONFIGURING = 60;
    public static final int INFO_THESAURUS_CONFIGURED = 61;
    public static final int WARN_NO_REPOSITORIES_IN_CONFIG = 62;
    public static final int INFO_CONFIGURE_DOCUMENTBASE_OPTIMIZATION = 63;
    public static final int INFO_APPLICATION_LOADING_DYNAMIC_CONFIGURATION = 64;

    /*UTILITIES errors - 100*/
    public static final int ERROR_DIRECTORY_PATH_NULL = 100;
    public static final int ERROR_DIRECTORY_NULL = 101;
    public final static int ERROR_CREATE_DIRS = 102;
    public final static int ERROR_NOT_DIRECTORY = 103;
    public final static int ERROR_DIRECTORY_NOT_READABLE = 104;
    public final static int ERROR_DIRECTORY_NOT_WRITABLE = 105;
    public static final int ERROR_RESOLVE_FILE_PROPS_NULL = 106;
    public static final int ERROR_RESOLVE_FILE_INVALID_FILE_PATH = 107;
    public static final int ERROR_RESOLVE_FILE = 108;
    public static final int ERROR_CONFIG_NULL = 109;
    public static final int ERROR_GET_REMOTE_INDEX = 110;
    public static final int ERROR_GET_QUERY_TERMS = 111;
    public static final int ERROR_BUILD_URL = 112;
    public static final int ERROR_GET_HSQLDB_CONNECTION = 113;
    public static final int ERROR_GET_PARAMETERS = 114;
    public static final int ERROR_RESOLVE_FILE_NULL_LOCATION = 115;


    /* INTERNAL errors - 200 */
    public final static int ERROR_LUCENE_READ = 200;
    public final static int ERROR_LUCENE_RETRIEVE_DOCUMENT = 201;
    public final static int ERROR_LUCENE_SEARCH = 202;
    public final static int ERROR_LUCENE_SEARCHER_GET = 203;
    public final static int ERROR_LUCENE_WRITE = 204;
    public final static int ERROR_LUCENE_DELETE = 205;
    public static final int ERROR_LUCENE_ACQUIRE_FSDIRECTORY = 206;
    //TODOException: find all places where this message will be useful and fix existing
    public static final int ERROR_INVALID_STRING = 207;
    public static final int ERROR_LUCENE_TERMDOCS_CLOSE = 208;
    public static final int ERROR_LUCENE_SEARCHER_CLOSE = 209;
    public static final int ERROR_LUCENE_TERMENUM_CLOSE = 210;
    public static final int ERROR_LUCENE_READER_CLOSE = 211;
    public static final int ERROR_INVALID_ID = 212;
    public static final int ERROR_OUTPUT_STREAM_NULL = 213;
    public static final int ERROR_XML_CONSUMER_NULL = 214;
    public static final int ERROR_CONTENT_HANDLER_NULL = 215;
    public static final int ERROR_LOCALE_NULL = 216;
    public static final int ERROR_DEFAULT_ENCODING = 217;
    public static final int ERROR_LUCENE_QUERY_NULL = 218;
    public static final int ERROR_CLOSE_STREAM = 219;
    public static final int ERROR_NEW_OBJECT_INSTANCE_NULL = 220;
    public static final int ERROR_SERVICE_MANAGER_NULL = 221;
    public static final int ERROR_LOOKUP_FRAMEWORK_SERVICE = 222;
    public static final int ERROR_LUCENE_OPTIMIZE = 223;
    public static final int ERROR_COMMIT_SQL_CONNECTION = 224;
    public static final int ERROR_ROLLBACK_SQL_CONNECTION = 225;
    public static final int ERROR_SET_AUTO_COMMIT_SQL_CONNECTION = 226;
    public static final int ERROR_LUCENE_MERGE_INDECES = 227;
    public static final int ERROR_LUCENE_DELETE_FILES_INDECES = 228;
    public static final int ERROR_LUCENE_DELETE_TEMPORARY_INDECES = 229;
    public static final int ERROR_LUCENE_COPY_MERGED_INDECES = 230;
    public static final int ERROR_LUCENE_UNLOCK = 231;


    /*Database errors - 300*/
    public static final int ERROR_CREATE_LUCENE_FIELD = 300;
    public static final int ERROR_INIT_DATABASE = 301;
    public static final int ERROR_GET_ENTITY = 302;
    public static final int ERROR_GET_ENTITIES = 303;
    public static final int ERROR_CONFIGURE_DATABASE = 304;
    public static final int ERROR_HSQLDB_NULL = 305;
    public static final int ERROR_SEARCH_DATABASE = 306;
    public static final int ERROR_SAVE_ENTITY = 307;
    public static final int ERROR_DELETE_ENTITY = 308;
    public static final int ERROR_DELETE_ENTITIES = 309;
    public static final int ERROR_CREATE_INDEX = 310;
    public static final int ERROR_ADD_PROPERTY = 311;
    public static final int ERROR_REMOVE_PROPERTY_WITH_ID = 312;
    public static final int ERROR_REMOVE_PROPERTY_WITHOUT_ID = 313;
    public static final int ERROR_OPTIMIZE = 314;
    public static final int INFO_LAUNCH_DOCUMENTBASE_OPTIMIZATION = 315;
    public static final int INFO_FINISHED_DOCUMENTBASE_OPTIMIZATION = 316;

    /*DatabaseConnection errors - 350*/


    /*Framework errors - 400*/
    public static final int ERROR_INVALID_NEW_SUPERUSER_ID = 400;
    public static final int ERROR_INVALID_NEW_SUPERUSER_PASSWORD = 401;
    public static final int ERROR_INVALID_NEW_SUPERUSER_DATA = 402;
    public static final int ERROR_WRITE_NEW_SUPERUSER_FILE = 403;
    public static final int ERROR_VALIDATE_SUPERUSER = 404;
    public static final int ERROR_SUPERUSER_PASSWORD = 405;
    public static final int ERROR_GET_ENCRYPTION = 406;
    public static final int ERROR_READ_NEW_SUPERUSER_FILE = 407;
    public static final int ERROR_INVALID_SUPERUSER_DATA_FROM_FILE = 408;
    public static final int ERROR_SUPERUSER_NOT_SET = 409;
    public static final int ERROR_CREATE_APP_FILE = 410;
    public static final int ERROR_CREATE_APPS_LIST_FILE = 411;
    public static final int ERROR_ACCESS_APPS_LIST_FILE = 412;

    /* APPLICATION errors. - 1000 */
    public final static int ERROR_UNKNOWN_APPLICATION = 1000;
    public final static int ERROR_UNKNOWN_DOCUMENT_BASE = 1001;
    public final static int ERROR_UNKNOWN_REPOSITORY = 1002;
    public final static int ERROR_USER_DOC_SAX_PARSE = 1003;
    public static final int ERROR_IDENTITY_NULL = 1004;
    public final static int ERROR_UNKNOWN_THESAURUS = 1005;
    public static final int ERROR_APPLICATION_XCONF_UNVAILABLE = 1006;
//    public final static int ERROR_SYSTEM_DIR_CONFIGURATION = 1006;


    /*DOCUMENTBASE ERRORS - 2000*/
    public static final int ERROR_NO_DOC_EXISTS_DOCBASE = 2000;
    public static final int ERROR_ACQUIRE_PARSER = 2001;
    public static final int ERROR_DOC_OWNED = 2002;
    public static final int ERROR_DOC_EXISTS = 2003;
    public static final int ERROR_CREATE_XML_PARSER = 2004;

    /*LuceneDocumentBase Errors - 2100*/
    public static final int ERROR_USING_DEFAULT_REPO = 2100;
    public static final int ERROR_ADDING_LUCENE_SUB_INDEX = 2101;
    public static final int ERROR_INITIALIZING_LUCENE_INDEX = 2102;
    public static final int ERROR_FREEING_LUCENE_RESOURCES = 2103;
    public static final int WARN_UNDECLARED_FIELD = 2104;

    /**LookUp Index errors*/
    public static final int ERROR_INVALID_REPO_ID = 2101;
    public static final int ERROR_RETRIEVE_REPO_FOR_DOCUMENT = 2102;

    /*Search Index errors*/
    public static final int WARN_INVALID_LUCENE_INDEX_DIRECTORY = 2200;


    /* REPOSITORY ERRORS - 3000 */
    public static final int ERROR_ADD_DOC = 3000;
    public static final int ERROR_GET_DOC = 3001;
    public static final int ERROR_NO_DOC_EXISTS_REPO = 3002;
    public static final int ERROR_EMPTY = 3003;
    public static final int ERROR_DELETE_DOC = 3004;
    public static final int ERROR_CONNECTION_NULL = 3005;
    public static final int ERROR_CLOSE_CONNECTION = 3006;
    public static final int ERROR_GET_CONNECTION = 3007;
    public static final int ERROR_INIT_REPO = 3008;
    public static final int ERROR_SIZE_REPO = 3009;
    public static final int ERROR_CLOSE_SQL_CONNECTION = 3010;



    /* File system repository - 3100 */

    /*JDBCRepository errors - 3200*/
    public static final int ERROR_CLOSE_RESULT_SET = 3200;
    public static final int ERROR_ACQUIRE_DATASOURCE = 3201;
    public static final int ERROR_CREATE_TABLE = 3202;
    public static final int ERROR_CLOSE_SQL_PREPARED_STATEMENT = 3203;

    /*URLRepository errors - 3300*/

    /*RepositoryConnection errors - 3400*/
    public static final int ERROR_COMMIT = 3400;
    public static final int ERROR_ROLLBACK = 3401;
    public static final int ERROR_SET_AUTO_COMMIT = 3402;

    /*JDBCRepositoryConnection errors - 3500*/


    /*SEARCH ERRORS*/
    public final static int ERROR_SEARCHLOCATIONS_NULL = 4000;
    public final static int ERROR_FIELD_DOES_NOT_EXIST = 4001;
    public static final int ERROR_HITS_NULL = 4002;
    public static final int ERROR_SEARCH_HITS_NULL = 4003;
    public static final int ERROR_FIELD_NULL = 4004;

    /*Query errors*/
    public final static int ERROR_QUERY_NULL = 4100;
    public final static int ERROR_QUERY_UNPARSABLE = 4101;
    public static final int ERROR_LUCENE_INDEX_INIT = 4102;
    public static final int ERROR_SEARCHER_NULL = 4103;
    public static final int ERROR_EXECUTE_QUERY = 4104;
    public static final int ERROR_GET_LUCENE_HITS_DOC = 4105;
    public static final int ERROR_NOT_DATE_FIELD = 4106;
    public static final int ERROR_DATE_INVALID = 4107;
    public static final int ERROR_QUERY_TERMS_NULL = 4108;
    public static final int ERROR_QUERY_PARSER_NULL = 4109;
    public static final int ERROR_GET_QUERY_PARSER = 4110;
    public static final int ERROR_PARSE_REGULAR_EXPRESSION = 4111;

    /*Terms errors*/
    public static final int ERROR_FIELD_NAME_NULL = 4200;
    public static final int ERROR_SETUP_TERMS = 4201;
    public static final int ERROR_GET_TERMS = 4202;


    /*Analyzer errors*/
    public static final int ERROR_FIELDS_DEF_NULL = 4300;
    public static final int ERROR_LOAD_ANALYZER = 4301;
    public static final int ERROR_LOAD_ANALYZER_CONFIG = 4302;
    public static final int ERROR_ANALYZER_CONFIG_FILE_READ = 4303;
    public static final int ERROR_SET_ANALYZER = 4304;

    /*Results errors*/
    public static final int ERROR_SETUP_RESULTS = 4400;
    public static final int ERROR_DOCUMENT_NOT_IN_RESULTS = 4401;

    /*SearchLocation errors*/
    public static final int ERROR_BUILD_MULTISEARCHER = 4500;
    public static final int ERROR_GET_FIRST_FIELD = 4501;
    public static final int ERROR_GET_DEFAULT_FIELD = 4502;
    public static final int ERROR_BUILD_MULTIREADER = 4503;
    public static final int WARN_USE_FIRST_SEARCHLOCATION = 4504;

    /*TermInfo errors*/
    public static final int ERROR_SETUP_TERMINFO = 4600;
    public static final int ERROR_TERMINFO_SETDOCID = 4601;

    /*Filter errors*/
    public static final int ERROR_LUCENE_FILTER_NULL = 4700;
    public static final int ERROR_INVALID_VALUE = 4701;
    public static final int WARN_STRING_FILTER_NULL = 4702;

    /*ResultDocument errors*/
    public static final int ERROR_LUCENE_DOCUMENT_NULL = 4800;

    /*SortSpecification errors*/
    public static final int ERROR_RESULT_DOCS_NULL = 4900;
    public static final int ERROR_INVALID_SORT_ORDER = 4901;

    /*DOCUMENT errors*/
    public static final int ERROR_DOC_NULL = 5000;
    public static final int ERROR_INVALID_DOC_ID = 5001;
    public static final int ERROR_GET_INPUTSOURCE = 5002;
    public static final int ERROR_GET_LENGTH = 5003;
    public static final int ERROR_BUILD_DOC_URL = 5004;
    public static final int ERROR_OPEN_STREAM = 5005;
    public static final int ERROR_USING_DEFAULT_GENERATOR = 5006;
    public static final int ERROR_NO_ID_GENERATOR = 5007;

    /*ParsableDocument errors - 5100*/
    public static final int ERROR_PARSER_NULL = 5100;
    public static final int ERROR_PARSE_DOC = 5101;
    public static final int ERROR_SET_TRANSFORMED_DOC = 5102;


    /*USER errors - 6000*/
    public static final int ERROR_NO_USER_EXISTS = 6000;
    public static final int ERROR_INVALID_NAME = 6001;
    public static final int ERROR_GROUPS_NULL = 6002;

    /*Pipeline errors - 7000*/
    public static final int ERROR_UNKNOWN_PIPELINE = 7000;
    public static final int ERROR_NEW_INSTANCE = 7001;
    public static final int ERROR_BUILD_TRANSFORMED_FILE = 7002;
    public static final int ERROR_GET_TRANSFORMED_FILE = 7003;

    /*Transformation errors - 8000*/

    /*DeleteResultsTransformation errors - 8100-8199*/
    public static final int ERROR_DELETE_APP_ID = 8100;
    
    /*Backup errors - 8200-8299*/
    public static final int ERROR_BACKUP_APPLICATION = 8200;
    public static final int ERROR_BACKUP_DOCUMENTBASE = 8201;
    public static final int ERROR_BACKUP_DATABASE = 8202;
    public static final int ERROR_BACKUP_INDEX = 8203;
    public static final int ERROR_BACKUP_REPOSITORY = 8204;
    
    /*Infos - 9000-9500*/
    public static final int INFO_SDX_INDEXATION_BATCH_START = 9000;
    public static final int INFO_IGNORING_DOCUMENT_WITH_SAME_ID = 9001;
    
    
    /*OAI - 10 000 - 10 500*/
    public static final int OAI_HARVESTER_CONFIGURED = 10000;
    public static final int OAI_REPOSITORY_CONFIGURED = 10001;
    public static final int OAI_REPOSITORY_CREATED = 10002;
    public static final int OAI_DEFAULT_REPOSITORY_CREATED = 10003;
    public static final int OAI_SERVING_REPOSITORY = 10004;
    public static final int OAI_NO_OAI_REPOSITORY_AVAILABLE = 10005;
    public static final int OAI_SERVING_SINGLE_REPOSITORY = 10006;
    public static final int OAI_SERVING_DEFAULT_REPOSITORY = 10007;
    public static final int OAI_MANAGE_DELETED_RECORD = 10008;
    public static final int OAI_REPOSITORY_CREATE_NEW_INSTANCE = 10009;
    public static final int OAI_NO_OAI_REPOSITORY_ID_AVAILABLE = 10010;
    public static final int OAI_NO_OAI_REPOSITORY_ID_AVAILABLE_FOR_URL = 10011;
    public static final int OAI_HARVESTER_CONFIGURING = 10012;
    public static final int OAI_HARVESTER_USES_DEFAULT_SYSTEM_TEMPDIR = 10013;
    public static final int OAI_HARVESTER_INITIALIZE_TEMPDIR = 10014;
    public static final int OAI_HARVESTER_ENABLE_CREATE_TEMPDIR = 10015;
    public static final int OAI_HARVESTER_KEEP_RECORDS = 10016;
    public static final int OAI_HARVESTER_RECEPTION_BEGIN = 10017;
    public static final int OAI_HARVESTER_RECEPTION_END = 10018;
    public static final int OAI_HARVESTER_INDEXATION_LAUNCH = 10019;
    public static final int OAI_HARVESTER_INDEXATION_NOTLAUNCH_DESACTIVATE = 10020;
    public static final int OAI_HARVESTER_INDEXATION_NOTLAUNCH_ERROR = 10021;
    public static final int OAI_HARVESTER_LAUNCHING = 10022;
    public static final int OAI_HARVESTER_LAUNCHING_ERROR_DOCUMENTBASE = 10023;
    public static final int OAI_REPOSITORY_CONFIGURING = 10024;
    public static final int OAI_HARVESTER_REQUEST_BUILDED = 10025;
    public static final int OAI_HARVESTER_REQUEST_ENDED = 10026;
    public static final int OAI_HARVESTER_SUMMARY = 10027;
    public static final int OAI_HARVESTER_DELETEDDOCUMENT_START = 10028;
}