Skip to content

Commit 9f18241

Browse files
committed
Removed System.out.println
1 parent c888d77 commit 9f18241

File tree

3 files changed

+0
-62
lines changed

3 files changed

+0
-62
lines changed

sdm/src/main/java/com/sap/cds/sdm/persistence/DBQuery.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -72,41 +72,30 @@ public CmisDocument getAttachmentForObjectID(
7272

7373
// Use the new API to resolve the target attachment entity
7474
String parentEntity = context.getParentEntity();
75-
System.out.println("Parent Entity: " + parentEntity);
7675
String compositionName = context.getCompositionName();
77-
System.out.println("Composition Name: " + compositionName);
7876
CdsModel model = context.getModel();
79-
System.out.println("model: " + model);
8077

8178
// Find the parent entity
8279
Optional<CdsEntity> optionalParentEntity = model.findEntity(parentEntity);
83-
System.out.println("optionalParentEntity: " + optionalParentEntity);
8480
if (optionalParentEntity.isEmpty()) {
85-
System.out.println("optionalParentEntity is empty");
8681
throw new ServiceException("Unable to find parent entity: " + parentEntity);
8782
}
8883

8984
// Find the composition element in the parent entity
9085
Optional<CdsElement> compositionElement =
9186
optionalParentEntity.get().findElement(compositionName);
92-
System.out.println("compositionElement: " + compositionElement);
9387
if (compositionElement.isEmpty() || !compositionElement.get().getType().isAssociation()) {
94-
System.out.println("compositionElement is empty or not an association");
9588
throw new ServiceException(
9689
"Unable to find composition '" + compositionName + "' in entity: " + parentEntity);
9790
}
9891

9992
// Get the target entity of the composition
10093
CdsAssociationType assocType = (CdsAssociationType) compositionElement.get().getType();
101-
System.out.println("assocType: " + assocType);
10294
String targetEntityName = assocType.getTarget().getQualifiedName();
103-
System.out.println("targetEntityName: " + targetEntityName);
10495

10596
// Find the target attachment entity
10697
Optional<CdsEntity> attachmentEntity = model.findEntity(targetEntityName);
107-
System.out.println("attachmentEntity: " + attachmentEntity);
10898
if (attachmentEntity.isEmpty()) {
109-
System.out.println("attachmentEntity is empty");
11099
throw new ServiceException("Unable to find target attachment entity: " + targetEntityName);
111100
}
112101

@@ -116,41 +105,30 @@ public CmisDocument getAttachmentForObjectID(
116105
.columns("linkUrl", "type")
117106
.where(doc -> doc.get("objectId").eq(id));
118107
Result result = persistenceService.run(q);
119-
System.out.println("result: " + result);
120108
Optional<Row> res = result.first();
121-
System.out.println("res: " + res);
122109

123110
CmisDocument cmisDocument = new CmisDocument();
124111
if (res.isPresent()) {
125112
Row row = res.get();
126-
System.out.println("row: " + row);
127113
cmisDocument.setType(row.get("type") != null ? row.get("type").toString() : null);
128114
cmisDocument.setUrl(row.get("linkUrl") != null ? row.get("linkUrl").toString() : null);
129115
} else {
130116
// Check in draft table as well
131-
System.out.println("Inside else");
132117
Optional<CdsEntity> attachmentDraftEntity = model.findEntity(targetEntityName + "_drafts");
133-
System.out.println("attachmentDraftEntity: " + attachmentDraftEntity);
134118
if (attachmentDraftEntity.isPresent()) {
135-
System.out.println("attachmentDraftEntity is present");
136119
q =
137120
Select.from(attachmentDraftEntity.get())
138121
.columns("linkUrl", "type")
139122
.where(doc -> doc.get("objectId").eq(id));
140123
result = persistenceService.run(q);
141-
System.out.println("result: " + result);
142124
res = result.first();
143-
System.out.println("res: " + res);
144125
if (res.isPresent()) {
145-
System.out.println("res is present");
146126
Row row = res.get();
147-
System.out.println("row: " + row);
148127
cmisDocument.setType(row.get("type") != null ? row.get("type").toString() : null);
149128
cmisDocument.setUrl(row.get("linkUrl") != null ? row.get("linkUrl").toString() : null);
150129
}
151130
}
152131
}
153-
System.out.println("cmisDocument: " + cmisDocument);
154132
return cmisDocument;
155133
}
156134

sdm/src/main/java/com/sap/cds/sdm/service/handler/SDMCustomServiceHandler.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,12 @@ public SDMCustomServiceHandler(
6969
@On(event = RegisterService.EVENT_COPY_ATTACHMENT)
7070
public void copyAttachments(AttachmentCopyEventContext context) throws IOException {
7171

72-
System.out.println("Inside copyAttachments handler of SDMCustomServiceHandler");
7372
String parentEntity = context.getParentEntity();
74-
System.out.println("parentEntity: " + parentEntity);
7573
String compositionName = context.getCompositionName();
76-
System.out.println("compositionName: " + compositionName);
7774
String upID = context.getUpId();
78-
System.out.println("upID: " + upID);
7975
String folderName = upID + "__" + compositionName;
80-
System.out.println("folderName: " + folderName);
8176
String repositoryId = SDMConstants.REPOSITORY_ID;
82-
System.out.println("repositoryId: " + repositoryId);
8377
Boolean isSystemUser = context.getSystemUser();
84-
System.out.println("isSystemUser: " + isSystemUser);
8578

8679
SDMCredentials sdmCredentials = tokenHandler.getSDMCredentials();
8780
// Check if folder exists before trying to create it
@@ -91,18 +84,15 @@ public void copyAttachments(AttachmentCopyEventContext context) throws IOExcepti
9184
String folderId = ensureFolderExists(folderName, repositoryId, sdmCredentials, isSystemUser);
9285

9386
List<String> objectIds = context.getObjectIds();
94-
System.out.println("objectIds: " + objectIds);
9587

9688
CopyAttachmentsResult copyResult =
9789
copyAttachmentsToSDM(
9890
context, objectIds, folderId, repositoryId, sdmCredentials, isSystemUser, folderExists);
9991

10092
List<List<String>> attachmentsMetadata = copyResult.getAttachmentsMetadata();
10193
List<CmisDocument> populatedDocuments = copyResult.getPopulatedDocuments();
102-
System.out.println("attachmentsMetadata: " + attachmentsMetadata);
10394

10495
String upIdKey = resolveUpIdKey(context, parentEntity, compositionName);
105-
System.out.println("upIdKey: " + upIdKey);
10696
createDraftEntries(
10797
attachmentsMetadata,
10898
populatedDocuments,
@@ -121,15 +111,13 @@ private String ensureFolderExists(
121111
throws IOException {
122112
String folderId =
123113
sdmService.getFolderIdByPath(folderName, repositoryId, sdmCredentials, isSystemUser);
124-
System.out.println("folderId: " + folderId);
125114
if (folderId == null) {
126115
folderId =
127116
sdmService.createFolder(
128117
folderName, SDMConstants.REPOSITORY_ID, sdmCredentials, isSystemUser);
129118
JSONObject jsonObject = new JSONObject(folderId);
130119
JSONObject succinctProperties = jsonObject.getJSONObject("succinctProperties");
131120
folderId = succinctProperties.getString("cmis:objectId");
132-
System.out.println("Created new folder with folderId: " + folderId);
133121
}
134122
return folderId;
135123
}
@@ -149,7 +137,6 @@ private CopyAttachmentsResult copyAttachmentsToSDM(
149137
for (String objectId : objectIds) {
150138
CmisDocument cmisDocument =
151139
dbQuery.getAttachmentForObjectID(persistenceService, objectId, context);
152-
System.out.println("cmisDocument: " + cmisDocument);
153140
cmisDocument.setObjectId(objectId);
154141
cmisDocument.setRepositoryId(repositoryId);
155142
cmisDocument.setFolderId(folderId);
@@ -179,10 +166,8 @@ private void handleCopyFailure(
179166
ServiceException e)
180167
throws IOException {
181168
if (!folderExists) {
182-
System.out.println("Exception occurred, deleting created folder with folderId: " + folderId);
183169
sdmService.deleteDocument("deleteTree", folderId, context.getUserInfo().getName());
184170
} else {
185-
System.out.println("Exception occurred, deleting copied attachments");
186171
for (List<String> attachmentMetadata : attachmentsMetadata) {
187172
sdmService.deleteDocument(
188173
"delete", attachmentMetadata.get(2), context.getUserInfo().getName());
@@ -195,38 +180,28 @@ private String resolveUpIdKey(
195180
AttachmentCopyEventContext context, String parentEntity, String compositionName) {
196181
CdsModel model = context.getModel();
197182
Optional<CdsEntity> optionalParentEntity = model.findEntity(parentEntity);
198-
System.out.println("optionalParentEntity: " + optionalParentEntity);
199183
if (optionalParentEntity.isEmpty()) {
200184
throw new ServiceException("Unable to find parent entity: " + parentEntity);
201185
}
202186

203187
Optional<CdsElement> compositionElement =
204188
optionalParentEntity.get().findElement(compositionName);
205-
System.out.println("compositionElement: " + compositionElement);
206189
if (compositionElement.isEmpty() || !compositionElement.get().getType().isAssociation()) {
207190
throw new ServiceException(
208191
"Unable to find composition '" + compositionName + "' in entity: " + parentEntity);
209192
}
210193

211194
CdsAssociationType assocType = (CdsAssociationType) compositionElement.get().getType();
212-
System.out.println("assocType: " + assocType);
213195
String targetEntityName = assocType.getTarget().getQualifiedName();
214-
System.out.println("targetEntityName: " + targetEntityName);
215196

216197
Optional<CdsEntity> attachmentDraftEntity = model.findEntity(targetEntityName + "_drafts");
217-
System.out.println("attachmentDraftEntity: " + attachmentDraftEntity);
218198
if (attachmentDraftEntity.isPresent()) {
219199
Optional<CdsElement> upAssociation = attachmentDraftEntity.get().findAssociation("up_");
220-
System.out.println("upAssociation: " + upAssociation);
221200
if (upAssociation.isPresent()) {
222201
CdsElement association = upAssociation.get();
223-
System.out.println("association: " + association);
224202
CdsAssociationType upAssocType = association.getType();
225-
System.out.println("upAssocType: " + upAssocType);
226203
List<String> fkElements = upAssocType.refs().map(ref -> "up__" + ref.path()).toList();
227-
System.out.println("fkElements: " + fkElements);
228204
String upIdKey = fkElements.get(0);
229-
System.out.println("upIdKey: " + upIdKey);
230205
return upIdKey;
231206
}
232207
}
@@ -249,9 +224,7 @@ private void createDraftEntries(
249224
Map<String, Object> updatedFields = new HashMap<>();
250225

251226
String fileName = attachmentMetadata.get(0);
252-
System.out.println("fileName: " + fileName);
253227
String mimeType = attachmentMetadata.get(1);
254-
System.out.println("mimeType: " + mimeType);
255228
if (mimeType.equalsIgnoreCase("application/internet-shortcut")) {
256229
int dotIndex = fileName.lastIndexOf('.');
257230
fileName = fileName.substring(0, dotIndex);
@@ -280,14 +253,11 @@ private void createDraftEntries(
280253
+ ":"
281254
+ mimeType);
282255
updatedFields.put(upIdKey, upID);
283-
System.out.println("updatedFields: " + updatedFields);
284256

285257
String baseKeyField = upIdKey != null ? upIdKey.replace("up__", "") : "ID";
286258
var insert =
287259
Insert.into(parentEntity, e -> e.filter(e.get(baseKeyField).eq(upID)).to(compositionName))
288260
.entry(updatedFields);
289-
System.out.println("Insert: " + insert);
290-
System.out.println("Using baseKeyField: " + baseKeyField + " for filter");
291261

292262
DraftService matchingService =
293263
draftService.stream()
@@ -296,7 +266,6 @@ private void createDraftEntries(
296266
.orElse(null);
297267

298268
if (matchingService != null) {
299-
System.out.println("Using DraftService: " + matchingService.getName());
300269
matchingService.newDraft(insert);
301270
} else {
302271
throw new ServiceException("No suitable service found for entity: " + parentEntity);

sdm/src/main/java/com/sap/cds/sdm/service/handler/SDMServiceGenericHandler.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,11 @@ public SDMServiceGenericHandler(
6767
@On(event = "copyAttachments")
6868
public void copyAttachments(EventContext context) throws IOException {
6969
String upID = context.get("up__ID").toString();
70-
System.out.println("upID: " + upID);
7170
String objectIdsString = context.get("objectIds").toString();
72-
System.out.println("objectIdsString: " + objectIdsString);
7371
List<String> objectIds = Arrays.stream(objectIdsString.split(",")).map(String::trim).toList();
7472

7573
// Use the full target qualified name as the facet
7674
String facet = context.getTarget().getQualifiedName();
77-
System.out.println("facet: " + facet);
7875

7976
var copyEventInput = new CopyAttachmentInput(upID, facet, objectIds);
8077

@@ -100,26 +97,20 @@ public void openAttachment(AttachmentReadContext context) throws Exception {
10097
CqnAnalyzer cqnAnalyzer = CqnAnalyzer.create(cdsModel);
10198
Optional<CdsEntity> attachmentEntity =
10299
cdsModel.findEntity(context.getTarget().getQualifiedName() + "_drafts");
103-
System.out.println("attachmentEntity: " + attachmentEntity);
104100
Map<String, Object> targetKeys =
105101
cqnAnalyzer.analyze((CqnSelect) context.get("cqn")).targetKeyValues();
106102
// get the objectId against the Id
107103
String id = targetKeys.get("ID").toString();
108-
System.out.println("id: " + id);
109104
CmisDocument cmisDocument =
110105
dbQuery.getObjectIdForAttachmentID(attachmentEntity.get(), persistenceService, id);
111-
System.out.println("cmisDocument: " + cmisDocument);
112106

113107
if (cmisDocument.getFileName() == null || cmisDocument.getFileName().isEmpty()) {
114108
// open attachment is triggered on non-draft entity
115109
attachmentEntity = cdsModel.findEntity(context.getTarget().getQualifiedName());
116110
cmisDocument =
117111
dbQuery.getObjectIdForAttachmentID(attachmentEntity.get(), persistenceService, id);
118-
System.out.println("cmisDocument (non-draft): " + cmisDocument);
119112
}
120113
if (cmisDocument.getMimeType().equalsIgnoreCase("application/internet-shortcut")) {
121-
System.out.println("Link detected, fetching URL");
122-
System.out.println("cmisDocument before fetching URL: " + cmisDocument.getUrl());
123114
context.setResult(cmisDocument.getUrl());
124115
} else {
125116
context.setResult("None");

0 commit comments

Comments
 (0)