use of org.eclipse.che.ide.websocket.Message 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.Message 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);
}
}
use of org.eclipse.che.ide.websocket.Message 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.Message 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);
}
use of org.eclipse.che.ide.websocket.Message 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);
}
Aggregations