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