public String resourceUrl(ISonarResource resource) { String urlTemplate = resourcesUrlTemplate(resource); String serverUrl = properties(resource).getUrl(); String key = resource.getKey(); return String.format(urlTemplate, serverUrl, key); }
@Override protected void open(ISonarResource sonarResource) { SonarProject sonarProject = SonarProject.getInstance(sonarResource.getProject()); String url = new SonarUrls().resourceUrl(sonarResource); ISonarServer sonarServer = SonarCorePlugin.getServersManager().findServer(sonarProject.getUrl()); if (sonarServer == null) { showMessage( NLS.bind( Messages.No_matching_server_in_configuration_for_project, sonarProject.getProject().getName(), url)); return; } if (sonarServer.disabled()) { showMessage("Server is disabled."); return; } if (!WSClientFactory.getSonarClient(sonarServer).exists(sonarResource.getKey())) { showMessage("Not found."); return; } super.open(sonarProject, url); }
private SonarProject properties(ISonarResource resource) { return SonarProject.getInstance(resource.getProject()); }
private String resourcesUrlTemplate(ISonarResource resource) { if (resource.getResource() instanceof IFile) { return "%s/resource/index/%s"; } return "%s/project/index/%s"; }