Skip to content

Commit 90c376e

Browse files
sonar fix
1 parent 1ec958e commit 90c376e

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,18 @@ private void processAttachment(
124124
CmisDocument cmisDocument = new CmisDocument();
125125
cmisDocument.setFileName(filenameInRequest);
126126
cmisDocument.setObjectId(objectId);
127-
if (fileNameInDB == null && filenameInRequest != null) {
128-
updatedSecondaryProperties.put("filename", filenameInRequest);
129-
} else if (!fileNameInDB.equals(filenameInRequest) && filenameInRequest != null) {
130-
updatedSecondaryProperties.put("filename", filenameInRequest);
131-
} else if (filenameInRequest == null) {
132-
throw new ServiceException("Filename cannot be empty");
127+
if (fileNameInDB == null) {
128+
if (filenameInRequest != null) {
129+
updatedSecondaryProperties.put("filename", filenameInRequest);
130+
} else {
131+
throw new ServiceException("Filename cannot be empty");
132+
}
133+
} else {
134+
if (filenameInRequest == null) {
135+
throw new ServiceException("Filename cannot be empty");
136+
} else if (!fileNameInDB.equals(filenameInRequest)) {
137+
updatedSecondaryProperties.put("filename", filenameInRequest);
138+
}
133139
}
134140
int responseCode =
135141
sdmService.updateAttachments(

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,18 @@ public void processAttachment(
133133
CmisDocument cmisDocument = new CmisDocument();
134134
cmisDocument.setFileName(filenameInRequest);
135135
cmisDocument.setObjectId(objectId);
136-
if (fileNameInDB == null && filenameInRequest != null) {
137-
updatedSecondaryProperties.put("filename", filenameInRequest);
138-
} else if (!fileNameInDB.equals(filenameInRequest) && filenameInRequest != null) {
139-
updatedSecondaryProperties.put("filename", filenameInRequest);
140-
} else if (filenameInRequest == null) {
141-
throw new ServiceException("Filename cannot be empty");
136+
if (fileNameInDB == null) {
137+
if (filenameInRequest != null) {
138+
updatedSecondaryProperties.put("filename", filenameInRequest);
139+
} else {
140+
throw new ServiceException("Filename cannot be empty");
141+
}
142+
} else {
143+
if (filenameInRequest == null) {
144+
throw new ServiceException("Filename cannot be empty");
145+
} else if (!fileNameInDB.equals(filenameInRequest)) {
146+
updatedSecondaryProperties.put("filename", filenameInRequest);
147+
}
142148
}
143149
if (!updatedSecondaryProperties.isEmpty()) {
144150
int responseCode =

0 commit comments

Comments
 (0)