Skip to content

Commit

Permalink
Implement endpoint for mail templates
Browse files Browse the repository at this point in the history
  • Loading branch information
pathob committed Oct 24, 2023
1 parent 05cd127 commit 892031e
Show file tree
Hide file tree
Showing 8 changed files with 569 additions and 0 deletions.
208 changes: 208 additions & 0 deletions index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,171 @@ ifdef::internal-generation[]
endif::internal-generation[]


[.MailTemplates]
=== MailTemplates


[.getMailTemplates]
==== getMailTemplates

`GET /mail-templates/mail-templates`

Get the mail templates

===== Description




// markup not found, no include::{specDir}mail-templates/mail-templates/GET/spec.adoc[opts=optional]



===== Parameters







===== Return Type

<<MailTemplatesBean>>


===== Content Type

* application/json

===== Responses

.http response codes
[cols="2,3,1"]
|===
| Code | Message | Datatype


| 200
|
| <<MailTemplatesBean>>


| 0
|
| <<ErrorCollection>>

|===

===== Samples


// markup not found, no include::{snippetDir}mail-templates/mail-templates/GET/http-request.adoc[opts=optional]


// markup not found, no include::{snippetDir}mail-templates/mail-templates/GET/http-response.adoc[opts=optional]



// file not found, no * wiremock data link :mail-templates/mail-templates/GET/GET.json[]


ifdef::internal-generation[]
===== Implementation

// markup not found, no include::{specDir}mail-templates/mail-templates/GET/implementation.adoc[opts=optional]


endif::internal-generation[]


[.setMailTemplates]
==== setMailTemplates

`PUT /mail-templates/mail-templates`

Set the mail templates

===== Description




// markup not found, no include::{specDir}mail-templates/mail-templates/PUT/spec.adoc[opts=optional]



===== Parameters


===== Body Parameter

[cols="2,3,1,1,1"]
|===
|Name| Description| Required| Default| Pattern

| MailTemplatesBean
| <<MailTemplatesBean>>
| -
|
|

|===





===== Return Type

<<MailTemplatesBean>>


===== Content Type

* application/json

===== Responses

.http response codes
[cols="2,3,1"]
|===
| Code | Message | Datatype


| 200
|
| <<MailTemplatesBean>>


| 0
|
| <<ErrorCollection>>

|===

===== Samples


// markup not found, no include::{snippetDir}mail-templates/mail-templates/PUT/http-request.adoc[opts=optional]


// markup not found, no include::{snippetDir}mail-templates/mail-templates/PUT/http-response.adoc[opts=optional]



// file not found, no * wiremock data link :mail-templates/mail-templates/PUT/PUT.json[]


ifdef::internal-generation[]
===== Implementation

// markup not found, no include::{specDir}mail-templates/mail-templates/PUT/implementation.adoc[opts=optional]


endif::internal-generation[]


[.Ping]
=== Ping

Expand Down Expand Up @@ -3469,6 +3634,49 @@ endif::internal-generation[]
|===


[#MailTemplatesBean]
=== _MailTemplatesBean_



[.fields-MailTemplatesBean]
[cols="2,1,2,4,1"]
|===
| Field Name| Required| Type| Description| Format

| forgottenPassword
|
| String
|
|

| forgottenUsername
|
| String
|
|

| passwordExpirationReminder
|
| String
|
|

| emailChangeValidation
|
| String
|
|

| emailChangeInfo
|
| String
|
|

|===


[#SettingsBean]
=== _SettingsBean_

Expand Down
50 changes: 50 additions & 0 deletions src/main/java/de/aservo/confapi/crowd/model/MailTemplatesBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package de.aservo.confapi.crowd.model;

import de.aservo.confapi.crowd.rest.api.MailTemplateResource;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@Data
@NoArgsConstructor
@XmlRootElement(name = MailTemplateResource.MAIL_TEMPLATES)
public class MailTemplatesBean {

@XmlElement
private String forgottenPassword;

@XmlElement
private String forgottenUsername;

@XmlElement
private String passwordExpirationReminder;

@XmlElement
private String emailChangeValidation;

@XmlElement
private String emailChangeInfo;

public static final MailTemplatesBean EXAMPLE_1;
public static final MailTemplatesBean EXAMPLE_2;

static {
EXAMPLE_1 = new MailTemplatesBean();
EXAMPLE_1.setForgottenPassword("Example1ForgottenPassword");
EXAMPLE_1.setForgottenUsername("Example1ForgottenUsername");
EXAMPLE_1.setPasswordExpirationReminder("Example1PasswordExpirationReminder");
EXAMPLE_1.setEmailChangeValidation("Example1ValidationMessage");
EXAMPLE_1.setEmailChangeInfo("Example1EmailChangeMessage");
}

static {
EXAMPLE_2 = new MailTemplatesBean();
EXAMPLE_2.setForgottenPassword("Example2ForgottenPassword");
EXAMPLE_2.setForgottenUsername("Example2ForgottenUsername");
EXAMPLE_2.setPasswordExpirationReminder("Example2PasswordExpirationReminder");
EXAMPLE_2.setEmailChangeValidation("Example2ValidationMessage");
EXAMPLE_2.setEmailChangeInfo("Example2EmailChangeMessage");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package de.aservo.confapi.crowd.rest;

import com.sun.jersey.spi.container.ResourceFilters;
import de.aservo.confapi.crowd.filter.SysadminOnlyResourceFilter;
import de.aservo.confapi.crowd.model.MailTemplatesBean;
import de.aservo.confapi.crowd.rest.api.MailTemplateResource;
import de.aservo.confapi.crowd.service.api.MailTemplatesService;
import org.springframework.stereotype.Component;

import javax.inject.Inject;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;

@Path(MailTemplateResource.MAIL_TEMPLATES)
@ResourceFilters(SysadminOnlyResourceFilter.class)
@Component
public class MailTemplatesResourceImpl implements MailTemplateResource {

private final MailTemplatesService mailTemplatesService;

@Inject
public MailTemplatesResourceImpl(
final MailTemplatesService mailTemplatesService) {

this.mailTemplatesService = mailTemplatesService;
}

@Override
public Response getMailTemplates() {
return Response.ok(mailTemplatesService.getMailTemplates()).build();
}

@Override
public Response setMailTemplates(
final MailTemplatesBean mailTemplatesBean) {

return Response.ok(mailTemplatesService.setMailTemplates(mailTemplatesBean)).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package de.aservo.confapi.crowd.rest.api;

import de.aservo.confapi.commons.model.ErrorCollection;
import de.aservo.confapi.crowd.model.MailTemplatesBean;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

public interface MailTemplateResource {

static final String MAIL_TEMPLATES = "mail-templates";

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path(MAIL_TEMPLATES)
@Operation(
tags = {MAIL_TEMPLATES},
summary = "Get the mail templates",
responses = {
@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = MailTemplatesBean.class))),
@ApiResponse(responseCode = "default", content = @Content(schema = @Schema(implementation = ErrorCollection.class)))
}
)
Response getMailTemplates();

@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path(MAIL_TEMPLATES)
@Operation(
tags = {MAIL_TEMPLATES},
summary = "Set the mail templates",
responses = {
@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = MailTemplatesBean.class))),
@ApiResponse(responseCode = "default", content = @Content(schema = @Schema(implementation = ErrorCollection.class)))
}
)
Response setMailTemplates(
MailTemplatesBean mailTemplatesBean);

}
Loading

0 comments on commit 892031e

Please sign in to comment.