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.agent;
17  
18  import jetbrains.buildServer.agent.BuildRunnerContext;
19  import org.whitesource.agent.api.model.AgentProjectInfo;
20  import org.whitesource.teamcity.common.Constants;
21  import org.whitesource.teamcity.common.WssUtils;
22  
23  import java.util.Collection;
24  import java.util.List;
25  
26  /**
27   * Base class for extractors of open source usage information;
28   *
29   * @author Edo.Shor
30   */
31  public abstract class BaseOssInfoExtractor {
32  
33      /* --- Members --- */
34  
35      protected BuildRunnerContext runner;
36  
37      protected String projectToken;
38  
39      protected List<String> includes;
40  
41      protected List<String> excludes;
42  
43      /* --- Constructors --- */
44  
45      /**
46       * Constructor
47       *
48       * @param runner
49       */
50      protected BaseOssInfoExtractor(BuildRunnerContext runner) {
51          this.runner = runner;
52  
53          projectToken = runner.getRunnerParameters().get(Constants.RUNNER_PROJECT_TOKEN);
54          includes = WssUtils.splitParameters(
55                  runner.getRunnerParameters().get(Constants.RUNNER_INCLUDES));
56          excludes = WssUtils.splitParameters(
57                  runner.getRunnerParameters().get(Constants.RUNNER_EXCLUDES));
58      }
59  
60      /* --- Abstract methods --- */
61  
62      public abstract Collection<AgentProjectInfo> extract();
63  
64  }