use of org.jboss.resteasy.spi.ResteasyProviderFactory in project syndesis by syndesisio.
the class ExternalVerifierService method verify.
@Override
public List<Result> verify(String connectorId, Map<String, String> options) {
final ResteasyJackson2Provider resteasyJacksonProvider = new ResteasyJackson2Provider();
resteasyJacksonProvider.setMapper(MAPPER);
final ResteasyProviderFactory providerFactory = ResteasyProviderFactory.newInstance();
providerFactory.register(resteasyJacksonProvider);
final Configuration configuration = new LocalResteasyProviderFactory(providerFactory);
Client client = ClientBuilder.newClient(configuration);
WebTarget target = client.target(String.format("http://%s/api/v1/verifier/%s", config.getService(), connectorId));
return target.request(MediaType.APPLICATION_JSON).post(Entity.entity(options, MediaType.APPLICATION_JSON), new GenericType<List<Result>>() {
});
}
use of org.jboss.resteasy.spi.ResteasyProviderFactory in project syndesis by syndesisio.
the class HttpClient method createClient.
/* default */
private Client createClient() {
final ResteasyJackson2Provider resteasyJacksonProvider = new ResteasyJackson2Provider();
resteasyJacksonProvider.setMapper(MAPPER);
final ResteasyProviderFactory providerFactory = ResteasyProviderFactory.newInstance();
providerFactory.register(resteasyJacksonProvider);
final Configuration configuration = new LocalResteasyProviderFactory(providerFactory);
return ClientBuilder.newClient(configuration);
}
use of org.jboss.resteasy.spi.ResteasyProviderFactory in project scheduling by ow2-proactive.
the class SchedulerStateRest method submitPlannings.
@Override
public String submitPlannings(String sessionId, PathSegment pathSegment, Map<String, String> jobContentXmlString) throws JobCreationRestException, NotConnectedRestException, IOException {
checkAccess(sessionId, "plannings");
Map<String, String> jobVariables = workflowVariablesTransformer.getWorkflowVariablesFromPathSegment(pathSegment);
if (jobContentXmlString == null || jobContentXmlString.size() != 1) {
throw new JobCreationRestException("Cannot find job body: code " + HttpURLConnection.HTTP_BAD_REQUEST);
}
Map<String, Object> requestBody = new HashMap<>(2);
requestBody.put(VARIABLES_KEY, jobVariables);
requestBody.put("xmlContentString", jobContentXmlString.entrySet().iterator().next().getValue());
Response response = null;
try {
ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
SchedulerRestClient.registerGzipEncoding(providerFactory);
ResteasyClient client = new ResteasyClientBuilder().providerFactory(providerFactory).build();
ResteasyWebTarget target = client.target(PortalConfiguration.JOBPLANNER_URL.getValueAsString());
response = target.request().header("sessionid", sessionId).post(Entity.entity(requestBody, "application/json"));
if (HttpURLConnection.HTTP_OK != response.getStatus()) {
throw new IOException(String.format("Cannot access resource %s: code %d", PortalConfiguration.JOBPLANNER_URL.getValueAsString(), response.getStatus()));
}
return response.readEntity(String.class);
} finally {
if (response != null) {
response.close();
}
}
}
use of org.jboss.resteasy.spi.ResteasyProviderFactory in project kie-wb-common by kiegroup.
the class MavenRestHandlerTest method post.
@Test
public void post() {
// Start preparation FS
try {
fileSystemTestingUtils.setup();
ioService = fileSystemTestingUtils.getIoService();
final String repoName = "myrepo";
final JGitFileSystem fs = (JGitFileSystem) ioService.newFileSystem(URI.create("git://" + repoName), new HashMap<String, Object>() {
{
put("init", Boolean.TRUE);
put("internal", Boolean.TRUE);
}
});
ioService.startBatch(fs);
String pom = "target/test-classes/kjar-2-single-resources/pom.xml";
if (!runIntoMavenCLI) {
pom = "kie-wb-common-services/kie-wb-common-compiler/kie-wb-common-compiler-distribution/target/test-classes/kjar-2-single-resources/pom.xml";
}
ioService.write(fs.getPath("/kjar-2-single-resources/pom.xml"), new String(java.nio.file.Files.readAllBytes(new File(pom).toPath())));
String personDotJava = "target/test-classes/kjar-2-single-resources/src/main/java/org/kie/maven/plugin/test/Person.java";
if (!runIntoMavenCLI) {
personDotJava = "kie-wb-common-services/kie-wb-common-compiler/kie-wb-common-compiler-distribution/target/test-classes/kjar-2-single-resources/src/main/java/org/kie/maven/plugin/test/Person.java";
}
ioService.write(fs.getPath("/kjar-2-single-resources/src/main/java/org/kie/maven/plugin/test/Person.java"), new String(java.nio.file.Files.readAllBytes(new File(personDotJava).toPath())));
String simpleRulesDotDRL = "target/test-classes/kjar-2-single-resources/src/main/resources/AllResourcesTypes/simple-rules.drl";
if (!runIntoMavenCLI) {
simpleRulesDotDRL = "kie-wb-common-services/kie-wb-common-compiler/kie-wb-common-compiler-distribution/target/test-classes/kjar-2-single-resources/src/main/resources/AllResourceTypes/simple-rules.drl";
}
ioService.write(fs.getPath("/kjar-2-single-resources/src/main/resources/AllResourcesTypes/simple-rules.drl"), new String(java.nio.file.Files.readAllBytes(new File(simpleRulesDotDRL).toPath())));
String kmodule = "target/test-classes/kjar-2-single-resources/src/main/resources/META-INF/kmodule.xml";
if (!runIntoMavenCLI) {
kmodule = "kie-wb-common-services/kie-wb-common-compiler/kie-wb-common-compiler-distribution/target/test-classes/kjar-2-single-resources/src/main/resources/META-INF/kmodule.xml";
}
ioService.write(fs.getPath("/kjar-2-single-resources/src/main/resources/META-INF/kmodule.xml"), new String(java.nio.file.Files.readAllBytes(new File(kmodule).toPath())));
ioService.endBatch();
java.nio.file.Path tmpRootCloned = java.nio.file.Files.createTempDirectory("cloned");
java.nio.file.Path tmpCloned = java.nio.file.Files.createDirectories(java.nio.file.Paths.get(tmpRootCloned.toString(), "dummy"));
final File gitClonedFolder = new File(tmpCloned.toFile(), ".clone.git");
final Git cloned = Git.cloneRepository().setURI(fs.getGit().getRepository().getDirectory().toURI().toString()).setBare(false).setDirectory(gitClonedFolder).call();
assertThat(cloned).isNotNull();
mavenRepoPath = java.nio.file.Paths.get(System.getProperty("user.home"), ".m2", "repository");
tmpRoot = java.nio.file.Paths.get(gitClonedFolder + "/dummy/");
// END preparation FS
Dispatcher dispatcher = new AsynchronousDispatcher(new ResteasyProviderFactory());
ResteasyProviderFactory.setInstance(dispatcher.getProviderFactory());
RegisterBuiltin.register(dispatcher.getProviderFactory());
POJOResourceFactory noDefaults = new POJOResourceFactory(MavenRestHandler.class);
dispatcher.getRegistry().addResourceFactory(noDefaults);
MockHttpRequest request = MockHttpRequest.create("POST", "build/maven/");
request.header("project", tmpRoot.toAbsolutePath().toString() + "/dummy").header("mavenrepo", mavenRepoPath.toAbsolutePath().toString());
MockHttpResponse response = new MockHttpResponse();
SynchronousExecutionContext synchronousExecutionContext = new SynchronousExecutionContext((SynchronousDispatcher) dispatcher, request, response);
request.setAsynchronousContext(synchronousExecutionContext);
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
byte[] serializedCompilationResponse = response.getOutput();
HttpCompilationResponse res = RestUtils.readDefaultCompilationResponseFromBytes(serializedCompilationResponse);
assertThat(res).isNotNull();
assertThat(res.getDependencies()).hasSize(4);
assertThat(res.getTargetContent()).hasSize(3);
tearDown();
} catch (Exception e) {
logger.error(e.getMessage());
} finally {
fileSystemTestingUtils.cleanup();
}
}
use of org.jboss.resteasy.spi.ResteasyProviderFactory in project fabric8 by jboss-fuse.
the class ResteasyGitRepoClient method createWebClient.
/**
* Creates a JAXRS web client for the given JAXRS client
*/
protected <T> T createWebClient(Class<T> clientType) {
String address = getAddress();
ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
providerFactory.register(ResteasyJackson2Provider.class);
providerFactory.register(Jackson2JsonpInterceptor.class);
providerFactory.register(StringTextStar.class);
providerFactory.register(DefaultTextPlain.class);
providerFactory.register(FileProvider.class);
providerFactory.register(InputStreamProvider.class);
providerFactory.register(new Authenticator());
providerFactory.register(clientType);
ResteasyClientBuilder builder = new ResteasyClientBuilder();
builder.providerFactory(providerFactory);
builder.connectionPoolSize(3);
Client client = builder.build();
ResteasyWebTarget target = (ResteasyWebTarget) client.target(address);
return target.proxy(clientType);
}
Aggregations