Search in sources :

Example 6 with MessageBuilder

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);
}
Also used : MessageBuilder(org.eclipse.che.ide.websocket.MessageBuilder) Message(org.eclipse.che.ide.websocket.Message) CloneRequest(org.eclipse.che.api.git.shared.CloneRequest)

Example 7 with MessageBuilder

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);
}
Also used : Message(org.eclipse.che.ide.websocket.Message) MessageBuilder(org.eclipse.che.ide.websocket.MessageBuilder)

Example 8 with MessageBuilder

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);
    }
}
Also used : ItemReference(org.eclipse.che.api.project.shared.dto.ItemReference) Message(org.eclipse.che.ide.websocket.Message) MessageBuilder(org.eclipse.che.ide.websocket.MessageBuilder) WebSocketException(org.eclipse.che.ide.websocket.WebSocketException) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

MessageBuilder (org.eclipse.che.ide.websocket.MessageBuilder)8 Message (org.eclipse.che.ide.websocket.Message)7 WebSocketException (org.eclipse.che.ide.websocket.WebSocketException)3 List (java.util.List)2 ItemReference (org.eclipse.che.api.project.shared.dto.ItemReference)2 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 DELETE (com.google.gwt.http.client.RequestBuilder.DELETE)1 POST (com.google.gwt.http.client.RequestBuilder.POST)1 PUT (com.google.gwt.http.client.RequestBuilder.PUT)1 URL (com.google.gwt.http.client.URL)1 Inject (com.google.inject.Inject)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 AddRequest (org.eclipse.che.api.git.shared.AddRequest)1 CloneRequest (org.eclipse.che.api.git.shared.CloneRequest)1 FetchRequest (org.eclipse.che.api.git.shared.FetchRequest)1 RemoteAddRequest (org.eclipse.che.api.git.shared.RemoteAddRequest)1 CopyOptions (org.eclipse.che.api.project.shared.dto.CopyOptions)1 MoveOptions (org.eclipse.che.api.project.shared.dto.MoveOptions)1 SourceEstimation (org.eclipse.che.api.project.shared.dto.SourceEstimation)1