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.model.ArtifactReference;
\r
27 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
\r
28 import org.codehaus.plexus.registry.RegistryException;
\r
29 import org.codehaus.plexus.xwork.action.PlexusActionSupport;
\r
31 import com.opensymphony.webwork.components.ActionError;
\r
32 import com.opensymphony.xwork.Preparable;
\r
35 * Add a LegacyArtifactPath to archiva configuration
\r
38 * @plexus.component role="com.opensymphony.xwork.Action" role-hint="addLegacyArtifactPathAction"
\r
40 public class AddLegacyArtifactPathAction
\r
41 extends PlexusActionSupport
\r
42 implements Preparable
\r
45 * @plexus.requirement
\r
47 private ArchivaConfiguration archivaConfiguration;
\r
50 * @plexus.requirement role-hint="legacy"
\r
52 private ManagedRepositoryContent repositoryContent;
\r
55 private LegacyArtifactPath legacyArtifactPath;
\r
58 public void prepare()
\r
60 this.legacyArtifactPath = new LegacyArtifactPath();
\r
63 public String input()
\r
68 public String commit()
\r
70 ArtifactReference artifact = this.legacyArtifactPath.getArtifactReference();
\r
71 String path = repositoryContent.toPath( artifact );
\r
72 if ( ! path.equals( this.legacyArtifactPath.getPath() ) )
\r
74 addActionError( "artifact reference does not match the initial path : " + path );
\r
78 Configuration configuration = archivaConfiguration.getConfiguration();
\r
79 configuration.addLegacyArtifactPath( legacyArtifactPath );
\r
80 return saveConfiguration( configuration );
\r
83 public LegacyArtifactPath getLegacyArtifactPath()
\r
85 return legacyArtifactPath;
\r
88 public void setLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath )
\r
90 this.legacyArtifactPath = legacyArtifactPath;
\r
93 protected String saveConfiguration( Configuration configuration )
\r
97 archivaConfiguration.save( configuration );
\r
98 addActionMessage( "Successfully saved configuration" );
\r
100 catch ( IndeterminateConfigurationException e )
\r
102 addActionError( e.getMessage() );
\r
105 catch ( RegistryException e )
\r
107 addActionError( "Configuration Registry Exception: " + e.getMessage() );
\r