From 9c08af387d17f690cc4e63901566d6953ec42eec Mon Sep 17 00:00:00 2001 From: kashike Date: Sun, 15 Jul 2018 12:33:27 -0700 Subject: [PATCH] don't require all groups to exist in RoleTypes --- app/controllers/ApiController.scala | 2 +- app/ore/permission/role/RoleTypes.scala | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/ApiController.scala b/app/controllers/ApiController.scala index 16977d2fa..322476276 100644 --- a/app/controllers/ApiController.scala +++ b/app/controllers/ApiController.scala @@ -309,7 +309,7 @@ final class ApiController @Inject()(api: OreRestfulApi, if (groups.trim == "") Set.empty else - groups.split(",").map(group => RoleTypes.withInternalName(group)).toSet[RoleType] + groups.split(",").flatMap(group => RoleTypes.withInternalName(group)).toSet[RoleType] ) } diff --git a/app/ore/permission/role/RoleTypes.scala b/app/ore/permission/role/RoleTypes.scala index 70e7cf218..63396b9f8 100644 --- a/app/ore/permission/role/RoleTypes.scala +++ b/app/ore/permission/role/RoleTypes.scala @@ -69,11 +69,7 @@ object RoleTypes extends Enumeration { * @param internalName Internal name * @return UserRole with specified internal name */ - def withInternalName(internalName: String): RoleType = this.values.find(_.internalName == internalName).getOrElse { - // Throw an exception instead of returning an Option to match Enumeration - // behavior - throw new NoSuchElementException - } + def withInternalName(internalName: String): Option[RoleType] = this.values.find(_.internalName == internalName).map(value => convert(value)) /** * Represents a User role.