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.

RemoteRepositoryContentMock.java 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package org.apache.archiva.repository.mock;
  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.common.utils.VersionUtil;
  21. import org.apache.archiva.model.ArtifactReference;
  22. import org.apache.archiva.model.RepositoryURL;
  23. import org.apache.archiva.repository.LayoutException;
  24. import org.apache.archiva.repository.RemoteRepository;
  25. import org.apache.archiva.repository.RemoteRepositoryContent;
  26. import org.apache.commons.lang3.StringUtils;
  27. import org.springframework.stereotype.Service;
  28. /**
  29. * @author Martin Stockhammer <martin_s@apache.org>
  30. */
  31. @Service("remoteRepositoryContent#mock")
  32. public class RemoteRepositoryContentMock implements RemoteRepositoryContent
  33. {
  34. RemoteRepository repository;
  35. RemoteRepositoryContentMock(RemoteRepository repo) {
  36. this.repository = repo;
  37. }
  38. @Override
  39. public String getId( )
  40. {
  41. return repository.getId();
  42. }
  43. @Override
  44. public RemoteRepository getRepository( )
  45. {
  46. return repository;
  47. }
  48. @Override
  49. public RepositoryURL getURL( )
  50. {
  51. return new RepositoryURL(repository.getLocation().toString());
  52. }
  53. @Override
  54. public void setRepository( RemoteRepository repo )
  55. {
  56. this.repository = repo;
  57. }
  58. @Override
  59. public ArtifactReference toArtifactReference( String path ) throws LayoutException
  60. {
  61. return null;
  62. }
  63. @Override
  64. public String toPath( ArtifactReference reference )
  65. {
  66. String baseVersion;
  67. if (VersionUtil.isSnapshot(reference.getVersion())) {
  68. baseVersion=VersionUtil.getBaseVersion(reference.getVersion());
  69. } else {
  70. baseVersion=reference.getVersion();
  71. }
  72. return reference.getGroupId().replaceAll("\\.", "/")+"/"+reference.getArtifactId()+"/"+baseVersion+"/"
  73. +reference.getArtifactId()+"-"+reference.getVersion()+(
  74. StringUtils.isNotEmpty(reference.getClassifier()) ? "-"+reference.getClassifier() : "")+"."+reference.getType();
  75. }
  76. @Override
  77. public RepositoryURL toURL( ArtifactReference reference )
  78. {
  79. return null;
  80. }
  81. }