@SuppressWarnings("deprecation") private void configRemoteRest(RemoteRestRuntimeEngineBuilder builder, RemoteRestModel model) { configRemote(builder, model); try { builder.addUrl(new URL(model.getUrl())); } catch (MalformedURLException mue) { throw new RuntimeException(mue); } builder.useFormBasedAuth(model.isUseFormBasedAuth()); }
@SuppressWarnings("deprecation") private void configRemoteRest(RemoteRestRuntimeEngineBuilder builder, RemoteRestModel model) { configRemote(builder, model); try { builder.addUrl(new URL(model.getUrl())); } catch (MalformedURLException mue) { throw new RuntimeException(mue); } builder.useFormBasedAuth(model.isUseFormBasedAuth()); }
/** * With the introduction of the fluent/builder API in 6.0.x, we could do this: * * RemoteRestRuntimeEngineFactory factory = * RemoteRestRuntimeEngineFactory.newBuilder() * .addUserName("user") * .addPassword("pass") * .addUrl(new URL("http://localhost:8080/business-central")) * .build(); * * RuntimeEngine runtimeEngine = factory.newRuntimeEngine(); * * With the 6.0.x code, we built a factory, that we then used to create the runtime.. * * Why not just build the runtime immediately? :) */ public void createRestRuntimeEngineWithBuilder() throws MalformedURLException { // unfortunately, this breaks backward compatibility, but the improvement and clarity in the API is worth the risk RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName("user") .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .build(); } }
protected KieSession initKieSession() throws CoreException { RuntimeEngine restSessionFactory; try { restSessionFactory = RemoteRuntimeEngineFactory.newRestBuilder() .addDeploymentId(bpmConfig.getDeploymentId()) .addUrl(new URL(bpmConfig.getBpmInstanceUrl())) .addUserName(bpmConfig.getUsername()) .addPassword(bpmConfig.getPassword()) .addTimeout(AUTHENTICATION_TIMEOUT_S) .build(); } catch (Exception e) { throw new CoreException("Could not initialize connection to BPM server at '" + bpmConfig.getBpmInstanceUrl() + "' check that the URL is correct.", e); } return restSessionFactory.getKieSession(); }
public void minimumRestBuilderExample() throws Exception { RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName("user") .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .build(); runtimeEngine.getTaskService().claim(23l, "user"); // This will throw a MissingRequiredInfoException because the deployment id is required here runtimeEngine.getKieSession().startProcess("org.test.process"); }
@Test public void notAceptedMethodTest() throws Exception { URL deploymentUrl = new URL( "http://localhost:8080/kie-wb/" ); RemoteRestRuntimeEngineFactory restSessionFactory = RemoteRuntimeEngineFactory.newRestBuilder() .addDeploymentId("deployment") .addUrl(deploymentUrl) .addUserName("mary") .addPassword("pass") .buildFactory(); WorkItemHandler wih = new DoNothingWorkItemHandler(); try { restSessionFactory.newRuntimeEngine().getKieSession().getWorkItemManager().registerWorkItemHandler("test", wih); fail( "The above call should have failed."); } catch( UnsupportedOperationException uoe ) { assertTrue("Incorrect error message: " + uoe.getMessage(), uoe.getMessage().contains("not supported on the Remote Client instance.")); } }
.addUrl(deploymentUrl) .addUserName(userId) .addPassword(password)
.addPassword("user").addUserName("pass") .addDeploymentId("deploymentId") .addUrl(new URL("http://localhost:" + port + "/" )) .build(); .addPassword("user").addUserName("pass") .addDeploymentId("deploymentId") .addUrl(new URL("http://localhost:" + port + "/" )) .addHeader(NOT_SENT_HEADER_NAME, String.valueOf(random.nextLong())) .clearHeaderFields()
.addUserName(authUser) .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .build(); .addUserName(authUser) .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .disableTaskSecurity() .build(); .addUserName(authUser) .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .build();
.addUserName("S") .addPassword("koek") .addUrl(new URL("http://localhost:8080/kie-wb")) .addTimeout(3) .addExtraJaxbClasses(MyType.class, Person.class) .addDeploymentId("deployment") .addPassword("poffertje") .addUrl(new URL("http://localhost:8080/kie-wb")) .addTimeout(3) .buildFactory(); .addDeploymentId("deployment") .addUserName("A") .addUrl(new URL("http://localhost:8080/kie-wb")) .addTimeout(3) .buildFactory(); .addUserName("joke") .addPassword("stroop") .addUrl(new URL("http://localhost:8080/kie-wb")) .buildFactory();
.addUrl(instanceUrl) .addDeploymentId(deploymentId) .addUserName(user)
.addUserName("S") .addPassword("koek") .addUrl(new URL("http://localhost:8080/kie-wb")) .addTimeout(3) .addExtraJaxbClasses(MyType.class, Person.class) .addDeploymentId("deployment") .addPassword("poffertje") .addUrl(new URL("http://localhost:8080/kie-wb")) .addTimeout(3) .build(); .addDeploymentId("deployment") .addUserName("A") .addUrl(new URL("http://localhost:8080/kie-wb")) .addTimeout(3) .build(); .addUserName("joke") .addPassword("stroop") .addUrl(new URL("http://localhost:8080/kie-wb")) .build();
@Test public void setHeaderFields() throws Exception { RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName("user") .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .addHeader("HEADER-NAME", "header-value") .clearHeaderFields() .addCorrelationProperties() .addDeploymentId("dep-id") .build(); try { runtimeEngine.getTaskService().claim(23l, "user"); fail( "This should have failed because there's no server running... "); } catch( org.kie.remote.client.api.exception.RemoteCommunicationException rce ) { // expected } } }
public void multipleDifferentRuntimeExamples(String deploymentId, URL deploymentUrl, boolean useFormBasedAuth) throws Exception { RemoteRestRuntimeEngineBuilder runtimeEngineBuilder = RemoteRuntimeEngineFactory.newRestBuilder() .addDeploymentId(deploymentId) .addUrl(deploymentUrl); RuntimeEngine krisRemoteEngine = runtimeEngineBuilder .addUserName(KRIS_USER) .addPassword(KRIS_PASSWORD) .build(); RuntimeEngine maryRemoteEngine = runtimeEngineBuilder .addUserName(MARY_USER) .addPassword(MARY_PASSWORD) .build(); RuntimeEngine johnRemoteEngine = runtimeEngineBuilder .addUserName(JOHN_USER) .addPassword(JOHN_PASSWORD) .build(); }
.addUrl(baseUrl) .addUserName(user) .addPassword(password)
.addUserName("user") .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .build();
.addUserName("user") .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .buildFactory();