001/* 002 * SonarQube 003 * Copyright (C) 2009-2016 SonarSource SA 004 * mailto:contact 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 * @return a non-null UUID. Format can change over versions. 043 */ 044 public abstract String getId(); 045 046 /** 047 * UUID generated on demand by system administrators. It is 048 * {@code null} by default on fresh installations. When defined, 049 * value does not change when server is restarted. 050 * @since 2.10 051 */ 052 @CheckForNull 053 public abstract String getPermanentServerId(); 054 055 /** 056 * Non-null version of SonarQube at runtime 057 */ 058 public abstract String getVersion(); 059 060 /** 061 * Date when server started 062 */ 063 public abstract Date getStartedAt(); 064 065 /** 066 * @deprecated in 6.0. Replaced by {@link ServerFileSystem#getHomeDir()} 067 * @return an existing directory in server and CE environments, {@code null} in scanner. 068 */ 069 @Deprecated 070 public abstract File getRootDir(); 071 072 /** 073 * @deprecated always {@code null} since version 6.0. No alternatives, as plugins do not have to touch this directory. 074 */ 075 @Deprecated 076 @CheckForNull 077 public abstract File getDeployDir(); 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 * The dev mode is enabled when the property {@code sonar.web.dev} is {@code true}. 098 * 099 * @since 5.4 100 */ 101 public abstract boolean isDev(); 102 103 /** 104 * Return whether or not the {#getPublicRootUrl} is started with https. 105 * 106 * @since 5.4 107 * @deprecated since 5.6, use instead {@link javax.servlet.http.HttpServletRequest#getHeader(String)} and check that X-Forwarded-Proto header is set to "https". 108 */ 109 @Deprecated 110 public abstract boolean isSecured(); 111 112 /** 113 * @return the server URL 114 * @since since 2.4 on batch side only, since 5.6 on both batch side and server side (WebServer and Compute Engine) 115 */ 116 public abstract String getURL(); 117}