public interface

ApplicationPropertiesService

com.atlassian.stash.server.ApplicationPropertiesService

Class Overview

Queries various properties of Stash.

Summary

Public Methods
void deleteMailHostConfiguration()
Remove the mail host configuration.
URI getBaseUrl()
Gets the base URL of the current instance.
@Nonnull File getBinDir()
String getBuildNumber()
Date getBuildTimestamp()
String getBuildVersion()
@Nonnull File getCacheDir()
String getCommitHash()
@Nonnull File getConfigDir()
@Nonnull File getDataDir()
TimeZone getDefaultTimeZone()
String getDisplayName()
Gets the display name of the current instance.
@Nonnull File getHomeDir()
Returns the current home directory of this Stash instance.
String getJdbcDriver()
String getJdbcDriverVersion()
String getJdbcUrl()
URI getLoginUri(URI redirectUri)
Gets the login page URI for the current instance.
@Nullable MailHostConfiguration getMailHostConfiguration()
Retrieves the mail host configuration
int getMaxCaptchaAttempts()
@Nullable String getPluginProperty(String propertyName, String defaultValue)
boolean getPluginProperty(String propertyName, boolean defaultValue)
int getPluginProperty(String propertyName, int defaultValue)
@Nullable String getPluginProperty(String propertyName)
Return a value of a property as defined in the applications configuration files.
long getPluginProperty(String propertyName, long defaultValue)
File getRepositoriesDir()
@Nonnull File getRepositoryDir(Repository repository)
String getServerEmailAddress()
Gets the email address used in the 'sender' field for any email notification.
String getServerId()
Retrieves the server ID used for licensing.
@Nonnull File getSharedHomeDir()
Returns the stash shared home directory.
@Nonnull File getTempDir()
boolean isAllowPublicSignUp()
boolean isDebugLoggingEnabled()
boolean isHttpScmHostingEnabled()
boolean isProfilingEnabled()
boolean isSetup()
boolean isShowCaptchaOnSignUp()
void setAllowPublicSignUp(boolean publicSignUp)
Sets whether public signup is allowed for external users.
void setBaseURL(URI baseUrl)
Sets the base URL of the current instance.
void setDisplayName(String name)
Sets the display name of the current instance.
void setHttpScmHostingEnabled(boolean enabled)
Sets whether the SCM requests are allowed over HTTP(S).
void setMailHostConfiguration(MailHostConfiguration mailHostConfiguration)
Sets the mail host configuration, replacing any existing configuration.
void setMaxCaptchaAttempts(int maxCaptchaAttempts)
Sets the number of failed login attempts before the user is required to enter a CAPTCHA verification.
void setServerEmailAddress(String emailAddress)
Sets the email address used in the 'sender' field for any email notification.
void setShowCaptchaOnSignUp(boolean captchaOnSignUp)
Sets whether a CAPTCHA verification is required for signing up.

Public Methods

public void deleteMailHostConfiguration ()

Remove the mail host configuration.

public URI getBaseUrl ()

Gets the base URL of the current instance.

The URL is guaranteed to be without a trailing slash.

Returns
  • base URL of the current instance, without trailing slash

@Nonnull public File getBinDir ()

Returns
  • the directory inside stash.home that contains any scripts / executables used by the application.

public String getBuildNumber ()

Returns
  • the build number of the current instance.

public Date getBuildTimestamp ()

Returns
  • the build timestamp of the current instance.

public String getBuildVersion ()

Returns
  • the build version of the current instance.

@Nonnull public File getCacheDir ()

Returns
  • the directory inside stash.home that contains any caches used by the application.

public String getCommitHash ()

Returns
  • the commit hash of the version of the current instance

@Nonnull public File getConfigDir ()

Returns
  • the directory inside stash.home that contains the configuration files.

@Nonnull public File getDataDir ()

Returns
  • the directory inside stash.home that contains data files, such as repositories

public TimeZone getDefaultTimeZone ()

Returns
  • the default time zone for the server.

public String getDisplayName ()

Gets the display name of the current instance.

Returns
  • name of the current instance

@Nonnull public File getHomeDir ()

Returns the current home directory of this Stash instance. The Stash home directory will contain only node local data like caches, backups, logs and tmp. In case Stash is running standalone mode this directory will mostly likely contains Stash shared home under /shared, but there is no guarantee.

Returns
  • the Home directory of the Stash instance.

public String getJdbcDriver ()

Returns
  • the JDBC driver class name Stash is currently using

public String getJdbcDriverVersion ()

Returns
  • the version of the JDBC driver Stash is currently using. In the format <MajorVersion>.<MinorVersion>

public String getJdbcUrl ()

