use of org.kie.workbench.common.services.backend.compiler.impl.DefaultHttpCompilationResponse in project kie-wb-common by kiegroup.
the class RestUtils method readDefaultCompilationResponseFromBytes.
public static HttpCompilationResponse readDefaultCompilationResponseFromBytes(byte[] bytes) {
ObjectInput in = null;
ByteArrayOutputStream bos = null;
try {
in = new ObjectInputStream(new ByteArrayInputStream(bytes));
Object newObj = in.readObject();
return (HttpCompilationResponse) newObj;
} catch (NotSerializableException nse) {
logger.warn("Object is not serializable {}", nse.getMessage());
StringBuilder sb = new StringBuilder("NotSerializableException:").append(nse.getMessage());
logger.error(sb.toString());
} catch (IOException ioe) {
StringBuilder sb = new StringBuilder("IOException:").append(ioe.getMessage());
logger.error(sb.toString());
} catch (ClassNotFoundException cnfe) {
StringBuilder sb = new StringBuilder("ClassNotFoundException:").append(cnfe.getMessage());
logger.error(sb.toString());
} catch (Exception e) {
StringBuilder sb = new StringBuilder("Exception:").append(e.getMessage());
logger.error(sb.toString());
} finally {
try {
if (bos != null) {
bos.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
logger.error(ex.getMessage());
}
}
return new DefaultHttpCompilationResponse(Boolean.FALSE);
}
use of org.kie.workbench.common.services.backend.compiler.impl.DefaultHttpCompilationResponse in project kie-wb-common by kiegroup.
the class MavenRestHandler method postAsync.
/**
* Endpoint to ask an async build
*/
@POST
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public void postAsync(@Suspended AsyncResponse ar, @HeaderParam("project") String projectRepo, @HeaderParam("mavenrepo") String mavenRepoPath, @HeaderParam("settings_xml") String settingsXmlPath) throws Exception {
CompletableFuture<KieCompilationResponse> response = compilerService.build(projectRepo, mavenRepoPath, settingsXmlPath);
response.whenCompleteAsync((kieCompilationResponse, throwable) -> {
if (throwable != null) {
logger.error(throwable.getMessage());
ar.resume(Response.serverError().build());
} else {
byte[] bytes = RestUtils.serialize(new DefaultHttpCompilationResponse(kieCompilationResponse));
ar.resume(Response.ok(bytes).build());
}
});
}
Aggregations