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.

BasicRemoteRepository.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package org.apache.archiva.repository.base;
  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.filelock.DefaultFileLockManager;
  21. import org.apache.archiva.common.filelock.FileLockManager;
  22. import org.apache.archiva.repository.ReleaseScheme;
  23. import org.apache.archiva.repository.RepositoryCapabilities;
  24. import org.apache.archiva.repository.RepositoryType;
  25. import org.apache.archiva.repository.StandardCapabilities;
  26. import org.apache.archiva.repository.storage.FilesystemStorage;
  27. import org.apache.archiva.repository.storage.RepositoryStorage;
  28. import org.apache.archiva.repository.features.IndexCreationFeature;
  29. import org.apache.archiva.repository.features.RemoteIndexFeature;
  30. import org.slf4j.Logger;
  31. import org.slf4j.LoggerFactory;
  32. import java.io.IOException;
  33. import java.nio.file.Path;
  34. import java.util.Locale;
  35. /**
  36. *
  37. * Just a helper class, mainly used for unit tests.
  38. *
  39. *
  40. */
  41. public class BasicRemoteRepository extends AbstractRemoteRepository
  42. {
  43. Logger log = LoggerFactory.getLogger(BasicRemoteRepository.class);
  44. RemoteIndexFeature remoteIndexFeature = new RemoteIndexFeature();
  45. IndexCreationFeature indexCreationFeature = new IndexCreationFeature(true);
  46. static final StandardCapabilities CAPABILITIES = new StandardCapabilities( new ReleaseScheme[] {
  47. ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT
  48. }, new String[] {"default"}, new String[0], new String[] {
  49. RemoteIndexFeature.class.toString(),
  50. IndexCreationFeature.class.toString()
  51. }, true, true, true, true, true );
  52. public BasicRemoteRepository( String id, String name, RepositoryStorage storage)
  53. {
  54. super( RepositoryType.MAVEN, id, name, storage);
  55. initFeatures();
  56. }
  57. public BasicRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage storage )
  58. {
  59. super( primaryLocale, type, id, name, storage );
  60. initFeatures();
  61. }
  62. private void initFeatures() {
  63. addFeature( remoteIndexFeature );
  64. addFeature( indexCreationFeature );
  65. }
  66. @Override
  67. public boolean hasIndex( )
  68. {
  69. return true;
  70. }
  71. @Override
  72. public RepositoryCapabilities getCapabilities( )
  73. {
  74. return CAPABILITIES;
  75. }
  76. public static BasicRemoteRepository newFilesystemInstance(String id, String name, Path basePath) throws IOException {
  77. FileLockManager lockManager = new DefaultFileLockManager();
  78. FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
  79. return new BasicRemoteRepository(id, name, storage);
  80. }
  81. }