in sessions/next24/books-genai-vertex-springai/src/main/java/services/domain/BooksService.java [193:218]
public Integer insertPagesBook(BufferedReader reader, Integer bookId) {
Integer success = 0;
try {
String content;
Integer page = 1;
List<Map<String, Object>> pages = dao.findPages(bookId);
if(!pages.isEmpty()) {
return success;
}
char[] cbuf = new char[6000];
int charsRead;
while ((charsRead = reader.read(cbuf)) != -1) {
content = new String(cbuf, 0, charsRead);
dao.insertPages( bookId,content,page );
page++;
}
reader.close();
success=1;
}catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
return success;
}