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 java.io.IOException;
23 import java.util.ArrayList;
24 import java.util.List;
26 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
27 import org.apache.maven.archiva.configuration.Configuration;
28 import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
29 import org.apache.maven.archiva.configuration.InvalidConfigurationException;
30 import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
31 import org.apache.maven.archiva.repository.audit.Auditable;
32 import org.apache.maven.archiva.security.ArchivaRoleConstants;
33 import org.apache.maven.archiva.web.action.PlexusActionSupport;
34 import org.codehaus.plexus.redback.rbac.Resource;
35 import org.codehaus.plexus.registry.RegistryException;
36 import org.codehaus.redback.integration.interceptor.SecureAction;
37 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
38 import org.codehaus.redback.integration.interceptor.SecureActionException;
41 * Abstract AdminRepositories Action base.
43 * Base class for all repository administrative functions.
44 * This should be neutral to the type of action (add/edit/delete) and type of repo (managed/remote)
48 public abstract class AbstractRepositoriesAdminAction
49 extends PlexusActionSupport
50 implements SecureAction, Auditable
55 protected ArchivaConfiguration archivaConfiguration;
57 public ArchivaConfiguration getArchivaConfiguration()
59 return archivaConfiguration;
62 public SecureActionBundle getSecureActionBundle()
63 throws SecureActionException
65 SecureActionBundle bundle = new SecureActionBundle();
67 bundle.setRequiresAuthentication( true );
68 bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
73 public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
75 this.archivaConfiguration = archivaConfiguration;
79 * Save the configuration.
81 * @param configuration the configuration to save.
82 * @return the webwork result code to issue.
83 * @throws IOException thrown if unable to save file to disk.
84 * @throws InvalidConfigurationException thrown if configuration is invalid.
85 * @throws RegistryException thrown if configuration subsystem has a problem saving the configuration to disk.
87 protected String saveConfiguration( Configuration configuration )
91 archivaConfiguration.save( configuration );
92 addActionMessage( "Successfully saved configuration" );
94 catch ( IndeterminateConfigurationException e )
96 addActionError( e.getMessage() );
99 catch ( RegistryException e )
101 addActionError( "Configuration Registry Exception: " + e.getMessage() );
109 * Get the list of ProxyConnectors that are present in the configuration.
111 * @return a new list of ProxyConnectors present in the configuration.
113 protected List<ProxyConnectorConfiguration> getProxyConnectors()
115 return new ArrayList<ProxyConnectorConfiguration>( archivaConfiguration.getConfiguration().getProxyConnectors() );