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.

DeleteProxyConnectorAction.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package org.apache.maven.archiva.web.action.admin.connectors.proxy;
  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 org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
  21. /**
  22. * DeleteProxyConnectorAction
  23. *
  24. * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  25. * @version $Id$
  26. *
  27. * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="deleteProxyConnectorAction"
  28. */
  29. public class DeleteProxyConnectorAction
  30. extends AbstractProxyConnectorAction
  31. {
  32. private String source;
  33. private String target;
  34. private ProxyConnectorConfiguration proxyConfig;
  35. public String confirmDelete()
  36. {
  37. this.proxyConfig = findProxyConnector( source, target );
  38. // Not set? Then there is nothing to delete.
  39. if ( this.proxyConfig == null )
  40. {
  41. addActionError( "Unable to delete proxy configuration, configuration with source [" + source
  42. + "], and target [" + target + "] does not exist." );
  43. return ERROR;
  44. }
  45. return INPUT;
  46. }
  47. public String delete()
  48. {
  49. this.proxyConfig = findProxyConnector( source, target );
  50. // Not set? Then there is nothing to delete.
  51. if ( this.proxyConfig == null )
  52. {
  53. addActionError( "Unable to delete proxy configuration, configuration with source [" + source
  54. + "], and target [" + target + "] does not exist." );
  55. return ERROR;
  56. }
  57. if ( hasActionErrors() )
  58. {
  59. return ERROR;
  60. }
  61. removeProxyConnector( proxyConfig );
  62. addActionMessage( "Successfully removed proxy connector [" + source + " , " + target + " ]" );
  63. setSource( null );
  64. setTarget( null );
  65. return saveConfiguration();
  66. }
  67. public String getSource()
  68. {
  69. return source;
  70. }
  71. public void setSource( String id )
  72. {
  73. this.source = id;
  74. }
  75. public String getTarget()
  76. {
  77. return target;
  78. }
  79. public void setTarget( String id )
  80. {
  81. this.target = id;
  82. }
  83. public ProxyConnectorConfiguration getProxyConfig()
  84. {
  85. return proxyConfig;
  86. }
  87. }