]> source.dussan.org Git - archiva.git/blob
1c484aa55281ff26dbb93e5998affd89f94b1b5c
[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.redback.rbac.Resource;
26 import org.apache.archiva.security.common.ArchivaRoleConstants;
27 import org.apache.archiva.web.action.AbstractActionSupport;
28 import org.apache.archiva.redback.integration.interceptor.SecureAction;
29 import org.apache.archiva.redback.integration.interceptor.SecureActionBundle;
30 import org.apache.archiva.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  * @since 1.4-M1
39  */
40 @Controller( "networkConfigurationAction" )
41 @Scope( "prototype" )
42 public class NetworkConfigurationAction
43     extends AbstractActionSupport
44     implements Preparable, SecureAction
45 {
46
47     @Inject
48     private ArchivaAdministration archivaAdministration;
49
50     private NetworkConfiguration networkConfiguration;
51
52     public void prepare( )
53         throws Exception
54     {
55         networkConfiguration = archivaAdministration.getNetworkConfiguration( );
56     }
57
58     public SecureActionBundle getSecureActionBundle( )
59         throws SecureActionException
60     {
61         SecureActionBundle bundle = new SecureActionBundle( );
62
63         bundle.setRequiresAuthentication( true );
64         bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
65
66         return bundle;
67     }
68
69     public String edit( )
70     {
71         return INPUT;
72     }
73
74     public String save( )
75     {
76         try
77         {
78             archivaAdministration.setNetworkConfiguration( this.networkConfiguration );
79         }
80         catch ( RepositoryAdminException e )
81         {
82             addActionError( "Error during networkConfiguration upate:" + e.getMessage( ) );
83             return ERROR;
84         }
85         addActionMessage( "Network Configuration Updated" );
86         return SUCCESS;
87     }
88
89     public NetworkConfiguration getNetworkConfiguration( )
90     {
91         return networkConfiguration;
92     }
93
94     public void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
95     {
96         this.networkConfiguration = networkConfiguration;
97     }
98 }