001/*
002 * SonarQube
003 * Copyright (C) 2009-2017 SonarSource SA
004 * mailto:info AT sonarsource DOT com
005 *
006 * This program is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019 */
020package org.sonar.api.platform;
021
022import java.io.File;
023import java.util.Date;
024import javax.annotation.CheckForNull;
025import org.sonar.api.batch.ScannerSide;
026import org.sonar.api.ce.ComputeEngineSide;
027import org.sonar.api.server.ServerSide;
028
029/**
030 * Runtime information about server
031 *
032 * @since 2.2
033 */
034@ScannerSide
035@ServerSide
036@ComputeEngineSide
037public abstract class Server {
038
039  /**
040   * UUID identifying the installation. It is persisted
041   * so that it does not change over time, even after
042   * a restart.
043   * In the context of cluster, the value is shared
044   * by all the nodes.
045   *
046   * @return a non-null UUID. Format can change over versions.
047   */
048  public abstract String getId();
049
050  /**
051   * UUID generated on demand by system administrators. It is
052   * {@code null} by default on fresh installations. When defined,
053   * value does not change when server is restarted.
054   * In the context of cluster, value is the same on all nodes.
055   * @since 2.10
056   */
057  @CheckForNull
058  public abstract String getPermanentServerId();
059
060  /**
061   * Non-null version of SonarQube at runtime
062   */
063  public abstract String getVersion();
064
065  /**
066   * Date when server started. In the context of cluster, this is the
067   * date of the startup of the first node. Value is the same on all
068   * cluster nodes.
069   */
070  public abstract Date getStartedAt();
071
072  /**
073   * @deprecated in 6.0. Replaced by {@link ServerFileSystem#getHomeDir()}
074   * @return an existing directory in server and CE environments, {@code null} in scanner.
075   */
076  @Deprecated
077  public abstract File getRootDir();
078
079  /**
080   * @deprecated always {@code null} since version 6.0. No alternatives, as plugins do not have to touch this directory.
081   */
082  @Deprecated
083  @CheckForNull
084  public abstract File getDeployDir();
085
086  /**
087   * Context path of web server. Value is blank {@code ""} by default. When defined by
088   * the property {@code sonar.web.context} of conf/sonar.properties, then value starts but does
089   * not end with slash {@code '/'}, for instance {@code "/sonarqube"}.
090   *
091   * @return non-null but possibly blank path
092   */
093  public abstract String getContextPath();
094
095  /**
096   * Return the public root url, for instance : https://nemo.sonarqube.org.
097   * Default value is {@link org.sonar.api.CoreProperties#SERVER_BASE_URL_DEFAULT_VALUE}
098   *
099   * @since 5.4
100   */
101  public abstract String getPublicRootUrl();
102
103  /**
104   * Before version 6.6, the dev mode is enabled when the property {@code sonar.web.dev} is {@code true}.
105   * Since 6.6, {@code false} is always returned.
106   * @deprecated in 6.6
107   * @since 5.4
108   */
109  @Deprecated
110  public abstract boolean isDev();
111
112  /**
113   * Return whether or not the {#getPublicRootUrl} is started with https.
114   *
115   * @since 5.4
116   * @deprecated since 5.6, use instead {@link javax.servlet.http.HttpServletRequest#getHeader(String)} and check that X-Forwarded-Proto header is set to "https".
117   */
118  @Deprecated
119  public abstract boolean isSecured();
120
121  /**
122   * @return the server URL
123   * @since since 2.4 on batch side only, since 5.6 on both batch side and server side (WebServer and Compute Engine)
124   * @deprecated since 6.5, please use {@link #getPublicRootUrl()} instead
125   */
126  @Deprecated
127  public abstract String getURL();
128}