class TeamCityConnection implements BuildCapability, TestCapability, ViewCapability {

    @Override
    public Map<SoftwareProjectId, String> listSoftwareProjectIds() {
        checkConnected();
        Map<SoftwareProjectId, String> projectIds = new HashMap<SoftwareProjectId, String>();
        try {
            List<TeamCityProject> projects = teamCity.findAllProjects();
            for (TeamCityProject project : projects) {
                try {
                    project = teamCity.findProject(project.getId());
                    List<TeamCityBuildType> buildTypes = project.getBuildTypes();
                    for (TeamCityBuildType teamCityBuildType : buildTypes) {
                        String id = teamCityBuildType.getId();
                        SoftwareProjectId softwareProjectId = new SoftwareProjectId(id);
                        projectIds.put(softwareProjectId, teamCityBuildType.getName());
                    }
                } catch (TeamCityProjectNotFoundException e) {
                    LOG.warn("Cannot find project with id " + project.getId(), e);
                }
            }
        } catch (TeamCityProjectsNotFoundException e) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Cannot build list of software project ids.", e);
            }
        }
        return projectIds;
    }

}