/** * Build up this date with original text as supplied by the user. * * @param original the original text. * @return this. */ public Date original(String original) { setOriginal(original); return this; }
public Date normalizeDate(String date, StateTransitionOption... options) { Link normalizedDateLink = getLink(Rel.NORMALIZED_DATE); if (normalizedDateLink == null || normalizedDateLink.getTemplate() == null) { return null; } String template = normalizedDateLink.getTemplate(); String uri; try { uri = UriTemplate.fromTemplate(template).set("date", date).expand(); } catch (VariableExpansionException e) { throw new GedcomxApplicationException(e); } catch (MalformedUriTemplateException e) { throw new GedcomxApplicationException(e); } ClientRequest request = createRequest().accept(MediaType.TEXT_PLAIN).build(URI.create(uri), HttpMethod.GET); ClientResponse response = invoke(request, options); Date dateValue = new Date(); dateValue.setOriginal(date); dateValue.addNormalizedExtension(new TextValue(response.getEntity(String.class))); if (response.getHeaders()!= null) { dateValue.setFormal(response.getHeaders().getFirst("Location")); dateValue.getNormalizedExtensions().get(0).setLang(response.getHeaders().getFirst("Content-Language")); } return dateValue; }