private void deleteFile(String fileToDelete, String boClassName, Integer documentId) { if(fileToDelete == null || fileToDelete.length() == 0) return; boolean success = false; File file = new File(fileToDelete); if(file.exists()) success = file.delete(); if (!success) { DocumentsToBeDeletedVo deleteDocument = new DocumentsToBeDeletedVo(); deleteDocument.setFileName(fileToDelete); deleteDocument.setReferenceId(documentId); deleteDocument.setReferenceType(boClassName); deleteDocument.validate(); domain.saveToBeDeteled(deleteDocument); System.out.println("File '" + fileToDelete + "' was not successfully deleted !"); } }
public void saveToBeDeteled(DocumentsToBeDeletedVo document) { if(document == null) throw new CodingRuntimeException("Can not save a null DocumentsToBeDeletedVo."); if(!document.isValidated()) throw new CodingRuntimeException("DocumentsToBeDeletedVo not validated"); DomainFactory factory = getDomainFactory(); DocumentsToBeDeleted doDocument = DocumentsToBeDeletedVoAssembler.extractDocumentsToBeDeleted(factory, document); try { factory.save(doDocument); } catch (StaleObjectException e) { //should never happen } }
private void deleteFile(String fileToDelete, ValueObject linkedObject) { if (fileToDelete == null || fileToDelete.length() == 0) return; boolean success = false; File file = new File(fileToDelete); if (file.exists()) success = file.delete(); if (!success) { DocumentsToBeDeletedVo deleteDocument = new DocumentsToBeDeletedVo(); deleteDocument.setFileName(fileToDelete); if (linkedObject != null) { deleteDocument.setReferenceId(linkedObject.getBoId()); deleteDocument.setReferenceType(linkedObject.getBoClassName()); } deleteDocument.validate(); domain.saveToBeDeteled(deleteDocument); System.out.println("File '" + fileToDelete + "' was not successfully deleted !"); } }
public void saveToBeDeteled(DocumentsToBeDeletedVo document) { PatientDocumentSearch domImpl = (PatientDocumentSearch) getDomainImpl(PatientDocumentSearchImpl.class); domImpl.saveToBeDeteled(document); }