protected fun getProject()

in aws-lambda-server/src/main/java/jetbrains/buildServer/runner/lambda/web/JsonController.kt [98:119]


    protected fun getProject(request: HttpServletRequest): SProject {
        if (!allowedMethods.contains(request.method)) {
            throw JsonControllerException(status = HttpStatus.METHOD_NOT_ALLOWED)
        }

        val settingsId =
                request.getParameter(LambdaConstants.BUILD_TYPE_ID) ?: throw JsonControllerException("Missing parameter ${LambdaConstants.BUILD_TYPE_ID}", HttpStatus.BAD_REQUEST)

        val buildTypeId = if (settingsId.startsWith(BUILD_TYPE_PREFIX)) {
            settingsId.substring(BUILD_TYPE_PREFIX.length)
        } else {
            settingsId
        }

        val buildType = projectManager.findBuildTypeByExternalId(buildTypeId)
                ?: throw JsonControllerException("Build Type $buildTypeId not found", HttpStatus.NOT_FOUND)

        val projectId = buildType.projectId
        val project = projectManager.findProjectById(projectId)
                ?: throw JsonControllerException("Project for Build Type $buildType not found", HttpStatus.NOT_FOUND)
        return project
    }