Minor fixes to detect empty file updates
This commit is contained in:
+1
-1
@@ -167,7 +167,7 @@ public class DocumentManagementApiResource {
|
||||
* passed in as a part of the update
|
||||
***/
|
||||
DocumentCommand documentCommand = null;
|
||||
if (inputStream != null) {
|
||||
if (inputStream != null && fileDetails.getFileName() != null) {
|
||||
modifiedParams.add("fileName");
|
||||
modifiedParams.add("size");
|
||||
modifiedParams.add("type");
|
||||
|
||||
-4
@@ -31,8 +31,6 @@ public class DocumentCommandValidator {
|
||||
.notExceedingLengthOf(250);
|
||||
baseDataValidator.reset().parameter("location")
|
||||
.value(command.getLocation()).ignoreIfNull().notBlank();
|
||||
baseDataValidator.reset().parameter("type").value(command.getName())
|
||||
.ignoreIfNull().notBlank().notExceedingLengthOf(250);
|
||||
baseDataValidator.reset().parameter("description")
|
||||
.value(command.getName()).ignoreIfNull()
|
||||
.notExceedingLengthOf(250);
|
||||
@@ -65,8 +63,6 @@ public class DocumentCommandValidator {
|
||||
baseDataValidator.reset().parameter("fileName")
|
||||
.value(command.getFileName()).notBlank()
|
||||
.notExceedingLengthOf(250);
|
||||
baseDataValidator.reset().parameter("type").value(command.getName())
|
||||
.notBlank().notExceedingLengthOf(250);
|
||||
baseDataValidator.reset().parameter("description")
|
||||
.value(command.getName()).notExceedingLengthOf(250);
|
||||
|
||||
|
||||
+2
-3
@@ -124,7 +124,7 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements
|
||||
}
|
||||
oldLocation = documentForUpdate.getLocation();
|
||||
// if a new file is also passed in
|
||||
if (inputStream != null) {
|
||||
if (inputStream != null && documentCommand.isFileNameChanged()) {
|
||||
String fileUploadLocation = FileUtils
|
||||
.generateFileParentDirectory(
|
||||
documentCommand.getParentEntityType(),
|
||||
@@ -136,7 +136,6 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements
|
||||
}
|
||||
|
||||
// TODO replace file system appender with an Amazon S3 appender
|
||||
// TODO delete the file at the previous location
|
||||
String fileLocation = FileUtils.saveToFileSystem(inputStream,
|
||||
fileUploadLocation, documentCommand.getFileName());
|
||||
documentCommand.setLocation(fileLocation);
|
||||
@@ -144,7 +143,7 @@ public class DocumentWritePlatformServiceJpaRepositoryImpl implements
|
||||
|
||||
documentForUpdate.update(documentCommand);
|
||||
|
||||
if (inputStream != null) {
|
||||
if (inputStream != null && documentCommand.isFileNameChanged()) {
|
||||
// delete previous file
|
||||
deleteFile(documentCommand.getName(), oldLocation);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user