Tabnine Logo
RestLiServiceException.getStatus
Code IndexAdd Tabnine to your IDE (free)

How to use
getStatus
method
in
com.linkedin.restli.server.RestLiServiceException

Best Java code snippets using com.linkedin.restli.server.RestLiServiceException.getStatus (Showing top 15 results out of 315)

origin: apache/incubator-gobblin

 @Override
 public void run() {
  try {
   while (true) {
    RequestAndCallback requestAndCallback = MockRequester.this.requestAndCallbackQueue.take();
    long nanoTime = System.nanoTime();
    long delayNanos = requestAndCallback.getProcessAfterNanos() - nanoTime;
    if (delayNanos > 0) {
     Thread.sleep(TimeUnit.NANOSECONDS.toMillis(delayNanos));
    }
    try {
     PermitAllocation allocation =
       MockRequester.this.limiterServer.getSync(new ComplexResourceKey<>(requestAndCallback.getRequest(), new EmptyRecord()));
     Response<PermitAllocation> response = Mockito.mock(Response.class);
     Mockito.when(response.getEntity()).thenReturn(allocation);
     requestAndCallback.getCallback().onSuccess(response);
    } catch (RestLiServiceException rexc) {
     RestLiResponseException returnException = Mockito.mock(RestLiResponseException.class);
     Mockito.when(returnException.getStatus()).thenReturn(rexc.getStatus().getCode());
     requestAndCallback.getCallback().onError(returnException);
    }
   }
  } catch (Throwable t) {
   log.error("Error", t);
   throw new RuntimeException(t);
  }
 }
}
origin: azkaban/azkaban

@Test
public void testErrorDeploy() {
 final ProjectManagerResource resource = new ProjectManagerResource();
 final Map<String, ValidationReport> reports = new LinkedHashMap<>();
 for (int i = 0; i < 3; i++) {
  addMockError(reports, "Test error level info message.");
 }
 // We expect that a RestLiServiceException is thrown given a
 // report with errors. Uncaught exceptions will result in failure
 try {
  resource.checkReports(reports);
  Assert.fail();
 } catch (final RestLiServiceException e) {
  //Ensure we have the right status code and exit
  assertEquals(e.getStatus(), HttpStatus.S_400_BAD_REQUEST);
 }
}
origin: azkaban/azkaban

/**
 * Test that an error message is attached to the exception on an error
 */
@Test
public void testErrorMessageDeploy() {
 final ProjectManagerResource resource = new ProjectManagerResource();
 final Map<String, ValidationReport> reports = new LinkedHashMap<>();
 addMockError(reports, "This should show up.");
 // We expect that a RestLiServiceException is thrown given a
 // report with errors. Uncaught exceptions will result in failure
 try {
  resource.checkReports(reports);
  Assert.fail();
 } catch (final RestLiServiceException e) {
  //Ensure we have the right status code and exit
  assertEquals(e.getStatus(), HttpStatus.S_400_BAD_REQUEST);
  assertEquals(e.getMessage(), "Validator Error reports errors: This should show up."
    + System.getProperty("line.separator"));
 }
}
origin: azkaban/azkaban

