WebinterfaceUtils#

public class WebinterfaceUtils#

This class is responsible for two things: Resolving relative paths of files of the web interface to File objects.Generating URIs to public files of the web interface from relative string paths.

Especially the AbstractCaosDBServerResource and the Webinterface use this class for these tasks.

Author:

Timm Fitschen (t.fitschen@indiscale.com)

Fields#

DEFAULT_BUILD_NUMBER_FILE#

public static final String DEFAULT_BUILD_NUMBER_FILE#

DEFAULT_ROUTE#

public static final String DEFAULT_ROUTE#

DEFAULT_WEBUI_PUBLIC#

public static final String DEFAULT_WEBUI_PUBLIC#

Constructors#

WebinterfaceUtils#

WebinterfaceUtils(String host, String contextRoot, String publicDir, String route, String buildNumberFile)#

Create a utility class for creating references to resources of the web interface.

Parameters:
  • host

  • contextRoot

  • publicDir

  • route

  • buildNumberFile

WebinterfaceUtils#

WebinterfaceUtils(Reference host)#

Create a utility class for creating references to resources of the web interface.

The route to the web interface, the build number file and the public folder of the web interface build directory are set to default values (DEFAULT_BUILD_NUMBER_FILE, DEFAULT_ROUTE, and DEFAULT_WEBUI_PUBLIC).

The contextRoute defaults to the server property ServerProperties.KEY_CONTEXT_ROOT.

Parameters:
  • host

    • the host of the web interface.

See also: {@linkWebinterfaceUtils.WebinterfaceUtils(String,String,String,String)}.

WebinterfaceUtils#

WebinterfaceUtils(String host)#

Create a utility class for creating references to resources of the web interface.

The route to the web interface, the build number file and the public folder of the web interface build directory are set to default values (DEFAULT_BUILD_NUMBER_FILE, DEFAULT_ROUTE, and DEFAULT_WEBUI_PUBLIC).

The contextRoot defaults to the server property ServerProperties.KEY_CONTEXT_ROOT.

Parameters:
  • host

    • the host of the web interface.

See also: {@linkWebinterfaceUtils.WebinterfaceUtils(String,String,String,String)}.

Methods#

getBuildNumber#

public String getBuildNumber()#

Determine the build number of the webui. Returns null if the build number could not be determined.

Because opening and reading the buildNumberFile content is expensive, the buildNumber is cached.

The cached buildNumber invalidates when the files modified time stamp is younger than the buildNumberDate. The validity of the cache is checked once every minute with a CronJob.

Returns:

Build number or null.

getBuildNumberFile#

public Path getBuildNumberFile()#

return the Path of the build number file.

getForwardedProto#

public static String getForwardedProto(Request request)#

getInstance#

public static WebinterfaceUtils getInstance(Request request)#

Retrieve an instance of WebinterfaceUtils for the request. The instance can be shared with other callers.

Parameters:
  • request

Returns:

a shared instance of WebinterfaceUtils.

getInstance#

public static WebinterfaceUtils getInstance(String host)#

Retrieve an instance of WebinterfaceUtils for the host. The instance can be shared with other callers.

Parameters:
  • host

Returns:

a shared instance of WebinterfaceUtils.

getPublicFile#

public File getPublicFile(String path)#

Return the public file or null if the file does not exists or is not in the public directory of the web interface.

This method is used to resolve requests for files of the web interface.

Parameters:
  • path

Returns:

The file or null

getPublicFilePath#

public Path getPublicFilePath(String path)#

Return the absolute path to the public file denoted by the path.

This method is used to resolve requests for files of the web interface.

Parameters:
  • path

    • path to the file of the web interface, relative to the public directory of the web interface.

Returns:

The absolute path of the web interface file.

getPublicRootPath#

public Path getPublicRootPath()#

Return the absolute path of the root of the public directory of the webui.

Returns:

Public directory of webui.

getServerRootURI#

public String getServerRootURI()#

Return the server root reference.

The server root is composed of the scheme (https://) the host name (example.com) the port if necessary (:10443) and the context root of the application (beta).

Returns:

the server root reference e.g. https://example.com:10443/beta.

getWebinterfaceRootURI#

public String getWebinterfaceRootURI()#

Return the root reference for the web interface.

The root reference for the web interface is the server root reference (getServerRootURI()) plus the route to the resource which routes to the individual resources of the web interface (Webinterface).

Returns:

root reference for the web interface.

getWebinterfaceURI#

public String getWebinterfaceURI(String publicFile)#

Return a URI to a public file of the web interface.

This method is used to generate references for *.xsl files or other resources of the web interface.

Parameters:
  • publicFile

    • the path of the public file, relative to the public directory of the web interface.

Returns:

a URI for the public file of the web interface.

readBuildNumber#

public String readBuildNumber()#

Return the latest buildNumber, freshly read from the buildNumberfile.

Returns:

fresh build number.

validateBuildNumber#

public void validateBuildNumber()#

Check the validity of the buildNumber and invalidate the buildNumber if the buildNumberDate is older than the File.lastModified time stamp of the buildNumberFile.