Source:
private Void deserializeAndUpdateContent(HttpServletRequest req, HttpServletResponse resp, boolean merge) { Boolean async = Boolean.valueOf(req.getParameter(ASYNC_PARAMETER)); Maybe<ApplicationConfiguration> possibleConfig; try { possibleConfig = appConfigFetcher.configurationFor(req); } catch (ApiKeyNotFoundException | RevokedApiKeyException | InvalidIpForApiKeyException ex) { return error(resp, HttpStatusCode.FORBIDDEN.code()); } if (possibleConfig.isNothing()) { return error(resp, HttpStatus.UNAUTHORIZED.value()); } byte[] inputStreamBytes; ContentWriteExecutor.InputContent inputContent; try { inputStreamBytes = IOUtils.toByteArray(req.getInputStream()); InputStream inputStream = new ByteArrayInputStream(inputStreamBytes); inputContent = writeExecutor.parseInputStream(inputStream); } catch (IOException e) { log.error("Error reading input for request " + req.getRequestURL(), e); return error(resp, HttpStatusCode.SERVER_ERROR.code()); } catch (Exception e) { log.error("Error reading input for request " + req.getRequestURL(), e); return error(resp, HttpStatusCode.BAD_REQUEST.code()); } Content content = inputContent.getContent(); if (!possibleConfig.requireValue().canWrite(content.getPublisher())) { return error(resp, HttpStatusCode.FORBIDDEN.code()); } if (Strings.isNullOrEmpty(content.getCanonicalUri())) { return error(resp, HttpStatusCode.BAD_REQUEST.code()); } Long contentId = lookupBackedContentIdGenerator.getId(content); try { if (async) { sendMessage(inputStreamBytes, contentId, merge); } else { content.setId(contentId); writeExecutor.writeContent(content, inputContent.getType(), merge); } } catch (Exception e) { log.error("Error executing request " + req.getRequestURL(), e); return error(resp, HttpStatusCode.SERVER_ERROR.code()); } setLocationHeader(resp, contentId); HttpStatus responseStatus = async ? HttpStatus.ACCEPTED : HttpStatus.OK; resp.setStatus(responseStatus.value()); resp.setContentLength(0); return null; }

Target:
private Void deserializeAndUpdateContent(HttpServletRequest req, HttpServletResponse resp, boolean merge) { Boolean async = Boolean.valueOf(req.getParameter(ASYNC_PARAMETER)); Maybe<ApplicationConfiguration> possibleConfig; try { possibleConfig = appConfigFetcher.configurationFor(req); } catch (ApiKeyNotFoundException | RevokedApiKeyException | InvalidIpForApiKeyException ex) { return error(resp, HttpStatusCode.FORBIDDEN.code()); } if (possibleConfig.isNothing()) { return error(resp, HttpStatus.UNAUTHORIZED.value()); } byte[] inputStreamBytes; ContentWriteExecutor.InputContent inputContent; try { inputStreamBytes = IOUtils.toByteArray(req.getInputStream()); InputStream inputStream = new ByteArrayInputStream(inputStreamBytes); inputContent = writeExecutor.parseInputStream(inputStream); } catch (IOException e) { logError("Error reading input for request", e, req); return error(resp, HttpStatusCode.SERVER_ERROR.code()); } catch (Exception e) { logError("Error reading input for request", e, req); return error(resp, HttpStatusCode.BAD_REQUEST.code()); } Content content = inputContent.getContent(); if (!possibleConfig.requireValue().canWrite(content.getPublisher())) { return error(resp, HttpStatusCode.FORBIDDEN.code()); } if (Strings.isNullOrEmpty(content.getCanonicalUri())) { return error(resp, HttpStatusCode.BAD_REQUEST.code()); } Long contentId = lookupBackedContentIdGenerator.getId(content); try { if (async) { sendMessage(inputStreamBytes, contentId, merge); } else { content.setId(contentId); writeExecutor.writeContent(content, inputContent.getType(), merge); } } catch (Exception e) { logError("Error executing request", e, req); return error(resp, HttpStatusCode.SERVER_ERROR.code()); } setLocationHeader(resp, contentId); HttpStatus responseStatus = async ? HttpStatus.ACCEPTED : HttpStatus.OK; resp.setStatus(responseStatus.value()); resp.setContentLength(0); return null; }