src/main/java/za/co/grindrodbank/dokuti/document/DocumentServiceImpl.java
private DocumentVersionEntity createDocumentVersionWithFile(MultipartFile file, DocumentEntity document) {
	    String defaultChecksumAlgo = "SHA-256";
	    
		String fileContentChecksum = "";
		String documentType ="";

		try {
			fileContentChecksum = getFileContentChecksum(file.getBytes(), defaultChecksumAlgo);
		} catch (IOException e) {
			logger.error(e.getMessage());
		}

		Tika tika = new Tika();
		try {
		    documentType = tika.detect(file.getInputStream());
        } catch (IOException e) {
            logger.error(e.getMessage());
            throw new ResourceNotFoundException("Error reading document data.", e);
        }
		
		DocumentVersionEntity newDocumentVersion = documentVersionService.createDocumentVersion(document,
				fileContentChecksum, defaultChecksumAlgo, documentType);
		documentStoreService.store(file, newDocumentVersion.getChecksum());

		return newDocumentVersion;
	}
/**
	 * Create a new document version record for a given document by storing the
	 * latest file version and creating the required database records for the new
	 * version.
	 * 
	 * @param file     The Multi-part representation of the file to create a new
	 *                 versions for
	 * @param document An instance of the document to create the new version for.
	 * @return The new document version that was created for the document.
	 */
Create a new document version record for a given document by storing the
latest file version and creating the required database records for the new
version.

@param file     The Multi-part representation of the file to create a new
versions for
@param document An instance of the document to create the new version for.
@return The new document version that was created for the document.
Create a new document version record for a given document by storing the latest file version and creating the required database records for the new version . @param file The Multi - part representation of the file to create a new versions for @param document An instance of the document to create the new version for . @return The new document version that was created for the document .
private DocumentVersionEntity createDocumentVersionWithFile(MultipartFile file, DocumentEntity document) {
	    String defaultChecksumAlgo = "SHA-256";
		String fileContentChecksum = "";
		String documentType ="";
		try {
			fileContentChecksum = getFileContentChecksum(file.getBytes(), defaultChecksumAlgo);
		} catch (IOException e) {
			logger.error(e.getMessage());
		}
		Tika tika = new Tika();
		try {
		    documentType = tika.detect(file.getInputStream());
        } catch (IOException e) {
            logger.error(e.getMessage());
            throw new ResourceNotFoundException("Error reading document data.", e);
        }
		DocumentVersionEntity newDocumentVersion = documentVersionService.createDocumentVersion(document,
				fileContentChecksum, defaultChecksumAlgo, documentType);
		documentStoreService.store(file, newDocumentVersion.getChecksum());
		return newDocumentVersion;
	}
private DocumentVersionEntity createDocumentVersionWithFile ( MultipartFile file , DocumentEntity document ) { String defaultChecksumAlgo = "SHA-256" ; String fileContentChecksum = "" ; String documentType = "" ; try { fileContentChecksum = getFileContentChecksum ( file . getBytes ( ) , defaultChecksumAlgo ) ; } catch ( IOException e ) { logger . error ( e . getMessage ( ) ) ; } Tika tika = new Tika ( ) ; try { documentType = tika . detect ( file . getInputStream ( ) ) ; } catch ( IOException e ) { logger . error ( e . getMessage ( ) ) ; throw new ResourceNotFoundException ( "Error reading document data." , e ) ; } DocumentVersionEntity newDocumentVersion = documentVersionService . createDocumentVersion ( document , fileContentChecksum , defaultChecksumAlgo , documentType ) ; documentStoreService . store ( file , newDocumentVersion . getChecksum ( ) ) ; return newDocumentVersion ; }
Create a new document version record for a given document by storing the
 latest file version and creating the required database records for the new
 version.
Create a new document version record for a given document by storing the latest file version and creating the required database records for the new version .