View Javadoc

1   /**
2    * Copyright (C) 2012 White Source Ltd.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.whitesource.teamcity.server;
17  
18  import jetbrains.buildServer.serverSide.SBuild;
19  import jetbrains.buildServer.serverSide.SBuildServer;
20  import jetbrains.buildServer.web.openapi.PagePlaces;
21  import jetbrains.buildServer.web.openapi.ViewLogTab;
22  import jetbrains.buildServer.web.reportTabs.ReportTabUtil;
23  import org.jetbrains.annotations.NotNull;
24  import org.jetbrains.annotations.Nullable;
25  
26  import javax.servlet.http.HttpServletRequest;
27  import java.util.Map;
28  
29  /**
30   * Setup a tab for the policy check report.
31   *
32   * @author Edo.Shor
33   */
34  public class PolicyCheckReportTab extends ViewLogTab {
35  
36      /* --- Static members --- */
37  
38      private static final String TAB_TITLE = "White Source";
39      private static final String TAB_CODE = "whitesourceReportTab";
40      private static final String TAB_STARTPAGE = "whitesource.zip!index.html";
41  
42      /* --- Constructors --- */
43  
44      /**
45       * Constructor
46       *
47       * @param pagePlaces
48       * @param server
49       */
50      public PolicyCheckReportTab(@NotNull PagePlaces pagePlaces, @NotNull SBuildServer server) {
51          super(TAB_TITLE, TAB_CODE, pagePlaces, server);
52          setIncludeUrl("/artifactsViewer.jsp");
53      }
54  
55      /* --- Concrete implementation methods --- */
56  
57      @Override
58      protected void fillModel(Map model, HttpServletRequest request, @Nullable SBuild build) {
59          model.put("startPage", ReportTabUtil.prepareStartPageForWeb(TAB_STARTPAGE));
60      }
61  
62      /* --- Overridden methods --- */
63  
64      @Override
65      protected boolean isAvailable(@NotNull HttpServletRequest request, @NotNull SBuild build) {
66          return super.isAvailable(request, build) && ReportTabUtil.isAvailable(build, TAB_STARTPAGE);
67      }
68  }