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.redback.integration.interceptor.SecureAction;
29 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
30 import org.codehaus.redback.integration.interceptor.SecureActionException;
31 import org.codehaus.plexus.registry.RegistryException;
33 import java.util.ArrayList;
34 import java.util.List;
35 import org.apache.maven.archiva.web.action.PlexusActionSupport;
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)
45 public abstract class AbstractRepositoriesAdminAction
46 extends PlexusActionSupport
47 implements SecureAction
52 protected ArchivaConfiguration archivaConfiguration;
54 public ArchivaConfiguration getArchivaConfiguration()
56 return archivaConfiguration;
59 public SecureActionBundle getSecureActionBundle()
60 throws SecureActionException
62 SecureActionBundle bundle = new SecureActionBundle();
64 bundle.setRequiresAuthentication( true );
65 bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
70 public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
72 this.archivaConfiguration = archivaConfiguration;
76 * Save the configuration.
78 * @param configuration the configuration to save.
79 * @return the webwork result code to issue.
80 * @throws IOException thrown if unable to save file to disk.
81 * @throws InvalidConfigurationException thrown if configuration is invalid.
82 * @throws RegistryException thrown if configuration subsystem has a problem saving the configuration to disk.
84 protected String saveConfiguration( Configuration configuration )
88 archivaConfiguration.save( configuration );
89 addActionMessage( "Successfully saved configuration" );
91 catch ( IndeterminateConfigurationException e )
93 addActionError( e.getMessage() );
96 catch ( RegistryException e )
98 addActionError( "Configuration Registry Exception: " + e.getMessage() );
106 * Get the list of ProxyConnectors that are present in the configuration.
108 * @return a new list of ProxyConnectors present in the configuration.
110 protected List<ProxyConnectorConfiguration> getProxyConnectors()
112 return new ArrayList<ProxyConnectorConfiguration>( archivaConfiguration.getConfiguration().getProxyConnectors() );