From 19422f382798ef361ace99782851094121912db5 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Tue, 14 Sep 2021 18:36:51 +0200 Subject: [PATCH] build first rest api --- .../de/hsadmin/rest/customer/ContactsAPI.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 cust-services/src/main/java/de/hsadmin/rest/customer/ContactsAPI.java diff --git a/cust-services/src/main/java/de/hsadmin/rest/customer/ContactsAPI.java b/cust-services/src/main/java/de/hsadmin/rest/customer/ContactsAPI.java new file mode 100644 index 0000000..220aaba --- /dev/null +++ b/cust-services/src/main/java/de/hsadmin/rest/customer/ContactsAPI.java @@ -0,0 +1,38 @@ +package de.hsadmin.rest.customer; + +import java.util.List; + +import javax.inject.Inject; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; + +import de.hsadmin.common.error.TechnicalException; +import de.hsadmin.common.error.UserException; +import de.hsadmin.login.LoginService; +import de.hsadmin.login.RequestContext; +import de.hsadmin.service.customer.ContactService; +import de.hsadmin.service.customer.ContactVO; + +@Path("/contacts") +public class ContactsAPI { + + @Inject + LoginService login; + + @Inject + ContactService ejb; + + @GET + @Path("/{customer}") + public List getContactsByMember(@PathParam("customer") String customer, @HeaderParam("Authorization") String ticket) throws UserException, TechnicalException { + RequestContext context = login.createContext(ticket, null); + ContactVO vo = new ContactVO(); + vo.setCustomer(customer); + List list = ejb.read(context, vo); + return list; + } + +} +