View Javadoc

1   package org.apache.maven.continuum.web.action.component;
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 com.opensymphony.xwork2.ActionSupport;
23  import org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelper;
24  import org.apache.maven.model.Model;
25  import org.apache.maven.shared.app.company.CompanyPomHandler;
26  import org.apache.maven.shared.app.configuration.MavenAppConfiguration;
27  
28  /**
29   * Stores the company information for displaying on the page.
30   *
31   * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="companyInfo"
32   */
33  public class CompanyInfoAction
34      extends ActionSupport
35  {
36      private String companyLogo;
37  
38      private String companyUrl;
39  
40      private String companyName;
41  
42      /**
43       * @plexus.requirement
44       */
45      private CompanyPomHandler handler;
46  
47      /**
48       * @plexus.requirement
49       */
50      private MavenAppConfiguration appConfiguration;
51  
52      /**
53       * @plexus.requirement
54       */
55      private MavenBuilderHelper helper;
56  
57      public String execute()
58          throws Exception
59      {
60          Model model = handler.getCompanyPomModel( appConfiguration.getConfiguration().getCompanyPom(),
61                                                    helper.getLocalRepository() );
62  
63          if ( model != null )
64          {
65              if ( model.getOrganization() != null )
66              {
67                  companyName = model.getOrganization().getName();
68                  companyUrl = model.getOrganization().getUrl();
69              }
70  
71              companyLogo = model.getProperties().getProperty( "organization.logo" );
72          }
73  
74          return SUCCESS;
75      }
76  
77      public String getCompanyLogo()
78      {
79          return companyLogo;
80      }
81  
82      public String getCompanyUrl()
83      {
84          return companyUrl;
85      }
86  
87      public String getCompanyName()
88      {
89          return companyName;
90      }
91  }