Search in sources :

Example 1 with WizardViewResponse

use of org.knime.core.node.wizard.WizardViewResponse in project knime-core by knime.

the class WebResourceController method processViewRequestInternal.

/**
 * Retrieves the response for a view request, which is from a node within a subnode
 *
 * @param subnodeID the node id of the subnode container
 * @param nodeID the node id of the wizard node, as fetched from the combined view
 * @param viewRequest the JSON serialized view request string
 * @param exec the execution monitor to set progress and check possible cancellation
 * @return a {@link WizardViewResponse} which is generated by the concrete node
 * @throws ViewRequestHandlingException If the request handling or response generation fails for any
 * reason.
 * @throws InterruptedException If the thread handling the request is interrupted.
 * @throws CanceledExecutionException If the handling of the request was canceled e.g. by user
 * intervention.
 * @since 3.7
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
protected WizardViewResponse processViewRequestInternal(final NodeID subnodeID, final String nodeID, final String viewRequest, final ExecutionMonitor exec) throws ViewRequestHandlingException, InterruptedException, CanceledExecutionException {
    WorkflowManager manager = m_manager;
    assert manager.isLockedByCurrentThread();
    NodeID.NodeIDSuffix suffix = NodeID.NodeIDSuffix.fromString(nodeID);
    NodeID id = suffix.prependParent(manager.getID());
    WizardNode model = getWizardNodeForVerifiedID(subnodeID, id);
    if (model == null || !(model instanceof WizardViewRequestHandler)) {
        throw new ViewRequestHandlingException("Node model can not process view requests. Possible implementation error.");
    }
    WizardViewRequest req = ((WizardViewRequestHandler) model).createEmptyViewRequest();
    try {
        req.loadFromStream(new ByteArrayInputStream(viewRequest.getBytes(Charset.forName("UTF-8"))));
    } catch (IOException ex) {
        throw new ViewRequestHandlingException("Error deserializing request: " + ex.getMessage(), ex);
    }
    return (WizardViewResponse) ((WizardViewRequestHandler) model).handleRequest(req, exec);
}
Also used : WizardViewRequest(org.knime.core.node.wizard.WizardViewRequest) ViewRequestHandlingException(org.knime.core.node.interactive.ViewRequestHandlingException) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) WizardNode(org.knime.core.node.wizard.WizardNode) WizardViewRequestHandler(org.knime.core.node.wizard.WizardViewRequestHandler) NodeIDSuffix(org.knime.core.node.workflow.NodeID.NodeIDSuffix) WizardViewResponse(org.knime.core.node.wizard.WizardViewResponse)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ViewRequestHandlingException (org.knime.core.node.interactive.ViewRequestHandlingException)1 WizardNode (org.knime.core.node.wizard.WizardNode)1 WizardViewRequest (org.knime.core.node.wizard.WizardViewRequest)1 WizardViewRequestHandler (org.knime.core.node.wizard.WizardViewRequestHandler)1 WizardViewResponse (org.knime.core.node.wizard.WizardViewResponse)1 NodeIDSuffix (org.knime.core.node.workflow.NodeID.NodeIDSuffix)1