@@ -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 );
0 commit comments