Beispiel #1
0
 @DELETE
 @Path("{userId}/addresses/{addressId}")
 public Response deleteAddress(
     @PathParam("userId") String userId, @PathParam("addressId") String addressId) {
   addressDao.deleteAddress(addressId, userId);
   return Response.ok().build();
 }
Beispiel #2
0
 @GET
 @Path("{userId}/addresses/{addressId}")
 public Response getAddress(
     @PathParam("userId") String userId, @PathParam("addressId") String addressId) {
   // TODO: validate user and address existing
   Address address = addressDao.getAddress(addressId);
   com.campusconnect.neo4j.types.web.Address returnAddress = mapAddressNeo4jToWeb(address);
   return Response.ok().entity(returnAddress).build();
 }
Beispiel #3
0
 @PUT
 @Path("{userId}/addresses/{addressId}")
 public Response updateAddress(
     @PathParam("userId") String userId,
     @PathParam("addressId") String addressId,
     com.campusconnect.neo4j.types.web.Address addressPayload) {
   // TODO: validate the address before updating
   Address address = mapAddressWebToNeo4j(addressPayload);
   Address updatedAddress = addressDao.updateAddress(address, userId);
   com.campusconnect.neo4j.types.web.Address returnAddress = mapAddressNeo4jToWeb(updatedAddress);
   return Response.ok().entity(returnAddress).build();
 }
Beispiel #4
0
 @GET
 @Path("{userId}/addresses")
 public Response getAddress(@PathParam("userId") final String userId) {
   List<Address> addresses = addressDao.getAddresses(userId);
   List<com.campusconnect.neo4j.types.web.Address> returnAddress =
       new ArrayList<>(addresses.size());
   for (Address address : addresses) {
     returnAddress.add(mapAddressNeo4jToWeb(address));
   }
   AddressesPage addressesPage = new AddressesPage(returnAddress.size(), 0, returnAddress);
   return Response.ok().entity(addressesPage).build();
 }
Beispiel #5
0
  @POST
  @Path("{userId}/addresses")
  public Response addAddress(
      @PathParam("userId") String userId,
      com.campusconnect.neo4j.types.web.Address addressPayload) {
    Address address = mapAddressWebToNeo4j(addressPayload);
    User user = userDao.getUser(userId);
    // create new address
    Address createdAddress = addressDao.createAddress(address, userId);
    // Link to user
    userDao.addAddressToUser(createdAddress, user);

    com.campusconnect.neo4j.types.web.Address returnAddress = mapAddressNeo4jToWeb(createdAddress);
    return Response.ok().entity(returnAddress).build();
  }