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.

DownloadArtifactTag.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package org.apache.maven.archiva.web.tags;
  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.struts2.views.jsp.TagUtils;
  21. import javax.servlet.jsp.JspException;
  22. import javax.servlet.jsp.tagext.TagSupport;
  23. /**
  24. * DownloadArtifactTag
  25. *
  26. * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  27. * @version $Id$
  28. */
  29. public class DownloadArtifactTag
  30. extends TagSupport
  31. {
  32. private String groupId_; // stores EL-based groupId property
  33. private String groupId; // stores the evaluated groupId object.
  34. private String artifactId_; // stores EL-based artifactId property
  35. private String artifactId; // stores the evaluated artifactId object.
  36. private String version_; // stores EL-based version property
  37. private String version; // stores the evaluated version object.
  38. private String mini_; // stores EL-based mini property
  39. private boolean mini; // stores the evaluated mini object.
  40. public int doEndTag()
  41. throws JspException
  42. {
  43. evaluateExpressions();
  44. DownloadArtifact download = new DownloadArtifact( TagUtils.getStack( pageContext ), pageContext );
  45. download.setGroupId( groupId );
  46. download.setArtifactId( artifactId );
  47. download.setVersion( version );
  48. download.setMini( mini );
  49. download.end( pageContext.getOut(), "" );
  50. return super.doEndTag();
  51. }
  52. private void evaluateExpressions()
  53. throws JspException
  54. {
  55. ExpressionTool exprTool = new ExpressionTool( pageContext, this, "download" );
  56. // Handle required properties.
  57. groupId = exprTool.requiredString( "groupId", groupId_ );
  58. artifactId = exprTool.requiredString( "artifactId", artifactId_ );
  59. version = exprTool.requiredString( "version", version_ );
  60. // Handle optional properties
  61. mini = exprTool.optionalBoolean( "mini", mini_, false );
  62. }
  63. public void setArtifactId( String artifactId )
  64. {
  65. this.artifactId_ = artifactId;
  66. }
  67. public void setGroupId( String groupId )
  68. {
  69. this.groupId_ = groupId;
  70. }
  71. public void setVersion( String version )
  72. {
  73. this.version_ = version;
  74. }
  75. }