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 org.apache.continuum.model.project.ProjectScmRoot;
23  import org.apache.maven.continuum.ContinuumException;
24  import org.apache.maven.continuum.web.action.ContinuumActionSupport;
25  import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
26  import org.apache.maven.continuum.web.util.StateGenerator;
27  import org.apache.struts2.ServletActionContext;
28  
29  /**
30   * @author <a href="mailto:ctan@apache.org">Maria Catherine Tan</a>
31   * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="scmResult"
32   */
33  public class ScmResultAction
34      extends ContinuumActionSupport
35  {
36      private int projectGroupId;
37  
38      private int projectScmRootId;
39  
40      private String projectGroupName;
41  
42      private String state;
43  
44      private ProjectScmRoot projectScmRoot;
45  
46      public String execute()
47          throws Exception
48      {
49          try
50          {
51              checkViewProjectGroupAuthorization( getProjectGroupName() );
52          }
53          catch ( AuthorizationRequiredException e )
54          {
55              return REQUIRES_AUTHORIZATION;
56          }
57  
58          projectScmRoot = getContinuum().getProjectScmRoot( projectScmRootId );
59  
60          state = StateGenerator.generate( projectScmRoot.getState(),
61                                           ServletActionContext.getRequest().getContextPath() );
62  
63          return SUCCESS;
64      }
65  
66      public int getProjectGroupId()
67      {
68          return projectGroupId;
69      }
70  
71      public void setProjectGroupId( int projectGroupId )
72      {
73          this.projectGroupId = projectGroupId;
74      }
75  
76      public int getProjectScmRootId()
77      {
78          return projectScmRootId;
79      }
80  
81      public void setProjectScmRootId( int projectScmRootId )
82      {
83          this.projectScmRootId = projectScmRootId;
84      }
85  
86      public ProjectScmRoot getProjectScmRoot()
87      {
88          return projectScmRoot;
89      }
90  
91      public void setProjectScmRoot( ProjectScmRoot projectScmRoot )
92      {
93          this.projectScmRoot = projectScmRoot;
94      }
95  
96      public String getProjectGroupName()
97          throws ContinuumException
98      {
99          projectGroupName = getContinuum().getProjectGroup( getProjectGroupId() ).getName();
100 
101         return projectGroupName;
102     }
103 
104     public void setProjectGroupName( String projectGroupName )
105     {
106         this.projectGroupName = projectGroupName;
107     }
108 
109     public String getState()
110     {
111         return state;
112     }
113 
114     public void setState( String state )
115     {
116         this.state = state;
117     }
118 }