public void addCopies(Set<BookCopy> bookCopiesSet) throws BookStoreException {
    int ISBN, numCopies;

    if (bookCopiesSet == null) {
      throw new BookStoreException(BookStoreConstants.NULL_INPUT);
    }
    try {
      bsLock.updateLock().lock();
      for (BookCopy bookCopy : bookCopiesSet) {
        ISBN = bookCopy.getISBN();
        numCopies = bookCopy.getNumCopies();
        if (BookStoreUtility.isInvalidISBN(ISBN))
          throw new BookStoreException(BookStoreConstants.ISBN + ISBN + BookStoreConstants.INVALID);
        if (!bookMap.containsKey(ISBN))
          throw new BookStoreException(BookStoreConstants.ISBN + ISBN + BookStoreConstants.INVALID);
        if (BookStoreUtility.isInvalidNoCopies(numCopies))
          throw new BookStoreException(
              BookStoreConstants.NUM_COPIES + numCopies + BookStoreConstants.INVALID);
      }
      bsLock.writeLock().lock();
      BookStoreBook book;
      // Update the number of copies
      for (BookCopy bookCopy : bookCopiesSet) {
        ISBN = bookCopy.getISBN();
        numCopies = bookCopy.getNumCopies();
        book = bookMap.get(ISBN);
        book.addCopies(numCopies);
      }

    } finally {
      bsLock.writeLock().unlock();
      bsLock.updateLock().unlock();
    }
  }
  public void addBooks(Set<StockBook> bookSet) throws BookStoreException {

    if (bookSet == null) {
      throw new BookStoreException(BookStoreConstants.NULL_INPUT);
    }
    try {
      // Check if all are there
      bsLock.updateLock().lock();
      for (StockBook book : bookSet) {
        int ISBN = book.getISBN();
        String bookTitle = book.getTitle();
        String bookAuthor = book.getAuthor();
        int noCopies = book.getNumCopies();
        float bookPrice = book.getPrice();
        if (BookStoreUtility.isInvalidISBN(ISBN)
            || BookStoreUtility.isEmpty(bookTitle)
            || BookStoreUtility.isEmpty(bookAuthor)
            || BookStoreUtility.isInvalidNoCopies(noCopies)
            || bookPrice < 0.0) {
          throw new BookStoreException(
              BookStoreConstants.BOOK + book.toString() + BookStoreConstants.INVALID);
        } else if (bookMap.containsKey(ISBN)) {
          throw new BookStoreException(
              BookStoreConstants.ISBN + ISBN + BookStoreConstants.DUPLICATED);
        }
      }
      bsLock.writeLock().lock();
      for (StockBook book : bookSet) {
        int ISBN = book.getISBN();
        bookMap.put(ISBN, new BookStoreBook(book));
      }
    } finally {
      bsLock.writeLock().unlock();
      bsLock.updateLock().unlock();
    }
    return;
  }