[
https://issues.apache.org/jira/browse/JAMES-2149?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16515295#comment-16515295
]
ASF GitHub Bot commented on JAMES-2149:
---------------------------------------
Github user chibenwa commented on a diff in the pull request:
https://github.com/apache/james-project/pull/119#discussion_r195953058
--- Diff:
server/protocols/webadmin/webadmin-data/src/main/java/org/apache/james/webadmin/routes/DomainMappingsRoutes.java
---
@@ -114,28 +126,56 @@ public HaltException removeDomainMapping(Request
request, Response response) {
@ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
message = "Internal server error - Something went bad
on the server side.")
})
- public Map<String, List<String>> get(Request request, Response
response) throws RecipientRewriteTableException {
+ public Map<String, List<String>> getAllMappings(Request request,
Response response) throws RecipientRewriteTableException {
return recipientRewriteTable.getAllMappings()
.entrySet()
.stream()
- .collect(toImmutableMap(e -> e.getKey().getFixedDomain(),
- e -> e.getValue()
- .select(Mapping.Type.Domain)
- .asStream()
- .map(Mapping::asString)
- .map(Mapping.Type.Domain::withoutPrefix)
- .collect(toImmutableList())
+ .filter(mappingsEntry ->
!mappingsEntry.getValue().isEmpty())
+ .filter(mappingsEntry ->
mappingsEntry.getValue().contains(Mapping.Type.Domain))
--- End diff --
The problem here is that we do not remove entries of the mappings that are
not a domainMapping.
What I would suggest you to do it:
```
.map(mappingEntry -> Pair.of(mappingEntry.getKey(),
mappingEntry.getValue().select(Mapping.Type.Domain))
.filter(mappingsEntry -> !mappingsEntry.getValue().isEmpty())
```
(We ensure to have only domain mappings, then we check it's not empty...).
> Create domain mappings via webadmin
> -----------------------------------
>
> Key: JAMES-2149
> URL: https://issues.apache.org/jira/browse/JAMES-2149
> Project: James Server
> Issue Type: New Feature
> Components: webadmin
> Affects Versions: master
> Reporter: Tellier Benoit
> Priority: Major
> Labels: feature, newbie
>
> Nowadays, the Rewrite Table engine supports domain redirections. That is to
> say [email protected] will be rewritten as [email protected].
> However, such a feature is not exposed via webadmin.
> You will need to :
> - Create a new **DomainMappingsRoutes** in webadmin-data
> - You will expose in this routes, using directly RecipientsRewriteTable, the
> endpoitns for adding, removing and listing domain mappings.
> {code:java}
> GET /domainMappings/
> {"fromDomain1":"toDomain1", "fromDomain2": "toDomain2"}
> PUT /domainMappings/fromDomain
> "toDomain"
> DELETE /domainMappings/fromDomain
> "toDomain"
> {code}
> You will write a test class from your endpoints. See *GroupsRoutesTest*.
> Don't hesitate to ask for help on the *Gitter* chat.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]