use of org.eclipse.che.ide.websocket.MessageBuilder in project che by eclipse.
the class GitServiceClientImpl method add.
@Override
public void add(DevMachine devMachine, ProjectConfig project, boolean update, @Nullable List<String> filePattern, RequestCallback<Void> callback) throws WebSocketException {
AddRequest addRequest = dtoFactory.createDto(AddRequest.class).withUpdate(update);
if (filePattern == null) {
addRequest.setFilePattern(AddRequest.DEFAULT_PATTERN);
} else {
addRequest.setFilePattern(filePattern);
}
String url = ADD + "?projectPath=" + project.getPath();
MessageBuilder builder = new MessageBuilder(POST, url);
builder.data(dtoFactory.toJson(addRequest)).header(CONTENTTYPE, APPLICATION_JSON);
Message message = builder.build();
sendMessageToWS(message, callback);
}
use of org.eclipse.che.ide.websocket.MessageBuilder in project che by eclipse.
the class JavaSearchServiceWS method findUsages.
@Override
public Promise<FindUsagesResponse> findUsages(final FindUsagesRequest request) {
final MessageBus messageBus = provider.getMachineMessageBus();
return createFromAsyncRequest(callback -> {
final MessageBuilder builder = new MessageBuilder(POST, pathToService + "find/usages");
builder.data(dtoFactory.toJson(request)).header(CONTENTTYPE, APPLICATION_JSON).header(ACCEPT, APPLICATION_JSON);
loader.show();
try {
messageBus.send(builder.build(), new RequestCallback<FindUsagesResponse>(unmarshallerFactory.newWSUnmarshaller(FindUsagesResponse.class)) {
@Override
protected void onSuccess(FindUsagesResponse result) {
loader.hide();
callback.onSuccess(result);
}
@Override
protected void onFailure(Throwable exception) {
loader.hide();
callback.onFailure(exception);
}
});
} catch (WebSocketException e) {
loader.hide();
callback.onFailure(e);
}
});
}
use of org.eclipse.che.ide.websocket.MessageBuilder in project che by eclipse.
the class JavaClasspathServiceClientImpl method updateDependencies.
/** {@inheritDoc} */
@Override
public void updateDependencies(String projectPath, RequestCallback<ClassPathBuilderResult> callback) {
final String requestUrl = baseHttpUrl + "/classpath/update?projectpath=" + projectPath;
MessageBuilder builder = new MessageBuilder(GET, requestUrl);
builder.header(ACCEPT, APPLICATION_JSON);
Message message = builder.build();
sendMessageToWS(message, callback);
}
use of org.eclipse.che.ide.websocket.MessageBuilder in project che by eclipse.
the class ProjectServiceClientImpl method importProject.
/** {@inheritDoc} */
@Override
public Promise<Void> importProject(final Path path, final SourceStorageDto source) {
return createFromAsyncRequest(callback -> {
final String url = PROJECT + IMPORT + path(path.toString());
final Message message = new MessageBuilder(POST, url).data(dtoFactory.toJson(source)).header(CONTENTTYPE, APPLICATION_JSON).build();
wsAgentStateController.getMessageBus().then(messageBus -> {
try {
messageBus.send(message, new RequestCallback<Void>() {
@Override
protected void onSuccess(Void result) {
callback.onSuccess(result);
}
@Override
protected void onFailure(Throwable exception) {
callback.onFailure(exception);
}
});
} catch (WebSocketException e) {
callback.onFailure(e);
}
}).catchError(error -> {
callback.onFailure(error.getCause());
});
});
}
use of org.eclipse.che.ide.websocket.MessageBuilder in project che by eclipse.
the class GitServiceClientImpl method fetch.
@Override
public void fetch(DevMachine devMachine, ProjectConfigDto project, String remote, List<String> refspec, boolean removeDeletedRefs, RequestCallback<String> callback) throws WebSocketException {
FetchRequest fetchRequest = dtoFactory.createDto(FetchRequest.class).withRefSpec(refspec).withRemote(remote).withRemoveDeletedRefs(removeDeletedRefs);
String url = FETCH + "?projectPath=" + project.getPath();
MessageBuilder builder = new MessageBuilder(POST, url);
builder.data(dtoFactory.toJson(fetchRequest)).header(CONTENTTYPE, APPLICATION_JSON);
Message message = builder.build();
sendMessageToWS(message, callback);
}
Aggregations