예제 #1
0
  @Override
  public void processError(ODataServerError error, ErrorResponse response) {
    int logLevel = error.getStatusCode() >= 500 ? MessageLevel.ERROR : MessageLevel.WARNING;
    Throwable ex = getRoot(error.getException());
    // many exceptions in TeiidServiceHandler default as INTERNAL_SERVER_ERROR
    // so we make a better check for codes here
    if (ex instanceof TeiidNotImplementedException) {
      error.setException((TeiidNotImplementedException) ex);
      error.setCode(((TeiidNotImplementedException) ex).getCode());
      error.setStatusCode(501);
      logLevel = MessageLevel.DETAIL;
    } else if (ex instanceof TeiidProcessingException) {
      error.setException((TeiidProcessingException) ex);
      error.setCode(((TeiidProcessingException) ex).getCode());
      error.setStatusCode(400);
      logLevel = MessageLevel.WARNING;
    } else if (ex instanceof TeiidException) {
      error.setException((TeiidException) ex);
      error.setCode(((TeiidException) ex).getCode());
      error.setStatusCode(500);
      logLevel = MessageLevel.ERROR;
    } else if (ex instanceof TeiidRuntimeException) {
      error.setException((TeiidRuntimeException) ex);
      error.setCode(((TeiidRuntimeException) ex).getCode());
      error.setStatusCode(500);
      logLevel = MessageLevel.ERROR;
    }

    if (ex != error.getException() && ex.getMessage() != null) {
      if (LogManager.isMessageToBeRecorded(LogConstants.CTX_ODATA, MessageLevel.DETAIL)
          || logLevel <= MessageLevel.ERROR) {
        LogManager.log(
            logLevel,
            LogConstants.CTX_ODATA,
            error.getException(),
            ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16050, error.getMessage(), ex.getMessage()));
      } else {
        LogManager.log(
            logLevel,
            LogConstants.CTX_DQP,
            ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16051, error.getMessage(), ex.getMessage()));
      }
    } else {
      if (LogManager.isMessageToBeRecorded(LogConstants.CTX_ODATA, MessageLevel.DETAIL)
          || logLevel <= MessageLevel.ERROR) {
        LogManager.log(
            logLevel,
            LogConstants.CTX_ODATA,
            error.getException(),
            ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16052, error.getMessage()));
      } else {
        LogManager.log(
            logLevel,
            LogConstants.CTX_DQP,
            ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16053, error.getMessage()));
      }
    }
    response.writeError(error);
  }
예제 #2
0
 @Override
 public void anyUnsupported(ODataRequest request, ODataResponse response)
     throws ODataLibraryException, ODataApplicationException {
   throw new ODataApplicationException(
       ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16049),
       HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),
       Locale.getDefault());
 }
예제 #3
0
 private void checkETag(String entityETag) throws ODataApplicationException {
   if (entityETag != null && !entityETag.equals("*")) {
     throw new ODataApplicationException(
         ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16030),
         HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),
         Locale.getDefault());
   }
 }
예제 #4
0
 @Override
 public void rollback(String txnId) throws ODataLibraryException, ODataApplicationException {
   try {
     getClient().rollback(txnId);
   } catch (SQLException e) {
     throw new ODataApplicationException(
         ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16039),
         HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
         Locale.getDefault());
   }
 }
예제 #5
0
 @Override
 public String startTransaction() throws ODataLibraryException, ODataApplicationException {
   try {
     return getClient().startTransaction();
   } catch (SQLException e) {
     throw new ODataApplicationException(
         ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16039),
         HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
         Locale.getDefault());
   }
 }