@@ -82,6 +82,7 @@ private void renameDocument(
8282 List <String > filesWithUnsupportedProperties = new ArrayList <>();
8383 Map <String , String > badRequest = new HashMap <>();
8484 Map <String , String > propertyTitles = new HashMap <>();
85+ List <String > fileWithWhiteSpace = new ArrayList <>();
8586 List <String > noSDMRoles = new ArrayList <>();
8687 for (Map <String , Object > entity : data ) {
8788 List <Map <String , Object >> attachments = (List <Map <String , Object >>) entity .get (composition );
@@ -109,7 +110,8 @@ private void renameDocument(
109110 filesWithUnsupportedProperties ,
110111 badRequest ,
111112 secondaryPropertiesWithInvalidDefinitions ,
112- noSDMRoles );
113+ noSDMRoles ,
114+ fileWithWhiteSpace );
113115 }
114116 }
115117 handleWarnings (
@@ -120,7 +122,8 @@ private void renameDocument(
120122 filesWithUnsupportedProperties ,
121123 badRequest ,
122124 propertyTitles ,
123- noSDMRoles );
125+ noSDMRoles ,
126+ fileWithWhiteSpace );
124127 }
125128
126129 private void processAttachments (
@@ -133,7 +136,8 @@ private void processAttachments(
133136 List <String > filesWithUnsupportedProperties ,
134137 Map <String , String > badRequest ,
135138 Map <String , String > secondaryPropertiesWithInvalidDefinitions ,
136- List <String > noSDMRoles )
139+ List <String > noSDMRoles ,
140+ List <String > fileWithWhiteSpace )
137141 throws IOException {
138142 Iterator <Map <String , Object >> iterator = attachments .iterator ();
139143 while (iterator .hasNext ()) {
@@ -148,7 +152,8 @@ private void processAttachments(
148152 filesWithUnsupportedProperties ,
149153 badRequest ,
150154 secondaryPropertiesWithInvalidDefinitions ,
151- noSDMRoles );
155+ noSDMRoles ,
156+ fileWithWhiteSpace );
152157 }
153158 SecondaryPropertiesKey secondaryPropertiesKey = new SecondaryPropertiesKey ();
154159 secondaryPropertiesKey .setRepositoryId (SDMConstants .REPOSITORY_ID );
@@ -168,7 +173,8 @@ public void processAttachment(
168173 List <String > filesWithUnsupportedProperties ,
169174 Map <String , String > badRequest ,
170175 Map <String , String > secondaryPropertiesWithInvalidDefinitions ,
171- List <String > noSDMRoles )
176+ List <String > noSDMRoles ,
177+ List <String > fileWithWhiteSpace )
172178 throws IOException {
173179 String id = (String ) attachment .get ("ID" );
174180 Map <String , String > secondaryTypeProperties =
@@ -222,8 +228,10 @@ public void processAttachment(
222228 throw new ServiceException ("Filename cannot be empty" );
223229 }
224230 } else {
225- if (filenameInRequest == null ) {
226- throw new ServiceException ("Filename cannot be empty" );
231+ if (filenameInRequest == null || filenameInRequest .trim ().length () == 0 ) {
232+ fileWithWhiteSpace .add (fileNameInDB );
233+ replacePropertiesInAttachment (
234+ attachment , fileNameInDB , propertiesInDB , secondaryTypeProperties );
227235 } else if (!fileNameInDB .equals (filenameInRequest )) {
228236 updatedSecondaryProperties .put ("filename" , filenameInRequest );
229237 }
@@ -313,7 +321,8 @@ private void handleWarnings(
313321 List <String > filesWithUnsupportedProperties ,
314322 Map <String , String > badRequest ,
315323 Map <String , String > propertyTitles ,
316- List <String > noSDMRoles ) {
324+ List <String > noSDMRoles ,
325+ List <String > fileWithWhiteSpace ) {
317326 if (!fileNameWithRestrictedCharacters .isEmpty ()) {
318327 context
319328 .getMessages ()
@@ -353,6 +362,14 @@ private void handleWarnings(
353362 if (!noSDMRoles .isEmpty ()) {
354363 context .getMessages ().warn (SDMConstants .noSDMRolesMessage (noSDMRoles , "update" ));
355364 }
365+ if (!fileWithWhiteSpace .isEmpty ()) {
366+ context
367+ .getMessages ()
368+ .warn (
369+ String .format (
370+ SDMConstants .FILENAME_WHITESPACE_WARNING_MESSAGE ,
371+ String .join (", " , fileWithWhiteSpace )));
372+ }
356373 }
357374
358375 private List <String > getEntityCompositions (CdsUpdateEventContext context ) {
0 commit comments