Package org.sonar.wsclient

Examples of org.sonar.wsclient.Sonar


    }
    return Optional.absent();
  }

  private Sonar createSonar() {
    Sonar sonar;
    if (mySonarServerConfig.isAnonymous()) {
      sonar = createSonar(mySonarServerConfig.getHostUrl(), null, null);
    } else {
      mySonarServerConfig.loadPassword();
      sonar = createSonar(mySonarServerConfig.getHostUrl(), mySonarServerConfig.getUser(), mySonarServerConfig.getPassword());
View Full Code Here


      }
    }
  }

  private static void testGetResources() {
    Sonar sonar = Sonar.create("https://sonar.corp.mobile.de/sonar");
    ResourceQuery projectResourceQuery = new ResourceQuery();
    projectResourceQuery.setQualifiers(Resource.QUALIFIER_PROJECT);
//        projectResourceQuery.
    List<Resource> projectResourceList = sonar.findAll(projectResourceQuery);
    for (Resource projectResource : projectResourceList) {
      System.out.println("##################################################");
      System.out.println(projectResource.toString() + " ::: " + projectResource.getQualifier());
      ResourceQuery moduleResourceQuery = new ResourceQuery(projectResource.getId());
      moduleResourceQuery.setDepth(-1);
      moduleResourceQuery.setQualifiers(Resource.QUALIFIER_MODULE);
      List<Resource> moduleResourceList = sonar.findAll(moduleResourceQuery);
      for (Resource moduleResource : moduleResourceList) {
        System.out.println("     " + moduleResource.toString() + " ::: " + moduleResource.getQualifier());
      }
      System.out.println("##################################################");
    }
View Full Code Here

    public String getServerUrl() {
        return serverUrl;
    }
   
    public String getVersion(UserCredentials userCredentials) {
        Sonar sonar;
        if(userCredentials == null) {
            sonar=Sonar.create(serverUrl);
        }else{
            sonar=Sonar.create(serverUrl, userCredentials.getUsername(), PassEncoder.decodeAsString(userCredentials.getPassword()));
        }
        ServerQuery serverQuery=new ServerQuery();
        return sonar.find(serverQuery).getVersion();
    }
View Full Code Here

    public double getRulesCompliance(UserCredentials userCredentials, String resource) {
        try{
            if(!existsProject(userCredentials, resource)) {
                throw new NoSuchProjectException(resource);
            }
            Sonar sonar;
            if(userCredentials == null) {
                sonar=Sonar.create(serverUrl);
            }else{
                sonar=Sonar.create(serverUrl, userCredentials.getUsername(), PassEncoder.decodeAsString(userCredentials.getPassword()));
            }
            ResourceQuery query=new ResourceQuery(resource);
            query.setMetrics(VIOLATIONS_DENSITY_METRICS);
            Resource r = sonar.find(query);
            return r.getMeasure(VIOLATIONS_DENSITY_METRICS).getValue();
        } catch(ConnectionException ex) {
            if(isError401(ex)){
                throw new AuthorizationException(ex);
            }else{
View Full Code Here

        }catch(HttpException ex){
            if(ex.getMessage().contains("Error 404")){
                RuleQuery ruleQuery=new RuleQuery("java");
                String[] tokens=ruleKey.split(":");
                ruleQuery.setSearchText(tokens.length == 2? tokens[1]: ruleKey);
                Sonar sonar;
                if(userCredentials == null) {
                    sonar=Sonar.create(serverUrl);
                }else {
                    sonar=Sonar.create(serverUrl, userCredentials.getUsername(), PassEncoder.decodeAsString(userCredentials.getPassword()));
                }
                List<Rule> rules = sonar.findAll(ruleQuery);
                for(Rule rule:rules) {
                    if(rule.getKey().equals(ruleKey)) {
                        return rule;
                    }
                }
View Full Code Here

        }
    }
   
    public List<String> getProjectsKeys(UserCredentials userCredentials) {
        try{
            Sonar sonar;
            if(userCredentials == null) {
                sonar=Sonar.create(serverUrl);
            }else {
                sonar=Sonar.create(serverUrl, userCredentials.getUsername(), PassEncoder.decodeAsString(userCredentials.getPassword()));
            }
            List<Resource> resources = sonar.findAll(new ResourceQuery());
            List<String> keys=new ArrayList<>(resources.size());
            for(Resource r:resources) {
                keys.add(r.getKey());
            }
            return keys;
View Full Code Here

        return ex.getMessage().contains("HTTP error: 401");
    }
   
    public List<SonarProject> getProjects(UserCredentials userCredentials) {
        try{
            Sonar sonar;
            if(userCredentials == null) {
                sonar=Sonar.create(serverUrl);
            }else {
                sonar=Sonar.create(serverUrl, userCredentials.getUsername(), PassEncoder.decodeAsString(userCredentials.getPassword()));
            }
            List<Resource> resources = sonar.findAll(new ResourceQuery());
            List<SonarProject> projects=new ArrayList<>(resources.size());
            for(Resource r:resources) {
                projects.add(new SonarProject(r.getKey(), r.getName()));
            }
            return projects;
View Full Code Here

                httpClient.getCredentialsProvider().setCredentials(authScope, proxyCredentials);
            }
            HttpHost proxy = new HttpHost(proxySettings.PROXY_HOST, proxySettings.PROXY_PORT);
            httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
        }
        return new Sonar(connector);
    }
View Full Code Here

    }

    @Override
    protected List<Rule> doInBackground() throws Exception {
        SonarProjectComponent component = project.getComponent(SonarProjectComponent.class);
        Sonar sonar = component.getSonar();
        return sonar.findAll(new RuleQuery("java"));
    }
View Full Code Here

        txtHost.setEnabled(false);
        txtUser.setEnabled(false);
        txtPassword.setEnabled(false);
        useProxyBox.setEnabled(false);

        final Sonar sonarConn = SonarUtils.getSonar(txtHost.getText(), txtUser.getText(), new String(txtPassword.getPassword()),
                                          useProxyBox.isSelected());
        final RefreshProjectListWorker refreshProjectListWorker = new RefreshProjectListWorker(sonarConn);
        refreshProjectListWorker.addListener(this);
        refreshProjectListWorker.execute();
    }
View Full Code Here

TOP

Related Classes of org.sonar.wsclient.Sonar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.