| | |
| | | import com.gitblit.models.ServerStatus; |
| | | import com.gitblit.models.SettingModel; |
| | | import com.gitblit.utils.StringUtils; |
| | | import com.gitblit.utils.XssFilter; |
| | | import com.google.inject.Inject; |
| | | import com.google.inject.Injector; |
| | | import com.google.inject.Singleton; |
| | | |
| | | @Singleton |
| | | public class RuntimeManager implements IRuntimeManager { |
| | | |
| | | private final Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | private final IStoredSettings settings; |
| | | |
| | | private final XssFilter xssFilter; |
| | | |
| | | private final ServerStatus serverStatus; |
| | | |
| | |
| | | |
| | | private TimeZone timezone; |
| | | |
| | | public RuntimeManager(IStoredSettings settings) { |
| | | this(settings, null); |
| | | @Inject |
| | | private Injector injector; |
| | | |
| | | @Inject |
| | | public RuntimeManager(IStoredSettings settings, XssFilter xssFilter) { |
| | | this(settings, xssFilter, null); |
| | | } |
| | | |
| | | public RuntimeManager(IStoredSettings settings, File baseFolder) { |
| | | public RuntimeManager(IStoredSettings settings, XssFilter xssFilter, File baseFolder) { |
| | | this.settings = settings; |
| | | this.settingsModel = new ServerSettings(); |
| | | this.serverStatus = new ServerStatus(); |
| | | this.xssFilter = xssFilter; |
| | | this.baseFolder = baseFolder == null ? new File("") : baseFolder; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public RuntimeManager stop() { |
| | | return this; |
| | | } |
| | | |
| | | @Override |
| | | public Injector getInjector() { |
| | | return injector; |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | // settingsModel.pushScripts = getAllScripts(); |
| | | return settingsModel; |
| | | } |
| | | |
| | | /** |
| | | * Determine if this Gitblit instance is actively serving git repositories |
| | | * or if it is merely a repository viewer. |
| | | * |
| | | * @return true if Gitblit is serving repositories |
| | | */ |
| | | @Override |
| | | public boolean isServingRepositories() { |
| | | return isServingHTTP() |
| | | || isServingGIT() |
| | | || isServingSSH(); |
| | | } |
| | | |
| | | /** |
| | | * Determine if this Gitblit instance is actively serving git repositories |
| | | * over the HTTP protocol. |
| | | * |
| | | * @return true if Gitblit is serving repositories over the HTTP protocol |
| | | */ |
| | | @Override |
| | | public boolean isServingHTTP() { |
| | | return settings.getBoolean(Keys.git.enableGitServlet, true); |
| | | } |
| | | |
| | | /** |
| | | * Determine if this Gitblit instance is actively serving git repositories |
| | | * over the Git Daemon protocol. |
| | | * |
| | | * @return true if Gitblit is serving repositories over the Git Daemon protocol |
| | | */ |
| | | @Override |
| | | public boolean isServingGIT() { |
| | | return settings.getInteger(Keys.git.daemonPort, 0) > 0; |
| | | } |
| | | |
| | | /** |
| | | * Determine if this Gitblit instance is actively serving git repositories |
| | | * over the SSH protocol. |
| | | * |
| | | * @return true if Gitblit is serving repositories over the SSH protocol |
| | | */ |
| | | @Override |
| | | public boolean isServingSSH() { |
| | | return settings.getInteger(Keys.git.sshPort, 0) > 0; |
| | | } |
| | | |
| | | /** |
| | |
| | | serverStatus.heapFree = Runtime.getRuntime().freeMemory(); |
| | | return serverStatus; |
| | | } |
| | | |
| | | /** |
| | | * Returns the XSS filter. |
| | | * |
| | | * @return the XSS filter |
| | | */ |
| | | @Override |
| | | public XssFilter getXssFilter() { |
| | | return xssFilter; |
| | | } |
| | | |
| | | } |