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.

ArtifactExtensionMapping.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package org.apache.archiva.repository.content.maven2;
  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.archiva.metadata.repository.storage.maven2.ArtifactMappingProvider;
  21. import org.apache.archiva.metadata.repository.storage.maven2.DefaultArtifactMappingProvider;
  22. /**
  23. * ArtifactExtensionMapping
  24. *
  25. *
  26. */
  27. public class ArtifactExtensionMapping
  28. {
  29. public static final String MAVEN_ONE_PLUGIN = "maven-one-plugin";
  30. // TODO: now only used in Maven 1, we should be using M1 specific mappings
  31. private static final ArtifactMappingProvider mapping = new DefaultArtifactMappingProvider();
  32. public static String getExtension( String type )
  33. {
  34. String ext = mapping.mapTypeToExtension( type );
  35. if ( ext == null )
  36. {
  37. ext = type;
  38. }
  39. return ext;
  40. }
  41. public static String mapExtensionAndClassifierToType( String classifier, String extension )
  42. {
  43. return mapExtensionAndClassifierToType( classifier, extension, extension );
  44. }
  45. public static String mapExtensionAndClassifierToType( String classifier, String extension,
  46. String defaultExtension )
  47. {
  48. String value = mapping.mapClassifierAndExtensionToType( classifier, extension );
  49. if ( value == null )
  50. {
  51. // TODO: Maven 1 plugin
  52. String value1 = null;
  53. if ( "tar.gz".equals( extension ) )
  54. {
  55. value1 = "distribution-tgz";
  56. }
  57. else if ( "tar.bz2".equals( extension ) )
  58. {
  59. value1 = "distribution-bzip";
  60. }
  61. else if ( "zip".equals( extension ) )
  62. {
  63. value1 = "distribution-zip";
  64. }
  65. value = value1;
  66. }
  67. return value != null ? value : defaultExtension;
  68. }
  69. }