/** * Looks up the component with the given name in the project with the given id. * * @param projectId id of the project. * @param componentName name of the component. * @return the component. * @throws EntityNotFoundException if no such component can be found. */ public MutableProjectComponent findByComponentName(Long projectId, String componentName) throws EntityNotFoundException { Collection<MutableProjectComponent> components = findAllForProject(projectId); for (MutableProjectComponent c : components) { if (c.getName().equals(componentName)) { return c; } } throw new EntityNotFoundException("The project with id '" + projectId + "' is not associated with a component with the name '" + componentName + "'."); }