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.release.distributed.DistributedReleaseUtil;
23  import org.apache.continuum.release.distributed.manager.DistributedReleaseManager;
24  import org.apache.maven.continuum.security.ContinuumRoleConstants;
25  import org.apache.maven.continuum.web.action.ContinuumActionSupport;
26  import org.apache.maven.continuum.web.model.DistributedReleaseSummary;
27  import org.codehaus.plexus.redback.rbac.Resource;
28  import org.codehaus.redback.integration.interceptor.SecureAction;
29  import org.codehaus.redback.integration.interceptor.SecureActionBundle;
30  import org.codehaus.redback.integration.interceptor.SecureActionException;
31  
32  import java.util.ArrayList;
33  import java.util.List;
34  import java.util.Map;
35  
36  /**
37   * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="distributedRelease"
38   */
39  public class DistributedReleasesAction
40      extends ContinuumActionSupport
41      implements SecureAction
42  {
43      private List<DistributedReleaseSummary> releasesSummary;
44  
45      public String list()
46          throws Exception
47      {
48          DistributedReleaseManager releaseManager = getContinuum().getDistributedReleaseManager();
49  
50          List<Map<String, Object>> releases = releaseManager.getAllReleasesInProgress();
51  
52          releasesSummary = new ArrayList<DistributedReleaseSummary>();
53  
54          for ( Map<String, Object> release : releases )
55          {
56              DistributedReleaseSummary summary = new DistributedReleaseSummary();
57              summary.setReleaseId( DistributedReleaseUtil.getReleaseId( release ) );
58              summary.setReleaseGoal( DistributedReleaseUtil.getReleaseGoal( release ) );
59              summary.setBuildAgentUrl( DistributedReleaseUtil.getBuildAgentUrl( release ) );
60              summary.setProjectId( DistributedReleaseUtil.getProjectId( release ) );
61  
62              releasesSummary.add( summary );
63          }
64  
65          return SUCCESS;
66      }
67  
68      public List<DistributedReleaseSummary> getReleasesSummary()
69      {
70          return releasesSummary;
71      }
72  
73      public void setReleasesSummary( List<DistributedReleaseSummary> releasesSummary )
74      {
75          this.releasesSummary = releasesSummary;
76      }
77  
78      public SecureActionBundle getSecureActionBundle()
79          throws SecureActionException
80      {
81          SecureActionBundle bundle = new SecureActionBundle();
82          bundle.setRequiresAuthentication( true );
83          bundle.addRequiredAuthorization( ContinuumRoleConstants.CONTINUUM_VIEW_RELEASE, Resource.GLOBAL );
84  
85          return bundle;
86      }
87  }