public static boolean isJavascriptUri(IRI uri) { if (uri == null) return false; return javascript.matcher(uri.toString()).matches(); }
public static boolean isMailtoUri(IRI uri) { if (uri == null) return false; return mailto.matcher(uri.toString()).matches(); }
public Object clone() { try { return super.clone(); } catch (CloneNotSupportedException e) { return new IRI(toString()); // not going to happen, but we have to // catch it } }
public String getTargetPath() { String uri = getUri().toString(); String cpath = getContextPath(); return cpath == null ? uri : uri.substring(cpath.length()); }
public void setUrl(String url) { if (url != null) { setAttributeValue("url", (new IRI(url)).toString()); } else { removeAttribute(new QName("url")); } }
protected void addEditLinkToEntry(Entry entry) throws Exception { if (ProviderHelper.getEditUriFromEntry(entry) == null) { entry.addLink(entry.getId().toString(), "edit"); } }
protected void addEditLinkToEntry(Entry entry) throws Exception { if (ProviderHelper.getEditUriFromEntry(entry) == null) { entry.addLink(entry.getId().toString(), "edit"); } }
public StreamWriter writeIRIElement( String name, String namespace, String prefix, IRI iri) { return startElement(name,namespace,prefix). writeElementText(iri.toString()). endElement(); }
private EntityTag calculateEntityTag(Base base) { String id = null; String modifiedDate = null; if (base instanceof Entry) { id = ((Entry) base).getId().toString(); modifiedDate = ((Entry) base).getUpdatedElement().getText(); } else if (base instanceof Feed) { id = ((Feed) base).getId().toString(); modifiedDate = ((Feed) base).getUpdatedElement().getText(); } return EntityTag.generate(id, modifiedDate); }
protected Element _parse(String value, IRI baseUri) throws ParseException, UnsupportedEncodingException { if (value == null) return null; FOMFactory fomfactory = (FOMFactory)factory; Parser parser = fomfactory.newParser(); ParserOptions options = parser.getDefaultParserOptions(); options.setFactory(fomfactory); Document doc = parser.parse(new StringReader(value), (baseUri != null) ? baseUri.toString() : null, options); return doc.getRoot(); }
private <T extends Element> Document<T> getEntry(InputStream stream, RequestContext request) throws ParseException, IOException { Parser parser = request.getAbdera().getParser(); if (parser == null) throw new IllegalArgumentException("No Parser implementation was provided"); Document<?> document = parser.parse(stream, request.getResolvedUri().toString(), parser.getDefaultParserOptions()); return (Document<T>)document; }
public Category setScheme(String scheme) { complete(); if (scheme != null) setAttributeValue(SCHEME, new IRI(scheme).toString()); else removeAttribute(SCHEME); return this; }
public Generator setUri(String uri) { complete(); if (uri != null) setAttributeValue(AURI, (new IRI(uri)).toString()); else removeAttribute(AURI); return this; }
public IRIElement setValue(String iri) { complete(); if (iri != null) ((Element)this).setText((new IRI(iri)).toString()); else _removeAllChildren(); return this; }
/** * Creates the ResponseContext for a newly created entry. By default, a BaseResponseContext is returned. The * Location, Content-Location, Etag and status are set appropriately. */ protected ResponseContext buildCreateEntryResponse(String link, Entry entry) { BaseResponseContext<Entry> rc = new BaseResponseContext<Entry>(entry); rc.setLocation(link); rc.setContentLocation(rc.getLocation().toString()); rc.setEntityTag(calculateEntityTag(entry)); rc.setStatus(201); return rc; }
private void setDSCommonProperties(Datastream dsVersion, DigitalObject obj, Entry entry, Feed feed) throws ObjectIntegrityException { IRI ref = ThreadHelper.getInReplyTo(entry).getRef(); Entry parent = feed.getEntry(ref.toString()); dsVersion.DatastreamID = getDatastreamId(obj, parent); dsVersion.DSControlGrp = getDSControlGroup(obj, parent); dsVersion.DSState = getDSState(parent); dsVersion.DSVersionable = getDSVersionable(obj, parent); setDatastreamVersionProperties(dsVersion, obj, entry); }
@Test public void testGetBooksWithCustomProvider() throws Exception { String endpointAddress = "http://localhost:" + PORT + "/bookstore/bookstore4/books/feed"; Feed feed = getFeed(endpointAddress, null); assertEquals("http://localhost:" + PORT + "/bookstore/bookstore4/books/feed", feed.getBaseUri().toString()); assertEquals("Collection of Books", feed.getTitle()); }
@Test public void testGetBooks2() throws Exception { String endpointAddress = "http://localhost:" + PORT + "/bookstore/sub/"; Feed feed = getFeed(endpointAddress, null); assertEquals("http://localhost:" + PORT + "/bookstore/sub/", feed.getBaseUri().toString()); assertEquals("Collection of Books", feed.getTitle()); getAndCompareJson("http://localhost:" + PORT + "/bookstore/sub/books/entries/123.json", "resources/expected_atom_book_json2.txt", "*/*"); }