You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ServerImpl.java 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2021 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.server.platform;
  21. import java.util.Date;
  22. import javax.annotation.CheckForNull;
  23. import org.sonar.api.CoreProperties;
  24. import org.sonar.api.SonarRuntime;
  25. import org.sonar.api.ce.ComputeEngineSide;
  26. import org.sonar.api.config.Configuration;
  27. import org.sonar.api.platform.Server;
  28. import org.sonar.api.server.ServerSide;
  29. @ComputeEngineSide
  30. @ServerSide
  31. public class ServerImpl extends Server {
  32. private final Configuration config;
  33. private final StartupMetadata state;
  34. private final ServerFileSystem fs;
  35. private final UrlSettings urlSettings;
  36. private final SonarRuntime runtime;
  37. public ServerImpl(Configuration config, StartupMetadata state, ServerFileSystem fs, UrlSettings urlSettings, SonarRuntime runtime) {
  38. this.config = config;
  39. this.state = state;
  40. this.fs = fs;
  41. this.urlSettings = urlSettings;
  42. this.runtime = runtime;
  43. }
  44. /**
  45. * Can be null when server is waiting for migration
  46. */
  47. @Override
  48. @CheckForNull
  49. public String getId() {
  50. return config.get(CoreProperties.SERVER_ID).orElse(null);
  51. }
  52. @Override
  53. public String getPermanentServerId() {
  54. return getId();
  55. }
  56. @Override
  57. public String getVersion() {
  58. return runtime.getApiVersion().toString();
  59. }
  60. @Override
  61. public Date getStartedAt() {
  62. return new Date(state.getStartedAt());
  63. }
  64. @Override
  65. public String getContextPath() {
  66. return urlSettings.getContextPath();
  67. }
  68. @Override
  69. public String getPublicRootUrl() {
  70. return urlSettings.getBaseUrl();
  71. }
  72. @Override
  73. public boolean isSecured() {
  74. return urlSettings.isSecured();
  75. }
  76. }