@@ -618,10 +618,10 @@ public static List<String> fetchAttachmentDataFromSDM(
618618 * @throws ServiceException if filename validation fails
619619 */
620620 public static void updateFilenameProperty (
621- String fileNameInDB , String filenameInRequest , Map <String , String > updatedSecondaryProperties )
621+ String fileNameInDB , String filenameInRequest , String fileNameInSDM , Map <String , String > updatedSecondaryProperties )
622622 throws ServiceException {
623623 if (fileNameInDB == null ) {
624- if (filenameInRequest != null ) {
624+ if (filenameInRequest != null && ( filenameInRequest != fileNameInSDM ) ) {
625625 updatedSecondaryProperties .put ("filename" , filenameInRequest );
626626 } else {
627627 throw new ServiceException ("Filename cannot be empty" );
@@ -635,25 +635,19 @@ public static void updateFilenameProperty(
635635 }
636636 }
637637
638- /**
639- * Updates the description property in the secondary properties map if needed.
640- *
641- * @param descriptionInDB the description currently in the database
642- * @param descriptionInRequest the description from the request
643- * @param updatedSecondaryProperties the map to update
644- */
645638 public static void updateDescriptionProperty (
646- String descriptionInDB ,
647- String descriptionInRequest ,
648- Map <String , String > updatedSecondaryProperties ) {
649- if (descriptionInDB == null ) {
639+ String descriptionInDB , String descriptionInRequest , String descriptionInSDM , Map <String , String > updatedSecondaryProperties , Boolean isUpdate )
640+ throws ServiceException {
641+ if (descriptionInDB == null && isUpdate ) { // Attachment did not contain description and is being updated now
650642 if (descriptionInRequest != null ) {
651643 updatedSecondaryProperties .put ("description" , descriptionInRequest );
652644 }
653- } else {
654- if (descriptionInRequest != null && ! descriptionInDB . equals ( descriptionInRequest )) {
645+ } else if ( descriptionInDB == null && ! isUpdate ) { // Attachment contained description during upload and it was changed before saving or description was added before save handler (create) was called
646+ if (( descriptionInRequest != descriptionInSDM )) {
655647 updatedSecondaryProperties .put ("description" , descriptionInRequest );
656648 }
649+ } else if ((descriptionInDB != null ) && (descriptionInDB != descriptionInRequest )) { // Attachment contained description and is being updated now
650+ updatedSecondaryProperties .put ("description" , descriptionInRequest );
657651 }
658652 }
659653
0 commit comments