GeoPubby  Version 0.1.0.0
HypermediaControls Class Reference

The hypermedia interface to a specific resource. More...

Collaboration diagram for HypermediaControls:

Public Member Functions

boolean isHosted ()
 Is the resource itself hosted by Pubby, that is, is it in Pubby's web base namespace? (If not, then Pubby merely provides a hypermedia browsing interface for the resource, but cannot be said to host the resource itself.) More...
 
String getAbsoluteIRI ()
 
String getBrowsableURL ()
 
ResourceDescription getResourceDescription ()
 
String getPageURL ()
 
String getDataURL ()
 
String getValuesPageURL (Property property)
 
String getInverseValuesPageURL (Property property)
 
String getValuesDataURL (Property property)
 
String getInverseValuesDataURL (Property property)
 

Static Public Member Functions

static HypermediaControls createFromPubbyPath (String path, Configuration config)
 Creates a new hypermedia resource from a Pubby path representing a resource. More...
 
static HypermediaControls createFromIRI (String absoluteIRI, Configuration config)
 Creates a new hypermedia resource from an absolute IRI. More...
 

Private Member Functions

 HypermediaControls (String absoluteIRI, Configuration config)
 
String getPubbyPath ()
 A version of the resource's IRI suitable for use in constructing Pubby path URLs. More...
 
String getPathURL (String urlPrefix, Property property)
 

Private Attributes

final String absoluteIRI
 
final boolean isHosted
 
final Configuration config
 

Detailed Description

The hypermedia interface to a specific resource.

The resource may be hosted by the server or merely made browsable by the server.

Constructor & Destructor Documentation

◆ HypermediaControls()

HypermediaControls ( String  absoluteIRI,
Configuration  config 
)
private
56  {
57  this.absoluteIRI = absoluteIRI;
58  this.config = config;
60  }
String getWebApplicationBaseURI()
Definition: Configuration.java:269
final String absoluteIRI
Definition: HypermediaControls.java:52
final Configuration config
Definition: HypermediaControls.java:54
final boolean isHosted
Definition: HypermediaControls.java:53

References HypermediaControls.absoluteIRI, HypermediaControls.config, and Configuration.getWebApplicationBaseURI().

Referenced by HypermediaControls.createFromIRI().

Member Function Documentation

◆ createFromIRI()

static HypermediaControls createFromIRI ( String  absoluteIRI,
Configuration  config 
)
static

Creates a new hypermedia resource from an absolute IRI.

Parameters
absoluteIRIAn IRI identifying the resource
configThe server's configuration
Returns
An object providing hypermedia controls for the resource, or null if this is not a Pubby-browsable resource.
46  {
47  if (absoluteIRI == null) return null;
48  if (!config.isBrowsable(absoluteIRI)) return null;
50  }
boolean isBrowsable(String iri)
Definition: Configuration.java:296
HypermediaControls(String absoluteIRI, Configuration config)
Definition: HypermediaControls.java:56

References HypermediaControls.absoluteIRI, HypermediaControls.config, HypermediaControls.HypermediaControls(), and Configuration.isBrowsable().

Referenced by HypermediaControls.createFromPubbyPath(), RootServlet.doGet(), ResourceDescription.ResourceProperty.getBrowsableURL(), and ResourceDescription.Value.getBrowsableURL().

◆ createFromPubbyPath()

static HypermediaControls createFromPubbyPath ( String  path,
Configuration  config 
)
static

Creates a new hypermedia resource from a Pubby path representing a resource.

Parameters
pathA Pubby path, either absolute or relative
configThe server's configuration
Returns
An object providing hypermedia controls for the resource, or null if this is not a Pubby-browsable resource.
25  {
26  try {
27  if (new URI(path).isAbsolute()) {
28  return createFromIRI(
29  PubbyIRIEscaper.unescapeSpecialCharacters(path), config);
30  } else {
33  }
34  } catch (URISyntaxException ex) {
35  return null;
36  }
37  }
String getWebResourcePrefix()
Definition: Configuration.java:273
static HypermediaControls createFromIRI(String absoluteIRI, Configuration config)
Creates a new hypermedia resource from an absolute IRI.
Definition: HypermediaControls.java:46

References HypermediaControls.config, HypermediaControls.createFromIRI(), Configuration.getWebApplicationBaseURI(), Configuration.getWebResourcePrefix(), and PubbyIRIEscaper.unescapeSpecialCharacters().

Referenced by Configuration.getControls().

◆ getAbsoluteIRI()

◆ getBrowsableURL()

String getBrowsableURL ( )
Returns
Best hyperlink for this resource (Pubby page if available).
101  {
102  if (isHosted) {
103  return absoluteIRI;
104  } else {
105  return getPageURL();
106  }
107  }
String getPageURL()
Definition: HypermediaControls.java:125

References HypermediaControls.absoluteIRI, HypermediaControls.getPageURL(), and HypermediaControls.isHosted.

Referenced by ResourceDescription.ResourceProperty.getBrowsableURL().

◆ getDataURL()

String getDataURL ( )
Returns
the RDF document describing the resource on the public Web server
132  {
133  return config.getWebApplicationBaseURI() + "data/" + getPubbyPath();
134 
135  }
String getPubbyPath()
A version of the resource's IRI suitable for use in constructing Pubby path URLs.
Definition: HypermediaControls.java:71

