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 com.opensymphony.xwork2.Preparable;
\r
23 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
\r
24 import org.apache.maven.archiva.configuration.Configuration;
\r
25 import org.apache.maven.archiva.configuration.LegacyArtifactPath;
\r
26 import org.apache.archiva.security.ArchivaRoleConstants;
\r
27 import org.apache.maven.archiva.web.action.AbstractActionSupport;
\r
28 import org.apache.archiva.web.util.ContextUtils;
\r
29 import org.apache.struts2.interceptor.ServletRequestAware;
\r
30 import org.codehaus.plexus.redback.rbac.Resource;
\r
31 import org.codehaus.redback.integration.interceptor.SecureAction;
\r
32 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
\r
33 import org.codehaus.redback.integration.interceptor.SecureActionException;
\r
34 import org.springframework.context.annotation.Scope;
\r
35 import org.springframework.stereotype.Controller;
\r
37 import javax.inject.Inject;
\r
38 import javax.servlet.http.HttpServletRequest;
\r
39 import java.util.ArrayList;
\r
40 import java.util.List;
\r
43 * Shows the LegacyArtifactPath Tab for the administrator.
\r
46 * plexus.component role="com.opensymphony.xwork2.Action" role-hint="legacyArtifactPathAction" instantiation-strategy="per-lookup"
\r
48 @Controller( "legacyArtifactPathAction" )
\r
49 @Scope( "prototype" )
\r
50 public class LegacyArtifactPathAction
\r
51 extends AbstractActionSupport
\r
52 implements SecureAction, ServletRequestAware, Preparable
\r
55 * plexus.requirement
\r
58 private ArchivaConfiguration archivaConfiguration;
\r
60 private List<LegacyArtifactPath> legacyArtifactPaths;
\r
63 * Used to construct the repository WebDAV URL in the repository action.
\r
65 private String baseUrl;
\r
67 public void setServletRequest( HttpServletRequest request )
\r
69 // TODO: is there a better way to do this?
\r
70 this.baseUrl = ContextUtils.getBaseURL( request, "repository" );
\r
73 public SecureActionBundle getSecureActionBundle()
\r
74 throws SecureActionException
\r
76 SecureActionBundle bundle = new SecureActionBundle();
\r
78 bundle.setRequiresAuthentication( true );
\r
79 bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION, Resource.GLOBAL );
\r
84 public void prepare()
\r
86 Configuration config = archivaConfiguration.getConfiguration();
\r
88 legacyArtifactPaths = new ArrayList<LegacyArtifactPath>( config.getLegacyArtifactPaths() );
\r
91 public List<LegacyArtifactPath> getLegacyArtifactPaths()
\r
93 return legacyArtifactPaths;
\r
96 public String getBaseUrl()
\r