changeset 32:2ae714d6faa5

global settings tab added
author Evgeniy.Koshkin
date Mon, 12 Aug 2013 16:28:03 +0400
parents 48b3a2443fd6
children 76233e3aceb7
files server/resources/symbolServerSettings.jsp server/src/META-INF/build-server-plugin-symbol-server.xml server/src/jetbrains/buildServer/symbols/SymbolServerSettingsTab.java
diffstat 3 files changed, 110 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/server/resources/symbolServerSettings.jsp	Mon Aug 12 16:28:03 2013 +0400
@@ -0,0 +1,30 @@
+<%@ include file="/include-internal.jsp"%>
+
+<jsp:useBean id="pageUrl" type="java.lang.String" scope="request"/>
+<jsp:useBean id="isGuestEnabled" scope="request" type="java.lang.Boolean"/>
+<jsp:useBean id="publicFeedUrl" scope="request" type="java.lang.String" />
+<jsp:useBean id="actualServerUrl" scope="request" type="java.lang.String" />
+
+<table class="runnerFormTable">
+  <tr>
+    <th>Symbol Server URL:</th>
+    <td>
+      <c:choose>
+        <c:when test="${not isGuestEnabled}">
+          <div>Not available.</div>
+            <span class="smallNote">
+              Guest user is disabled.
+            </span>
+            <span class="smallNote">
+              You need to enable guest user login in TeamCity <a href="<c:url value="/admin/admin.html?item=auth"/>">Authentication Settings</a> for Symbol Server to work.
+            </span>
+        </c:when>
+        <c:otherwise>
+          <c:set var="url"><c:url value="${actualServerUrl}${publicFeedUrl}"/></c:set>
+          <div><a href="${url}">${url}</a></div>
+          <span class="smallNote">Use this URL in Visual Studio and WinDbg settings.</span>
+        </c:otherwise>
+      </c:choose>
+    </td>
+  </tr>
+</table>
\ No newline at end of file
--- a/server/src/META-INF/build-server-plugin-symbol-server.xml	Fri Aug 09 16:19:21 2013 +0400
+++ b/server/src/META-INF/build-server-plugin-symbol-server.xml	Mon Aug 12 16:28:03 2013 +0400
@@ -6,7 +6,9 @@
         default-autowire="constructor"
         >
 
+  <bean class="jetbrains.buildServer.symbols.SymbolServerSettingsTab"/>
   <bean class="jetbrains.buildServer.symbols.IndexSymbolsBuildFeature"/>
+
   <bean class="jetbrains.buildServer.symbols.BuildSymbolsIndexProvider"/>
   <bean class="jetbrains.buildServer.symbols.DownloadSymbolsController"/>
   <bean class="jetbrains.buildServer.symbols.DownloadSourcesController"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/server/src/jetbrains/buildServer/symbols/SymbolServerSettingsTab.java	Mon Aug 12 16:28:03 2013 +0400
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jetbrains.buildServer.symbols;
+
+import jetbrains.buildServer.serverSide.auth.AuthUtil;
+import jetbrains.buildServer.serverSide.auth.Permission;
+import jetbrains.buildServer.serverSide.auth.SecurityContext;
+import jetbrains.buildServer.serverSide.impl.ServerSettings;
+import jetbrains.buildServer.web.openapi.PagePlaces;
+import jetbrains.buildServer.web.openapi.PlaceId;
+import jetbrains.buildServer.web.openapi.PluginDescriptor;
+import jetbrains.buildServer.web.openapi.SimpleCustomTab;
+import jetbrains.buildServer.web.util.WebUtil;
+import org.jetbrains.annotations.NotNull;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+/**
+ * @author Evgeniy.Koshkin
+ */
+public class SymbolServerSettingsTab extends SimpleCustomTab {
+
+  private static final String TAB_ID = "sourceServerSettingsTab";
+
+  @NotNull private final ServerSettings myServerSettings;
+  @NotNull private final SecurityContext mySecurityContext;
+
+  public SymbolServerSettingsTab(@NotNull final PagePlaces pagePlaces,
+                                 @NotNull final ServerSettings serverSettings,
+                                 @NotNull final SecurityContext context,
+                                 @NotNull final PluginDescriptor descriptor) {
+    super(pagePlaces,
+            PlaceId.ADMIN_SERVER_CONFIGURATION_TAB,
+            TAB_ID,
+            descriptor.getPluginResourcesPath("symbolServerSettings.jsp"),
+            "Symbol Server");
+    myServerSettings = serverSettings;
+    mySecurityContext = context;
+    register();
+  }
+
+  @Override
+  public boolean isVisible() {
+    return super.isVisible() && hasAccess();
+  }
+
+  @Override
+  public boolean isAvailable(@NotNull HttpServletRequest request) {
+    return super.isAvailable(request) && hasAccess();
+  }
+
+  @Override
+  public void fillModel(@NotNull Map<String, Object> model, @NotNull HttpServletRequest request) {
+    super.fillModel(model, request);
+    model.put("isGuestEnabled", myServerSettings.isGuestLoginAllowed());
+    model.put("actualServerUrl", WebUtil.getRootUrl(request));
+    model.put("publicFeedUrl", WebUtil.GUEST_AUTH_PREFIX + SymbolsConstants.APP_SYMBOLS);
+  }
+
+  private boolean hasAccess() {
+    return AuthUtil.hasGlobalPermission(mySecurityContext.getAuthorityHolder(), Permission.CHANGE_SERVER_SETTINGS);
+  }
+}