Source:
<code>public final Response uploadTempResourceMulti(@Context final HttpServletRequest request, @Context final HttpServletResponse response, final FormDataMultiPart body) { try { if (!Config.getBooleanProperty(TempFileAPI.TEMP_RESOURCE_ENABLED, true)) { final String message = "Temp Files Resource is not enabled, please change the TEMP_RESOURCE_ENABLED to true in your properties file"; Logger.error(this, message); <START> throw new DoesNotExistException(message); <END> } final boolean allowAnonToUseTempFiles = !Config .getBooleanProperty(TempFileAPI.TEMP_RESOURCE_ALLOW_ANONYMOUS, true); final InitDataObject initDataObject = this.webResource .init(false, request, allowAnonToUseTempFiles); final User user = initDataObject.getUser(); final String uniqueKey = request.getSession().getId(); if (!new SecurityUtils().validateReferer(request)) { throw new BadRequestException("Invalid Origin or referer"); } final List<DotTempFile> tempFiles = new ArrayList<DotTempFile>(); for (final BodyPart part : body.getBodyParts()) { InputStream in = (part.getEntity() instanceof InputStream) ? InputStream.class .cast(part.getEntity()) : Try.of(() -> part.getEntityAs(InputStream.class)).getOrNull(); if (in == null) { continue; } final ContentDisposition meta = part.getContentDisposition(); if (meta == null) { continue; } final String fileName = meta.getFileName(); if (fileName == null || fileName.startsWith(".") || fileName.contains("/.")) { continue; } tempFiles.add(tempApi.createTempFile(fileName, user, uniqueKey, in)); } return Response.ok(ImmutableMap.of("tempFiles", tempFiles)).build(); } catch (Exception e) { Logger.warnAndDebug(this.getClass(), e); return ResponseUtil.mapExceptionResponse(e); } }</code><technical_language>easy refactor: extract entire if in a private method call verifyTempResourceEnabled() replace in method</technical_language>

Target:
public final Response uploadTempResourceMulti(@Context final HttpServletRequest request, @Context final HttpServletResponse response, final FormDataMultiPart body) { try { verifyTempResourceEnabled(); final boolean allowAnonToUseTempFiles = !Config .getBooleanProperty(TempFileAPI.TEMP_RESOURCE_ALLOW_ANONYMOUS, true); final InitDataObject initDataObject = this.webResource .init(false, request, allowAnonToUseTempFiles); final User user = initDataObject.getUser(); final String uniqueKey = request.getSession().getId(); if (!new SecurityUtils().validateReferer(request)) { throw new BadRequestException("Invalid Origin or referer"); } final List<DotTempFile> tempFiles = new ArrayList<DotTempFile>(); for (final BodyPart part : body.getBodyParts()) { InputStream in = (part.getEntity() instanceof InputStream) ? InputStream.class .cast(part.getEntity()) : Try.of(() -> part.getEntityAs(InputStream.class)).getOrNull(); if (in == null) { continue; } final ContentDisposition meta = part.getContentDisposition(); if (meta == null) { continue; } final String fileName = meta.getFileName(); if (fileName == null || fileName.startsWith(".") || fileName.contains("/.")) { continue; } tempFiles.add(tempApi.createTempFile(fileName, user, uniqueKey, in)); } return Response.ok(ImmutableMap.of("tempFiles", tempFiles)).build(); } catch (Exception e) { Logger.warnAndDebug(this.getClass(), e); return ResponseUtil.mapExceptionResponse(e); } }