View Javadoc

1   package org.apache.continuum.web.action;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.Collections;
23  import java.util.HashMap;
24  import java.util.List;
25  import java.util.Map;
26  
27  import org.apache.maven.continuum.installation.InstallationService;
28  import org.apache.maven.continuum.model.system.Installation;
29  import org.apache.maven.continuum.model.system.Profile;
30  import org.apache.maven.continuum.web.action.ContinuumActionSupport;
31  import org.codehaus.plexus.util.StringUtils;
32  
33  public class AbstractReleaseAction
34      extends ContinuumActionSupport
35  {
36      protected Map<String, String> getEnvironments( Profile profile )
37      {
38          if ( profile == null )
39          {
40              return Collections.EMPTY_MAP;
41          }
42  
43          Map<String, String> envVars = new HashMap<String, String>();
44  
45          String javaHome = getJavaHomeValue( profile );
46          if ( !StringUtils.isEmpty( javaHome ) )
47          {
48              envVars.put( getContinuum().getInstallationService().getEnvVar( InstallationService.JDK_TYPE ), javaHome );
49          }
50  
51          Installation builder = profile.getBuilder();
52          if ( builder != null )
53          {
54              envVars.put( getContinuum().getInstallationService().getEnvVar( InstallationService.MAVEN2_TYPE ), builder.getVarValue() );
55          }
56  
57          List<Installation> installations = profile.getEnvironmentVariables();
58          for ( Installation installation : installations )
59          {
60              envVars.put( installation.getVarName(), installation.getVarValue() );
61          }
62          return envVars;
63      }
64  
65      private String getJavaHomeValue( Profile profile )
66      {
67          Installation jdk = profile.getJdk();
68          if ( jdk == null )
69          {
70              return null;
71          }
72          return jdk.getVarValue();
73      }
74  }