Updating documents using data from a third-party API

We currently create documents in the repository from data coming from a third-party API using JCR calls, building a Node and saving it in the relevant location. If changes come in, we delete the existing entry and re-insert it as it could previously not be edited within the CMS.

We now have content coming through which will be editable in the CMS and want to be able to update the documents rather than delete/insert.

I’ve tried implementing a change using the WorkflowManager to get the DocumentWorkflow to update correctly from the hippo:handle node to keep the state of the documents below correct (after reading this: https://documentation.bloomreach.com/library/concepts/workflow/document-workflow.html), but keep getting an error trying to get the DocumentWorkflow from the WorkflowManager. Here’s the code I’ve been trying (and variations thereof) to no success:

WorkflowManager workflowManager = ((HippoWorkspace) session.getWorkspace()).getWorkflowManager();
DocumentWorkflow documentWorkflow = (DocumentWorkflow) workflowManager.getWorkflow("default", node.getParent());

node.getParent() returns the handle node.

When I run the last line above I get the following exception:

Caused by: javax.jcr.RepositoryException: Problem creating workflow proxy
at org.apache.jackrabbit.rmi.server.ServerObject.getRepositoryException(ServerObject.java:145)
at org.hippoecm.repository.decorating.server.ServerWorkflowManager.getWorkflow(ServerWorkflowManager.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:283)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:260)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:227)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:179)
at com.sun.proxy.$Proxy26.getWorkflow(Unknown Source)
at org.hippoecm.repository.decorating.client.ClientWorkflowManager.getWorkflow(ClientWorkflowManager.java:76)

Am I doing this correctly, or is there an alternative way of doing what I need?

May I ask, why are you using RMI protocol?

Hi Marijan,

That’s how we have been connecting to the repository from all of our microservices that access the repo. Is there another way you’d suggest?

as far as know RMI protocol is (always was) partially supported and we deprecated pretty much all of our tooling (and also disabled RMI server by default) few years ago.
You should use one of our REST implementations (you can protect those by using HST authentication/authorization)