Source:
<code>private Void deserializeAndUpdatePerson(HttpServletRequest req, HttpServletResponse resp, boolean merge) { java.util.Optional<Application> possibleApplication; Boolean strict = Boolean.valueOf(req.getParameter(STRICT)); try { possibleApplication = appConfigFetcher.applicationFor(req); } catch (InvalidApiKeyException e) { log.error("Problem with API key for request " + req.getRequestURL(), e); return error(req, resp, AtlasErrorSummary.forException(e)); } Person person; <START> try { <END> person = complexify(deserialize(new InputStreamReader(req.getInputStream()), strict)); } catch (UnrecognizedPropertyException | JsonParseException | ConstraintViolationException e) { return error(req, resp, AtlasErrorSummary.forException(e)); } catch (IOException ioe) { log.error("Error reading input for request " + req.getRequestURL(), ioe); return error(req, resp, AtlasErrorSummary.forException(ioe)); } catch (Exception e) { log.error("Error reading input for request " + req.getRequestURL(), e); AtlasErrorSummary errorSummary = new AtlasErrorSummary(e) .withMessage("Error reading input for the request") .withStatusCode(HttpStatusCode.BAD_REQUEST); return error(req, resp, errorSummary); } if (!possibleApplication.get().getConfiguration().isWriteEnabled(person.getPublisher())) { return error( req, resp, AtlasErrorSummary.forException(new ForbiddenException( "API key does not have write permission")) ); } try { person = merge(resolveExisting(person), person, merge); store.createOrUpdatePerson(person); } catch (Exception e) { log.error("Error reading input for request " + req.getRequestURL(), e); AtlasErrorSummary errorSummary = new AtlasErrorSummary(e) .withStatusCode(HttpStatusCode.BAD_REQUEST); return error(req, resp, errorSummary); } resp.setStatus(HttpStatusCode.OK.code()); resp.setContentLength(0); return null; }</code><technical_language>need check if application is present if throw this error</technical_language>

Target:
private Void deserializeAndUpdatePerson( HttpServletRequest req, HttpServletResponse resp, boolean merge ) { java.util.Optional<Application> possibleApplication; Boolean strict = Boolean.valueOf(req.getParameter(STRICT)); try { possibleApplication = applicationFetcher.applicationFor(req); } catch (InvalidApiKeyException e) { log.error("Problem with API key for request: {}", req.getRequestURL(), e); return error(req, resp, AtlasErrorSummary.forException(e)); } if (!possibleApplication.isPresent()) { log.error("No application found for request: {}", req.getRequestURL()); return error( req, resp, AtlasErrorSummary.forException( ApplicationNotFoundException.create(req.getRequestURL().toString()) ) ); } Application application = possibleApplication.get(); Person person; try { person = complexify(deserialize(new InputStreamReader(req.getInputStream()), strict)); } catch (UnrecognizedPropertyException | JsonParseException | ConstraintViolationException e) { return error(req, resp, AtlasErrorSummary.forException(e)); } catch (IOException ioe) { log.error("Error reading input for request " + req.getRequestURL(), ioe); return error(req, resp, AtlasErrorSummary.forException(ioe)); } catch (Exception e) { log.error("Error reading input for request " + req.getRequestURL(), e); AtlasErrorSummary errorSummary = new AtlasErrorSummary(e) .withMessage("Error reading input for the request") .withStatusCode(HttpStatusCode.BAD_REQUEST); return error(req, resp, errorSummary); } if (!application.getConfiguration().isWriteEnabled(person.getPublisher())) { return error( req, resp, AtlasErrorSummary.forException(new ForbiddenException( "API key does not have write permission")) ); } try { person = merge(resolveExisting(person), person, merge); store.createOrUpdatePerson(person); } catch (Exception e) { log.error("Error reading input for request " + req.getRequestURL(), e); AtlasErrorSummary errorSummary = new AtlasErrorSummary(e) .withStatusCode(HttpStatusCode.BAD_REQUEST); return error(req, resp, errorSummary); } resp.setStatus(HttpStatusCode.OK.code()); resp.setContentLength(0); return null; }