I need to introduce java component in workflow which needs to extract content as InputStream and write to network path.
The attachments are available in workflow in form of array.
I tried connecting to same CE instance from my component using below code:
vwAttachments[0].getId();
Connection conn = Factory.Connection.getConnection(ceUrl);
Subject subject = UserContext.createSubject(conn, username, password, "FileNetP8");
UserContext uc = UserContext.get();
uc.pushSubject(subject);
Domain domain = Factory.Domain.getInstance(conn, myDomain);
ObjectStore objectStore = Factory.ObjectStore.fetchInstance(domain, vwAttachments[0].getLibraryName(), null);
VersionSeries vs = Factory.VersionSeries.fetchInstance(objectStore, new Id( vwAttachments[0].getId()), null);
Document document = (Document) vs.get_CurrentVersion();
ContentTransfer contentTransfer = (ContentTransfer) document.get_ContentElements().get(0);
InputStream inputStream = contentTransfer.accessContentStream();
When I execute this component its giving be below error:
error=Access to the Content Engine was not allowed because the Content Engine API library or the Web Service Interface (WSI) Listener could not find the required security context information. Expected credentials were not found in the security context.
I did independent testing of same user, password and ceurl to check if the informations are correct.
And using small java class in eclipse, I was able to connect CE server using these parameters.
Am I missing something here?
OR
Is there any other way by which I can extract content from VMAttachment array object in my java component ?
------------------------------
Rajesh Panchal
------------------------------