Package org.sonar.core.component

Examples of org.sonar.core.component.ComponentDto


  public void updateKey(String projectOrModuleKey, String newKey) {
    UserSession.get().checkComponentPermission(UserRole.ADMIN, projectOrModuleKey);

    DbSession session = dbClient.openSession(false);
    try {
      ComponentDto projectOrModule = getByKey(projectOrModuleKey);
      resourceKeyUpdaterDao.updateKey(projectOrModule.getId(), newKey);
      session.commit();

      previewCache.reportResourceModification(newKey);

      session.commit();
View Full Code Here


  public Map<String, String> checkModuleKeysBeforeRenaming(String projectKey, String stringToReplace, String replacementString) {
    UserSession.get().checkProjectPermission(UserRole.ADMIN, projectKey);
    DbSession session = dbClient.openSession(false);
    try {
      ComponentDto project = getByKey(projectKey);
      return resourceKeyUpdaterDao.checkModuleKeysBeforeRenaming(project.getId(), stringToReplace, replacementString);
    } finally {
      session.close();
    }
  }
View Full Code Here

  public void bulkUpdateKey(String projectKey, String stringToReplace, String replacementString) {
    UserSession.get().checkProjectPermission(UserRole.ADMIN, projectKey);

    DbSession session = dbClient.openSession(false);
    try {
      ComponentDto project = getByKey(projectKey);

      resourceKeyUpdaterDao.bulkUpdateKey(project.getId(), stringToReplace, replacementString);
      session.commit();

      ComponentDto newProject = dbClient.componentDao().getById(project.getId(), session);
      previewCache.reportResourceModification(newProject.key());

      session.commit();
    } finally {
      session.close();
    }
View Full Code Here

      MyBatis.closeQuietly(session);
    }
  }

  void addProject(int profileId, long projectId, UserSession userSession, DbSession session) {
    ComponentDto project = db.componentDao().getById(projectId, session);
    checkPermission(userSession, project.key());
    QualityProfileDto qualityProfile = findNotNull(profileId, session);

    db.propertiesDao().setProperty(new PropertyDto().setKey(
      QProfileProjectLookup.PROFILE_PROPERTY_PREFIX + qualityProfile.getLanguage()).setValue(qualityProfile.getName()).setResourceId(project.getId()), session);
    session.commit();
  }
View Full Code Here

  }

  public void removeProject(int profileId, long projectId, UserSession userSession) {
    DbSession session = db.openSession(false);
    try {
      ComponentDto project = db.componentDao().getById(projectId, session);
      checkPermission(userSession, project.key());
      QualityProfileDto qualityProfile = findNotNull(profileId, session);

      db.propertiesDao().deleteProjectProperty(QProfileProjectLookup.PROFILE_PROPERTY_PREFIX + qualityProfile.getLanguage(), project.getId(), session);
      session.commit();
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

  }

  public void removeProject(String language, long projectId, UserSession userSession) {
    DbSession session = db.openSession(false);
    try {
      ComponentDto project = db.componentDao().getById(projectId, session);
      checkPermission(userSession, project.key());

      db.propertiesDao().deleteProjectProperty(QProfileProjectLookup.PROFILE_PROPERTY_PREFIX + language, project.getId(), session);
      session.commit();
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

  public ComponentDao(System2 system) {
    super(ComponentMapper.class, system);
  }

  public ComponentDto getById(Long id, DbSession session) {
    ComponentDto componentDto = getNullableById(id, session);
    if (componentDto == null) {
      throw new NotFoundException(String.format("Project with id '%s' not found", id));
    }
    return componentDto;
  }
View Full Code Here

  public ComponentDto getNullableByUuid(DbSession session, String uuid) {
    return mapper(session).selectByUuid(uuid);
  }

  public ComponentDto getByUuid(DbSession session, String uuid) {
    ComponentDto componentDto = getNullableByUuid(session, uuid);
    if (componentDto == null) {
      throw new NotFoundException(String.format("Project with uuid '%s' not found", uuid));
    }
    return componentDto;
  }
View Full Code Here

  public ComponentDto getNullableRootProjectByKey(String componentKey, DbSession session) {
    return mapper(session).selectRootProjectByKey(componentKey);
  }

  public ComponentDto getRootProjectByKey(String componentKey, DbSession session) {
    ComponentDto componentDto = getNullableRootProjectByKey(componentKey, session);
    if (componentDto == null) {
      throw new NotFoundException(String.format("Root project for project '%s' not found", componentKey));
    }
    return componentDto;
  }
View Full Code Here

    verifyZeroInteractions(issueAuthorizationDao);
  }

  @Test
  public void remove_component_permission_from_anyone_group() throws Exception {
    ComponentDto project = ComponentTesting.newProjectDto().setId(10L).setKey("org.sample.Sample");
    when(componentDao.getByKey(session, "org.sample.Sample")).thenReturn(project);

    params = buildPermissionChangeParams(null, DefaultGroups.ANYONE, "org.sample.Sample", "codeviewer");
    setUpComponentGroupPermissions(DefaultGroups.ANYONE, 10L, "codeviewer");
    MockUserSession.set().setLogin("admin").addProjectPermissions(UserRole.ADMIN, "org.sample.Sample");

    service.removePermission(params);

    verify(permissionFacade).deleteGroupPermission(eq(10L), eq((Long) null), eq("codeviewer"), eq(session));
    verify(issueAuthorizationDao).synchronizeAfter(eq(session), any(Date.class), eq(ImmutableMap.of("project", project.uuid())));
  }
View Full Code Here

TOP

Related Classes of org.sonar.core.component.ComponentDto

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.