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); } }
@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(); } }
@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); } }
@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(); }
@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); } }
private static void checkPermission(UserSession userSession) { userSession.checkLoggedIn(); userSession.checkPermission(GlobalPermissions.QUALITY_PROFILE_ADMIN); }