chibenwa commented on code in PR #1707:
URL: https://github.com/apache/james-project/pull/1707#discussion_r1316938730
##########
server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/routes/UserQuotaRoutes.java:
##########
@@ -102,21 +101,20 @@ private static Optional<Integer>
intQueryParameter(Request request) {
}
private static List<QuotaComponent> getQuotaComponent(Request request)
{
- List<QuotaComponent> quotaComponents = new ArrayList<>();
String[] quotaComponentStrings =
request.queryParamsValues(QUOTA_COMPONENT);
if (Objects.isNull(quotaComponentStrings) ||
quotaComponentStrings.length == 0) {
return ImmutableList.of();
}
- for (String quotaComponentString : quotaComponentStrings) {
- QuotaComponent quotaComponent =
QUOTA_COMPONENT_MAP.get(quotaComponentString);
- if (Objects.isNull(quotaComponent)) {
- throw new IllegalArgumentException(String.format("Illegal
value supplied for query parameter '%s' with value '%s', expecting existing " +
- "quota components", QUOTA_COMPONENT,
quotaComponentString));
- }
- quotaComponents.add(quotaComponent);
- }
-
- return ImmutableList.copyOf(quotaComponents);
+ return Arrays.stream(quotaComponentStrings)
+ .map(quotaComponentString -> {
+ QuotaComponent quotaComponent =
QUOTA_COMPONENT_MAP.get(quotaComponentString);
+ if (Objects.isNull(quotaComponent)) {
+ throw new
IllegalArgumentException(String.format("Illegal value supplied for query
parameter '%s' with value '%s', expecting existing " +
+ "quota components", QUOTA_COMPONENT,
quotaComponentString));
+ }
+ return quotaComponent;
Review Comment:
```suggestion
return
Optional.ofNullable(QUOTA_COMPONENT_MAP.get(quotaComponentString))
.orRlseThrow(() -> new
IllegalArgumentException(String.format("Illegal value supplied for query
parameter '%s' with value '%s', expecting existing quota components",
QUOTA_COMPONENT, quotaComponentString)));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]