Skip to content

Commit d428861

Browse files
Revert "whitespace"
1 parent b416bea commit d428861

3 files changed

Lines changed: 13 additions & 50 deletions

File tree

sdm/src/main/java/com/sap/cds/sdm/constants/SDMConstants.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ private SDMConstants() {
7777
public static final String FAILED_TO_FETCH_UP_ID = "Failed to fetch up_id";
7878
public static final String FAILED_TO_FETCH_FACET =
7979
"Invalid facet format, unable to extract required information.";
80-
public static final String FILENAME_WHITESPACE_WARNING_MESSAGE =
81-
"The following file(s) could not be updated because the filename(s) cannot be empty.";
8280

8381
public static String nameConstraintMessage(
8482
List<String> fileNameWithRestrictedCharacters, String operation) {

sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/SDMCreateAttachmentsHandler.java

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ public void updateName(CdsCreateEventContext context, List<CdsData> data, String
7171
List<String> filesNotFound = new ArrayList<>();
7272
List<String> filesWithUnsupportedProperties = new ArrayList<>();
7373
Map<String, String> badRequest = new HashMap<>();
74-
List<String> fileWithWhiteSpace = new ArrayList<>();
7574
List<String> noSDMRoles = new ArrayList<>();
7675
for (Map<String, Object> entity : data) {
7776
List<Map<String, Object>> attachments = (List<Map<String, Object>>) entity.get(composition);
@@ -96,8 +95,7 @@ public void updateName(CdsCreateEventContext context, List<CdsData> data, String
9695
composition,
9796
attachmentEntity,
9897
secondaryPropertiesWithInvalidDefinitions,
99-
noSDMRoles,
100-
fileWithWhiteSpace);
98+
noSDMRoles);
10199
handleWarnings(
102100
context,
103101
fileNameWithRestrictedCharacters,
@@ -106,7 +104,6 @@ public void updateName(CdsCreateEventContext context, List<CdsData> data, String
106104
filesWithUnsupportedProperties,
107105
badRequest,
108106
propertyTitles,
109-
fileWithWhiteSpace,
110107
noSDMRoles);
111108
}
112109
}
@@ -133,8 +130,7 @@ private void processEntity(
133130
String composition,
134131
Optional<CdsEntity> attachmentEntity,
135132
Map<String, String> secondaryPropertiesWithInvalidDefinitions,
136-
List<String> noSDMRoles,
137-
List<String> fileWithWhiteSpace)
133+
List<String> noSDMRoles)
138134
throws IOException {
139135
List<Map<String, Object>> attachments = (List<Map<String, Object>>) entity.get(composition);
140136
if (attachments != null) {
@@ -150,8 +146,7 @@ private void processEntity(
150146
composition,
151147
attachmentEntity,
152148
secondaryPropertiesWithInvalidDefinitions,
153-
noSDMRoles,
154-
fileWithWhiteSpace);
149+
noSDMRoles);
155150
}
156151
SecondaryPropertiesKey secondaryPropertiesKey =
157152
new SecondaryPropertiesKey(); // Emptying cache after attachments are updated in loop
@@ -171,7 +166,6 @@ private void processAttachment(
171166
String composition,
172167
Optional<CdsEntity> attachmentEntity,
173168
Map<String, String> secondaryPropertiesWithInvalidDefinitions,
174-
List<String> fileWithWhiteSpace,
175169
List<String> noSDMRoles)
176170
throws IOException {
177171
String id = (String) attachment.get("ID");
@@ -236,11 +230,8 @@ private void processAttachment(
236230
throw new ServiceException("Filename cannot be empty");
237231
}
238232
} else {
239-
if (filenameInRequest == null || filenameInRequest.trim().length() == 0) {
240-
fileWithWhiteSpace.add(fileNameInDB);
241-
replacePropertiesInAttachment(
242-
attachment, fileNameInDB, propertiesInDB, secondaryTypeProperties);
243-
233+
if (filenameInRequest == null) {
234+
throw new ServiceException("Filename cannot be empty");
244235
} else if (!fileNameInDB.equals(
245236
filenameInRequest)) { // If the file name in DB is not equal to the file name in
246237
// request, it means that the file name has been modified
@@ -331,7 +322,6 @@ private void handleWarnings(
331322
List<String> filesWithUnsupportedProperties,
332323
Map<String, String> badRequest,
333324
Map<String, String> propertyTitles,
334-
List<String> fileWithWhiteSpace,
335325
List<String> noSDMRoles) {
336326
if (!fileNameWithRestrictedCharacters.isEmpty()) {
337327
context
@@ -373,14 +363,6 @@ private void handleWarnings(
373363
if (!noSDMRoles.isEmpty()) {
374364
context.getMessages().warn(SDMConstants.noSDMRolesMessage(noSDMRoles, "create"));
375365
}
376-
if (!fileWithWhiteSpace.isEmpty()) {
377-
context
378-
.getMessages()
379-
.warn(
380-
String.format(
381-
SDMConstants.FILENAME_WHITESPACE_WARNING_MESSAGE,
382-
String.join(", ", fileWithWhiteSpace)));
383-
}
384366
}
385367

386368
private List<String> getEntityCompositions(CdsCreateEventContext context) {

sdm/src/main/java/com/sap/cds/sdm/handler/applicationservice/SDMUpdateAttachmentsHandler.java

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ 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<>();
8685
List<String> noSDMRoles = new ArrayList<>();
8786
for (Map<String, Object> entity : data) {
8887
List<Map<String, Object>> attachments = (List<Map<String, Object>>) entity.get(composition);
@@ -110,8 +109,7 @@ private void renameDocument(
110109
filesWithUnsupportedProperties,
111110
badRequest,
112111
secondaryPropertiesWithInvalidDefinitions,
113-
noSDMRoles,
114-
fileWithWhiteSpace);
112+
noSDMRoles);
115113
}
116114
}
117115
handleWarnings(
@@ -122,8 +120,7 @@ private void renameDocument(
122120
filesWithUnsupportedProperties,
123121
badRequest,
124122
propertyTitles,
125-
noSDMRoles,
126-
fileWithWhiteSpace);
123+
noSDMRoles);
127124
}
128125

129126
private void processAttachments(
@@ -136,8 +133,7 @@ private void processAttachments(
136133
List<String> filesWithUnsupportedProperties,
137134
Map<String, String> badRequest,
138135
Map<String, String> secondaryPropertiesWithInvalidDefinitions,
139-
List<String> noSDMRoles,
140-
List<String> fileWithWhiteSpace)
136+
List<String> noSDMRoles)
141137
throws IOException {
142138
Iterator<Map<String, Object>> iterator = attachments.iterator();
143139
while (iterator.hasNext()) {
@@ -152,8 +148,7 @@ private void processAttachments(
152148
filesWithUnsupportedProperties,
153149
badRequest,
154150
secondaryPropertiesWithInvalidDefinitions,
155-
noSDMRoles,
156-
fileWithWhiteSpace);
151+
noSDMRoles);
157152
}
158153
SecondaryPropertiesKey secondaryPropertiesKey = new SecondaryPropertiesKey();
159154
secondaryPropertiesKey.setRepositoryId(SDMConstants.REPOSITORY_ID);
@@ -173,8 +168,7 @@ public void processAttachment(
173168
List<String> filesWithUnsupportedProperties,
174169
Map<String, String> badRequest,
175170
Map<String, String> secondaryPropertiesWithInvalidDefinitions,
176-
List<String> noSDMRoles,
177-
List<String> fileWithWhiteSpace)
171+
List<String> noSDMRoles)
178172
throws IOException {
179173
String id = (String) attachment.get("ID");
180174
Map<String, String> secondaryTypeProperties =
@@ -228,10 +222,8 @@ public void processAttachment(
228222
throw new ServiceException("Filename cannot be empty");
229223
}
230224
} else {
231-
if (filenameInRequest == null || filenameInRequest.trim().length() == 0) {
232-
fileWithWhiteSpace.add(fileNameInDB);
233-
replacePropertiesInAttachment(
234-
attachment, fileNameInDB, propertiesInDB, secondaryTypeProperties);
225+
if (filenameInRequest == null) {
226+
throw new ServiceException("Filename cannot be empty");
235227
} else if (!fileNameInDB.equals(filenameInRequest)) {
236228
updatedSecondaryProperties.put("filename", filenameInRequest);
237229
}
@@ -321,8 +313,7 @@ private void handleWarnings(
321313
List<String> filesWithUnsupportedProperties,
322314
Map<String, String> badRequest,
323315
Map<String, String> propertyTitles,
324-
List<String> noSDMRoles,
325-
List<String> fileWithWhiteSpace) {
316+
List<String> noSDMRoles) {
326317
if (!fileNameWithRestrictedCharacters.isEmpty()) {
327318
context
328319
.getMessages()
@@ -362,14 +353,6 @@ private void handleWarnings(
362353
if (!noSDMRoles.isEmpty()) {
363354
context.getMessages().warn(SDMConstants.noSDMRolesMessage(noSDMRoles, "update"));
364355
}
365-
if (!fileWithWhiteSpace.isEmpty()) {
366-
context
367-
.getMessages()
368-
.warn(
369-
String.format(
370-
SDMConstants.FILENAME_WHITESPACE_WARNING_MESSAGE,
371-
String.join(", ", fileWithWhiteSpace)));
372-
}
373356
}
374357

375358
private List<String> getEntityCompositions(CdsUpdateEventContext context) {

0 commit comments

Comments
 (0)