Package org.sonar.core.persistence

Examples of org.sonar.core.persistence.DbSession


    }
  }

  @CheckForNull
  public QualityProfileDto getByLangAndName(String lang, String name) {
    DbSession dbSession = db.openSession(false);
    try {
      return db.qualityProfileDao().getByNameAndLanguage(name, lang, dbSession);
    } finally {
      dbSession.close();
    }
  }
View Full Code Here


  }

  // ------------- DELETION

  void delete(String key) {
    DbSession session = db.openSession(false);
    try {
      delete(session, key, false);
      session.commit();
    } finally {
      session.close();
    }
  }
View Full Code Here

  // ------------- DEFAULT PROFILE

  @CheckForNull
  QualityProfileDto getDefault(String language) {
    DbSession dbSession = db.openSession(false);
    try {
      return getDefault(dbSession, language);
    } finally {
      dbSession.close();
    }
  }
View Full Code Here

  public QualityProfileDto getDefault(DbSession session, String language) {
    return db.qualityProfileDao().getDefaultProfile(language, session);
  }

  void setDefault(String profileKey) {
    DbSession dbSession = db.openSession(false);
    try {
      setDefault(dbSession, profileKey);
    } finally {
      dbSession.close();
    }
  }
View Full Code Here

      .setValue(profile.getName());
    db.propertiesDao().setProperty(property, session);
  }

  QualityProfileDto getByProjectAndLanguage(String projectKey, String language) {
    DbSession dbSession = db.openSession(false);
    try {
      return getByProjectAndLanguage(dbSession, projectKey, language);
    } finally {
      dbSession.close();
    }
  }
View Full Code Here

  public QualityProfileDto getByProjectAndLanguage(DbSession session, String projectKey, String language) {
    return db.qualityProfileDao().getByProjectAndLanguage(projectKey, language, PROFILE_PROPERTY_PREFIX + language, session);
  }

  QualityProfileDto getByNameAndLanguage(String name, String language) {
    DbSession dbSession = db.openSession(false);
    try {
      return getByNameAndLanguage(dbSession, name, language);
    } finally {
      dbSession.close();
    }
  }
View Full Code Here

  // ------------- RENAME

  public boolean rename(String key, String newName) {
    Verifications.check(StringUtils.isNotBlank(newName), "Name must be set");
    Verifications.check(newName.length() < 100, String.format("Name is too long (>%d characters)", 100));
    DbSession dbSession = db.openSession(false);
    try {
      QualityProfileDto profile = db.qualityProfileDao().getNonNullByKey(dbSession, key);
      if (!StringUtils.equals(newName, profile.getName())) {
        if (db.qualityProfileDao().getByNameAndLanguage(newName, profile.getLanguage(), dbSession) != null) {
          throw new BadRequestException("Quality profile already exists: " + newName);
        }
        String previousName = profile.getName();
        profile.setName(newName);
        db.qualityProfileDao().update(dbSession, profile);
        db.propertiesDao().updateProperties(PROFILE_PROPERTY_PREFIX + profile.getLanguage(), previousName, newName, dbSession);
        dbSession.commit();
        return true;
      }
      return false;
    } finally {
      dbSession.close();
    }
  }
View Full Code Here

  public void analyzeReport(AnalysisReportDto report) {
    TimeProfiler profiler = new TimeProfiler(LOG).start(String.format("#%s - %s - Analysis report processing", report.getId(), report.getProjectKey()));

    // Synchronization of a lot of data can only be done with a batch session for the moment
    DbSession session = dbClient.openSession(true);

    ComponentDto project = findProject(report, session);

    try {
      report.succeed();
      for (ComputationStep step : stepRegistry.steps()) {
        TimeProfiler stepProfiler = new TimeProfiler(LOG).start(step.getDescription());
        step.execute(session, report, project);
        session.commit();
        stepProfiler.stop();
      }

    } catch (Exception exception) {
      report.fail();
      Throwables.propagate(exception);
    } finally {
      logActivity(session, report, project);
      session.commit();
      MyBatis.closeQuietly(session);
      profiler.stop();
    }
  }
View Full Code Here

    updater.executeUpdate();
  }

  public void removeGroupFromTemplates(String groupName) {
    UserSession.get().checkGlobalPermission(GlobalPermissions.SYSTEM_ADMIN);
    DbSession session = myBatis.openSession(false);
    try {
      GroupDto group = userDao.selectGroupByName(groupName, session);
      if (group == null) {
        throw new NotFoundException("Group does not exists : " + groupName);
      }
      permissionTemplateDao.removeByGroup(group.getId(), session);
      session.commit();
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

    UserSession userSession = UserSession.get();

    JsonWriter json = response.newJsonWriter();
    json.beginObject();

    DbSession session = dbClient.openSession(false);
    try {
      ComponentDto component = dbClient.componentDao().getNullableByKey(session, fileKey);
      if (component == null) {
        throw new NotFoundException(String.format("Component '%s' does not exist", fileKey));
      }
View Full Code Here

TOP

Related Classes of org.sonar.core.persistence.DbSession

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.