@Test
public void testWarnErrorDeploy() {
 final ProjectManagerResource resource = new ProjectManagerResource();
 final Map<String, ValidationReport> reports = new LinkedHashMap<>();
 for (int i = 0; i < 7; i++) {
  // If i is even, make an error report, otherwise make a warning report
  if (i % 2 == 0) {
   addMockError(reports, "Test error level info message.");
  } else {
   addMockWarning(reports, "Test warn level info message.");
  }
 }
 // We expect that a RestLiServiceException is thrown given a
 // report with errors. Uncaught exceptions will result in failure
 try {
  resource.checkReports(reports);
  Assert.fail();
 } catch (final RestLiServiceException e) {
  //Ensure we have the right status code and exit
  assertEquals(e.getStatus(), HttpStatus.S_400_BAD_REQUEST);
 }
}
origin: apache/incubator-gobblin

 Assert.fail();
} catch (RestLiServiceException exc) {
 Assert.assertEquals(exc.getStatus(), HttpStatus.S_403_FORBIDDEN);
 Assert.fail();
} catch (RestLiServiceException exc) {
 Assert.assertEquals(exc.getStatus(), HttpStatus.S_403_FORBIDDEN);
origin: com.linkedin.pegasus/restli-server

/**
 * Constructs a CreateResponse containing error details.
 *
 * @param error A rest.li exception containing the appropriate HTTP response status and error details.
 */
public CreateResponse(RestLiServiceException error)
{
 _id = null;
 _status = error.getStatus();
 _error = error;
}
origin: com.linkedin.pegasus/restli-server

/**
 * Gets the status of the response.
 *
 * @return the http status.
 */
public HttpStatus getStatus()
{
 return _exception != null ? _exception.getStatus() : _status;
}
origin: com.linkedin.pegasus/restli-server

/**
 * Instantiates a failed entry within a collection create response.
 *
 * @param exception the exception that triggered the failure.
 */
public CollectionCreateResponseItem(RestLiServiceException exception)
{
 _exception = exception;
 _recordResponse = null;
 _httpStatus = exception.getStatus();
}
origin: com.linkedin.pegasus/restli-server

public IndividualResponseException(RestLiServiceException e, ErrorResponseBuilder errorResponseBuilder)
{
 super(e);
 _response = createErrorIndividualResponse(e.getStatus(), errorResponseBuilder.buildErrorResponse(e));
}
origin: com.linkedin.pegasus/restli-server

public static IndividualResponse createErrorIndividualResponse(RestLiServiceException e, ErrorResponseBuilder errorResponseBuilder)
{
 return createErrorIndividualResponse(e.getStatus(), errorResponseBuilder.buildErrorResponse(e));
}
origin: com.linkedin.pegasus/restli-server

batchResponseMap.put(finalKey, new BatchResponseEntry(entry.getValue().getStatus(), entry.getValue()));
batchResponseMap.put(finalKey, new BatchResponseEntry(entry.getValue().getStatus(), entry.getValue()));
origin: com.linkedin.pegasus/restli-server

protected RestLiResponseException buildPreRoutingError(Throwable throwable, Request request)
{
 Map<String, String> requestHeaders = request.getHeaders();
 Map<String, String> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
 headers.put(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION,
   ProtocolVersionUtil.extractProtocolVersion(requestHeaders).toString());
 headers.put(HeaderUtil.getErrorResponseHeaderName(requestHeaders), RestConstants.HEADER_VALUE_ERROR);
 RestLiServiceException restLiServiceException = RestLiServiceException.fromThrowable(throwable);
 ErrorResponse errorResponse = _errorResponseBuilder.buildErrorResponse(restLiServiceException);
 RestLiResponse restLiResponse = new RestLiResponse.Builder()
   .status(restLiServiceException.getStatus())
   .entity(errorResponse)
   .headers(headers)
   .cookies(Collections.emptyList())
   .build();
 return new RestLiResponseException(throwable, restLiResponse);
}
origin: com.linkedin.pegasus/restli-server

private RestLiResponse buildErrorResponse(Throwable th, RestLiResponseData<?> responseData)
{
 Map<String, String> responseHeaders = responseData.getHeaders();
 responseHeaders.put(HeaderUtil.getErrorResponseHeaderName(responseHeaders), RestConstants.HEADER_VALUE_ERROR);
 RestLiServiceException ex;
 if (th instanceof RestLiServiceException)
 {
  ex = (RestLiServiceException) th;
 }
 else
 {
  ex = new RestLiServiceException(HttpStatus.S_500_INTERNAL_SERVER_ERROR, th.getMessage(), th);
 }
 return new RestLiResponse.Builder().headers(responseHeaders).cookies(responseData.getCookies())
   .status(ex.getStatus())
   .entity(_errorResponseBuilder.buildErrorResponse(ex))
   .build();
}
origin: com.linkedin.pegasus/restli-server

if (errorResponseFormat.showStatusCodeInBody())
 er.setStatus(result.getStatus().getCode());
origin: com.linkedin.pegasus/restli-server

@Override
@SuppressWarnings("unchecked")
public RestLiResponse buildResponse(RoutingResult routingResult, RestLiResponseData<BatchCreateResponseEnvelope> responseData)
{
 List<BatchCreateResponseEnvelope.CollectionCreateResponseItem> collectionCreateResponses =
                       responseData.getResponseEnvelope().getCreateResponses();
 List<CreateIdStatus<Object>> formattedResponses = new ArrayList<>(collectionCreateResponses.size());
 // Iterate through the responses and generate the ErrorResponse with the appropriate override for exceptions.
 // Otherwise, add the result as is.
 for (BatchCreateResponseEnvelope.CollectionCreateResponseItem response : collectionCreateResponses)
 {
  if (response.isErrorResponse())
  {
   RestLiServiceException exception = response.getException();
   formattedResponses.add(new CreateIdStatus<>(exception.getStatus().getCode(),
                            response.getId(),
                            _errorResponseBuilder.buildErrorResponse(exception),
                            ProtocolVersionUtil.extractProtocolVersion(responseData.getHeaders())));
  }
  else
  {
   formattedResponses.add((CreateIdStatus<Object>) response.getRecord());
  }
 }
 RestLiResponse.Builder builder = new RestLiResponse.Builder();
 BatchCreateIdResponse<Object> batchCreateIdResponse = new BatchCreateIdResponse<>(formattedResponses);
 return builder.headers(responseData.getHeaders()).cookies(responseData.getCookies()).entity(batchCreateIdResponse).build();
}
com.linkedin.restli.serverRestLiServiceExceptiongetStatus

Popular methods of RestLiServiceException

  • <init>
  • setErrorDetails
  • getErrorDetails
  • getMessage
  • hasErrorDetails
  • fromThrowable
  • getLocalizedMessage
  • getOverridingFormat
  • getServiceErrorCode
  • hasOverridingErrorResponseFormat
    Returns whether this exception has an overriding error format.
  • hasServiceErrorCode
  • printStackTrace
  • hasServiceErrorCode,
  • printStackTrace,
  • setServiceErrorCode

Popular in Java

  • Start an intent from android
  • onCreateOptionsMenu (Activity)
  • getContentResolver (Context)
  • getExternalFilesDir (Context)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • JOptionPane (javax.swing)
  • IsNull (org.hamcrest.core)
    Is the value null?
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now