Package org.sonar.core.persistence

Examples of org.sonar.core.persistence.DbSession


    this.permissionFacade = permissionFacade;
  }

  @Override
  public boolean hasRoles(Resource resource) {
    DbSession session = myBatis.openSession(false);
    try {
      if (resource.getId() != null) {
        Long resourceId = Long.valueOf(resource.getId());
        return permissionFacade.countComponentPermissions(session, resourceId) > 0;
      }
View Full Code Here


  }

  @Override
  public void grantUserRole(Resource resource, String login, String role) {
    if (resource.getId() != null) {
      DbSession session = myBatis.openSession(false);
      try {
        UserDto user = session.getMapper(UserMapper.class).selectUserByLogin(login);
        if (user != null) {
          permissionFacade.deleteUserPermission(Long.valueOf(resource.getId()), user.getId(), role, session);
          permissionFacade.insertUserPermission(Long.valueOf(resource.getId()), user.getId(), role, session);
          session.commit();
        }
      } finally {
        MyBatis.closeQuietly(session);
      }
    }
View Full Code Here

  }

  @Override
  public void grantGroupRole(Resource resource, String groupName, String role) {
    if (resource.getId() != null) {
      DbSession session = myBatis.openSession(false);
      try {
        permissionFacade.deleteGroupPermission(Long.valueOf(resource.getId()), groupName, role, session);
        permissionFacade.insertGroupPermission(Long.valueOf(resource.getId()), groupName, role, session);
        session.commit();
      } finally {
        MyBatis.closeQuietly(session);
      }
    }
  }
View Full Code Here

    permissionFacade.grantDefaultRoles(session, Long.valueOf(resource.getId()), resource.getQualifier());
  }

  @Override
  public void grantDefaultRoles(Resource resource) {
    DbSession session = myBatis.openSession(false);
    try {
      grantDefaultRoles(session, resource);
      session.commit();
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

  @Override
  public void execute() {
    Timer timer = new Timer("Db Migration Progress");
    timer.schedule(progressTask, MassUpdate.ProgressTask.PERIOD_MS, MassUpdate.ProgressTask.PERIOD_MS);

    final DbSession readSession = db.openSession(false);
    final DbSession writeSession = db.openSession(true);
    try {
      readSession.select("org.sonar.core.persistence.migration.v50.Migration50Mapper.selectRootProjects", new ResultHandler() {
        @Override
        public void handleResult(ResultContext context) {
          Component project = (Component) context.getResultObject();
          Map<Long, String> uuidByComponentId = newHashMap();
          migrateEnabledComponents(readSession, writeSession, project, uuidByComponentId);
          migrateDisabledComponents(readSession, writeSession, project, uuidByComponentId);
        }
      });
      writeSession.commit();
      readSession.commit();

      migrateComponentsWithoutUuid(readSession, writeSession);
      writeSession.commit();

      // log the total number of process rows
      progressTask.log();
    } finally {
      readSession.close();
      writeSession.close();
      timer.cancel();
      timer.purge();
    }
  }
View Full Code Here

  /**
   * @deprecated use {@link #insert(org.sonar.core.persistence.DbSession, QualityProfileDto, QualityProfileDto...)}
   */
  @Deprecated
  public void insert(QualityProfileDto dto) {
    DbSession session = mybatis.openSession(false);
    try {
      insert(session, dto);
      session.commit();
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

  /**
   * @deprecated use {@link #update(DbSession, QualityProfileDto, QualityProfileDto...)}
   */
  @Deprecated
  public void update(QualityProfileDto dto) {
    DbSession session = mybatis.openSession(false);
    try {
      update(session, dto);
      session.commit();
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

  /**
   * @deprecated use {@link #delete(DbSession, QualityProfileDto, QualityProfileDto...)}
   */
  @Deprecated
  public void delete(int id) {
    DbSession session = mybatis.openSession(false);
    try {
      delete(id, session);
      session.commit();
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

   * @deprecated Replaced by
   *    {@link #findAll(DbSession)}
   */
  @Deprecated
  public List<QualityProfileDto> findAll() {
    DbSession session = mybatis.openSession(false);
    try {
      return session.getMapper(QualityProfileMapper.class).selectAll();
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

    return session.getMapper(QualityProfileMapper.class).selectDefaultProfile(language, String.format("sonar.profile.%s", language));
  }

  @CheckForNull
  public QualityProfileDto getDefaultProfile(String language) {
    DbSession session = mybatis.openSession(false);
    try {
      return getDefaultProfile(language, session);
    } finally {
      MyBatis.closeQuietly(session);
    }
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.