References HypermediaControls.config, HypermediaControls.getPubbyPath(), and Configuration.getWebApplicationBaseURI().

Referenced by DataURLServlet.doGet(), WebURIServlet.doGet(), PageURLServlet.doGet(), and MetadataConfiguration.parsePlaceholder().

◆ getInverseValuesDataURL()

String getInverseValuesDataURL ( Property  property)
149  {
150  return getPathURL("values.data/-", property);
151  }
String getPathURL(String urlPrefix, Property property)
Definition: HypermediaControls.java:153

References HypermediaControls.getPathURL().

Referenced by DataURLServlet.addHighDegreePropertyLinks().

◆ getInverseValuesPageURL()

String getInverseValuesPageURL ( Property  property)
141  {
142  return getPathURL("values/-", property);
143  }

References HypermediaControls.getPathURL().

Referenced by ResourceDescription.ResourceProperty.getValuesPageURL().

◆ getPageURL()

String getPageURL ( )
Returns
the HTML page describing the resource on the public Web server
125  {
126  return config.getWebApplicationBaseURI() + "page/" + getPubbyPath();
127  }

References HypermediaControls.config, HypermediaControls.getPubbyPath(), and Configuration.getWebApplicationBaseURI().

Referenced by WebURIServlet.doGet(), HypermediaControls.getBrowsableURL(), and ResourceDescription.Value.getBrowsableURL().

◆ getPathURL()

String getPathURL ( String  urlPrefix,
Property  property 
)
private
153  {
154  if (config.getPrefixes().qnameFor(property.getURI()) == null) {
155  String encoded = PubbyIRIEscaper.escapeSpecialCharacters(property.getURI());
156  return config.getWebApplicationBaseURI() + urlPrefix +
157  "!" + encoded + "///" +
158  getPubbyPath();
159  }
160  return config.getWebApplicationBaseURI() + urlPrefix +
161  config.getPrefixes().qnameFor(property.getURI()) + "/" +
162  getPubbyPath();
163  }
PrefixMapping getPrefixes()
Definition: Configuration.java:221

References HypermediaControls.config, PubbyIRIEscaper.escapeSpecialCharacters(), Configuration.getPrefixes(), HypermediaControls.getPubbyPath(), and Configuration.getWebApplicationBaseURI().

Referenced by HypermediaControls.getInverseValuesDataURL(), HypermediaControls.getInverseValuesPageURL(), HypermediaControls.getValuesDataURL(), and HypermediaControls.getValuesPageURL().

◆ getPubbyPath()

String getPubbyPath ( )
private

A version of the resource's IRI suitable for use in constructing Pubby path URLs.

If the resource is Pubby-hosted, this will be its IRI relative to the resource base (conf:webBase + conf:webResourcePrefix). Otherwise, it will be its full absolute IRI with special characters escaped to make it safe in constructing paths.

Returns
71  {
72  if (isHosted) {
73  int resourceBaseLength = config.getWebApplicationBaseURI().length() +
74  config.getWebResourcePrefix().length();
75  return absoluteIRI.substring(resourceBaseLength);
76  } else {
77  return PubbyIRIEscaper.escapeSpecialCharacters(absoluteIRI);
78  }
79  }

References HypermediaControls.absoluteIRI, HypermediaControls.config, PubbyIRIEscaper.escapeSpecialCharacters(), Configuration.getWebApplicationBaseURI(), Configuration.getWebResourcePrefix(), and HypermediaControls.isHosted.

Referenced by HypermediaControls.getDataURL(), HypermediaControls.getPageURL(), and HypermediaControls.getPathURL().

◆ getResourceDescription()

ResourceDescription getResourceDescription ( )
Returns
A description of the resource that allows interrogation of the data
112  {
113  DataSource source = config.getDataSource();
114  Model model = source.describeResource(absoluteIRI);
115  if (model.isEmpty()) return null;
116  return new ResourceDescription(this, model,
117  source.getHighIndegreeProperties(absoluteIRI),
118  source.getHighOutdegreeProperties(absoluteIRI),
119  config);
120  }
DataSource getDataSource()
A composite DataSource representing the merge of all datasets.
Definition: Configuration.java:192
Model describeResource(String absoluteIRI)
Returns a subgraph of the data source describing one resource.

References HypermediaControls.absoluteIRI, HypermediaControls.config, DataSource.describeResource(), Configuration.getDataSource(), DataSource.getHighIndegreeProperties(), and DataSource.getHighOutdegreeProperties().

Referenced by DataURLServlet.doGet(), and PageURLServlet.doGet().

◆ getValuesDataURL()

String getValuesDataURL ( Property  property)
145  {
146  return getPathURL("values.data/", property);
147  }

References HypermediaControls.getPathURL().

Referenced by DataURLServlet.addHighDegreePropertyLinks().

◆ getValuesPageURL()

String getValuesPageURL ( Property  property)
137  {
138  return getPathURL("values/", property);
139  }

References HypermediaControls.getPathURL().

Referenced by ResourceDescription.ResourceProperty.getValuesPageURL().

◆ isHosted()

boolean isHosted ( )

Is the resource itself hosted by Pubby, that is, is it in Pubby's web base namespace? (If not, then Pubby merely provides a hypermedia browsing interface for the resource, but cannot be said to host the resource itself.)

87  {
88  return isHosted;
89  }

References HypermediaControls.isHosted.

Member Data Documentation

◆ absoluteIRI

◆ config

◆ isHosted