Remove unused fileName and resourceId from ContentRepository deleteFile() & deleteImage() (FINERACT-1201)

This commit is contained in:
Michael Vorburger
2020-11-19 10:25:32 +01:00
committed by Percy Enoabane
parent bf0c7e240f
commit 3e1444a6e4
5 changed files with 21 additions and 21 deletions
@@ -26,6 +26,9 @@ import org.apache.fineract.infrastructure.documentmanagement.data.FileData;
import org.apache.fineract.infrastructure.documentmanagement.data.ImageData;
import org.apache.fineract.infrastructure.documentmanagement.domain.StorageType;
/**
* Repository which stores Files (AKA Documents) and Images.
*/
public interface ContentRepository {
// TODO:Vishwas Need to move these settings to the Database
@@ -36,7 +39,7 @@ public interface ContentRepository {
String saveFile(InputStream uploadedInputStream, DocumentCommand documentCommand);
void deleteFile(String fileName, String documentPath);
void deleteFile(String documentPath);
FileData fetchFile(DocumentData documentData);
@@ -44,7 +47,7 @@ public interface ContentRepository {
String saveImage(Base64EncodedImage base64EncodedImage, Long resourceId, String imageName);
void deleteImage(Long resourceId, String location);
void deleteImage(String location);
ImageData fetchImage(ImageData imageData);
@@ -78,25 +78,22 @@ public class FileSystemContentRepository implements ContentRepository {
}
@Override
public void deleteImage(final Long resourceId, final String location) {
final boolean fileDeleted = deleteFile(location);
if (!fileDeleted) {
// no need to throw an Error, simply log a warning
LOG.warn("Unable to delete image associated with clients with Id {}", resourceId);
}
public void deleteImage(final String location) {
deleteFileInternal(location);
}
@Override
public void deleteFile(final String fileName, final String documentPath) {
final boolean fileDeleted = deleteFile(documentPath);
if (!fileDeleted) {
throw new ContentManagementException(fileName, null);
}
public void deleteFile(final String documentPath) {
deleteFileInternal(documentPath);
}
private boolean deleteFile(final String documentPath) {
private void deleteFileInternal(final String documentPath) {
final File fileToBeDeleted = new File(documentPath);
return fileToBeDeleted.delete();
final boolean fileDeleted = fileToBeDeleted.delete();
if (!fileDeleted) {
// no need to throw an Error, what's a caller going to do about it, so simply log a warning
LOG.warn("Unable to delete file {}", documentPath);
}
}
@Override
@@ -73,7 +73,7 @@ public class S3ContentRepository implements ContentRepository {
}
@Override
public void deleteFile(final String documentName, final String documentPath) {
public void deleteFile(final String documentPath) {
deleteObject(documentPath);
}
@@ -99,7 +99,7 @@ public class S3ContentRepository implements ContentRepository {
}
@Override
public void deleteImage(final Long resourceId, final String location) {
public void deleteImage(final String location) {
deleteObject(location);
}
@@ -128,7 +128,7 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements DocumentWr
if (inputStream != null && documentCommand.isFileNameChanged()) {
final ContentRepository contentRepository = this.contentRepositoryFactory.getRepository(documentStoreType);
contentRepository.deleteFile(documentCommand.getName(), oldLocation);
contentRepository.deleteFile(oldLocation);
}
this.documentRepository.saveAndFlush(documentForUpdate);
@@ -157,7 +157,7 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements DocumentWr
this.documentRepository.delete(document);
final ContentRepository contentRepository = this.contentRepositoryFactory.getRepository(document.storageType());
contentRepository.deleteFile(document.getName(), document.getLocation());
contentRepository.deleteFile(document.getLocation());
return new CommandProcessingResult(document.getId());
}
@@ -99,7 +99,7 @@ public class ImageWritePlatformServiceJpaRepositoryImpl implements ImageWritePla
if (image != null) {
final ContentRepository contentRepository = this.contentRepositoryFactory
.getRepository(StorageType.fromInt(image.getStorageType()));
contentRepository.deleteImage(clientId, image.getLocation());
contentRepository.deleteImage(image.getLocation());
this.imageRepository.delete(image);
}
@@ -126,7 +126,7 @@ public class ImageWritePlatformServiceJpaRepositoryImpl implements ImageWritePla
if (image != null) {
final ContentRepository contentRepository = this.contentRepositoryFactory
.getRepository(StorageType.fromInt(image.getStorageType()));
contentRepository.deleteImage(entityId, image.getLocation());
contentRepository.deleteImage(image.getLocation());
}
return owner;
}