[
https://issues.apache.org/jira/browse/JAMES-2149?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16515300#comment-16515300
]
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_r195953283
--- 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))
+ .collect(Guavate.toImmutableMap(
+ mappingsEntry ->
mappingsEntry.getKey().getFixedDomain(),
+ mappingsEntry ->
toDomainList(mappingsEntry.getValue())
));
}
- private void doMapping(final Request request, final
ThrowingBiConsumer<MappingSource, Domain> op) {
- MappingSource fromDomain = createDomainOrThrow()
+ @GET
+ @Path(SPECIFIC_MAPPING_PATH)
+ @ApiOperation(value = "Lists mappings for specific domain.")
+ @ApiImplicitParams({
+ @ApiImplicitParam(required = true, dataType = "string", name =
FROM_DOMAIN, paramType = "path")
+ })
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpStatus.OK_200, message = "Domain
mappings.", responseContainer = "List"),
+ @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "Not
existing mappings."),
+ @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500,
+ message = "Internal server error - Something went bad
on the server side.")
+ })
+ public List<String> getMapping(Request request, Response response)
throws RecipientRewriteTableException {
+ final MappingSource mappingSource = mappingSourceFrom(request);
+
+ return
Optional.ofNullable(recipientRewriteTable.getAllMappings().get(mappingSource))
--- End diff --
You can rely on `RecipientRewriteTable::getUserDomainMappings`, litterally:
```
recipientRewriteTable.getUserDomainMappings(mappingSource)
.select(Mapping.Type.Domain)
```
> 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]