1 package org.apache.maven.repository.manager.web.action.admin;
4 * Copyright 2005-2006 The Apache Software Foundation.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import org.apache.maven.repository.configuration.AbstractRepositoryConfiguration;
20 import org.apache.maven.repository.configuration.Configuration;
21 import org.apache.maven.repository.configuration.ConfigurationChangeException;
22 import org.apache.maven.repository.configuration.ConfigurationStore;
23 import org.apache.maven.repository.configuration.ConfigurationStoreException;
24 import org.apache.maven.repository.configuration.InvalidConfigurationException;
25 import org.apache.maven.repository.configuration.RepositoryConfiguration;
26 import org.codehaus.plexus.xwork.action.PlexusActionSupport;
28 import java.io.IOException;
31 * Base action for repository removal actions.
33 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
35 public abstract class AbstractDeleteRepositoryAction
36 extends PlexusActionSupport
41 private ConfigurationStore configurationStore;
44 * The repository ID to lookup when editing a repository.
46 protected String repoId;
49 * Which operation to select.
51 private String operation = "unmodified";
53 public String execute()
54 throws ConfigurationStoreException, IOException, InvalidConfigurationException, ConfigurationChangeException
56 // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded
58 if ( "delete-entry".equals( operation ) || "delete-contents".equals( operation ) )
60 Configuration configuration = configurationStore.getConfigurationFromStore();
62 AbstractRepositoryConfiguration existingRepository = getRepository( configuration );
63 if ( existingRepository == null )
65 addActionError( "A repository with that id does not exist" );
69 // TODO: remove from index too!
71 removeRepository( configuration, existingRepository );
73 configurationStore.storeConfiguration( configuration );
75 if ( "delete-contents".equals( operation ) )
77 removeContents( existingRepository );
84 protected abstract void removeContents( AbstractRepositoryConfiguration existingRepository )
87 protected abstract AbstractRepositoryConfiguration getRepository( Configuration configuration );
89 protected abstract void removeRepository( Configuration configuration,
90 AbstractRepositoryConfiguration existingRepository );
97 public String getRepoId()
102 public void setRepoId( String repoId )
104 this.repoId = repoId;
107 public String getOperation()
112 public void setOperation( String operation )
114 this.operation = operation;