PageRenderTime 367ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/branches/ZObjects/src/org/zonales/errors/ZMessages.java

https://gitlab.com/BGCX261/zonales-svn-to-git
Java | 111 lines | 97 code | 3 blank | 11 comment | 1 complexity | 2e5eb606760f9b2af0c6e845fdf70b4b MD5 | raw file
Possible License(s): BSD-3-Clause
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package org.zonales.errors;
  6. /**
  7. *
  8. * @author nacho
  9. */
  10. public class ZMessages {
  11. public static String appendMessage(ZMessage error, String msg) {
  12. return "{\"cod\": \"" + error.getCod() + "\", \"msg\": \"" + error.getMsg() + msg + "\"}";
  13. }
  14. public static ZMessage switchMessages(int code) {
  15. switch (code) {
  16. case 200:
  17. return PREVIUS_STATE_WRONG;
  18. case 201:
  19. return UPDATE_FAILED;
  20. case 202:
  21. return SAVE_FAILED;
  22. case 203:
  23. return DATA_NOT_FOUND;
  24. case 204:
  25. return PARAM_REQUIRED_FAILED;
  26. case 205:
  27. return TAG_TYPE_NOT_FOUND;
  28. case 206:
  29. return CONFIG_NOT_FOUND;
  30. case 220:
  31. return ZPARSER_ZGRAM_PARTIALLY_PARSED;
  32. case 300:
  33. return UNKNOWN_ERROR;
  34. case 301:
  35. return NO_DB_FAILED;
  36. case 302:
  37. return MONGODB_ERROR;
  38. case 303:
  39. return CONN_ERROR;
  40. case 320:
  41. return ZPARSER_USE_ERROR;
  42. case 321:
  43. return ZPARSER_PARSE_VISITOR_ERROR;
  44. case 322:
  45. return ZPARSER_PARSE_VISITOR_ILEGAL_ERROR;
  46. case 323:
  47. return ZPARSER_PARSE_VISITOR_INSTANT_ERROR;
  48. case 324:
  49. return ZPARSER_CANNOT_PARSE;
  50. case 350:
  51. return ZSCHEDULER_SCHEDULER_ERROR;
  52. case 351:
  53. return ZSCHEDULER_NAMING_ERROR;
  54. case 352:
  55. return ZSCHEDULER_UNKNOW_ERROR;
  56. case 353:
  57. return ZSCHEDULER_CONN_ERROR;
  58. case 354:
  59. return ZSCHEDULER_URL_ERROR;
  60. case 370:
  61. return ZSOURCES_CONN_ERROR;
  62. case 371:
  63. return ZSOURCES_GETURL_ERROR;
  64. case 380:
  65. return ZSERVLETS_CONN_ERROR;
  66. case 390:
  67. return GSON_CONVERTION_ERROR;
  68. case 400:
  69. return FACEBOOK_GENERAL_ERROR;
  70. case 401:
  71. return FACEBOOK_API_EXCEPTION;
  72. default:
  73. return SUCCESS;
  74. }
  75. }
  76. //INFO
  77. public static final ZMessage SUCCESS = new ZMessage(100, "Success");
  78. //Warning (errores de código, manejados, etc.
  79. public static final ZMessage PREVIUS_STATE_WRONG = new ZMessage(200, "Previus state wrong");
  80. public static final ZMessage UPDATE_FAILED = new ZMessage(201, "Update failed");
  81. public static final ZMessage SAVE_FAILED = new ZMessage(202, "Save failed");
  82. public static final ZMessage DATA_NOT_FOUND = new ZMessage(203, "Data not found");
  83. public static final ZMessage CONFIG_NOT_FOUND = new ZMessage(206, "Crawl Config not found");
  84. public static final ZMessage PARAM_REQUIRED_FAILED = new ZMessage(204, "Param required failed");
  85. public static final ZMessage TAG_TYPE_NOT_FOUND = new ZMessage(205, "Declared tag type doesn't exists");
  86. public static final ZMessage ZPARSER_ZGRAM_PARTIALLY_PARSED = new ZMessage(220, "ZParser - La consulta se parseo parcialmente. La porción correcta se guardó.");
  87. //Error (Excepciones)
  88. public static final ZMessage UNKNOWN_ERROR = new ZMessage(300, "Unknown Error");
  89. public static final ZMessage NO_DB_FAILED = new ZMessage(301, "DB is unavailable");
  90. public static final ZMessage MONGODB_ERROR = new ZMessage(302, "MongoDB error");
  91. public static final ZMessage CONN_ERROR = new ZMessage(303, "Connection error");
  92. public static final ZMessage ZPARSER_USE_ERROR = new ZMessage(320, "ZParser - use error: Parser [-rule rulename] [-trace] <-file file | -string string> [-visitor visitor]");
  93. public static final ZMessage ZPARSER_PARSE_VISITOR_ERROR = new ZMessage(321, "ZParser - visitor error: class not found");
  94. public static final ZMessage ZPARSER_PARSE_VISITOR_ILEGAL_ERROR = new ZMessage(322, "ZParser - visitor error: illegal access");
  95. public static final ZMessage ZPARSER_PARSE_VISITOR_INSTANT_ERROR = new ZMessage(323, "ZParser - visitor error: instantiation failure");
  96. public static final ZMessage ZPARSER_CANNOT_PARSE = new ZMessage(324, "ZParser - No se pudo parsear la consulta");
  97. public static final ZMessage ZSCHEDULER_SCHEDULER_ERROR = new ZMessage(350, "ZScheduler - Error en el scheduler");
  98. public static final ZMessage ZSCHEDULER_NAMING_ERROR = new ZMessage(351, "ZScheduler - No se pudo obtener el scheduler del contexto");
  99. public static final ZMessage ZSCHEDULER_UNKNOW_ERROR = new ZMessage(352, "ZScheduler - Error desconocido");
  100. public static final ZMessage ZSCHEDULER_CONN_ERROR = new ZMessage(353, "ZScheduler - Error de conección");
  101. public static final ZMessage ZSCHEDULER_URL_ERROR = new ZMessage(354, "ZScheduler - Error en URL");
  102. public static final ZMessage ZSOURCES_CONN_ERROR = new ZMessage(370, "ZSources - Error de conección");
  103. public static final ZMessage ZSOURCES_GETURL_ERROR = new ZMessage(371, "ZSources - Error obteniendo URL de extracción");
  104. public static final ZMessage ZSERVLETS_CONN_ERROR = new ZMessage(380, "ZServlet - Error de conección");
  105. public static final ZMessage GSON_CONVERTION_ERROR = new ZMessage(390, "GSon - Error de Conversión");
  106. public static final ZMessage FACEBOOK_GENERAL_ERROR = new ZMessage(400, "Facebook Information Retrieval - Error no identificado");
  107. public static final ZMessage FACEBOOK_API_EXCEPTION = new ZMessage(401, "Facebook Information Retrieval - Error en Api de Facebook");
  108. }