/** * URL-decodes any terminating hash characters ("%23"). Any non-terminating URL-encoded hashes will be * left as they are (since there should be no intermediate hashes in a URL). * * @param iri * the IRI to desanitize * @return the desanitized IRI */ public static IRI desanitize(IRI iri) { return IRI.create(desanitize(iri.toString())); }
/** * Extracts an OWL Ontology ID from its standard string form. The string must be of type * <tt>ontologyIRI[:::versionIRI]</tt>. Any substring <tt>"%3A%3A%3A"</tt> present in <tt>ontologyIRI</tt> * or <tt>versionIRI</tt> will be URL-decoded (i.e. converted to <tt>":::"</tt>).<br/> * <br/> * Also note that both <tt>ontologyIRI</tt> and <tt>versionIRI</tt> are desanitized in the process. * * @param stringForm * the string to decode * @return the string form of this ID. * @see URIUtils#desanitize(IRI) */ public static OWLOntologyID decode(String stringForm) { if (stringForm == null || stringForm.isEmpty()) throw new IllegalArgumentException( "Supplied string form must be non-null and non-empty."); IRI oiri, viri; String[] split = stringForm.split(":::"); if (split.length >= 1) { oiri = URIUtils.desanitize(IRI.create(split[0].replace("%3A%3A%3A", ":::"))); viri = (split.length > 1) ? URIUtils.desanitize(IRI.create(split[1].replace("%3A%3A%3A", ":::"))) : null; return (viri != null) ? new OWLOntologyID(oiri, viri) : new OWLOntologyID(oiri); } else return null; // Anonymous but versioned ontologies are not acceptable. }
/** * Extracts an OWL Ontology ID from its standard string form. The string must be of type * <tt>ontologyIRI[:::versionIRI]</tt>. Any substring <tt>"%3A%3A%3A"</tt> present in <tt>ontologyIRI</tt> * or <tt>versionIRI</tt> will be URL-decoded (i.e. converted to <tt>":::"</tt>).<br/> * <br/> * Also note that both <tt>ontologyIRI</tt> and <tt>versionIRI</tt> are desanitized in the process. * * @param stringForm * the string to decode * @return the string form of this ID. * @see URIUtils#desanitize(IRI) */ public static OWLOntologyID decode(String stringForm) { if (stringForm == null || stringForm.isEmpty()) throw new IllegalArgumentException( "Supplied string form must be non-null and non-empty."); IRI oiri, viri; String[] split = stringForm.split(":::"); if (split.length >= 1) { oiri = URIUtils.desanitize(IRI.create(split[0].replace("%3A%3A%3A", ":::"))); viri = (split.length > 1) ? URIUtils.desanitize(IRI.create(split[1].replace("%3A%3A%3A", ":::"))) : null; return (viri != null) ? new OWLOntologyID(oiri, viri) : new OWLOntologyID(oiri); } else return null; // Anonymous but versioned ontologies are not acceptable. }
if (reg != null && !reg.isEmpty()) try { srcs.add(new LibrarySource(URIUtils.desanitize(IRI.create(reg)), regMgr)); } catch (Exception e1) { throw new WebApplicationException(e1, BAD_REQUEST);