private Link getLink(final LinkHeaderParam link, ClientRequestContext context) { LinkHeader linkHeader = context.getClientResponse().getLinkHeader(); if (!"".equals(link.rel())) return linkHeader.getLinkByRelationship(link.rel()); else return linkHeader.getLinkByTitle(link.title()); }
protected void initialize() throws Exception { super.start(); initialized = true; initAuthentication(); ClientRequest request = executor.createRequest(registration.getTarget().getHref()); for (XmlHttpHeader header : registration.getHeaders()) { request.header(header.getName(), header.getValue()); } ClientResponse<?> res = request.head(); if (res.getStatus() != 200) { throw new RuntimeException("Failed to query REST destination for init information. Status: " + res.getStatus()); } String url = (String) res.getHeaders().getFirst("msg-create-with-id"); if (url == null) { if (res.getLinkHeader() == null) { throw new RuntimeException("Could not find create-with-id URL"); } Link link = res.getLinkHeader().getLinkByTitle("create-with-id"); if (link == null) { throw new RuntimeException("Could not find create-with-id URL"); } url = link.getHref(); } targetUri = ResteasyUriBuilder.fromTemplate(url); }
protected void initialize() throws Exception { super.start(); initialized = true; initAuthentication(); ClientRequest request = executor.createRequest(registration.getTarget().getHref()); for (XmlHttpHeader header : registration.getHeaders()) { request.header(header.getName(), header.getValue()); } ClientResponse<?> res = request.head(); if (res.getStatus() != 200) { throw new RuntimeException("Failed to query REST destination for init information. Status: " + res.getStatus()); } String url = (String) res.getHeaders().getFirst("msg-create-with-id"); if (url == null) { if (res.getLinkHeader() == null) { throw new RuntimeException("Could not find create-with-id URL"); } Link link = res.getLinkHeader().getLinkByTitle("create-with-id"); if (link == null) { throw new RuntimeException("Could not find create-with-id URL"); } url = link.getHref(); } targetUri = ResteasyUriBuilder.fromTemplate(url); }
Link link = res.getLinkHeader().getLinkByTitle("create-with-id"); if (link == null)