]> source.dussan.org Git - archiva.git/blob
552682a9cd25a5f59d9c601ddde1e78adf1e3464
[archiva.git] /
1 package org.apache.archiva.web.action.admin.network;
2 /*
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  */
20
21 import com.opensymphony.xwork2.Preparable;
22 import org.apache.archiva.admin.model.RepositoryAdminException;
23 import org.apache.archiva.admin.model.admin.ArchivaAdministration;
24 import org.apache.archiva.admin.model.beans.NetworkConfiguration;
25 import org.apache.archiva.security.common.ArchivaRoleConstants;
26 import org.apache.archiva.web.action.AbstractActionSupport;
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 import org.springframework.context.annotation.Scope;
32 import org.springframework.stereotype.Controller;
33
34 import javax.inject.Inject;
35
36 /**
37  * @author Olivier Lamy
38  */
39 @Controller( "networkConfigurationAction" )
40 @Scope( "prototype" )
41 public class NetworkConfigurationAction
42     extends AbstractActionSupport
43     implements Preparable, SecureAction
44 {
45
46     @Inject
47     private ArchivaAdministration archivaAdministration;
48
49     private NetworkConfiguration networkConfiguration;
50
51     public void prepare( )
52         throws Exception
53     {
54         networkConfiguration = archivaAdministration.getNetworkConfiguration( );
55     }
56
57     public SecureActionBundle getSecureActionBundle( )
58         throws SecureActionException
59     {
60         SecureActionBundle bundle = new SecureActionBundle( );
61
62         bundle.setRequiresAuthentication( true );
63         bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
64
65         return bundle;
66     }
67
68     public String edit( )
69     {
70         return INPUT;
71     }
72
73     public String save( )
74     {
75         try
76         {
77             archivaAdministration.setNetworkConfiguration( this.networkConfiguration );
78         }
79         catch ( RepositoryAdminException e )
80         {
81             addActionError( "Error during networkConfiguration upate:" + e.getMessage( ) );
82             return ERROR;
83         }
84         addActionMessage( "Network Configuration Updated" );
85         return SUCCESS;
86     }
87
88     public NetworkConfiguration getNetworkConfiguration( )
89     {
90         return networkConfiguration;
91     }
92
93     public void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
94     {
95         this.networkConfiguration = networkConfiguration;
96     }
97 }