/** * Gets header name of the affordance, either Link or Link-Template depending on the presence of template * variables. * * @return header name * @see <a href="http://tools.ietf.org/html/rfc5988">Web Linking rfc-5988</a> * @see <a href="http://tools.ietf.org/html/draft-nottingham-link-template-01">Link-Template Header</a> */ @JsonIgnore public String getHeaderName() { String headerName; if (super.isTemplated()) { headerName = "Link-Template"; } else { headerName = "Link"; } return headerName; }
/** * Gets header name of the affordance, either Link or Link-Template depending on the presence of template * variables. * * @return header name * @see <a href="http://tools.ietf.org/html/rfc5988">Web Linking rfc-5988</a> * @see <a href="http://tools.ietf.org/html/draft-nottingham-link-template-01">Link-Template Header</a> */ @JsonIgnore public String getHeaderName() { String headerName; if (super.isTemplated()) { headerName = "Link-Template"; } else { headerName = "Link"; } return headerName; }
private List<Link> getEmbeddedLinks(List<Link> links) { List<Link> ret = new ArrayList<Link>(); for (Link link : links) { if (!navigationalRels.contains(link.getRel())) { if (link instanceof Affordance) { Affordance affordance = (Affordance) link; List<ActionDescriptor> actionDescriptors = affordance.getActionDescriptors(); for (ActionDescriptor actionDescriptor : actionDescriptors) { if ("GET".equals(actionDescriptor.getHttpMethod()) && !affordance.isTemplated()) { ret.add(link); } } } else { // templated links are actions, not embedded links if(!link.isTemplated()) { ret.add(link); } } } } return ret; }
private List<Link> getEmbeddedLinks(List<Link> links) { List<Link> ret = new ArrayList<Link>(); for (Link link : links) { if (!navigationalRels.contains(link.getRel())) { if (link instanceof Affordance) { Affordance affordance = (Affordance) link; List<ActionDescriptor> actionDescriptors = affordance.getActionDescriptors(); for (ActionDescriptor actionDescriptor : actionDescriptors) { if ("GET".equals(actionDescriptor.getHttpMethod()) && !affordance.isTemplated()) { ret.add(link); } } } else { // templated links are actions, not embedded links if(!link.isTemplated()) { ret.add(link); } } } } return ret; }
private List<Link> getActions(List<Link> links) { List<Link> ret = new ArrayList<Link>(); for (Link link : links) { if (link instanceof Affordance) { Affordance affordance = (Affordance) link; List<ActionDescriptor> actionDescriptors = affordance.getActionDescriptors(); for (ActionDescriptor actionDescriptor : actionDescriptors) { // non-self GET non-GET and templated links are actions if (!("GET".equals(actionDescriptor.getHttpMethod())) || affordance.isTemplated()) { ret.add(link); // add just once for eligible link break; } } } else { // templated links are actions if (!navigationalRels.contains(link.getRel()) && link.isTemplated()) { ret.add(link); } } } return ret; }
private List<Link> getActions(List<Link> links) { List<Link> ret = new ArrayList<Link>(); for (Link link : links) { if (link instanceof Affordance) { Affordance affordance = (Affordance) link; List<ActionDescriptor> actionDescriptors = affordance.getActionDescriptors(); for (ActionDescriptor actionDescriptor : actionDescriptors) { // non-self GET non-GET and templated links are actions if (!("GET".equals(actionDescriptor.getHttpMethod())) || affordance.isTemplated()) { ret.add(link); // add just once for eligible link break; } } } else { // templated links are actions if (!navigationalRels.contains(link.getRel()) && link.isTemplated()) { ret.add(link); } } } return ret; }
if (!link.isTemplated()) { throw new IllegalArgumentException("cannot expand link: link is not templated");
} else if (link.isTemplated()) { templatedLinks.add(link); } else {
} else if (link.isTemplated()) { List<SirenField> fields = new ArrayList<SirenField>(); List<TemplateVariable> variables = link.getVariables();
} else if (link.isTemplated()) { List<SirenField> fields = new ArrayList<SirenField>(); List<TemplateVariable> variables = link.getVariables();
private void appendLinkWithoutActionDescriptor(Link link) throws IOException { if (link.isTemplated()) { // TODO ensure that template expansion takes place for base uri Link expanded = link.expand(); // remove query variables beginForm(OptionalAttributes.attr("action", expanded.getHref()) .and("method", "GET")); List<TemplateVariable> variables = link.getVariables(); for (TemplateVariable variable : variables) { String variableName = variable.getName(); String label = variable.hasDescription() ? variable.getDescription() : variableName; writeLabelWithDoc(label, variableName, null); // no documentation url input(variableName, Type.TEXT); } } else { String rel = link.getRel(); String title = (rel != null ? rel : link.getHref()); // TODO: write html <link> instead of anchor <a> here? writeAnchor(OptionalAttributes.attr("href", link.getHref()) .and("rel", link.getRel()), title); } }
private void appendLinkWithoutActionDescriptor(Link link) throws IOException { if (link.isTemplated()) { // TODO ensure that template expansion takes place for base uri Link expanded = link.expand(); // remove query variables beginForm(OptionalAttributes.attr("action", expanded.getHref()) .and("method", "GET")); List<TemplateVariable> variables = link.getVariables(); for (TemplateVariable variable : variables) { String variableName = variable.getName(); String label = variable.hasDescription() ? variable.getDescription() : variableName; writeLabelWithDoc(label, variableName, null); // no documentation url input(variableName, Type.TEXT); } } else { String rel = link.getRel(); String title = (rel != null ? rel : link.getHref()); // TODO: write html <link> instead of anchor <a> here? writeAnchor(OptionalAttributes.attr("href", link.getHref()) .and("rel", link.getRel()), title); } }