Session login and logout fixes

This commit is contained in:
Gopi Katwala 2019-06-08 09:11:02 -04:00
parent ae84433801
commit cc8e8f5feb
2 changed files with 18 additions and 11 deletions

View File

@ -25,18 +25,19 @@ public class CustomerContactResource {
}
@GET
public Response getCustomerContacts(@QueryParam("customerId") String customerId)
public Response getCustomerContacts(@QueryParam("sessionId") String sessionId, @QueryParam("customerId") String customerId)
throws AstuteException {
// TODO , @QueryParam("sessionId") String sessionId
// authService.getUser(sessionId);
authService.authenticateSession(sessionId);
return new ApiResponse(service.getCustomerContacts(customerId)).toResponse();
}
@Path("/{customerId}")
@PUT
public Response updateCustomerContact(@PathParam("customerId") String customerId, CustomerContactRequest request)
public Response updateCustomerContact(@QueryParam("sessionId") String sessionId, @PathParam("customerId") String customerId, CustomerContactRequest request)
throws AstuteException {
System.out.println("in updateCustomerContact()");
authService.authenticateSession(sessionId);
service.updateCustomerContact(customerId, request.getContactId(), request.getName(), request.getTitle(), request.getWorkPhone(),
request.getPhExt(), request.getMobile(), request.getFax(), request.getEmail(), request.getAddress());
return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse();
@ -44,17 +45,19 @@ public class CustomerContactResource {
@Path("/{customerId}/{contactId}/delete")
@PUT
public Response deleteCustomerContact(@PathParam("customerId") String customerId, @PathParam("contactId") int contactId)
public Response deleteCustomerContact(@QueryParam("sessionId") String sessionId, @PathParam("customerId") String customerId, @PathParam("contactId") int contactId)
throws AstuteException {
System.out.println("in deleteCustomerContact()");
authService.authenticateSession(sessionId);
service.deleteCustomerContact(customerId, contactId);
return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse();
}
@POST
public Response createCustomerContact(CustomerContactRequest request)
public Response createCustomerContact(@QueryParam("sessionId") String sessionId, CustomerContactRequest request)
throws AstuteException {
System.out.println("in AstuteSyste CustomerContactRequest()");
authService.authenticateSession(sessionId);
service.createCustomerContact(request.getCustomerId(), request.getName(), request.getTitle(), request.getWorkPhone(),
request.getPhExt(), request.getMobile(), request.getFax(), request.getEmail(), request.getAddress());
return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse();

View File

@ -23,25 +23,27 @@ public class CustomerResource {
}
@GET
public Response getCustomers(@QueryParam("customerId") String customerId)
public Response getCustomers(@QueryParam("sessionId") String sessionId, @QueryParam("customerId") String customerId)
throws AstuteException {
// TODO , @QueryParam("sessionId") String sessionId
// authService.getUser(sessionId);
authService.authenticateSession(sessionId);
return new ApiResponse(service.getCustomers(customerId)).toResponse();
}
@Path("/{poNumber}")
@GET
public Response getCustomer(@PathParam("poNumber") String poNumber)
public Response getCustomer(@QueryParam("sessionId") String sessionId, @PathParam("poNumber") String poNumber)
throws AstuteException {
authService.authenticateSession(sessionId);
return new ApiResponse(service.getCustomer(poNumber)).toResponse();
}
@Path("/{customerId}")
@PUT
public Response updateCustomer(@PathParam("customerId") String customerId, CustomerRequest request)
public Response updateCustomer(@QueryParam("sessionId") String sessionId, @PathParam("customerId") String customerId, CustomerRequest request)
throws AstuteException {
System.out.println("in updateCustomer()");
authService.authenticateSession(sessionId);
service.updateCustomer(customerId, request.getCustomerName(), request.getBillToDept(), request.getAdd1(),
request.getAdd2(), request.getCity(), request.getState(), request.getZip(), request.getZiplast4(), request.getEmail(), request.getPhone(), request.getPhExt(), request.getFax());
return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse();
@ -49,17 +51,19 @@ public class CustomerResource {
@Path("/{customerId}/delete")
@PUT
public Response deleteCustomer(@PathParam("customerId") String customerId)
public Response deleteCustomer(@QueryParam("sessionId") String sessionId, @PathParam("customerId") String customerId)
throws AstuteException {
System.out.println("in deleteCustomer()");
authService.authenticateSession(sessionId);
service.deleteCustomer(customerId);
return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse();
}
@POST
public Response createCustomer(CustomerRequest request)
public Response createCustomer(@QueryParam("sessionId") String sessionId, CustomerRequest request)
throws AstuteException {
System.out.println("in AstuteSyste createCustomer()");
authService.authenticateSession(sessionId);
return new ApiResponse(service.createCustomer(request.getCustomerId(), request.getCustomerName(), request.getBillToDept(), request.getAdd1(),
request.getAdd2(), request.getCity(), request.getState(), request.getZip(), request.getZiplast4(), request.getEmail(), request.getPhone(), request.getPhExt(), request.getFax())).toResponse();
}