} catch (AtlasServiceException e) { if (e.getStatus().getStatusCode() == AtlasErrorCode.INSTANCE_NOT_FOUND.getHttpCode().getStatusCode() && e.getMessage().contains(AtlasErrorCode.INSTANCE_NOT_FOUND.getErrorCode())) {
private boolean updateResidualList(AtlasBaseException e, List<String> lineageList, String guid) { if (!e.getAtlasErrorCode().getErrorCode().equals(AtlasErrorCode.INVALID_OBJECT_ID.getErrorCode())) { return false; } lineageList.add(guid); return true; }
private boolean updateResidualList(AtlasBaseException e, List<String> lineageList, String guid) { if (!e.getAtlasErrorCode().getErrorCode().equals(AtlasErrorCode.INVALID_OBJECT_ID.getErrorCode())) { return false; } lineageList.add(guid); return true; }
protected Response buildAtlasBaseExceptionResponse(AtlasBaseException baseException) { Map<String, String> errorJsonMap = new LinkedHashMap<>(); AtlasErrorCode errorCode = baseException.getAtlasErrorCode(); errorJsonMap.put("errorCode", errorCode.getErrorCode()); errorJsonMap.put("errorMessage", baseException.getMessage()); if (baseException.getCause() != null) { errorJsonMap.put("errorCause", baseException.getCause().getMessage()); } Response.ResponseBuilder responseBuilder = Response.status(errorCode.getHttpCode()); // No body for 204 (and maybe 304) if (Response.Status.NO_CONTENT != errorCode.getHttpCode()) { responseBuilder.entity(AtlasType.toJson(errorJsonMap)); } return responseBuilder.build(); } }
@Test public void importServiceProcessesIOException() { ImportService importService = new ImportService(typeDefStore, typeRegistry, null); AtlasImportRequest req = mock(AtlasImportRequest.class); Answer<Map> answer = invocationOnMock -> { throw new IOException("file is read only"); }; when(req.getFileName()).thenReturn("some-file.zip"); when(req.getOptions()).thenAnswer(answer); try { importService.run(req, "a", "b", "c"); } catch (AtlasBaseException ex) { assertEquals(ex.getAtlasErrorCode().getErrorCode(), AtlasErrorCode.INVALID_PARAMETERS.getErrorCode()); } }
AtlasAuthorizationUtils.getRequestIpAddress(httpServletRequest)); } catch (AtlasBaseException excp) { if (excp.getAtlasErrorCode().getErrorCode().equals(AtlasErrorCode.IMPORT_ATTEMPTING_EMPTY_ZIP)) { LOG.info(excp.getMessage()); } else {
} catch (AtlasServiceException e) { if (e.getStatus().getStatusCode() == AtlasErrorCode.INSTANCE_NOT_FOUND.getHttpCode().getStatusCode() && e.getMessage().contains(AtlasErrorCode.INSTANCE_NOT_FOUND.getErrorCode())) {