Source:
<code>private ScriptDTO buildScript(String typeId, String categoryId, String applicationId, String typeFileName, String categoryFileName, String applicationFileName, String scriptFileName) throws RepositoryException { try { final String scriptJsonFile = packagePath + "/" + typeFileName + "/" + categoryFileName + "/" + applicationFileName + "/" + scriptFileName + "/script.json"; final InputStream scriptJsonInputStream = getClass().getResourceAsStream(scriptJsonFile); final InputStream scriptFile = getClass().getResourceAsStream( packagePath + "/" + typeFileName + "/" + categoryFileName + "/" + applicationFileName + "/" + scriptFileName + "/script.js"); if (scriptJsonInputStream == null) { return null; } URI icon = null; final String iconResource = packagePath + "/" + typeFileName + "/" + categoryFileName + "/" + applicationFileName + "/" + scriptFileName + "/icon.png"; URL iconResourceURL = getClass().getResource(iconResource); if (iconResourceURL != null) { try { icon = iconResourceURL.toURI(); } catch (URISyntaxException e) { LOGGER.debug("Could not get URI of script icon."); } } else { LOGGER.debug("Could not find script icon."); } ScriptDTO.Builder scriptDTOBuilder = new ScriptDTO.Builder( objectMapper.readValue(scriptJsonInputStream, ScriptDTO.class)) .withTypeId(typeId) .withCategoryId(categoryId) .withApplicationId(applicationId) .withScript(new String(IOUtils.toByteArray(scriptFile))) .withIcon(icon); if (StringUtils.isBlank(scriptDTOBuilder.getId())) { if (!StringUtils.isBlank(scriptDTOBuilder.getScriptName())) { scriptDTOBuilder.withId(scriptDTOBuilder.getScriptName().replaceAll("[^a-zA-Z0-9_.]", "")); } else { <START> scriptDTOBuilder.withId(scriptFileName.replaceAll("[^a-zA-Z0-9_.]", "")); <END> } } return scriptDTOBuilder.build(); } catch (IOException e) { throw new RepositoryException("Could not build script", e); } }</code><technical_language>ID_REGEX</technical_language>

Target:
private ScriptDTO buildScript(String typeId, String categoryId, String applicationId, String typeFileName, String categoryFileName, String applicationFileName, String scriptFileName) throws RepositoryException { try { final String scriptJsonFile = packagePath + "/" + typeFileName + "/" + categoryFileName + "/" + applicationFileName + "/" + scriptFileName + "/script.json"; final InputStream scriptJsonInputStream = getClass().getResourceAsStream(scriptJsonFile); final InputStream scriptFile = getClass().getResourceAsStream( packagePath + "/" + typeFileName + "/" + categoryFileName + "/" + applicationFileName + "/" + scriptFileName + "/script.js"); if (scriptJsonInputStream == null) { return null; } URI icon = null; final String iconResource = packagePath + "/" + typeFileName + "/" + categoryFileName + "/" + applicationFileName + "/" + scriptFileName + "/icon.png"; URL iconResourceURL = getClass().getResource(iconResource); if (iconResourceURL != null) { try { icon = iconResourceURL.toURI(); } catch (URISyntaxException e) { LOGGER.debug("Could not get URI of script icon."); } } else { LOGGER.debug("Could not find script icon."); } ScriptDTO.Builder scriptDTOBuilder = new ScriptDTO.Builder( objectMapper.readValue(scriptJsonInputStream, ScriptDTO.class)) .withTypeId(typeId) .withCategoryId(categoryId) .withApplicationId(applicationId) .withScript(new String(IOUtils.toByteArray(scriptFile))) .withIcon(icon); if (StringUtils.isBlank(scriptDTOBuilder.getId())) { if (!StringUtils.isBlank(scriptDTOBuilder.getScriptName())) { scriptDTOBuilder.withId(scriptDTOBuilder.getScriptName().replaceAll(INVALID_ID_CHARS_REGEX, "")); } else { scriptDTOBuilder.withId(scriptFileName.replaceAll(INVALID_ID_CHARS_REGEX, "")); } } return scriptDTOBuilder.build(); } catch (IOException e) { throw new RepositoryException("Could not build script", e); } }