Creating behavior to validate the file signature

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2021 02:26 AM
I am trying to fetch the content of the uploded document but I am getting the contentReader value as null.How to get the uploaded document content on onCreateNode method?Below is the code snippet that I was implemented
public void onCreateNode(ChildAssociationRef parentChildAssocRef) {
logger.info("Inside onCreateNode");
NodeRef parentFolderRef = parentChildAssocRef.getParentRef();
NodeRef docRef = parentChildAssocRef.getChildRef();
System.out.println("onCreateNode NodeRef "+docRef);
ContentReader reader = this.getContentService().getReader(docRef, ContentModel.PROP_CONTENT);
System.out.println("onCreateNode Reader "+reader);
}
- Labels:
-
Alfresco Content Services
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2021 03:21 AM
This behaviour validates electronic signatures on a file:
I guess you should listen to "onContentUpdate" policy instead of "onCreateNode" one.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2021 02:06 PM
I changed the NotificationFrequency to TRANSACTION_COMMIT in onCreateNode then I am not getting the contentReader value as null but while to am trying to fetch the content as a stream object then I am facing issue as ContentIOException.
Caused by: org.alfresco.service.cmr.repository.ContentIOException: 00190021 Failed to open stream onto channel:
dms-impl-acs_1 | accessor: ContentAccessor[ contentUrl=store://2021/1/19/18/47/7d2e073a-43b0-4e7d-8caa-aa180047be66.bin, mimetype=image/png, size=158162, encoding=UTF-8, locale=en_GB]
Below is the code snippet
public void onCreateNode(ChildAssociationRef parentChildAssocRef) {
logger.info("Inside onCreateNode");
NodeRef parentFolderRef = parentChildAssocRef.getParentRef();
NodeRef docRef = parentChildAssocRef.getChildRef();
System.out.println("onCreateNode NodeRef "+docRef);
ContentReader reader = this.getContentService().getReader(docRef, ContentModel.PROP_CONTENT);
System.out.println("onCreateNode Reader "+reader);
InputStream originalInputStream = reader.getContentInputStream();
System.out.println("originalInputStream "+originalInputStream);
}
