1 package org.apache.maven.archiva.web.action.admin.repositories;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
23 import org.apache.maven.archiva.configuration.Configuration;
24 import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
25 import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
26 import org.apache.maven.archiva.security.ArchivaRoleConstants;
27 import org.codehaus.plexus.redback.rbac.Resource;
28 import org.codehaus.plexus.redback.xwork.interceptor.SecureAction;
29 import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
30 import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
31 import org.codehaus.plexus.registry.RegistryException;
32 import org.codehaus.plexus.xwork.action.PlexusActionSupport;
34 import java.util.ArrayList;
35 import java.util.List;
38 * Abstract AdminRepositories Action base.
40 * Base class for all repository administrative functions.
41 * This should be neutral to the type of action (add/edit/delete) and type of repo (managed/remote)
43 * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
46 public abstract class AbstractRepositoriesAdminAction
47 extends PlexusActionSupport
48 implements SecureAction
53 protected ArchivaConfiguration archivaConfiguration;
55 public ArchivaConfiguration getArchivaConfiguration()
57 return archivaConfiguration;
60 public SecureActionBundle getSecureActionBundle()
61 throws SecureActionException
63 SecureActionBundle bundle = new SecureActionBundle();
65 bundle.setRequiresAuthentication( true );
66 bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
71 public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
73 this.archivaConfiguration = archivaConfiguration;
77 * Save the configuration.
79 * @param configuration the configuration to save.
80 * @return the webwork result code to issue.
81 * @throws IOException thrown if unable to save file to disk.
82 * @throws InvalidConfigurationException thrown if configuration is invalid.
83 * @throws RegistryException thrown if configuration subsystem has a problem saving the configuration to disk.
85 protected String saveConfiguration( Configuration configuration )
89 archivaConfiguration.save( configuration );
90 addActionMessage( "Successfully saved configuration" );
92 catch ( IndeterminateConfigurationException e )
94 addActionError( e.getMessage() );
97 catch ( RegistryException e )
99 addActionError( "Configuration Registry Exception: " + e.getMessage() );
107 * Get the list of ProxyConnectors that are present in the configuration.
109 * @return a new list of ProxyConnectors present in the configuration.
111 protected List<ProxyConnectorConfiguration> getProxyConnectors()
113 return new ArrayList<ProxyConnectorConfiguration>( archivaConfiguration.getConfiguration().getProxyConnectors() );