Source:
<code>public List<Workflow> allPublishedWorkflows( @ApiParam(value = "Start index of paging. Pagination results can be based on numbers or other values chosen by the registry implementor (for example, SHA values). If this exceeds the current result set return an empty set. If not specified in the request, this will start at the beginning of the results.") @QueryParam("offset") String offset, @ApiParam(value = "Amount of records to return in a given page, limited to " + PAGINATION_LIMIT, allowableValues = "range[1,100]", defaultValue = PAGINATION_LIMIT) @DefaultValue(PAGINATION_LIMIT) @QueryParam("limit") Integer limit, @ApiParam(value = "Filter, this is a search string that filters the results.") @DefaultValue("") @QueryParam("filter") String filter, @ApiParam(value = "Sort column") @DefaultValue("stars") @QueryParam("sortCol") String sortCol, @ApiParam(value = "Sort order", allowableValues = "asc,desc") @DefaultValue("desc") @QueryParam("sortOrder") String sortOrder, @ApiParam(value = "services", defaultValue = "false") @DefaultValue("false") @QueryParam("services") boolean services, @Context HttpServletResponse response) { int maxLimit = Math.min(Integer.parseInt(PAGINATION_LIMIT), limit); List<Workflow> workflows = workflowDAO.findAllPublished(offset, maxLimit, filter, sortCol, sortOrder, (Class<Workflow>)(services ? Service.class : BioWorkflow.class)); filterContainersForHiddenTags(workflows); stripContent(workflows); <START> if (services) { <END> response.addHeader("X-total-count", String.valueOf(serviceEntryDAO.countAllPublished(Optional.of(filter)))); } else { response.addHeader("X-total-count", String.valueOf(bioWorkflowDAO.countAllPublished(Optional.of(filter)))); } response.addHeader("Access-Control-Expose-Headers", "X-total-count"); return workflows; }</code><technical_language>a candidate for DRY, EntryDAO pointer = services ? serviceEntryDAO : bioWorkflowDAO; response.addHeader("X-total-count", String.valueOf(pointer.countAllPublished(Optional.of(filter))));</technical_language>

Target:
public List<Workflow> allPublishedWorkflows( @ApiParam(value = "Start index of paging. Pagination results can be based on numbers or other values chosen by the registry implementor (for example, SHA values). If this exceeds the current result set return an empty set. If not specified in the request, this will start at the beginning of the results.") @QueryParam("offset") String offset, @ApiParam(value = "Amount of records to return in a given page, limited to " + PAGINATION_LIMIT, allowableValues = "range[1,100]", defaultValue = PAGINATION_LIMIT) @DefaultValue(PAGINATION_LIMIT) @QueryParam("limit") Integer limit, @ApiParam(value = "Filter, this is a search string that filters the results.") @DefaultValue("") @QueryParam("filter") String filter, @ApiParam(value = "Sort column") @DefaultValue("stars") @QueryParam("sortCol") String sortCol, @ApiParam(value = "Sort order", allowableValues = "asc,desc") @DefaultValue("desc") @QueryParam("sortOrder") String sortOrder, @ApiParam(value = "services", defaultValue = "false") @DefaultValue("false") @QueryParam("services") boolean services, @Context HttpServletResponse response) { int maxLimit = Math.min(Integer.parseInt(PAGINATION_LIMIT), limit); List<Workflow> workflows = workflowDAO.findAllPublished(offset, maxLimit, filter, sortCol, sortOrder, (Class<Workflow>)(services ? Service.class : BioWorkflow.class)); filterContainersForHiddenTags(workflows); stripContent(workflows); EntryDAO entryDAO = services ? serviceEntryDAO : bioWorkflowDAO; response.addHeader("X-total-count", String.valueOf(entryDAO.countAllPublished(Optional.of(filter)))); response.addHeader("Access-Control-Expose-Headers", "X-total-count"); return workflows; }