use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class RemoteServiceDescriptor method getLinks.
/** @see ServiceDescriptor#getLinks() */
public List<Link> getLinks() throws ServerException, IOException {
final List<Link> links = getServiceDescriptor().getLinks();
// always copy list and links itself!
final List<Link> copy = new ArrayList<>(links.size());
for (Link link : links) {
copy.add(DtoFactory.getInstance().clone(link));
}
return copy;
}
use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class Service method generateServiceDescriptor.
private ServiceDescriptor generateServiceDescriptor(UriInfo uriInfo, Class<? extends Service> service) {
final List<Link> links = new ArrayList<>();
for (Method method : service.getMethods()) {
final GenerateLink generateLink = method.getAnnotation(GenerateLink.class);
if (generateLink != null) {
try {
links.add(generateLinkForMethod(uriInfo, generateLink.rel(), method));
} catch (RuntimeException ignored) {
}
}
}
final Description description = service.getAnnotation(Description.class);
final ServiceDescriptor dto = createServiceDescriptor().withHref(uriInfo.getRequestUriBuilder().replaceQuery(null).build().toString()).withLinks(links).withVersion(Constants.API_VERSION);
if (description != null) {
dto.setDescription(description.value());
}
return dto;
}
use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class ServiceDescriptorTest method testLinkInfo.
@Test
public void testLinkInfo() throws Exception {
Link link = getLink("echo");
Assert.assertEquals(link.getMethod(), HttpMethod.GET);
Assert.assertEquals(link.getHref(), SERVICE_URI + "/my_method");
Assert.assertEquals(link.getProduces(), MediaType.TEXT_PLAIN);
}
use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class MachineEntityImpl method getTerminalUrl.
public String getTerminalUrl() {
for (Link link : machineLinks) {
if (Constants.TERMINAL_REFERENCE.equals(link.getRel())) {
return link.getHref();
}
}
//should not be
final String message = "Reference " + Constants.TERMINAL_REFERENCE + " not found in " + machineConfig.getName() + " description";
Log.error(getClass(), message);
throw new RuntimeException(message);
}
use of org.eclipse.che.api.core.rest.shared.dto.Link in project che by eclipse.
the class MachineEntityImpl method getExecAgentUrl.
public String getExecAgentUrl() {
for (Link link : machineLinks) {
if (Constants.EXEC_AGENT_REFERENCE.equals(link.getRel())) {
return link.getHref();
}
}
//should not be
final String message = "Reference " + Constants.EXEC_AGENT_REFERENCE + " not found in " + machineConfig.getName() + " description";
Log.error(getClass(), message);
throw new RuntimeException(message);
}
Aggregations