1 package org.apache.maven.archiva.web.action.admin.legacy;
\r
4 * Licensed to the Apache Software Foundation (ASF) under one
\r
5 * or more contributor license agreements. See the NOTICE file
\r
6 * distributed with this work for additional information
\r
7 * regarding copyright ownership. The ASF licenses this file
\r
8 * to you under the Apache License, Version 2.0 (the
\r
9 * "License"); you may not use this file except in compliance
\r
10 * with the License. You may obtain a copy of the License at
\r
12 * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * Unless required by applicable law or agreed to in writing,
\r
15 * software distributed under the License is distributed on an
\r
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
\r
17 * KIND, either express or implied. See the License for the
\r
18 * specific language governing permissions and limitations
\r
19 * under the License.
\r
22 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
\r
23 import org.apache.maven.archiva.configuration.Configuration;
\r
24 import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
\r
25 import org.apache.maven.archiva.configuration.LegacyArtifactPath;
\r
26 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
\r
27 import org.codehaus.plexus.registry.RegistryException;
\r
28 import org.codehaus.plexus.xwork.action.PlexusActionSupport;
\r
30 import com.opensymphony.xwork.Preparable;
\r
33 * Add a LegacyArtifactPath to archiva configuration
\r
36 * @plexus.component role="com.opensymphony.xwork.Action" role-hint="addLegacyArtifactPathAction"
\r
38 public class AddLegacyArtifactPathAction
\r
39 extends PlexusActionSupport
\r
40 implements Preparable
\r
43 * @plexus.requirement
\r
45 private ArchivaConfiguration archivaConfiguration;
\r
48 * @plexus.requirement role-hint="legacy"
\r
50 private ManagedRepositoryContent repositoryContent;
\r
53 private LegacyArtifactPath legacyArtifactPath;
\r
56 public void prepare()
\r
58 this.legacyArtifactPath = new LegacyArtifactPath();
\r
61 public String input()
\r
66 public String commit()
\r
68 ArtifactReference artifact = this.legacyArtifactPath.getArtifactReference();
\r
69 String path = repositoryContent.toPath( artifact );
\r
70 if ( ! path.equals( this.legacyArtifactPath.getPath() ) )
\r
72 addActionError( "artifact reference does not match the initial path : " + path );
\r
76 Configuration configuration = archivaConfiguration.getConfiguration();
\r
77 configuration.addLegacyArtifactPath( legacyArtifactPath );
\r
78 return saveConfiguration( configuration );
\r
81 public LegacyArtifactPath getLegacyArtifactPath()
\r
83 return legacyArtifactPath;
\r
86 public void setLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath )
\r
88 this.legacyArtifactPath = legacyArtifactPath;
\r
91 protected String saveConfiguration( Configuration configuration )
\r
95 archivaConfiguration.save( configuration );
\r
96 addActionMessage( "Successfully saved configuration" );
\r
98 catch ( IndeterminateConfigurationException e )
\r
100 addActionError( e.getMessage() );
\r
103 catch ( RegistryException e )
\r
105 addActionError( "Configuration Registry Exception: " + e.getMessage() );
\r