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.

EditProxyConnectorAction.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. * EditProxyConnectorAction
  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="editProxyConnectorAction"
  28. */
  29. public class EditProxyConnectorAction
  30. extends AbstractProxyConnectorFormAction
  31. {
  32. /**
  33. * The proxy connector source id to edit. (used with {@link #target})
  34. */
  35. private String source;
  36. /**
  37. * The proxy connector target id to edit. (used with {@link #source})
  38. */
  39. private String target;
  40. @Override
  41. public void prepare()
  42. {
  43. super.prepare();
  44. connector = findProxyConnector( source, target );
  45. }
  46. public String input()
  47. {
  48. if ( connector == null )
  49. {
  50. addActionError( "Unable to edit non existant proxy connector with source [" + source + "] and target ["
  51. + target + "]" );
  52. return ERROR;
  53. }
  54. return INPUT;
  55. }
  56. public String commit()
  57. {
  58. validateConnector();
  59. if ( hasActionErrors() )
  60. {
  61. return INPUT;
  62. }
  63. String sourceId = connector.getSourceRepoId();
  64. String targetId = connector.getTargetRepoId();
  65. ProxyConnectorConfiguration otherConnector = findProxyConnector( sourceId, targetId );
  66. if ( otherConnector != null )
  67. {
  68. // Remove the previous connector.
  69. removeProxyConnector( otherConnector );
  70. }
  71. if ( hasActionErrors() )
  72. {
  73. return INPUT;
  74. }
  75. addProxyConnector( connector );
  76. return saveConfiguration();
  77. }
  78. public String getSource()
  79. {
  80. return source;
  81. }
  82. public void setSource( String source )
  83. {
  84. this.source = source;
  85. }
  86. public String getTarget()
  87. {
  88. return target;
  89. }
  90. public void setTarget( String target )
  91. {
  92. this.target = target;
  93. }
  94. }