Package org.sonar.server.user

Examples of org.sonar.server.user.UserSession


    );
  }

  @Test
  public void can_modify_if_logged_user_has_permission() throws Exception {
    UserSession userSession = MockUserSession.set().setLogin("simon").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
    test(userSession,
      new DefaultIssueFilter()
        .setId(13L)
        .setName("Blocker issues")
        .setDescription("All Blocker Issues")
View Full Code Here


      }
    }

    collectFacetsData(request, result, projectUuids, componentUuids, userLogins, actionPlanKeys);

    UserSession userSession = UserSession.get();
    if (userSession.isLoggedIn()) {
      userLogins.add(userSession.login());
    }

    DbSession session = dbClient.openSession(false);
    try {
      List<DefaultIssueComment> comments = issueChangeDao.selectCommentsByIssues(session, issueKeys);
View Full Code Here

    List<String> assignees = Lists.newArrayList("");
    List<String> assigneesFromRequest = request.paramAsStrings(IssueFilterParameters.ASSIGNEES);
    if (assigneesFromRequest != null) {
      assignees.addAll(assigneesFromRequest);
    }
    UserSession userSession = UserSession.get();
    if (userSession.isLoggedIn()) {
      assignees.add(userSession.login());
    }
    addMandatoryFacetValues(results, IssueFilterParameters.ASSIGNEES, assignees);
    addMandatoryFacetValues(results, IssueFilterParameters.REPORTERS, request.paramAsStrings(IssueFilterParameters.REPORTERS));
    addMandatoryFacetValues(results, IssueFilterParameters.RULES, request.paramAsStrings(IssueFilterParameters.RULES));
    addMandatoryFacetValues(results, IssueFilterParameters.LANGUAGES, request.paramAsStrings(IssueFilterParameters.LANGUAGES));
View Full Code Here

        qualityProfile.getName(), PROFILE_PROPERTY_PREFIX + qualityProfile.getLanguage(), session
        )) {
        componentsByKeys.put(component.key(), component);
      }

      UserSession userSession = UserSession.get();
      List<Component> result = Lists.newArrayList();
      Collection<String> authorizedProjectKeys = db.authorizationDao().selectAuthorizedRootProjectsKeys(userSession.userId(), UserRole.USER);
      for (String key : componentsByKeys.keySet()) {
        if (authorizedProjectKeys.contains(key)) {
          result.add(componentsByKeys.get(key));
        }
      }
View Full Code Here

      .setDescription("Optionally, the ID of the current filter");
  }

  @Override
  public void handle(Request request, Response response) throws Exception {
    UserSession session = UserSession.get();

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

    // Current filter (optional)
    Integer filterId = request.paramAsInt("id");
    DefaultIssueFilter filter = null;
    if (filterId != null && filterId >= 0) {
      filter = service.find((long) filterId, session);
    }

    // Permissions
    json.prop("canManageFilters", session.isLoggedIn());
    json.prop("canBulkChange", session.isLoggedIn());

    // Selected filter
    if (filter != null) {
      issueFilterWriter.write(session, filter, json);
    }

    // Favorite filters, if logged in
    if (session.isLoggedIn()) {
      List<DefaultIssueFilter> favorites = service.findFavoriteFilters(session);
      json.name("favorites").beginArray();
      for (DefaultIssueFilter favorite : favorites) {
        json
          .beginObject()
View Full Code Here

      .setRequired(true);
  }

  @Override
  public void handle(Request request, Response response) throws Exception {
    UserSession session = UserSession.get();
    DefaultIssueFilter filter = service.find(request.mandatoryParamAsLong("id"), session);

    JsonWriter json = response.newJsonWriter();
    json.beginObject();
    issueFilterWriter.write(session, filter, json);
View Full Code Here

      .setHandler(this);
  }

  @Override
  public void handle(Request request, Response response) throws Exception {
    UserSession session = UserSession.get();
    JsonWriter json = response.newJsonWriter();
    json.beginObject().name("favoriteFilters").beginArray();
    if (session.isLoggedIn()) {
      for (DefaultIssueFilter favorite : service.findFavoriteFilters(session)) {
        json.beginObject();
        json.prop("id", favorite.id());
        json.prop("name", favorite.name());
        json.prop("user", favorite.user());
View Full Code Here

  @Test
  public void modify_issue_when_executing_a_function() {
    Function function = new TweetFunction();

    UserSession userSession = mock(UserSession.class);
    when(userSession.login()).thenReturn("arthur");

    when(componentDao.getByKey(eq(session), anyString())).thenReturn(mock(ComponentDto.class));
    when(issueService.getByKeyForUpdate(session, "ABCD")).thenReturn(issue);

    actions.add("link-to-jira").setConditions(new AlwaysMatch()).setFunctions(function);
View Full Code Here

  @Test
  public void inject_project_settings_when_executing_a_function() {
    Function function = new TweetFunction();

    UserSession userSession = mock(UserSession.class);
    when(userSession.login()).thenReturn("arthur");

    when(componentDao.getByKey(session, "struts")).thenReturn(new ComponentDto().setKey("struts"));
    when(issueService.getByKeyForUpdate(session, "ABCD")).thenReturn(issue.setProjectKey("struts"));

    actions.add("link-to-jira").setConditions(new AlwaysMatch()).setFunctions(function);
View Full Code Here

    // Create a user having user permission on the two projects and the global quality profile admin permission
    UserDto user = new UserDto().setLogin("john").setName("John").setEmail("jo@hn.com").setCreatedAt(new Date()).setUpdatedAt(new Date());
    db.userDao().insert(dbSession, user);
    tester.get(PermissionFacade.class).insertUserPermission(project1.getId(), user.getId(), UserRole.USER, dbSession);
    tester.get(PermissionFacade.class).insertUserPermission(project2.getId(), user.getId(), UserRole.USER, dbSession);
    UserSession userSession = MockUserSession.set().setUserId(user.getId().intValue()).setLogin("john").setName("John")
      .setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);

    dbSession.commit();

    projectOperations.addProject(profile.getId(), project1.getId(), userSession);
View Full Code Here

TOP

Related Classes of org.sonar.server.user.UserSession

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.