You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LegacyArtifactPathAction.java 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package org.apache.maven.archiva.web.action.admin.legacy;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import java.util.ArrayList;
  21. import java.util.List;
  22. import javax.servlet.http.HttpServletRequest;
  23. import org.apache.maven.archiva.configuration.ArchivaConfiguration;
  24. import org.apache.maven.archiva.configuration.Configuration;
  25. import org.apache.maven.archiva.configuration.LegacyArtifactPath;
  26. import org.apache.maven.archiva.security.ArchivaRoleConstants;
  27. import org.apache.maven.archiva.web.util.ContextUtils;
  28. import org.codehaus.plexus.redback.rbac.Resource;
  29. import org.codehaus.plexus.redback.struts2.interceptor.SecureAction;
  30. import org.codehaus.plexus.redback.struts2.interceptor.SecureActionBundle;
  31. import org.codehaus.plexus.redback.struts2.interceptor.SecureActionException;
  32. import org.apache.struts2.interceptor.ServletRequestAware;
  33. import com.opensymphony.xwork2.Preparable;
  34. import org.apache.maven.archiva.web.action.PlexusActionSupport;
  35. /**
  36. * Shows the LegacyArtifactPath Tab for the administrator.
  37. *
  38. * @since 1.1
  39. * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="legacyArtifactPathAction"
  40. */
  41. public class LegacyArtifactPathAction
  42. extends PlexusActionSupport
  43. implements SecureAction, ServletRequestAware, Preparable
  44. {
  45. /**
  46. * @plexus.requirement
  47. */
  48. private ArchivaConfiguration archivaConfiguration;
  49. private List<LegacyArtifactPath> legacyArtifactPaths;
  50. /**
  51. * Used to construct the repository WebDAV URL in the repository action.
  52. */
  53. private String baseUrl;
  54. public void setServletRequest( HttpServletRequest request )
  55. {
  56. // TODO: is there a better way to do this?
  57. this.baseUrl = ContextUtils.getBaseURL( request, "repository" );
  58. }
  59. public SecureActionBundle getSecureActionBundle()
  60. throws SecureActionException
  61. {
  62. SecureActionBundle bundle = new SecureActionBundle();
  63. bundle.setRequiresAuthentication( true );
  64. bundle.addRequiredAuthorization( ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION,
  65. Resource.GLOBAL );
  66. return bundle;
  67. }
  68. public void prepare()
  69. {
  70. Configuration config = archivaConfiguration.getConfiguration();
  71. legacyArtifactPaths = new ArrayList<LegacyArtifactPath>( config.getLegacyArtifactPaths() );
  72. }
  73. public List<LegacyArtifactPath> getLegacyArtifactPaths()
  74. {
  75. return legacyArtifactPaths;
  76. }
  77. public String getBaseUrl()
  78. {
  79. return baseUrl;
  80. }
  81. }