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 com.opensymphony.xwork2.Preparable;
24 import org.apache.commons.lang.StringUtils;
25 import org.apache.maven.archiva.configuration.Configuration;
26 import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
27 import org.apache.maven.archiva.repository.audit.AuditEvent;
28 import org.codehaus.plexus.redback.role.RoleManagerException;
30 import java.io.IOException;
33 * EditRemoteRepositoryAction
37 * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="editRemoteRepositoryAction" instantiation-strategy="per-lookup"
39 public class EditRemoteRepositoryAction
40 extends AbstractRemoteRepositoriesAction
44 * The model for this action.
46 private RemoteRepositoryConfiguration repository;
49 * The repository id to edit.
51 private String repoid;
56 if ( StringUtils.isNotBlank( repoid ) )
58 this.repository = archivaConfiguration.getConfiguration().findRemoteRepositoryById( id );
64 if ( StringUtils.isBlank( repoid ) )
66 addActionError( "Edit failure, unable to edit a repository with a blank repository id." );
73 public String commit()
75 Configuration configuration = archivaConfiguration.getConfiguration();
77 // We are in edit mode, remove the old repository configuration.
78 removeRepository( repository.getId(), configuration );
80 // Save the repository configuration.
84 addRepository( repository, configuration );
85 triggerAuditEvent( repository.getId(), null, AuditEvent.MODIFY_REMOTE_REPO );
86 result = saveConfiguration( configuration );
88 catch ( IOException e )
90 addActionError( "I/O Exception: " + e.getMessage() );
93 catch ( RoleManagerException e )
95 addActionError( "Role Manager Exception: " + e.getMessage() );
102 public RemoteRepositoryConfiguration getRepository()
107 public void setRepository( RemoteRepositoryConfiguration repository )
109 this.repository = repository;
112 public String getRepoid()
117 public void setRepoid( String repoid )
119 this.repoid = repoid;