1 package org.apache.maven.archiva.web.action.admin.appearance;
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 org.apache.commons.lang.StringUtils;
23 import org.apache.maven.artifact.repository.ArtifactRepository;
24 import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
25 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
26 import org.codehaus.plexus.xwork.action.PlexusActionSupport;
32 * AbstractAppearanceAction
34 * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
37 public abstract class AbstractAppearanceAction
38 extends PlexusActionSupport
41 * @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
43 private Map<String, ArtifactRepositoryLayout> repositoryLayouts;
48 private ArtifactRepositoryFactory repoFactory;
50 protected ArtifactRepository createLocalRepository()
52 String id = "archiva-local-repo";
53 String layout = "default";
54 String directory = System.getProperty( "user.home" ) + "/.m2/archiva";
56 ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) repositoryLayouts.get( layout );
57 File repository = new File( directory );
60 String repoDir = repository.toURI().toString();
61 //workaround for spaces non converted by PathUtils in wagon
62 //TODO: remove it when PathUtils will be fixed
63 if ( repoDir.indexOf( "%20" ) >= 0 )
65 repoDir = StringUtils.replace( repoDir, "%20", " " );
68 return repoFactory.createArtifactRepository( id, repoDir, repositoryLayout, null, null );