-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement endpoint for mail templates
- Loading branch information
Showing
8 changed files
with
569 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/de/aservo/confapi/crowd/model/MailTemplatesBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/de/aservo/confapi/crowd/rest/MailTemplatesResourceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/de/aservo/confapi/crowd/rest/api/MailTemplateResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} |
Oops, something went wrong.