コード例 #1
0
 private void checkPermissions(CeTaskQuery query) {
   List<String> componentUuids = query.getComponentUuids();
   if (componentUuids != null && componentUuids.size() == 1) {
     if (!isAllowedOnComponentUuid(userSession, componentUuids.get(0))) {
       throw new ForbiddenException("Requires administration permission");
     }
   } else {
     userSession.checkPermission(UserRole.ADMIN);
   }
 }
コード例 #2
0
ファイル: DeleteAction.java プロジェクト: Godin/sonar
  @Override
  public void handle(Request request, Response response) throws Exception {
    userSession.checkPermission(GlobalPermissions.SYSTEM_ADMIN);

    String key = request.mandatoryParam(PARAM_KEY);
    preventDeletionOfDefaultOrganization(key, defaultOrganizationProvider.get());

    try (DbSession dbSession = dbClient.openSession(false)) {
      dbClient.organizationDao().deleteByKey(dbSession, key);
      dbSession.commit();

      response.noContent();
    }
  }
コード例 #3
0
ファイル: UploadAction.java プロジェクト: n-b-sonar/sonarqube
  @Override
  public void handle(Request request, Response response) throws Exception {
    userSession.checkPermission(GlobalPermissions.SYSTEM_ADMIN);

    Part part = request.mandatoryParamAsPart(PARAM_FILE);
    String fileName = part.getFileName();
    checkArgument(fileName.endsWith(".jar"), "Only jar file is allowed");
    InputStream inputStream = part.getInputStream();
    try {
      File destPlugin = new File(downloadDir, fileName);
      Files.copy(inputStream, destPlugin.toPath(), REPLACE_EXISTING);
      response.noContent();
    } finally {
      closeQuietly(inputStream);
    }
  }
コード例 #4
0
ファイル: UpdatesAction.java プロジェクト: Godin/sonar
  @Override
  public void handle(Request request, Response response) throws Exception {
    userSession.checkPermission(SYSTEM_ADMIN);
    JsonWriter jsonWriter = response.newJsonWriter();
    jsonWriter.beginObject();

    Optional<UpdateCenter> updateCenter =
        updateCenterMatrixFactory.getUpdateCenter(DO_NOT_FORCE_REFRESH);

    writePlugins(jsonWriter, updateCenter);

    pluginWSCommons.writeUpdateCenterProperties(jsonWriter, updateCenter);

    jsonWriter.endObject();
    jsonWriter.close();
  }
コード例 #5
0
  @Override
  public void handle(Request request, Response response) throws Exception {
    userSession.checkPermission(GlobalPermissions.PREVIEW_EXECUTION);
    final String moduleKey = request.mandatoryParam(PARAM_KEY);

    response.stream().setMediaType(MediaTypes.PROTOBUF);
    DbSession session = dbClient.openSession(false);
    try {
      ComponentDto component = componentFinder.getByKey(session, moduleKey);
      Map<String, String> keysByUUid = keysByUUid(session, component);

      BatchInput.ServerIssue.Builder issueBuilder = BatchInput.ServerIssue.newBuilder();
      for (Iterator<IssueDoc> issueDocIterator = issueIndex.selectIssuesForBatch(component);
          issueDocIterator.hasNext(); ) {
        handleIssue(issueDocIterator.next(), issueBuilder, keysByUUid, response.stream().output());
      }
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
コード例 #6
0
 private static void checkPermission(UserSession userSession) {
   userSession.checkLoggedIn();
   userSession.checkPermission(GlobalPermissions.QUALITY_PROFILE_ADMIN);
 }