Пример #1
0
 public static void updatePersistentProperties(
     IFile resource, SonarProject sonarProject, ISonarServer sonarServer) {
   try {
     resource.setPersistentProperty(
         MODIFICATION_STAMP_PERSISTENT_PROP_KEY, "" + resource.getModificationStamp());
     resource.setPersistentProperty(
         LAST_ANALYSIS_DATE_PERSISTENT_PROP_KEY,
         ""
             + WSClientFactory.getSonarClient(sonarServer)
                 .getLastAnalysisDate(sonarProject.getKey())
                 .getTime());
   } catch (CoreException e) {
     LOG.error("Unable to update persistent properties", e);
   }
 }
Пример #2
0
 private static boolean newAnalysisAvailableSinceLastRefresh(
     IResource resource, ISonarProject sonarProject, ISonarServer sonarServer) {
   try {
     String previousAnalysisDateStr =
         resource.getPersistentProperty(LAST_ANALYSIS_DATE_PERSISTENT_PROP_KEY);
     long previousAnalysisDate =
         previousAnalysisDateStr != null ? Long.valueOf(previousAnalysisDateStr) : -1;
     long lastAnalysisDate =
         WSClientFactory.getSonarClient(sonarServer)
             .getLastAnalysisDate(sonarProject.getKey())
             .getTime();
     if (previousAnalysisDate != lastAnalysisDate) {
       return true;
     }
   } catch (CoreException e) {
     return true;
   }
   return false;
 }
Пример #3
0
 @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);
 }
 @Override
 public void run(IProgressMonitor monitor) {
   monitor.beginTask("Testing", IProgressMonitor.UNKNOWN);
   try {
     SonarServer newServer =
         SonarCorePlugin.getServersManager().create("test", serverUrl, username, password);
     ConnectionTestResult result = WSClientFactory.getSonarClient(newServer).testConnection();
     switch (result.status) {
       case OK:
         status =
             new Status(
                 IStatus.OK,
                 SonarUiPlugin.PLUGIN_ID,
                 Messages.ServerLocationWizardPage_msg_connected);
         break;
       case AUTHENTICATION_ERROR:
         status =
             new Status(
                 IStatus.ERROR,
                 SonarUiPlugin.PLUGIN_ID,
                 Messages.ServerLocationWizardPage_msg_authentication_error);
         break;
       case CONNECT_ERROR:
         status =
             new Status(
                 IStatus.ERROR,
                 SonarUiPlugin.PLUGIN_ID,
                 Messages.ServerLocationWizardPage_msg_connection_error + result.message);
         break;
       default:
         throw new SonarEclipseException("Unknow status code: " + result);
     }
   } finally {
     monitor.done();
   }
 }