Hi. I’m trying to make a custom API for creating documents. I’m following the example, but getting ClassCastException with the wpm.createObject() method.
WorkflowPersistenceManager wpm = (WorkflowPersistenceManager) getPersistenceManager(requestContext);
//HippoFolderBean contentBaseFolder = getMountContentBaseBean(requestContext); //returns null
//String eventDocumentFolderPath = contentBaseFolder.getPath() + "/eventDocument"; //throws NPE
String beanPath = wpm.createAndReturn(
path, //where the content will go - comes from payload
"cm:"+documentTypeName, //where the document type definition is - workaround because of nulls above
HippoDocument hippoDocument = (HippoDocument) wpm.getObject(beanPath); //works
// EventDocument eventDocumentBean = (EventDocument) wpm.getObject(beanPath); //throws ClassCastException
java.lang.ClassCastException: class org.hippoecm.hst.content.beans.standard.HippoDocument$EventDocument$4vkQoxwy cannot be cast to class org.sae.cm.modules.document.EventDocument (org.hippoecm.hst.content.beans.standard.HippoDocument$EventDocument$4vkQoxwy and org.sae.cm.modules.document.EventDocument are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @3bb44eac)
To create a document using an API, you will need to follow these general steps:
Choose an API: Select an API that supports document creation. Some popular options include Google Drive API, Microsoft Office 365 API, and Dropbox API.
Set up authentication: Authenticate your application with the API by obtaining an access token or API key.
Create the document: Use the API to create a new document. This may involve specifying the document type, format, and location.
Add content: Use the API to add content to the document. This may involve uploading files, inserting text or images, or applying formatting.
Save the document: Use the API to save the document to the desired location.
Test and refine: Test your document creation process and refine it as needed to ensure that it works as expected.
Keep in mind that the specific steps involved in creating a document using an API may vary depending on the API you choose and the requirements of your application. Be sure to refer to the API documentation and follow any guidelines or best practices recommended by the API provider.
Click here more information: https://crecentech.com/