Search in sources :

Example 6 with Link

use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.

the class DefaultHttpJsonResponseTest method shouldBeAbleToRequestListOfJsonSerializableElements.

@Test
public void shouldBeAbleToRequestListOfJsonSerializableElements() throws Exception {
    final Link testLink = createLink("POST", "http://localhost:8080", "rel");
    final String responseBody = DtoFactory.getInstance().toJson(new JsonArrayImpl<>(singletonList(testLink)));
    final DefaultHttpJsonResponse response = new DefaultHttpJsonResponse(responseBody, 200);
    assertEquals(response.asList(Link.class), singletonList(testLink));
}
Also used : Link(org.eclipse.che.api.core.rest.shared.dto.Link) LinksHelper.createLink(org.eclipse.che.api.core.util.LinksHelper.createLink) Test(org.testng.annotations.Test)

Example 7 with Link

use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.

the class ServiceDescriptorTest method testLinkParameters.

@Test
public void testLinkParameters() throws Exception {
    Link link = getLink("echo");
    List<LinkParameter> parameters = link.getParameters();
    Assert.assertEquals(parameters.size(), 1);
    LinkParameter linkParameter = parameters.get(0);
    Assert.assertEquals(linkParameter.getDefaultValue(), "a");
    Assert.assertEquals(linkParameter.getDescription(), "some text");
    Assert.assertEquals(linkParameter.getName(), "text");
    Assert.assertEquals(linkParameter.getType(), ParameterType.String);
    Assert.assertTrue(linkParameter.isRequired());
    List<String> valid = linkParameter.getValid();
    Assert.assertEquals(valid.size(), 2);
    Assert.assertTrue(valid.contains("a"));
    Assert.assertTrue(valid.contains("b"));
}
Also used : LinkParameter(org.eclipse.che.api.core.rest.shared.dto.LinkParameter) Link(org.eclipse.che.api.core.rest.shared.dto.Link) GenerateLink(org.eclipse.che.api.core.rest.annotations.GenerateLink) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 8 with Link

use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.

the class WorkspaceEventsHandler method subscribeOnEnvironmentOutputChannel.

private void subscribeOnEnvironmentOutputChannel(WorkspaceDto workspace) {
    if (environmentOutputSubscriptionHandler != null) {
        return;
    }
    final Link link = workspace.getLink(LINK_REL_ENVIRONMENT_OUTPUT_CHANNEL);
    final LinkParameter logsChannelLinkParameter = link.getParameter("channel");
    if (logsChannelLinkParameter == null) {
        return;
    }
    environmentOutputChannel = logsChannelLinkParameter.getDefaultValue();
    environmentOutputSubscriptionHandler = new EnvironmentOutputSubscriptionHandler();
    subscribeToChannel(environmentOutputChannel, environmentOutputSubscriptionHandler);
}
Also used : LinkParameter(org.eclipse.che.api.core.rest.shared.dto.LinkParameter) Link(org.eclipse.che.api.core.rest.shared.dto.Link)

Example 9 with Link

use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.

the class WorkspaceEventsHandler method subscribeOnEnvironmentStatusChannel.

private void subscribeOnEnvironmentStatusChannel(WorkspaceDto workspace) {
    if (environmentStatusSubscriptionHandler != null) {
        return;
    }
    final Link link = workspace.getLink(LINK_REL_ENVIRONMENT_STATUS_CHANNEL);
    final LinkParameter statusChannelLinkParameter = link.getParameter("channel");
    if (statusChannelLinkParameter == null) {
        return;
    }
    environmentStatusChannel = statusChannelLinkParameter.getDefaultValue();
    environmentStatusSubscriptionHandler = new EnvironmentStatusSubscriptionHandler();
    subscribeToChannel(environmentStatusChannel, environmentStatusSubscriptionHandler);
}
Also used : LinkParameter(org.eclipse.che.api.core.rest.shared.dto.LinkParameter) Link(org.eclipse.che.api.core.rest.shared.dto.Link)

Example 10 with Link

use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.

the class WorkspaceEventsHandler method subscribeToWorkspaceStatusEvents.

private void subscribeToWorkspaceStatusEvents(final WorkspaceDto workspace) {
    final Link workspaceEventsLink = workspace.getLink(LINK_REL_GET_WORKSPACE_EVENTS_CHANNEL);
    if (workspaceEventsLink == null) {
        //should never be
        notificationManager.notify(locale.workspaceSubscribeOnEventsFailed(), FAIL, EMERGE_MODE);
        Log.error(getClass(), "Link " + LINK_REL_GET_WORKSPACE_EVENTS_CHANNEL + " not found in workspace links. So events will be not handle");
        return;
    }
    workspaceStatusChannel = workspaceEventsLink.getParameter("channel").getDefaultValue();
    if (isNullOrEmpty(workspaceStatusChannel)) {
        //should never be
        notificationManager.notify(locale.workspaceSubscribeOnEventsFailed(), FAIL, EMERGE_MODE);
        Log.error(getClass(), "Channel for handling Workspace events not provide. So events will be not handle");
        return;
    }
    try {
        workspaceStatusSubscriptionHandler = new WorkspaceStatusSubscriptionHandler(workspace);
        messageBus.subscribe(workspaceStatusChannel, workspaceStatusSubscriptionHandler);
    } catch (WebSocketException exception) {
        Log.error(getClass(), exception);
    }
}
Also used : WebSocketException(org.eclipse.che.ide.websocket.WebSocketException) Link(org.eclipse.che.api.core.rest.shared.dto.Link)

Aggregations

Link (org.eclipse.che.api.core.rest.shared.dto.Link)40 UriBuilder (javax.ws.rs.core.UriBuilder)15 LinksHelper.createLink (org.eclipse.che.api.core.util.LinksHelper.createLink)13 ArrayList (java.util.ArrayList)11 Test (org.testng.annotations.Test)11 GenerateLink (org.eclipse.che.api.core.rest.annotations.GenerateLink)7 LinkParameter (org.eclipse.che.api.core.rest.shared.dto.LinkParameter)7 LinkedList (java.util.LinkedList)4 HttpMethod (javax.ws.rs.HttpMethod)2 Produces (javax.ws.rs.Produces)2 Description (org.eclipse.che.api.core.rest.annotations.Description)2 ItemReference (org.eclipse.che.api.project.shared.dto.ItemReference)2 ProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 Annotation (java.lang.annotation.Annotation)1 Method (java.lang.reflect.Method)1 URI (java.net.URI)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1