Source:
<code>public Rendition getDefaultRendition(DocumentModel doc, String reason, Map<String, Serializable> extendedInfos) { Rendition rendition = null; <START> if (defaultRenditionDescriptor != null) { <END> Map<String, Object> context = new HashMap<>(); Map<String, Serializable> ei = extendedInfos == null ? Collections.emptyMap() : extendedInfos; NuxeoPrincipal currentUser = ClientLoginModule.getCurrentPrincipal(); context.put("Document", doc); context.put("Reason", reason); context.put("Infos", ei); context.put("CurrentUser", currentUser); ScriptEngine engine = scriptEngineManager.getEngineByName(defaultRenditionDescriptor.getScriptLanguage()); if (engine == null) { throw new NuxeoException( "Engine not found for language: " + defaultRenditionDescriptor.getScriptLanguage()); } if (!(engine instanceof Invocable)) { throw new NuxeoException("Engine " + engine.getClass().getName() + " not Invocable for language: " + defaultRenditionDescriptor.getScriptLanguage()); } try { engine.eval(defaultRenditionDescriptor.getScript()); engine.getBindings(ScriptContext.ENGINE_SCOPE).putAll(context); Object result = ((Invocable) engine).invokeFunction("run"); if (!(result instanceof String)) { log.error("Failed to get rendition name (" + result + ")"); } else { String defaultRenditionName = (String) result; if (StringUtils.isBlank(defaultRenditionName)) { log.info("Default rendition name cannot be evaluated, returning null"); } else { try { rendition = getRendition(doc, defaultRenditionName); } catch (NuxeoException e) { log.error("Unable to use default rendition " + defaultRenditionName, e); } } } } catch (NoSuchMethodException e) { throw new NuxeoException( "Script does not contain function: run() in defaultRendition: ", e); } catch (ScriptException e) { log.error("Failed to evaluate script: ", e); } } return rendition; }</code><technical_language>do early-exit if (defaultRenditionDescriptor == null) { return null; } avoid a big indented block</technical_language>

Target:
public Rendition getDefaultRendition(DocumentModel doc, String reason, Map<String, Serializable> extendedInfos) { if (defaultRenditionDescriptor == null) { return null; } Map<String, Object> context = new HashMap<>(); Map<String, Serializable> ei = extendedInfos == null ? Collections.emptyMap() : extendedInfos; NuxeoPrincipal currentUser = ClientLoginModule.getCurrentPrincipal(); context.put("Document", doc); context.put("Reason", reason); context.put("Infos", ei); context.put("CurrentUser", currentUser); ScriptEngine engine = scriptEngineManager.getEngineByName(defaultRenditionDescriptor.getScriptLanguage()); if (engine == null) { throw new NuxeoException( "Engine not found for language: " + defaultRenditionDescriptor.getScriptLanguage()); } if (!(engine instanceof Invocable)) { throw new NuxeoException("Engine " + engine.getClass().getName() + " not Invocable for language: " + defaultRenditionDescriptor.getScriptLanguage()); } Rendition rendition = null; try { engine.eval(defaultRenditionDescriptor.getScript()); engine.getBindings(ScriptContext.ENGINE_SCOPE).putAll(context); Object result = ((Invocable) engine).invokeFunction("run"); if (!(result instanceof String)) { log.error("Failed to get rendition name (" + result + ")"); } else { String defaultRenditionName = (String) result; if (StringUtils.isBlank(defaultRenditionName)) { log.info("Default rendition name cannot be evaluated, returning null"); } else { try { rendition = getRendition(doc, defaultRenditionName); } catch (NuxeoException e) { log.error("Unable to use default rendition " + defaultRenditionName, e); } } } } catch (NoSuchMethodException e) { throw new NuxeoException("Script does not contain function: run() in defaultRendition: ", e); } catch (ScriptException e) { log.error("Failed to evaluate script: ", e); } return rendition; }