diff --git a/src/main/scala/gitbucket/core/controller/AccountController.scala b/src/main/scala/gitbucket/core/controller/AccountController.scala index 0308a4a..7d3d1eb 100644 --- a/src/main/scala/gitbucket/core/controller/AccountController.scala +++ b/src/main/scala/gitbucket/core/controller/AccountController.scala @@ -134,7 +134,7 @@ context.loginAccount.exists(x => members.exists { member => member.userName == x.userName && member.isManager })) } } - } getOrElse NotFound + } getOrElse NotFound() } get("/:userName.atom") { @@ -157,7 +157,7 @@ val userName = params("userName") getAccountByUserName(userName).map { x => html.edit(x, flash.get("info"), flash.get("error")) - } getOrElse NotFound + } getOrElse NotFound() }) post("/:userName/_edit", editForm)(oneselfOnly { form => @@ -173,7 +173,7 @@ flash += "info" -> "Account information has been updated." redirect(s"/${userName}/_edit") - } getOrElse NotFound + } getOrElse NotFound() }) get("/:userName/_delete")(oneselfOnly { @@ -197,14 +197,14 @@ session.invalidate redirect("/") } - } getOrElse NotFound + } getOrElse NotFound() }) get("/:userName/_ssh")(oneselfOnly { val userName = params("userName") getAccountByUserName(userName).map { x => html.ssh(x, getPublicKeys(x.userName)) - } getOrElse NotFound + } getOrElse NotFound() }) post("/:userName/_ssh", sshKeyForm)(oneselfOnly { form => @@ -235,7 +235,7 @@ case _ => None } html.application(x, tokens, generatedToken) - } getOrElse NotFound + } getOrElse NotFound() }) post("/:userName/_personalToken", personalTokenForm)(oneselfOnly { form => @@ -261,7 +261,7 @@ } else { html.register() } - } else NotFound + } else NotFound() } post("/register", newForm){ form => @@ -269,7 +269,7 @@ createAccount(form.userName, sha1(form.password), form.fullName, form.mailAddress, false, form.url) updateImage(form.userName, form.fileId, false) redirect("/signin") - } else NotFound + } else NotFound() } get("/groups/new")(usersOnly { @@ -330,7 +330,7 @@ updateImage(form.groupName, form.fileId, form.clearImage) redirect(s"/${form.groupName}") - } getOrElse NotFound + } getOrElse NotFound() } }) @@ -372,7 +372,7 @@ ) case _ => redirect(s"/${loginUserName}") } - } else BadRequest + } else BadRequest() }) post("/:owner/:repository/fork", accountForm)(readableUsersOnly { (form, repository) => @@ -429,7 +429,7 @@ redirect(s"/${accountName}/${repository.name}") } } - } else BadRequest + } else BadRequest() }) private def existsAccount: Constraint = new Constraint(){ diff --git a/src/main/scala/gitbucket/core/controller/ApiController.scala b/src/main/scala/gitbucket/core/controller/ApiController.scala index 9a2f2a4..d535a58 100644 --- a/src/main/scala/gitbucket/core/controller/ApiController.scala +++ b/src/main/scala/gitbucket/core/controller/ApiController.scala @@ -66,7 +66,7 @@ get("/api/v3/orgs/:groupName") { getAccountByUserName(params("groupName")).filter(account => account.isGroupAccount).map { account => JsonFormat(ApiUser(account)) - } getOrElse NotFound + } getOrElse NotFound() } /** @@ -75,7 +75,7 @@ get("/api/v3/users/:userName") { getAccountByUserName(params("userName")).filterNot(account => account.isGroupAccount).map { account => JsonFormat(ApiUser(account)) - } getOrElse NotFound + } getOrElse NotFound() } /** @@ -145,7 +145,7 @@ get("/api/v3/user") { context.loginAccount.map { account => JsonFormat(ApiUser(account)) - } getOrElse Unauthorized + } getOrElse Unauthorized() } /** @@ -179,7 +179,7 @@ ) } } - }) getOrElse NotFound + }) getOrElse NotFound() }) /** @@ -203,7 +203,7 @@ ) } } - }) getOrElse NotFound + }) getOrElse NotFound() }) /** @@ -221,7 +221,7 @@ disableBranchProtection(repository.owner, repository.name, branch) } JsonFormat(ApiBranch(branch, protection)(RepositoryName(repository))) - }) getOrElse NotFound + }) getOrElse NotFound() }) /** @@ -243,7 +243,7 @@ comments = getCommentsForApi(repository.owner, repository.name, issueId.toInt) } yield { JsonFormat(comments.map{ case (issueComment, user, issue) => ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(user), issue.isPullRequest) }) - }).getOrElse(NotFound) + }) getOrElse NotFound() }) /** @@ -259,7 +259,7 @@ issueComment <- getComment(repository.owner, repository.name, id.toString()) } yield { JsonFormat(ApiComment(issueComment, RepositoryName(repository), issueId, ApiUser(context.loginAccount.get), issue.isPullRequest)) - }) getOrElse NotFound + }) getOrElse NotFound() }) /** @@ -393,7 +393,7 @@ ApiRepository(headRepo, ApiUser(headOwner)), ApiRepository(repository, ApiUser(baseOwner)), ApiUser(issueUser))) - }).getOrElse(NotFound) + }) getOrElse NotFound() }) /** @@ -412,7 +412,7 @@ JsonFormat(commits) } } - } getOrElse NotFound + } getOrElse NotFound() }) /** @@ -437,7 +437,7 @@ status <- getCommitStatus(repository.owner, repository.name, statusId) } yield { JsonFormat(ApiCommitStatus(status, ApiUser(creator))) - }) getOrElse NotFound + }) getOrElse NotFound() }) /** @@ -453,7 +453,7 @@ JsonFormat(getCommitStatuesWithCreator(repository.owner, repository.name, sha).map{ case(status, creator) => ApiCommitStatus(status, ApiUser(creator)) }) - }) getOrElse NotFound + }) getOrElse NotFound() }) /** @@ -478,7 +478,7 @@ } yield { val statuses = getCommitStatuesWithCreator(repository.owner, repository.name, sha) JsonFormat(ApiCombinedCommitStatus(sha, statuses, ApiRepository(repository, owner))) - }) getOrElse NotFound + }) getOrElse NotFound() }) private def isEditable(owner: String, repository: String, author: String)(implicit context: Context): Boolean = diff --git a/src/main/scala/gitbucket/core/controller/ControllerBase.scala b/src/main/scala/gitbucket/core/controller/ControllerBase.scala index db795dd..ef1a634 100644 --- a/src/main/scala/gitbucket/core/controller/ControllerBase.scala +++ b/src/main/scala/gitbucket/core/controller/ControllerBase.scala @@ -248,7 +248,7 @@ protected def reservedNames(): Constraint = new Constraint(){ override def validate(name: String, value: String, messages: Messages): Option[String] = if(allReservedNames.contains(value)){ Some(s"${value} is reserved") - }else{ + } else { None } } diff --git a/src/main/scala/gitbucket/core/controller/FileUploadController.scala b/src/main/scala/gitbucket/core/controller/FileUploadController.scala index ac90bbc..d264341 100644 --- a/src/main/scala/gitbucket/core/controller/FileUploadController.scala +++ b/src/main/scala/gitbucket/core/controller/FileUploadController.scala @@ -48,7 +48,7 @@ // Check whether logged-in user is collaborator collaboratorsOnly(owner, repository, loginAccount){ execute({ (file, fileId) => - val fileName = file.getName + val fileName = file.getName LockUtil.lock(s"${owner}/${repository}/wiki") { using(Git.open(Directory.getWikiRepositoryDir(owner, repository))) { git => val builder = DirCache.newInCore.builder() @@ -75,7 +75,7 @@ } }, FileUtil.isUploadableType) } - } getOrElse BadRequest + } getOrElse BadRequest() } post("/import") { @@ -93,7 +93,7 @@ loginAccount match { case x if(x.isAdmin) => action case x if(getCollaborators(owner, repository).contains(x.userName)) => action - case _ => BadRequest + case _ => BadRequest() } } @@ -101,10 +101,9 @@ case Some(file) if(mimeTypeChcker(file.name)) => defining(FileUtil.generateFileId){ fileId => f(file, fileId) - Ok(fileId) } - case _ => BadRequest + case _ => BadRequest() } } diff --git a/src/main/scala/gitbucket/core/controller/IssuesController.scala b/src/main/scala/gitbucket/core/controller/IssuesController.scala index f425b60..954e92f 100644 --- a/src/main/scala/gitbucket/core/controller/IssuesController.scala +++ b/src/main/scala/gitbucket/core/controller/IssuesController.scala @@ -72,7 +72,7 @@ getLabels(owner, name), hasWritePermission(owner, name, context.loginAccount), repository) - } getOrElse NotFound + } getOrElse NotFound() } }) @@ -139,8 +139,8 @@ createReferComment(owner, name, issue.copy(title = title), title, context.loginAccount.get) redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}") - } else Unauthorized - } getOrElse NotFound + } else Unauthorized() + } getOrElse NotFound() } }) @@ -154,8 +154,8 @@ createReferComment(owner, name, issue, content.getOrElse(""), context.loginAccount.get) redirect(s"/${owner}/${name}/issues/_data/${issue.issueId}") - } else Unauthorized - } getOrElse NotFound + } else Unauthorized() + } getOrElse NotFound() } }) @@ -166,7 +166,7 @@ redirect(s"/${repository.owner}/${repository.name}/${ if(issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}") } - } getOrElse NotFound + } getOrElse NotFound() }) post("/:owner/:repository/issue_comments/state", issueStateForm)(readableUsersOnly { (form, repository) => @@ -176,7 +176,7 @@ redirect(s"/${repository.owner}/${repository.name}/${ if(issue.isPullRequest) "pull" else "issues"}/${form.issueId}#comment-${id}") } - } getOrElse NotFound + } getOrElse NotFound() }) ajaxPost("/:owner/:repository/issue_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) => @@ -185,8 +185,8 @@ if(isEditable(owner, name, comment.commentedUserName)){ updateComment(comment.commentId, form.content) redirect(s"/${owner}/${name}/issue_comments/_data/${comment.commentId}") - } else Unauthorized - } getOrElse NotFound + } else Unauthorized() + } getOrElse NotFound() } }) @@ -195,8 +195,8 @@ getComment(owner, name, params("id")).map { comment => if(isEditable(owner, name, comment.commentedUserName)){ Ok(deleteComment(comment.commentId)) - } else Unauthorized - } getOrElse NotFound + } else Unauthorized() + } getOrElse NotFound() } }) @@ -223,8 +223,8 @@ ) ) } - } else Unauthorized - } getOrElse NotFound + } else Unauthorized() + } getOrElse NotFound() }) ajaxGet("/:owner/:repository/issue_comments/_data/:id")(readableUsersOnly { repository => @@ -249,8 +249,8 @@ ) ) } - } else Unauthorized - } getOrElse NotFound + } else Unauthorized() + } getOrElse NotFound() }) ajaxPost("/:owner/:repository/issues/new/label")(collaboratorsOnly { repository => @@ -284,7 +284,7 @@ getMilestonesWithIssueCount(repository.owner, repository.name) .find(_._1.milestoneId == milestoneId).map { case (_, openCount, closeCount) => gitbucket.core.issues.milestones.html.progress(openCount + closeCount, closeCount) - } getOrElse NotFound + } getOrElse NotFound() } getOrElse Ok() }) @@ -313,7 +313,7 @@ registerIssueLabel(repository.owner, repository.name, issueId, labelId) } } - } getOrElse NotFound + } getOrElse NotFound() }) post("/:owner/:repository/issues/batchedit/assign")(collaboratorsOnly { repository => @@ -340,7 +340,7 @@ RawData(FileUtil.getMimeType(file.getName), file) } case _ => None - }) getOrElse NotFound + }) getOrElse NotFound() }) val assignedUserName = (key: String) => params.get(key) filter (_.trim != "") diff --git a/src/main/scala/gitbucket/core/controller/MilestonesController.scala b/src/main/scala/gitbucket/core/controller/MilestonesController.scala index 50cd068..323b114 100644 --- a/src/main/scala/gitbucket/core/controller/MilestonesController.scala +++ b/src/main/scala/gitbucket/core/controller/MilestonesController.scala @@ -42,7 +42,7 @@ get("/:owner/:repository/issues/milestones/:milestoneId/edit")(collaboratorsOnly { repository => params("milestoneId").toIntOpt.map{ milestoneId => html.edit(getMilestone(repository.owner, repository.name, milestoneId), repository) - } getOrElse NotFound + } getOrElse NotFound() }) post("/:owner/:repository/issues/milestones/:milestoneId/edit", milestoneForm)(collaboratorsOnly { (form, repository) => @@ -51,7 +51,7 @@ updateMilestone(milestone.copy(title = form.title, description = form.description, dueDate = form.dueDate)) redirect(s"/${repository.owner}/${repository.name}/issues/milestones") } - } getOrElse NotFound + } getOrElse NotFound() }) get("/:owner/:repository/issues/milestones/:milestoneId/close")(collaboratorsOnly { repository => @@ -60,7 +60,7 @@ closeMilestone(milestone) redirect(s"/${repository.owner}/${repository.name}/issues/milestones") } - } getOrElse NotFound + } getOrElse NotFound() }) get("/:owner/:repository/issues/milestones/:milestoneId/open")(collaboratorsOnly { repository => @@ -69,7 +69,7 @@ openMilestone(milestone) redirect(s"/${repository.owner}/${repository.name}/issues/milestones") } - } getOrElse NotFound + } getOrElse NotFound() }) get("/:owner/:repository/issues/milestones/:milestoneId/delete")(collaboratorsOnly { repository => @@ -78,7 +78,7 @@ deleteMilestone(repository.owner, repository.name, milestone.milestoneId) redirect(s"/${repository.owner}/${repository.name}/issues/milestones") } - } getOrElse NotFound + } getOrElse NotFound() }) } diff --git a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala index 803ab51..f3bd241 100644 --- a/src/main/scala/gitbucket/core/controller/PullRequestsController.scala +++ b/src/main/scala/gitbucket/core/controller/PullRequestsController.scala @@ -104,7 +104,7 @@ flash.toMap.map(f => f._1 -> f._2.toString)) } } - } getOrElse NotFound + } getOrElse NotFound() }) ajaxGet("/:owner/:repository/pull/:id/mergeguide")(referrersOnly { repository => @@ -138,7 +138,7 @@ repository, getRepository(pullreq.requestUserName, pullreq.requestRepositoryName).get) } - } getOrElse NotFound + } getOrElse NotFound() }) get("/:owner/:repository/pull/:id/delete/*")(collaboratorsOnly { repository => @@ -153,7 +153,7 @@ } createComment(repository.owner, repository.name, userName, issueId, branchName, "delete_branch") redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}") - } getOrElse NotFound + } getOrElse NotFound() }) post("/:owner/:repository/pull/:id/update_branch")(referrersOnly { baseRepository => @@ -222,7 +222,7 @@ } redirect(s"/${repository.owner}/${repository.name}/pull/${issueId}") } - }) getOrElse NotFound + }) getOrElse NotFound() }) post("/:owner/:repository/pull/:id/merge", mergeForm)(collaboratorsOnly { (form, repository) => @@ -273,7 +273,7 @@ } } } - } getOrElse NotFound + } getOrElse NotFound() }) get("/:owner/:repository/compare")(referrersOnly { forkedRepository => @@ -290,7 +290,7 @@ redirect(s"/${forkedRepository.owner}/${forkedRepository.name}/compare/${originUserName}:${oldBranch}...${newBranch}") } - } getOrElse NotFound + } getOrElse NotFound() } case _ => { using(Git.open(getRepositoryDir(forkedRepository.owner, forkedRepository.name))){ git => @@ -386,7 +386,7 @@ s"${forkedOwner}:${newId.map(_ => forkedId).getOrElse(forkedRepository.repository.defaultBranch)}") } } - }) getOrElse NotFound + }) getOrElse NotFound() }) ajaxGet("/:owner/:repository/compare/*...*/mergecheck")(collaboratorsOnly { forkedRepository => @@ -416,7 +416,7 @@ } html.mergecheck(conflict) } - }) getOrElse NotFound + }) getOrElse NotFound() }) post("/:owner/:repository/pulls/new", pullRequestForm)(referrersOnly { (form, repository) => diff --git a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala index 6d7c981..41455cc 100644 --- a/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositorySettingsController.scala @@ -300,7 +300,7 @@ get("/:owner/:repository/settings/hooks/edit")(ownerOnly { repository => getWebHook(repository.owner, repository.name, params("url")).map{ case (webhook, events) => html.edithooks(webhook, events, repository, flash.get("info"), false) - } getOrElse NotFound + } getOrElse NotFound() }) /** diff --git a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala index 4307fbb..f61b406 100644 --- a/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala +++ b/src/main/scala/gitbucket/core/controller/RepositoryViewerController.scala @@ -152,7 +152,7 @@ logs.splitWith{ (commit1, commit2) => view.helpers.date(commit1.commitTime) == view.helpers.date(commit2.commitTime) }, page, hasNext, hasWritePermission(repository.owner, repository.name, context.loginAccount)) - case Left(_) => NotFound + case Left(_) => NotFound() } } }) @@ -177,7 +177,7 @@ html.editor(branch, repository, paths.take(paths.size - 1).toList, Some(paths.last), JGitUtil.getContentInfo(git, path, objectId), protectedBranch) - } getOrElse NotFound + } getOrElse NotFound() } }) @@ -190,7 +190,7 @@ val paths = path.split("/") html.delete(branch, repository, paths.take(paths.size - 1).toList, paths.last, JGitUtil.getContentInfo(git, path, objectId)) - } getOrElse NotFound + } getOrElse NotFound() } }) @@ -250,7 +250,7 @@ loader.copyTo(response.outputStream) () } - } getOrElse NotFound + } getOrElse NotFound() } }) @@ -270,7 +270,7 @@ response.setContentLength(loader.getSize.toInt) loader.copyTo(response.outputStream) () - } getOrElse NotFound + } getOrElse NotFound() } else { html.blob(id, repository, path.split("/").toList, JGitUtil.getContentInfo(git, path, objectId), @@ -278,7 +278,7 @@ hasWritePermission(repository.owner, repository.name, context.loginAccount), request.paths(2) == "blame") } - } getOrElse NotFound + } getOrElse NotFound() } }) @@ -334,7 +334,7 @@ } } } catch { - case e:MissingObjectException => NotFound + case e:MissingObjectException => NotFound() } }) @@ -397,8 +397,8 @@ ) )) } - } else Unauthorized - } getOrElse NotFound + } else Unauthorized() + } getOrElse NotFound() }) ajaxPost("/:owner/:repository/commit_comments/edit/:id", commentForm)(readableUsersOnly { (form, repository) => @@ -407,8 +407,8 @@ if(isEditable(owner, name, comment.commentedUserName)){ updateCommitComment(comment.commentId, form.content) redirect(s"/${owner}/${name}/commit_comments/_data/${comment.commentId}") - } else Unauthorized - } getOrElse NotFound + } else Unauthorized() + } getOrElse NotFound() } }) @@ -417,8 +417,8 @@ getCommitComment(owner, name, params("id")).map { comment => if(isEditable(owner, name, comment.commentedUserName)){ Ok(deleteCommitComment(comment.commentId)) - } else Unauthorized - } getOrElse NotFound + } else Unauthorized() + } getOrElse NotFound() } }) @@ -489,7 +489,7 @@ archiveRepository(name, ".zip", repository) case name if name.endsWith(".tar.gz") => archiveRepository(name, ".tar.gz", repository) - case _ => BadRequest + case _ => BadRequest() } }) @@ -518,7 +518,7 @@ val ref = multiParams("splat").head JGitUtil.getTreeId(git, ref).map{ treeId => html.find(ref, treeId, repository) - } getOrElse NotFound + } getOrElse NotFound() } }) @@ -573,7 +573,7 @@ getPullRequestFromBranch(repository.owner, repository.name, revstr, repository.repository.defaultBranch), flash.get("info"), flash.get("error")) } - } getOrElse NotFound + } getOrElse NotFound() } } } diff --git a/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala b/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala index deaf4d0..7a68746 100644 --- a/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala +++ b/src/main/scala/gitbucket/core/controller/SystemSettingsController.scala @@ -233,7 +233,7 @@ updateImage(userName, form.fileId, form.clearImage) redirect("/admin/users") } - } getOrElse NotFound + } getOrElse NotFound() }) get("/admin/users/_newgroup")(adminOnly { @@ -291,7 +291,7 @@ updateImage(form.groupName, form.fileId, form.clearImage) redirect("/admin/users") - } getOrElse NotFound + } getOrElse NotFound() } }) diff --git a/src/main/scala/gitbucket/core/controller/WikiController.scala b/src/main/scala/gitbucket/core/controller/WikiController.scala index 847c421..29f0569 100644 --- a/src/main/scala/gitbucket/core/controller/WikiController.scala +++ b/src/main/scala/gitbucket/core/controller/WikiController.scala @@ -201,7 +201,7 @@ getFileContent(repository.owner, repository.name, path).map { bytes => RawData(FileUtil.getContentType(path, bytes), bytes) - } getOrElse NotFound + } getOrElse NotFound() }) private def unique: Constraint = new Constraint(){