Search in sources :

Example 1 with MessageBuilder

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

Example 2 with MessageBuilder

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);
        }
    });
}
Also used : MessageBus(org.eclipse.che.ide.websocket.MessageBus) FindUsagesResponse(org.eclipse.che.ide.ext.java.shared.dto.search.FindUsagesResponse) MessageBuilder(org.eclipse.che.ide.websocket.MessageBuilder) WebSocketException(org.eclipse.che.ide.websocket.WebSocketException)

Example 3 with MessageBuilder

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

Example 4 with MessageBuilder

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());
        });
    });
}
Also used : AsyncPromiseHelper.createFromAsyncRequest(org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.createFromAsyncRequest) AsyncRequestFactory(org.eclipse.che.ide.rest.AsyncRequestFactory) NewProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.NewProjectConfigDto) Inject(com.google.inject.Inject) RequestCallback(org.eclipse.che.ide.websocket.rest.RequestCallback) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) DELETE(com.google.gwt.http.client.RequestBuilder.DELETE) Promise(org.eclipse.che.api.promises.client.Promise) AppContext(org.eclipse.che.ide.api.app.AppContext) Map(java.util.Map) URL(com.google.gwt.http.client.URL) Message(org.eclipse.che.ide.websocket.Message) MessageBuilder(org.eclipse.che.ide.websocket.MessageBuilder) CONTENT_TYPE(org.eclipse.che.ide.rest.HTTPHeader.CONTENT_TYPE) DtoUnmarshallerFactory(org.eclipse.che.ide.rest.DtoUnmarshallerFactory) DtoFactory(org.eclipse.che.ide.dto.DtoFactory) LoaderFactory(org.eclipse.che.ide.ui.loaders.request.LoaderFactory) CONTENTTYPE(org.eclipse.che.ide.rest.HTTPHeader.CONTENTTYPE) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) APPLICATION_JSON(org.eclipse.che.ide.MimeType.APPLICATION_JSON) WsAgentStateController(org.eclipse.che.ide.api.machine.WsAgentStateController) StringUnmarshaller(org.eclipse.che.ide.rest.StringUnmarshaller) SourceStorageDto(org.eclipse.che.api.workspace.shared.dto.SourceStorageDto) TreeElement(org.eclipse.che.api.project.shared.dto.TreeElement) MoveOptions(org.eclipse.che.api.project.shared.dto.MoveOptions) PUT(com.google.gwt.http.client.RequestBuilder.PUT) ItemReference(org.eclipse.che.api.project.shared.dto.ItemReference) POST(com.google.gwt.http.client.RequestBuilder.POST) WebSocketException(org.eclipse.che.ide.websocket.WebSocketException) List(java.util.List) CopyOptions(org.eclipse.che.api.project.shared.dto.CopyOptions) MimeType(org.eclipse.che.ide.MimeType) ACCEPT(org.eclipse.che.ide.rest.HTTPHeader.ACCEPT) SourceEstimation(org.eclipse.che.api.project.shared.dto.SourceEstimation) Path(org.eclipse.che.ide.resource.Path) UrlBuilder(org.eclipse.che.ide.rest.UrlBuilder) Message(org.eclipse.che.ide.websocket.Message) MessageBuilder(org.eclipse.che.ide.websocket.MessageBuilder) RequestCallback(org.eclipse.che.ide.websocket.rest.RequestCallback) WebSocketException(org.eclipse.che.ide.websocket.WebSocketException)

Example 5 with MessageBuilder

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

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