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 org.sonar.api.batch.ScannerSide; 025import org.sonar.api.ce.ComputeEngineSide; 026import org.sonar.api.server.ServerSide; 027 028/** 029 * Runtime information about server 030 * 031 * @since 2.2 032 */ 033@ScannerSide 034@ServerSide 035@ComputeEngineSide 036public abstract class Server { 037 038 /** 039 * UUID identifying the installation. It is persisted 040 * so that it does not change over time, even after 041 * a restart. 042 * In the context of cluster, the value is shared 043 * by all the nodes. 044 * 045 * @return a non-null UUID. Format can change over versions. 046 */ 047 public abstract String getId(); 048 049 /** 050 * Since 6.7, it returns exactly {@link #getId()}. In previous 051 * versions it returned ab UUID generated on demand by system 052 * administrators and may be null. 053 * 054 * @deprecated replaced by {@link #getId()} in 6.7. 055 * @since 2.10 056 */ 057 @Deprecated 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 * Context path of web server. Value is blank {@code ""} by default. When defined by 081 * the property {@code sonar.web.context} of conf/sonar.properties, then value starts but does 082 * not end with slash {@code '/'}, for instance {@code "/sonarqube"}. 083 * 084 * @return non-null but possibly blank path 085 */ 086 public abstract String getContextPath(); 087 088 /** 089 * Return the public root url, for instance : https://nemo.sonarqube.org. 090 * Default value is {@link org.sonar.api.CoreProperties#SERVER_BASE_URL_DEFAULT_VALUE} 091 * 092 * @since 5.4 093 */ 094 public abstract String getPublicRootUrl(); 095 096 /** 097 * Before version 6.6, the dev mode is enabled when the property {@code sonar.web.dev} is {@code true}. 098 * Since 6.6, {@code false} is always returned. 099 * @deprecated in 6.6 100 * @since 5.4 101 */ 102 @Deprecated 103 public abstract boolean isDev(); 104 105 /** 106 * Return whether or not the {#getPublicRootUrl} is started with https. 107 * 108 * @since 5.4 109 * @deprecated since 5.6, use instead {@link javax.servlet.http.HttpServletRequest#getHeader(String)} and check that X-Forwarded-Proto header is set to "https". 110 */ 111 @Deprecated 112 public abstract boolean isSecured(); 113 114 /** 115 * @return the server URL 116 * @since since 2.4 on batch side only, since 5.6 on both batch side and server side (WebServer and Compute Engine) 117 * @deprecated since 6.5, please use {@link #getPublicRootUrl()} instead 118 */ 119 @Deprecated 120 public abstract String getURL(); 121}