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 * Name is misleading, this is an UUID generated 041 * at each startup, so it changes if server is restarted. 042 * In the context of cluster, the value is shared 043 * by all the nodes. 044 * @return a non-null UUID. Format can change over versions. 045 */ 046 public abstract String getId(); 047 048 /** 049 * UUID generated on demand by system administrators. It is 050 * {@code null} by default on fresh installations. When defined, 051 * value does not change when server is restarted. 052 * In the context of cluster, value is the same on all nodes. 053 * @since 2.10 054 */ 055 @CheckForNull 056 public abstract String getPermanentServerId(); 057 058 /** 059 * Non-null version of SonarQube at runtime 060 */ 061 public abstract String getVersion(); 062 063 /** 064 * Date when server started. In the context of cluster, this is the 065 * date of the startup of the first node. Value is the same on all 066 * cluster nodes. 067 */ 068 public abstract Date getStartedAt(); 069 070 /** 071 * @deprecated in 6.0. Replaced by {@link ServerFileSystem#getHomeDir()} 072 * @return an existing directory in server and CE environments, {@code null} in scanner. 073 */ 074 @Deprecated 075 public abstract File getRootDir(); 076 077 /** 078 * @deprecated always {@code null} since version 6.0. No alternatives, as plugins do not have to touch this directory. 079 */ 080 @Deprecated 081 @CheckForNull 082 public abstract File getDeployDir(); 083 084 /** 085 * Context path of web server. Value is blank {@code ""} by default. When defined by 086 * the property {@code sonar.web.context} of conf/sonar.properties, then value starts but does 087 * not end with slash {@code '/'}, for instance {@code "/sonarqube"}. 088 * 089 * @return non-null but possibly blank path 090 */ 091 public abstract String getContextPath(); 092 093 /** 094 * Return the public root url, for instance : https://nemo.sonarqube.org. 095 * Default value is {@link org.sonar.api.CoreProperties#SERVER_BASE_URL_DEFAULT_VALUE} 096 * 097 * @since 5.4 098 */ 099 public abstract String getPublicRootUrl(); 100 101 /** 102 * The dev mode is enabled when the property {@code sonar.web.dev} is {@code true}. 103 * 104 * @since 5.4 105 */ 106 public abstract boolean isDev(); 107 108 /** 109 * Return whether or not the {#getPublicRootUrl} is started with https. 110 * 111 * @since 5.4 112 * @deprecated since 5.6, use instead {@link javax.servlet.http.HttpServletRequest#getHeader(String)} and check that X-Forwarded-Proto header is set to "https". 113 */ 114 @Deprecated 115 public abstract boolean isSecured(); 116 117 /** 118 * @return the server URL 119 * @since since 2.4 on batch side only, since 5.6 on both batch side and server side (WebServer and Compute Engine) 120 */ 121 public abstract String getURL(); 122}