class HudsonConnection implements BuildCapability, ViewCapability, TestCapability {

    @Override
    public String getLastBuildId(SoftwareProjectId projectId) throws ProjectNotFoundException, BuildIdNotFoundException {
        checkConnected();
        checkSoftwareProjectId(projectId);
        try {
            String projectName = jobName(projectId);
            return String.valueOf(hudson.getLastBuildNumber(projectName));
        } catch (HudsonJobNotFoundException e) {
            throw new ProjectNotFoundException(e);
        } catch (HudsonBuildNotFoundException e) {
            throw new BuildIdNotFoundException(e);
        }
    }

}