test RESt API

This commit is contained in:
Peter Hormanns 2021-10-27 19:28:39 +02:00
parent 71ff5dcd2b
commit ef637b1b85

View File

@ -2,7 +2,7 @@ package de.hsadmin.rest.customer;
import java.util.List;
import javax.ejb.EJB;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
@ -10,30 +10,30 @@ 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.LoginServiceLocal;
import de.hsadmin.login.RequestContext;
import de.hsadmin.service.customer.ContactService;
import de.hsadmin.service.customer.ContactServiceLocal;
import de.hsadmin.service.customer.ContactVO;
@Path("/contacts")
public class ContactsAPI {
@EJB
LoginService login;
@Inject
LoginServiceLocal loginEJB;
@EJB
ContactService ejb;
@Inject
ContactServiceLocal contactEJB;
@GET
@Path("/{customer}")
public List<ContactVO> getContactsByMember(@PathParam("customer") String customer, @HeaderParam("X-HS-Auth") String ticket) throws UserException, TechnicalException {
System.out.println("customer: " + customer);
System.out.println("ticket: " + ticket);
System.out.println("LoginService: " + login);
RequestContext context = login.createContext(ticket, null);
System.out.println("LoginService: " + loginEJB);
RequestContext context = loginEJB.createContext(ticket.trim(), "");
ContactVO vo = new ContactVO();
vo.setCustomer(customer);
List<ContactVO> list = ejb.read(context, vo);
List<ContactVO> list = contactEJB.read(context, vo);
return list;
}