@@ -648,28 +648,58 @@ public static void updateFilenameProperty(
648648 }
649649 }
650650
651+ // public static void updateDescriptionProperty(
652+ // String descriptionInDB,
653+ // String descriptionInRequest,
654+ // String descriptionInSDM,
655+ // Map<String, String> updatedSecondaryProperties,
656+ // Boolean isUpdate)
657+ // throws ServiceException {
658+ // if (descriptionInRequest == null) {
659+ // descriptionInRequest = "";
660+ // }
661+ // if (descriptionInDB == null
662+ // && isUpdate) { // Attachment did not contain description and is being updated now
663+ // updatedSecondaryProperties.put("description", descriptionInRequest);
664+ // } else if (descriptionInDB
665+ // == null) { // Attachment contained description during upload and it was changed before
666+ // // saving or description was added before save handler (create) was called
667+ // if (!(descriptionInRequest.equals(descriptionInSDM))) {
668+ // updatedSecondaryProperties.put("description", descriptionInRequest);
669+ // }
670+ // } else if (!(descriptionInDB.equals(
671+ // descriptionInRequest))) { // Attachment contained description and is being updated now
672+ // updatedSecondaryProperties.put("description", descriptionInRequest);
673+ // }
674+ // }
675+
651676 public static void updateDescriptionProperty (
652677 String descriptionInDB ,
653678 String descriptionInRequest ,
654679 String descriptionInSDM ,
655680 Map <String , String > updatedSecondaryProperties ,
656681 Boolean isUpdate )
657682 throws ServiceException {
658- if (descriptionInRequest == null ) {
659- descriptionInRequest = "" ;
660- }
683+ // Normalize null to empty string for comparison
684+ String normalizedRequest = descriptionInRequest == null ? "" : descriptionInRequest ;
685+ String normalizedDB = descriptionInDB == null ? "" : descriptionInDB ;
686+ String normalizedSDM = descriptionInSDM == null ? "" : descriptionInSDM ;
687+
661688 if (descriptionInDB == null
662689 && isUpdate ) { // Attachment did not contain description and is being updated now
663- updatedSecondaryProperties .put ("description" , descriptionInRequest );
690+ // Only update if the request actually has a value different from what's in SDM
691+ if (!normalizedRequest .isEmpty () && !normalizedRequest .equals (normalizedSDM )) {
692+ updatedSecondaryProperties .put ("description" , normalizedRequest );
693+ }
664694 } else if (descriptionInDB
665695 == null ) { // Attachment contained description during upload and it was changed before
666696 // saving or description was added before save handler (create) was called
667- if (!( descriptionInRequest .equals (descriptionInSDM ) )) {
668- updatedSecondaryProperties .put ("description" , descriptionInRequest );
697+ if (!normalizedRequest .equals (normalizedSDM )) {
698+ updatedSecondaryProperties .put ("description" , normalizedRequest );
669699 }
670- } else if (!( descriptionInDB .equals (
671- descriptionInRequest ) )) { // Attachment contained description and is being updated now
672- updatedSecondaryProperties .put ("description" , descriptionInRequest );
700+ } else if (!normalizedDB .equals (
701+ normalizedRequest )) { // Attachment contained description and is being updated now
702+ updatedSecondaryProperties .put ("description" , normalizedRequest );
673703 }
674704 }
675705
0 commit comments