@@ -71,21 +71,38 @@ public SDMServiceGenericHandler(
7171 @ On (event = "changelog" )
7272 public void changelog (AttachmentLogContext context ) throws IOException {
7373 CdsModel cdsModel = context .getModel ();
74+ System .out .println ("cdsModel: " + cdsModel );
7475 CqnAnalyzer cqnAnalyzer = CqnAnalyzer .create (cdsModel );
75- Optional <CdsEntity > attachmentDraftEntity =
76+ System .out .println ("cqnAnalyzer: " + cqnAnalyzer );
77+ Optional <CdsEntity > attachmentEntity =
7678 cdsModel .findEntity (context .getTarget ().getQualifiedName () + "_drafts" );
79+ System .out .println ("attachmentDraftEntity: " + attachmentEntity );
80+
7781 Map <String , Object > targetKeys =
7882 cqnAnalyzer .analyze ((CqnSelect ) context .get ("cqn" )).targetKeyValues ();
83+ System .out .println ("targetKeys: " + targetKeys );
7984 // get the objectId against the Id
80- String ID = targetKeys .get ("ID" ).toString ();
85+ String id = targetKeys .get ("ID" ).toString ();
86+ System .out .println ("ID: " + id );
8187 CmisDocument cmisDocument =
82- dbQuery .getObjectIdForAttachmentID (attachmentDraftEntity .get (), persistenceService , ID );
88+ dbQuery .getObjectIdForAttachmentID (attachmentEntity .get (), persistenceService , id );
89+ if (cmisDocument .getFileName () == null || cmisDocument .getFileName ().isEmpty ()) {
90+ System .out .println ("Filename is null or empty in draft entity" );
91+ // open attachment is triggered on non-draft entity
92+ attachmentEntity = cdsModel .findEntity (context .getTarget ().getQualifiedName ());
93+ cmisDocument =
94+ dbQuery .getObjectIdForAttachmentID (attachmentEntity .get (), persistenceService , id );
95+ }
96+ System .out .println ("cmisDocument: " + cmisDocument );
8397 SDMCredentials sdmCredentials = tokenHandler .getSDMCredentials ();
98+ System .out .println ("sdmCredentials: " + sdmCredentials );
8499
85100 JSONObject jsonObject =
86101 sdmService .getChangeLog (
87102 cmisDocument .getObjectId (), sdmCredentials , context .getUserInfo ().isSystemUser ());
103+ System .out .println ("jsonObject: " + jsonObject );
88104 jsonObject .put ("filename" , cmisDocument .getFileName ());
105+ System .out .println ("jsonObject after adding filename: " + jsonObject );
89106 context .setResult (jsonObject );
90107 }
91108
0 commit comments