}
// If conf:datasetURIPattern is set, then filter the dataset accordingly.
if (hasProperty(CONF.datasetURIPattern)) {
final Pattern pattern = Pattern.compile(getString(CONF.datasetURIPattern));
result = new FilteredDataSource(result) {
@Override
public boolean canDescribe(String absoluteIRI) {
return pattern.matcher(absoluteIRI).find();
}
};
}
IRIRewriter rewriter = IRIRewriter.identity;
// If conf:datasetBase is set (and different from conf:webBase),
// rewrite the IRIs accordingly
// Base IRI for IRIs considered to be "in" the data source
String fullWebBase = configuration.getWebApplicationBaseURI() +
configuration.getWebResourcePrefix();
String datasetBase = getIRI(CONF.datasetBase,
fullWebBase);
if (!datasetBase.equals(fullWebBase)) {
rewriter = IRIRewriter.createNamespaceBased(datasetBase, fullWebBase);
}
// Escape special characters in IRIs
rewriter = IRIRewriter.chain(rewriter, new PubbyIRIEscaper(
fullWebBase, !supportsIRIs()));
result = new RewrittenDataSource(
result, rewriter, addSameAsStatements());
// Determine all browsable namespaces for this dataset
final Set<String> browsableNamespaces = new HashSet<String>();
browsableNamespaces.add(fullWebBase);
for (String iri: getBrowsableNamespaces()) {
browsableNamespaces.add(iri);
}
browsableNamespaces.addAll(configuration.getBrowsableNamespaces());
// Filter the dataset to keep only those resources in the datasetBase
// and in browsable namespaces, unless it's an annotation provider
if (!hasType(CONF.AnnotationProvider)) {
result = new FilteredDataSource(result) {
@Override
public boolean canDescribe(String absoluteIRI) {
for (String namespace: browsableNamespaces) {
if (absoluteIRI.startsWith(namespace)) return true;
}