1 package org.apache.continuum.web.action;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 }