Source:
public List<Tool> refreshTools(final long userId, final UserDAO userDAO, final ToolDAO toolDAO, final TagDAO tagDAO, final FileDAO fileDAO, final FileFormatDAO fileFormatDAO, final HttpClient client, final Token githubToken, final Token bitbucketToken, final Token gitlabToken, String organization, final EventDAO eventDAO, final String dashboardPrefix) { List<String> namespaces; if (organization != null) { namespaces = Collections.singletonList(organization); } else { namespaces = getNamespaces(); } List<Tool> apiTools = getToolsFromNamespace(namespaces); String registryString = getRegistry().getDockerPath(); User user = userDAO.findById(userId); List<Tool> manualTools = toolDAO.findByModeRegistryNamespace(ToolMode.MANUAL_IMAGE_PATH, registryString, organization); List<Tool> notManualTools = toolDAO.findByNotModeRegistryNamespace(ToolMode.MANUAL_IMAGE_PATH, registryString, organization); apiTools.addAll(manualTools); updateAPIToolsWithBuildInformation(apiTools); List<Tool> newDBTools = updateTools(apiTools, notManualTools, user, toolDAO); for (Tool tool : newDBTools) { logToolRefresh(dashboardPrefix, tool); List<Tag> toolTags = getTags(tool); final SourceCodeRepoInterface sourceCodeRepo = SourceCodeRepoFactory .createSourceCodeRepo(tool.getGitUrl(), client, bitbucketToken == null ? null : bitbucketToken.getContent(), gitlabToken == null ? null : gitlabToken.getContent(), githubToken.getContent()); updateTags(toolTags, tool, sourceCodeRepo, tagDAO, fileDAO, toolDAO, fileFormatDAO, eventDAO, user); } return newDBTools; }

Target:
public List<Tool> refreshTools(final long userId, final UserDAO userDAO, final ToolDAO toolDAO, final TagDAO tagDAO, final FileDAO fileDAO, final FileFormatDAO fileFormatDAO, final HttpClient client, final Token githubToken, final Token bitbucketToken, final Token gitlabToken, String organization, final EventDAO eventDAO, final String dashboardPrefix) { List<String> namespaces; if (organization != null) { namespaces = Collections.singletonList(organization); } else { namespaces = getNamespaces(); } List<Tool> apiTools = getToolsFromNamespace(namespaces); String registryString = getRegistry().getDockerPath(); User user = userDAO.findById(userId); List<Tool> userTools = toolDAO.findByUserRegistryNamespace(userId, registryString, organization); List<Tool> manualTools = userTools.stream().filter(tool -> ToolMode.MANUAL_IMAGE_PATH.equals(tool.getMode())).collect(Collectors.toList()); List<Tool> notManualTools = userTools.stream().filter(tool -> !ToolMode.MANUAL_IMAGE_PATH.equals(tool.getMode())).collect(Collectors.toList()); apiTools.addAll(manualTools); updateAPIToolsWithBuildInformation(apiTools); List<Tool> newDBTools = updateTools(apiTools, notManualTools, user, toolDAO); for (Tool tool : newDBTools) { logToolRefresh(dashboardPrefix, tool); List<Tag> toolTags = getTags(tool); final SourceCodeRepoInterface sourceCodeRepo = SourceCodeRepoFactory .createSourceCodeRepo(tool.getGitUrl(), client, bitbucketToken == null ? null : bitbucketToken.getContent(), gitlabToken == null ? null : gitlabToken.getContent(), githubToken == null ? null : githubToken.getContent()); updateTags(toolTags, tool, sourceCodeRepo, tagDAO, fileDAO, toolDAO, fileFormatDAO, eventDAO, user); } return newDBTools; }