Returns
  • the JDBC url to the database Stash is currently using.

public URI getLoginUri (URI redirectUri)

Gets the login page URI for the current instance.

Parameters
redirectUri the URI the user should be redirected to after a successful login.
Returns
  • the login page URI for the current instance.

@Nullable public MailHostConfiguration getMailHostConfiguration ()

Retrieves the mail host configuration

Returns
  • the mail host configuration, null if undefined.

public int getMaxCaptchaAttempts ()

Returns
  • the number of failed login attempts before the user is required to enter a CAPTCHA verification.

@Nullable public String getPluginProperty (String propertyName, String defaultValue)

Parameters
propertyName Name of the property
defaultValue The default value to return if it is not present
Returns
  • property value or defaultValue if not defined.

public boolean getPluginProperty (String propertyName, boolean defaultValue)

Parameters
propertyName Name of the property
defaultValue The default value to return if it is not present
Returns
  • property value or defaultValue if not defined.

public int getPluginProperty (String propertyName, int defaultValue)

Parameters
propertyName Name of the property
defaultValue The default value to return if it is not present
Returns
  • property value or defaultValue if not defined.

@Nullable public String getPluginProperty (String propertyName)

Return a value of a property as defined in the applications configuration files. Code usually should use the Spring @Value annotation to get these injected, but in cases where that is not possible or the property name must be dynamically determined, this method and its adjuncts can be used instead.

This method should be used only by plugins.

Parameters
propertyName name of the property, which must start with "plugin."
Returns
  • property value or null if not defined.
Throws
IllegalArgumentException if the property name is null, or if the property name does not start with "plugin."

public long getPluginProperty (String propertyName, long defaultValue)

Parameters
propertyName Name of the property
defaultValue The default value to return if it is not present
Returns
  • property value or defaultValue if not defined.

public File getRepositoriesDir ()

Returns
  • the directory inside stash.shared.home that contains the repositories.

@Nonnull public File getRepositoryDir (Repository repository)

Parameters
repository the repository
Returns
  • the directory containing the hosted repository.

public String getServerEmailAddress ()

Gets the email address used in the 'sender' field for any email notification.

Returns
  • sender address for email notifications

public String getServerId ()

Retrieves the server ID used for licensing.

Returns
  • the server ID

@Nonnull public File getSharedHomeDir ()

Returns the stash shared home directory. This directory is the new home of data, config and plugins/installed-plugins. When in clustering environment this directory is shared among all clustering nodes (most likely by NFS).

Returns
  • the Shared Home directory of the Stash instance.

@Nonnull public File getTempDir ()

Returns
  • the Temp directory of the Stash instance.

public boolean isAllowPublicSignUp ()

Returns
  • whether public signup is allowed for external users.

public boolean isDebugLoggingEnabled ()

Returns
  • whether debug logging is enabled.

public boolean isHttpScmHostingEnabled ()

Returns
  • whether the SCM requests are allowed over HTTP(S).

public boolean isProfilingEnabled ()

Returns
  • whether profiling is enabled.

public boolean isSetup ()

Returns
  • whether or not the application has completed setup

public boolean isShowCaptchaOnSignUp ()

Returns
  • whether CAPTCHA is required for signing up.

public void setAllowPublicSignUp (boolean publicSignUp)

Sets whether public signup is allowed for external users.

Parameters
publicSignUp whether to allow public signup

public void setBaseURL (URI baseUrl)

Sets the base URL of the current instance.

The URL will be persisted without a trailing slash, if present. Ex: given http://server/stash/, the property will be saved as http://server/stash

Parameters
baseUrl publicly accessible URL for the current instance

public void setDisplayName (String name)

Sets the display name of the current instance.

Parameters
name display name for the current instance

public void setHttpScmHostingEnabled (boolean enabled)

Sets whether the SCM requests are allowed over HTTP(S).

Parameters
enabled whether to enable HTTP(S) access

public void setMailHostConfiguration (MailHostConfiguration mailHostConfiguration)

Sets the mail host configuration, replacing any existing configuration.

Parameters
mailHostConfiguration the configuration to store

public void setMaxCaptchaAttempts (int maxCaptchaAttempts)

Sets the number of failed login attempts before the user is required to enter a CAPTCHA verification.

Parameters
maxCaptchaAttempts maximum number of failed CAPTCHA

public void setServerEmailAddress (String emailAddress)

Sets the email address used in the 'sender' field for any email notification.

Parameters
emailAddress sender address for email notifications

public void setShowCaptchaOnSignUp (boolean captchaOnSignUp)

Sets whether a CAPTCHA verification is required for signing up.

Parameters
captchaOnSignUp whether to enable CAPTCHA on signup