/** {@inheritDoc} */
  @GET
  @Path("/patron")
  @TypeHint(Patron.class)
  @Override
  public Response getCardInformation(
      @QueryParam("personId") String personId,
      @QueryParam("byuId") String byuId,
      @QueryParam("ssn") String ssn,
      @QueryParam("netId") String netId,
      @QueryParam("proxId") String proxId) {
    Patron patron = null;
    try {
      if (personId != null && personId.length() == 9) {
        patron = cardManager.getPatronByPersonId(personId);
      } else if (byuId != null) {
        patron = cardManager.getPatronByByuId(byuId);
      } else if (ssn != null) {
        patron = cardManager.getPatronBySSN(ssn);
      } else if (netId != null) {
        patron = cardManager.getPatronByNetId(netId);
      } else if (proxId != null) {
        patron = cardManager.getPatronByProxId(proxId);
      }
    } catch (IllegalArgumentException iae) {
      return Response.status(Response.Status.NOT_FOUND).entity(iae.getMessage()).build();
    }

    return Response.ok().entity(patron).build();
  }
  /** {@inheritDoc} */
  @POST
  @Path("/picture/{personId}")
  @Consumes("image/jpeg")
  public Response uploadImage(@PathParam("personId") String personId, InputStream inputStream)
      throws IOException {
    String destinationPath = PICTURE_BASE_PATH + personId + ".jpg";

    try {
      int read;
      byte[] bytes = new byte[1024];

      new File(destinationPath).delete();

      FileOutputStream out = new FileOutputStream(destinationPath, false);
      while ((read = inputStream.read(bytes)) > 0) {
        out.write(bytes, 0, read);
      }
      inputStream.close();
      out.flush();
      out.close();
      cardManager.updateImage(personId);
    } catch (IOException e) {
      return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e).build();
    }
    return Response.ok().build();
  }
 /** {@inheritDoc} */
 @DELETE
 @Path("/note/{noteId}")
 @Override
 public Response archiveNote(@PathParam("noteId") int noteId) {
   cardManager.archiveNote(noteId);
   return Response.ok().build();
 }
 @GET
 @Path("/LoggedinUserGroups")
 @Override
 public Response getGroupsLoggedinUser() {
   UserGroups userGroups = cardManager.getLoggedUsersGroups();
   // cardManager.getLoggedUsersGroups();
   return Response.ok().entity(userGroups).build();
   // return Response.ok().build();
 }
 @PUT
 @Path("/note/{noteId}")
 @Consumes(MediaType.APPLICATION_XML)
 @Override
 public Response updateNote(@PathParam("noteId") Integer noteId, Note note) {
   if (noteId == note.getNoteId()) {
     cardManager.updateNote(note);
   } else {
     return Response.status(Response.Status.BAD_REQUEST).build();
   }
   return Response.ok(note).build();
 }
  /** {@inheritDoc} */
  @POST
  @Path("/patron")
  @TypeHint(Patron.class)
  @Override
  public Response printCard(Cardstock cardstock) {
    boolean isNewCard = true;
    if (cardstock.getNewCard() != null && cardstock.getNewCard().equals("N")) {
      isNewCard = false;
    }
    cardManager.printCard(cardstock);

    Patron patron = null;
    try {
      if (cardstock.getPersonID() != null && cardstock.getPersonID().length() == 9) {
        patron = cardManager.getPatronByPersonId(cardstock.getPersonID());
      }
    } catch (IllegalArgumentException iae) {
      return Response.status(Response.Status.NOT_FOUND).entity(iae.getMessage()).build();
    }

    return Response.ok().entity(patron).build();
  }
 /** {@inheritDoc} */
 @POST
 @Path("/note")
 @Consumes(MediaType.APPLICATION_XML)
 @TypeHint(Note.class)
 @Override
 public Response addNote(Note note) {
   IdCardNote newNote;
   Note savedNote;
   try {
     newNote = cardManager.addNote(note);
     savedNote = Note.createNote(newNote);
   } catch (IllegalArgumentException e) {
     return Response.status(Response.Status.BAD_REQUEST).entity(e.getMessage()).build();
   }
   return Response.ok().entity(savedNote).build();
 }
 @POST
 @Path("/proxid")
 @Override
 @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
 public Response setProxId(
     @FormParam("cardid") String byuId,
     @FormParam("issuenumber") String issueNumber,
     @FormParam("facilityid") String facilityId,
     @FormParam("proxid") String proxId) {
   LOG.info("cardid = " + byuId);
   LOG.info("issuenumber = " + issueNumber);
   LOG.info("facilityid = " + facilityId);
   LOG.info("proxid = " + proxId);
   LOG.info("facilityid = " + facilityId);
   cardManager.updateProxId(byuId, proxId, facilityId);
   return Response.ok().build();
 }
 /** {@inheritDoc} */
 @GET
 @Path("/newCard")
 @Override
 @TypeHint(IdCard.class)
 public Response getNewCard(
     @QueryParam("personId") String personId,
     @QueryParam("byuId") String byuId,
     @QueryParam("ssn") String ssn,
     @QueryParam("netId") String netId,
     @QueryParam("proxId") String proxId) {
   IdCard newCard;
   try {
     newCard = cardManager.getNewCard(personId, byuId, ssn, netId);
   } catch (IllegalArgumentException iae) {
     return Response.status(Response.Status.BAD_REQUEST).entity(iae.getMessage()).build();
   }
   return Response.ok().entity(newCard).build();
 }