use of org.eclipse.che.ide.websocket.MessageBuilder in project che by eclipse.
the class GitServiceClientImpl method cloneRepository.
@Override
public void cloneRepository(DevMachine devMachine, ProjectConfigDto project, String remoteUri, String remoteName, RequestCallback<RepoInfo> callback) throws WebSocketException {
CloneRequest cloneRequest = dtoFactory.createDto(CloneRequest.class).withRemoteName(remoteName).withRemoteUri(remoteUri).withWorkingDir(project.getPath());
String params = "?projectPath=" + project.getPath();
String url = CLONE + params;
MessageBuilder builder = new MessageBuilder(POST, url);
builder.data(dtoFactory.toJson(cloneRequest)).header(CONTENTTYPE, APPLICATION_JSON).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 GitServiceClientImpl method init.
@Override
public void init(DevMachine devMachine, ProjectConfigDto project, boolean bare, final RequestCallback<Void> callback) throws WebSocketException {
String url = INIT + "?projectPath=" + project.getPath() + "&bare=" + bare;
Message message = new MessageBuilder(POST, url).header(ACCEPT, TEXT_PLAIN).build();
sendMessageToWS(message, callback);
}
use of org.eclipse.che.ide.websocket.MessageBuilder in project che by eclipse.
the class NavigateToFilePresenter method onFileNameChanged.
@Override
public void onFileNameChanged(String fileName) {
if (fileName.isEmpty()) {
view.showItems(new ArrayList<ItemReference>());
return;
}
// add '*' to allow search files by first letters
final String url = SEARCH_URL + "/?name=" + URL.encodePathSegment(fileName + "*");
final Message message = new MessageBuilder(GET, url).header(ACCEPT, APPLICATION_JSON).build();
final Unmarshallable<List<ItemReference>> unmarshaller = dtoUnmarshallerFactory.newWSListUnmarshaller(ItemReference.class);
try {
wsMessageBus.send(message, new RequestCallback<List<ItemReference>>(unmarshaller) {
@Override
protected void onSuccess(List<ItemReference> result) {
view.showItems(result);
}
@Override
protected void onFailure(Throwable exception) {
Log.error(getClass(), exception);
}
});
} catch (WebSocketException e) {
Log.error(getClass(), e);
}
}
Aggregations